Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import java.io.Serializable;
 
/**
 * @hibernate.class table="FONCTION"
 */
public class Fonction implements Serializable {
    private static final long serialVersionUID = -2289281489628390283L;
    private Long identifiant;
    private Fonction parent;
 
    //getter
    public Long getIdentifiant() {
        return identifiant;
    }
    public Fonction getParent() {
        return parent;
    }
    //Setter
    public void setIdentifiant(Long identifiant) {
        this.identifiant = identifiant;
    }
    public void setParent(Fonction parent) {
        this.parent = parent;
    }
}
le fichier de Mapping :
Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 <?xml version="1.0" encoding="UTF-8"?>
 
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN" 
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
 
<hibernate-mapping>
    <class name="mon.projet.model.Fonction"
        table="FONCTION">
 
        <id name="identifiant" column="identifiant"
            type="java.lang.Long">
            <generator class="native"></generator>
        </id>
        <many-to-one name="parent"
            class="mon.projet.model.Function" cascade="none"
            outer-join="auto" update="true" insert="true" column="parent" />
    </class>
 
</hibernate-mapping>

Erreur :

Erreur au niveau du chargement : org.hibernate.MappingException: An association from the table FONCTION refers to an unmapped class: mon.projet.model.Function
Exception in thread "main" java.lang.ExceptionInInitializerError
at mon.projet.dao.HibernateUtil.<clinit>(HibernateUtil.java:24)
at mon.projet.dao.manager.UtilisateurManager.insertUtilisateur(UtilisateurManager.java:81)
at mon.projetdao.manager.TestDAO.main(TestDAO.java:72)
Caused by: org.hibernate.MappingException: An association from the table FONCTION refers to an unmapped class: ma.coursupreme.greffe.model.Function
at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1176)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1094)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1210)
at mon.projet.dao.HibernateUtil.<clinit>(HibernateUtil.java:20)
... 2 more



je trouve un vrais probleme pour mapper cette classe, y a pas une astuce pour mapper cette classe recurente..???