je suis débutante avec hibernate
voici mon problème
j'ai ceci
et voici le mapping associé
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87 public class Activite private int duree; private boolean dureeNull = true; private short aFinal; private boolean aFinalNull = true; private String code; private String name; private java.util.UUID idActivite; public Activite() { } public int getDuree() { return duree; } public void setDuree(int duree) { this.duree = duree; setDureeNull( false ); } public void setDureeNull(boolean dureeNull) { this.dureeNull = dureeNull; } public boolean isDureeNull() { return dureeNull; } public short getAFinal() { return aFinal; } public void setAFinal(short aFinal) { this.aFinal = aFinal; setAFinalNull( false ); } public void setAFinalNull(boolean aFinalNull) { this.aFinalNull = aFinalNull; } public boolean isAFinalNull() { return aFinalNull; } public java.lang.String getCode() { return code; } public void setCode(java.lang.String code) { this.code = code; } public java.lang.String getName() { return name; } public void setName(java.lang.String name) { this.name = name; } public java.util.UUID getIdActivite() { return idActivite; } public void setIdActivite(java.util.UUID idActivite) { this.idActivite = idActivite; } }
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 <?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="com.mycompany.myapp.hibernate.Activite" table="activite"> <id name="idActivite" column="id_activite"> <generator class="increment" /> </id> <property name="duree" column="duree" /> <property name="aFinal" column="final" /> <property name="code" column="code" not-null="true" /> <property name="name" column="name" /> <property name="idActivite" column="id_activite" not-null="true" /> </class> </hibernate-mapping>
voici le fichier conf
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
21
22
23
24 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="connection.driver_class" >"org.postgresql.Driver"</property> <property name="connection.url" >"jdbc:postgresql://localhost:5432/BD_Mapping"</property> <property name="connection.username" >"postgres"</property> <property name="connection.password" >"postgres"</property> <property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property> <property name="show_sql">true</property> <mapping resource="hbm/Activite.hbm.xml" /> <mapping resource="hbm/Ara.hbm.xml" /> <mapping resource="hbm/Dossier.hbm.xml" /> <mapping resource="hbm/DossierFlow.hbm.xml" /> <mapping resource="hbm/Flow.hbm.xml" /> <mapping resource="hbm/Message.hbm.xml" /> <mapping resource="hbm/MessagePj.hbm.xml" /> <mapping resource="hbm/PieceJointe.hbm.xml" /> <mapping resource="hbm/Scenario.hbm.xml" /> <mapping resource="hbm/ScenarioFlow.hbm.xml" /> <mapping resource="hbm/Xsd.hbm.xml" /> </session-factory> </hibernate-configuration>
je veux insérer un objet activite dans la base mais j'ai ce résultat
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Initial SessionFactory creation failed.org.hibernate.MappingException: Repeated column in mapping for entity: com.mycompany.myapp.hibernate.DossierFlow column: id_flow (should be mapped with insert="false" update="false")
Exception in thread "main" java.lang.ExceptionInInitializerError
Partager