1

休止状態で注釈を使用しています.Mでこのエラーが発生します:

org.hibernate.MappingException: 不明なエンティティ: xyz.bean.test at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:550) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:68) org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878) で org.hibernate.impl.SessionImpl.load(SessionImpl.java:795) で org.hibernate.impl.SessionImpl.load(SessionImpl.java:788) で)ushila.Servlet.testS.processRequest(testS.java:41)でsushila.Servlet.testS.doGet(testS.java:60)でjavax.servlet.http.HttpServlet.service(HttpServlet.java:734)でjavaxでorg.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539) の .servlet.http.HttpServlet.service(HttpServlet.java:847) org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281) org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) で org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655) で org.apache.catalina.core .StandardPipeline.invoke(StandardPipeline.java:595) com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98) com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91) org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162) で org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330) で org.apache.catalina.connector.CoyoteAdapter.service( CoyoteAdapter.java:231) の com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174) の com.sun.grizzly.http.ProcessorTask.com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725) の invokeAdapter(ProcessorTask.java:828) com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019) com.sun .grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225) で com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) で com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) でcom.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90) com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java: 54) com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) で com.sun.grizzly.ContextTask.run(ContextTask.java:71) com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) で com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) で java.lang.Thread .run(Thread.java:722)

私のコードは次のとおりです。

test.java

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package xyz.bean;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Id;
import org.hibernate.annotations.Entity;
import javax.persistence.Table;

/**
 *
 * @author Dell10
 */
@Entity
@Table( name = "hrms_people")
public class test implements Serializable{
    @Id
  @Column(name = "person_code")
    public Integer person_code;

    @Column(name="first_name")
    public String first_name;

    @Column(name="last_name")
    public String last_name;

    @Column(name="email")
    public String email;

    @Column(name="permission")
    public String permission;

    @Column(name="create_project")
    public String create_project;

    @Column(name="companyID")
    public Integer companyID;

    @Column(name="person_pwd")
    public String person_pwd;


    public Integer getCompanyID() {
        return companyID;
    }

    public void setCompanyID(Integer companyID) {
        this.companyID = companyID;
    }

    public String getCreate_project() {
        return create_project;
    }

    public void setCreate_project(String create_project) {
        this.create_project = create_project;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getFirst_name() {
        return first_name;
    }

    public void setFirst_name(String frist_name) {
        this.first_name = frist_name;
    }

    public String getLast_name() {
        return last_name;
    }

    public void setLast_name(String last_name) {
        this.last_name = last_name;
    }

    public String getPermission() {
        return permission;
    }

    public void setPermission(String permission) {
        this.permission = permission;
    }

    public Integer getPerson_code() {
        return person_code;
    }

    public void setPerson_code(Integer person_code) {
        this.person_code = person_code;
    }

    public String getPerson_pwd() {
        return person_pwd;
    }

    public void setPerson_pwd(String person_pwd) {
        this.person_pwd = person_pwd;
    }
}

testS.java

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package xyz.Servlet;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.hibernate.Session;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
import xyz.bean.test;

/**
 *
 * @author Dell10
 */
public class testS extends HttpServlet {

    /** 
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
           //Session ses= new Configuration().configure().buildSessionFactory().openSession();
            Configuration configuration= new AnnotationConfiguration().addAnnotatedClass(test.class).configure();
            Session ses= configuration.buildSessionFactory().openSession();
           test t=new test();

           t=(test)ses.load(test.class, 1);

           out.println("Success " + t.getFirst_name());
        } finally {            
            out.close();
        }
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /** 
     * Handles the HTTP <code>GET</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /** 
     * Handles the HTTP <code>POST</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /** 
     * Returns a short description of the servlet.
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>
}

助けてください。前もって感謝します..........

4

1 に答える 1