嵌套异常是java.lang.NoClassDefFoundError:无法初始化类com.my.util.HibernateUtil

时间:2015-08-06 07:47:38

标签: java spring hibernate hibernate-mapping

我正在使用spring处理应用程序,我遇到以下错误,我不知道如何处理它。

    Etat HTTP 500 - Handler processing failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class com.my.util.HibernateUtil

type Rapport d''exception

message Handler processing failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class com.my.util.HibernateUtil

description Le serveur a rencontré une erreur interne qui l''a empêché de satisfaire la requête.

exception

org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class com.my.util.HibernateUtil
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:820)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:563)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
cause mère

java.lang.NoClassDefFoundError: Could not initialize class com.my.util.HibernateUtil
    com.my.dao.EmployeImplDB.getAllEmploye(EmployeImplDB.java:114)
    com.my.service.EmployeImplMetier.getAll(EmployeImplMetier.java:55)
    com.my.controller.ImportController.Read(ImportController.java:235)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    java.lang.reflect.Method.invoke(Unknown Source)
    org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doInvokeMethod(HandlerMethodInvoker.java:710)
    org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:167)
    org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:414)
    org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:402)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:563)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
note La trace complète de la cause mère de cette erreur est disponible dans les fichiers journaux de Apache Tomcat/8.0.23.

Apache Tomcat/8.0.23

这是我的com.my.util.HibernateUtil类

package com.my.util;
/**
 * 
 * @author ILIAS
 */
import org.hibernate.*;
import org.hibernate.cfg.*;

public class HibernateUtil {
    public static final SessionFactory sessionFactory;
    private static HibernateUtil singleton = null;

    private HibernateUtil(){}

    static {
        try {
            sessionFactory = new Configuration().configure("Hibernate.cfg.xml").buildSessionFactory();
        } catch (Throwable ex) {
            System.err.println("Initial SessionFactory creation failed.***************************" + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }

    public static HibernateUtil getInstance(){
        if(singleton == null){
            singleton = new HibernateUtil();
        }
        return singleton;
    }

    public static SessionFactory getSessionFactory() {
        return sessionFactory;}}

这是tomcat服务器日志

Initial SessionFactory creation failed.****************************************org.hibernate.PropertyNotFoundException: Could not find a getter for Employe in class com.my.dao.Departement
août 06, 2015 9:18:18 AM org.apache.catalina.core.StandardWrapperValve invoke
GRAVE: Servlet.service() for servlet [action] in context with path [/Gestion_et_Generation_Docs_des_Salaries] threw exception [Handler processing failed; nested exception is java.lang.ExceptionInInitializerError] with root cause
org.hibernate.PropertyNotFoundException: Could not find a getter for Employe in class com.my.dao.Departement
    at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:282)
    at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:275)
    at org.hibernate.mapping.Property.getGetter(Property.java:272)
    at org.hibernate.tuple.entity.PojoEntityTuplizer.buildPropertyGetter(PojoEntityTuplizer.java:247)
    at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:125)
    at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
    at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:56)
    at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:302)
    at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)
    at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
    at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
    at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300)
    at com.my.util.HibernateUtil.<clinit>(HibernateUtil.java:19)
    at com.my.dao.EmployeImplDB.getAllEmploye(EmployeImplDB.java:114)
    at com.my.service.EmployeImplMetier.getAll(EmployeImplMetier.java:55)
    at com.my.controller.ImportController.Read(ImportController.java:235)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doInvokeMethod(HandlerMethodInvoker.java:710)
    at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:167)
    at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:414)
    at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:402)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:563)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)

- cleaning up connection pool: jdbc:mysql://localhost:3306/GestionDocs

这是我的com.my.dao.Departement课程

package com.my.dao;
import java.util.Set;

/**
 * @author Ilias
 * @version 1.0
 */
public class Departement {

    private int id;
    private String nomDepartement;
    private Set<Employe> Employe;

    /**
     * @return the employe
     */
    public Set<Employe> getEmploye() {
        return Employe;
    }

    /**
     * @param employe the employe to set
     */
    public void setEmploye(Set<Employe> Employe) {
        this.Employe = Employe;
    }

    /**
     * @return the id
     */
    public int getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(int id) {
        this.id = id;
    }

    /**
     * @return the nomDepartement
     */
    public String getNomDepartement() {
        return nomDepartement;
    }

    /**
     * @param nomDepartement the nomDepartement to set
     */
    public void setNomDepartement(String nomDepartement) {
        this.nomDepartement = nomDepartement;
    }

    public Departement(String nomDepartement) {
        super();
        this.nomDepartement = nomDepartement;

    }

    public Departement(){
    }

    /**
     * 
     * @exception Throwable
     */
    public void finalize()
      throws Throwable{
    }
}

这是我的com.my.dao.Employe类

package com.my.dao;

import java.util.Date;

/**
 * @author Ilias
 * @version 1.0
 */

public class Employe {

private int id;
private String nomEmploye;
private String prenomEmploye;
private int matriculeMY;
private String adresse;
private String sexe;
private String cin;
private Date dateNaissance;
private String situationFamiliale;
private int nombreEnfant;
private Date dateEntree;
private Date dateSortie;
private String numCIMR;
private String numCNSS;
private String numMUT;
private String profile;
private String resteConge;
private String banque;
private String numCpteBanc;
private String fonction;
private float salaire;
private float indTransport;
private float indRepresent;
private float indPanier;
private Departement eDepartement;
private Fonction eFonction;
private Service eService;
private TypePaiement eTypePaiement;
private ModePaiement eModePaiement;
/**
 * @return the id
 */
public int getId() {
    return id;
}
/**
 * @param id the id to set
 */
public void setId(int id) {
    this.id = id;
}
/**
 * @return the nomEmploye
 */
public String getNomEmploye() {
    return nomEmploye;
}
/**
 * @param nomEmploye the nomEmploye to set
 */
public void setNomEmploye(String nomEmploye) {
    this.nomEmploye = nomEmploye;
}
/**
 * @return the prenomEmploye
 */
public String getPrenomEmploye() {
    return prenomEmploye;
}
/**
 * @param prenomEmploye the prenomEmploye to set
 */
public void setPrenomEmploye(String prenomEmploye) {
    this.prenomEmploye = prenomEmploye;
}
/**
 * @return the matriculeMY
 */
public int getMatriculeMY() {
    return matriculeMY;
}
/**
 * @param matriculeMY the matriculeMY to set
 */
public void setMatriculeMY(int matriculeMY) {
    this.matriculeMY = matriculeMY;
}
/**
 * @return the adresse
 */
public String getAdresse() {
    return adresse;
}
/**
 * @param adresse the adresse to set
 */
public void setAdresse(String adresse) {
    this.adresse = adresse;
}
/**
 * @return the sexe
 */
public String getSexe() {
    return sexe;
}
/**
 * @param sexe the sexe to set
 */
public void setSexe(String sexe) {
    this.sexe = sexe;
}
/**
 * @return the cin
 */
public String getCin() {
    return cin;
}
/**
 * @param cin the cin to set
 */
public void setCin(String cin) {
    this.cin = cin;
}
/**
 * @return the dateNaissance
 */
public Date getDateNaissance() {
    return dateNaissance;
}
/**
 * @param dateNaissance the dateNaissance to set
 */
public void setDateNaissance(Date dateNaissance) {
    this.dateNaissance = dateNaissance;
}
/**
 * @return the situationFamiliale
 */
public String getSituationFamiliale() {
    return situationFamiliale;
}
/**
 * @param situationFamiliale the situationFamiliale to set
 */
public void setSituationFamiliale(String situationFamiliale) {
    this.situationFamiliale = situationFamiliale;
}
/**
 * @return the nombreEnfant
 */
public int getNombreEnfant() {
    return nombreEnfant;
}
/**
 * @param nombreEnfant the nombreEnfant to set
 */
public void setNombreEnfant(int nombreEnfant) {
    this.nombreEnfant = nombreEnfant;
}
/**
 * @return the dateEntree
 */
public Date getDateEntree() {
    return dateEntree;
}
/**
 * @param dateEntree the dateEntree to set
 */
public void setDateEntree(Date dateEntree) {
    this.dateEntree = dateEntree;
}
/**
 * @return the dateSortie
 */
public Date getDateSortie() {
    return dateSortie;
}
/**
 * @param dateSortie the dateSortie to set
 */
public void setDateSortie(Date dateSortie) {
    this.dateSortie = dateSortie;
}
/**
 * @return the numCIMR
 */
public String getNumCIMR() {
    return numCIMR;
}
/**
 * @param numCIMR the numCIMR to set
 */
public void setNumCIMR(String numCIMR) {
    this.numCIMR = numCIMR;
}
/**
 * @return the numCNSS
 */
public String getNumCNSS() {
    return numCNSS;
}
/**
 * @param numCNSS the numCNSS to set
 */
public void setNumCNSS(String numCNSS) {
    this.numCNSS = numCNSS;
}
/**
 * @return the numMUT
 */
public String getNumMUT() {
    return numMUT;
}
/**
 * @param numMUT the numMUT to set
 */
public void setNumMUT(String numMUT) {
    this.numMUT = numMUT;
}
/**
 * @return the profile
 */
public String getProfile() {
    return profile;
}
/**
 * @param profile the profile to set
 */
public void setProfile(String profile) {
    this.profile = profile;
}
/**
 * @return the resteConge
 */
public String getResteConge() {
    return resteConge;
}
/**
 * @param resteConge the resteConge to set
 */
public void setResteConge(String resteConge) {
    this.resteConge = resteConge;
}
/**
 * @return the banque
 */
public String getBanque() {
    return banque;
}
/**
 * @param banque the banque to set
 */
public void setBanque(String banque) {
    this.banque = banque;
}
/**
 * @return the numCpteBanc
 */
public String getNumCpteBanc() {
    return numCpteBanc;
}
/**
 * @param numCpteBanc the numCpteBanc to set
 */
public void setNumCpteBanc(String numCpteBanc) {
    this.numCpteBanc = numCpteBanc;
}
/**
 * @return the fonction
 */
public String getFonction() {
    return fonction;
}
/**
 * @param fonction the fonction to set
 */
public void setFonction(String fonction) {
    this.fonction = fonction;
}
/**
 * @return the salaire
 */
public float getSalaire() {
    return salaire;
}
/**
 * @param salaire the salaire to set
 */
public void setSalaire(float salaire) {
    this.salaire = salaire;
}
/**
 * @return the indTransport
 */
public float getIndTransport() {
    return indTransport;
}
/**
 * @param indTransport the indTransport to set
 */
public void setIndTransport(float indTransport) {
    this.indTransport = indTransport;
}
/**
 * @return the indRepresent
 */
public float getIndRepresent() {
    return indRepresent;
}
/**
 * @param indRepresent the indRepresent to set
 */
public void setIndRepresent(float indRepresent) {
    this.indRepresent = indRepresent;
}
/**
 * @return the indPanier
 */
public float getIndPanier() {
    return indPanier;
}
/**
 * @param indPanier the indPanier to set
 */
public void setIndPanier(float indPanier) {
    this.indPanier = indPanier;
}
/**
 * @return the eDepartement
 */
public Departement geteDepartement() {
    return eDepartement;
}
/**
 * @param eDepartement the eDepartement to set
 */
public void seteDepartement(Departement eDepartement) {
    this.eDepartement = eDepartement;
}
/**
 * @return the eFonction
 */
public Fonction geteFonction() {
    return eFonction;
}
/**
 * @param eFonction the eFonction to set
 */
public void seteFonction(Fonction eFonction) {
    this.eFonction = eFonction;
}
/**
 * @return the eService
 */
public Service geteService() {
    return eService;
}
/**
 * @param eService the eService to set
 */
public void seteService(Service eService) {
    this.eService = eService;
}
/**
 * @return the eTypePaiement
 */
public TypePaiement geteTypePaiement() {
    return eTypePaiement;
}
/**
 * @param eTypePaiement the eTypePaiement to set
 */
public void seteTypePaiement(TypePaiement eTypePaiement) {
    this.eTypePaiement = eTypePaiement;
}
/**
 * @return the eModePaiement
 */
public ModePaiement geteModePaiement() {
    return eModePaiement;
}
/**
 * @param eModePaiement the eModePaiement to set
 */
public void seteModePaiement(ModePaiement eModePaiement) {
    this.eModePaiement = eModePaiement;
}

public Employe(String nomEmploye, String prenomEmploye, int matriculeMY, String adresse, String sexe, String cin,
        Date dateNaissance, String situationFamiliale, int nombreEnfant, Date dateEntree, Date dateSortie,
        String numCIMR, String numCNSS, String numMUT, String profile, String resteConge, String banque,
        String numCpteBanc, String fonction, float salaire, float indTransport, float indRepresent, float indPanier,
        Departement eDepartement, Fonction eFonction, Service eService, TypePaiement eTypePaiement,
        ModePaiement eModePaiement) {
    super();
    this.nomEmploye = nomEmploye;
    this.prenomEmploye = prenomEmploye;
    this.matriculeMY = matriculeMY;
    this.adresse = adresse;
    this.sexe = sexe;
    this.cin = cin;
    this.dateNaissance = dateNaissance;
    this.situationFamiliale = situationFamiliale;
    this.nombreEnfant = nombreEnfant;
    this.dateEntree = dateEntree;
    this.dateSortie = dateSortie;
    this.numCIMR = numCIMR;
    this.numCNSS = numCNSS;
    this.numMUT = numMUT;
    this.profile = profile;
    this.resteConge = resteConge;
    this.banque = banque;
    this.numCpteBanc = numCpteBanc;
    this.fonction = fonction;
    this.salaire = salaire;
    this.indTransport = indTransport;
    this.indRepresent = indRepresent;
    this.indPanier = indPanier;
    this.eDepartement = eDepartement;
    this.eFonction = eFonction;
    this.eService = eService;
    this.eTypePaiement = eTypePaiement;
    this.eModePaiement = eModePaiement;
}

public Employe(Employe e){

this.setNomEmploye(e.nomEmploye);
this.setPrenomEmploye(e.prenomEmploye);
this.setCin(e.cin);
this.setDateNaissance(e.dateNaissance);
this.setSituationFamiliale(e.situationFamiliale);
this.setNombreEnfant(e.nombreEnfant);
this.setDateEntree(e.dateEntree);
this.setDateSortie(e.dateSortie);
this.setNumCIMR(e.numCIMR);
this.setNumCNSS(e.numCNSS);
this.setNumMUT(e.numMUT);
this.setProfile(e.profile);
this.setResteConge(e.resteConge);
this.setBanque(e.banque);
this.setNumCpteBanc(e.numCpteBanc);
this.setSalaire(e.salaire);
this.setIndTransport(e.indTransport);
this.setIndRepresent(e.indRepresent);
this.setIndPanier(e.indPanier);
//this.setFonction(e.fonction);
this.seteDepartement(e.eDepartement);
this.seteFonction(e.eFonction);
this.seteService(e.eService);
this.seteModePaiement(e.eModePaiement);
this.seteTypePaiement(e.eTypePaiement);    
}

public Employe() {
    super();
       }
/**
 * {@exception} Throwable
 */
public void finalize() throws Throwable{
}}

这是Departement.hbm.xml

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 5 ao?t 2015 11:05:44 by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
    <class name="com.my.dao.Departement" table="DEPARTEMENT">
        <id name="id" type="int">
            <column name="ID" />
            <generator class="native" />
        </id>
        <property name="nomDepartement" type="java.lang.String">
            <column name="NOMDEPARTEMENT" />
        </property>
        <set name="Employe" inverse="true">
            <key column="ID" not-null="true"/>
            <one-to-many class="com.my.dao.Employe" />
        </set>
    </class>
</hibernate-mapping>

这是Employe.hbm.xml

   <?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 5 ao?t 2015 11:05:44 by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
    <class name="com.my.dao.Employe" table="EMPLOYE">
        <id name="id" type="int">
            <column name="ID" />
            <generator class="native" />
        </id>
        <property name="nomEmploye" type="java.lang.String">
            <column name="NOMEMPLOYE" />
        </property>
        <property name="prenomEmploye" type="java.lang.String">
            <column name="PRENOMEMPLOYE" />
        </property>
        <property name="matriculeMY" type="int">
            <column name="MATRICULEMY" />
        </property>
        <property name="adresse" type="java.lang.String">
            <column name="ADRESSE" />
        </property>
        <property name="sexe" type="java.lang.String">
            <column name="SEXE" />
        </property>
        <property name="cin" type="java.lang.String">
            <column name="CIN" />
        </property>
        <property name="dateNaissance" type="java.lang.String">
            <column name="DATENAISSANCE" />
        </property>
        <property name="situationFamiliale" type="java.lang.String">
            <column name="SITUATIONFAMILIALE" />
        </property>
        <property name="dateEntree" type="java.lang.String">
            <column name="DATEENTREE" />
        </property>
        <property name="dateSortie" type="java.lang.String">
            <column name="DATESORTIE" />
        </property>
        <property name="numCIMR" type="java.lang.String">
            <column name="NUMCIMR" />
        </property>
        <property name="numCNSS" type="java.lang.String">
            <column name="NUMCNSS" />
        </property>
        <property name="numMUT" type="java.lang.String">
            <column name="NUMMUT" />
        </property>
        <property name="profile" type="java.lang.String">
            <column name="PROFILE" />
        </property>
        <property name="resteConge" type="java.lang.String">
            <column name="RESTECONGE" />
        </property>
        <property name="banque" type="java.lang.String">
            <column name="BANQUE" />
        </property>
        <property name="numCpteBanc" type="java.lang.String">
            <column name="NUMCPTEBANC" />
        </property>
        <!-- <property name="fonction" type="java.lang.String">
            <column name="FONCTION" />
        </property> -->
        <property name="salaire" type="float">
            <column name="SALAIRE" />
        </property>
        <property name="indTransport" type="float">
            <column name="INDTRANSPORT" />
        </property>
        <property name="indRepresent" type="float">
            <column name="INDREPRESENT" />
        </property>
        <property name="indPanier" type="float">
            <column name="INDPANIER" />
        </property>
        <many-to-one name="eDepartement" class="com.my.dao.Departement" access="field" fetch="join">
            <column name="EDEPARTEMENT" />
        </many-to-one>
        <many-to-one name="eFonction" class="com.my.dao.Fonction" access="field" fetch="join">
            <column name="EFONCTION" />
        </many-to-one>
        <many-to-one name="eService" class="com.my.dao.Service" access="field" fetch="join">
            <column name="ESERVICE" />
        </many-to-one>
        <many-to-one name="eTypePaiement" class="com.my.dao.TypePaiement" access="field" fetch="join">
            <column name="ETYPEPAIEMENT" />
        </many-to-one>
        <many-to-one name="eModePaiement" class="com.my.dao.ModePaiement" access="field" fetch="join">
            <column name="EMODEPAIEMENT" />
        </many-to-one>
    </class>
</hibernate-mapping>

我是初学者,这是我在春天的第一个项目 我想我在hibernate-mapping上有问题,
 但我找不到问题在哪里,你能帮助PLZ吗?

1 个答案:

答案 0 :(得分:1)

在您的日志中我们可以看到

  

org.hibernate.PropertyNotFoundException:在com.my.dao.Departement类中找不到Employe的getter

我认为Hibernate无法初始化您的映射。

在你的Departement.hbm.xml中输入

  <set name="Employe" inverse="true">
        <key column="ID" not-null="true"/>
        <one-to-many class="com.my.dao.Employe" />
    </set>

但在Department.java中没有归属于员工。所以你必须添加一个这样的:

private Set<Employe> Employe;

为它添加getter / setter

顺便说一下,你应该像员工一样重命名员工(以小写字母开头)。