Bonjour tt le monde,
Je suis un étudiant en Projet de fin d'études actuellement, je suis donc déutant dans Hibernate mais je connais un peu les bases du mapping O/R,
J'ai conçu ma base de données en utilisant Merise2 (j'ai utilisé un héritage), je vous poste une partie de mon MCD ainsi que le modèle physique de données relatif à cet MCD.. J'ai implémenté ma base de données et j'ai utilisé Hibernate Synchronizer pour générer les classes de mapping automatiquement..
En essayant de faire une requête select avec HQL à partir d'une classe simple qui contient un main j'obtiens l'erreur suivante : (fin du post)
Je commence par vous poster le schéma de ma base le MCD :
[IMG][/IMG]
Les "features", "requirements", 'design", 'implem".. sont des spécialisations de Artifact (ils hériteront donc des attributs de Artifact) comme le montre le Modèle Physique de données ci-dessous :
Je vous poste mes fichiers hbm (pas tous à cause de la longuer du post) :
Produit.hbm.xml :
Artifact.hbm.xml :
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111 <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" > <hibernate-mapping package="com.oxia.hibernate" default-lazy="false"> <class name="com.oxia.hibernate.Produit" table="produit" > <meta attribute="sync-DAO">true</meta> <id name="Id" type="java.lang.Long" > <column name="id_prod" sql-type="BIGINT"/> <generator class="increment"/> </id> <property name="NomProd" type="string" > <column name="nom_prod" sql-type="varchar(20)" not-null="false"/> </property> <property name="DateCreation" type="timestamp" > <column name="date_creation" sql-type="timestamp" not-null="true"/> </property> <property name="DateEstimLivr" type="timestamp" > <column name="date_estim_livr" sql-type="timestamp" length="19" not-null="false"/> </property> <property name="ResponsableProd" type="string" > <column name="responsable_prod" sql-type="varchar(30)" not-null="false"/> </property> <property name="ChefProjet" type="string" > <column name="chef_projet" sql-type="varchar(30)" not-null="false"/> </property> <property name="ChargeProd" type="string" > <column name="charge_prod" sql-type="varchar(10)" not-null="false"/> </property> <property name="PrioriteProd" type="long" > <column name="priorite_prod" sql-type="int(10)" not-null="false"/> </property> <property name="ObjectifVente" type="string" > <column name="objectif_vente" sql-type="varchar(20)" not-null="false"/> </property> <set name="Artifacts" inverse="true" lazy="false" cascade="persist,save-update"> <key column="id_prod"/> <one-to-many class="com.oxia.hibernate.Artifact"/> </set> <set name="Utilisateurs" table="gere" cascade="all" > <key column="id_prod"/> <many-to-many column="id_user" class="com.oxia.hibernate.Utilisateur"/> </set> </class> </hibernate-mapping>
Feature.hbm.xml :
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 <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping package="com.oxia.hibernate" default-lazy="false" > <class name="com.oxia.hibernate.Artifact" table="artifact" > <meta attribute="sync-DAO">true</meta> <id name="Id" type="java.lang.Long"> <column name="id_art" sql-type="BIGINT" /> <generator class="increment" /> </id> <property name="NomArt" type="string"> <column name="nom_art" sql-type="varchar(10)" not-null="false" /> </property> <property name="verArt" type="string" > <column name="ver_art" sql-type="longtext" not-null="false"/> </property> <property name="StatutArt" type="string"> <column name="statut_art" sql-type="longtext" not-null="false"/> </property> <property name="DescriptionArt" type="string"> <column name="description_art" sql-type="longtext" not-null="false"/> </property> <many-to-one name="IdProd" column="id_prod" class="com.oxia.hibernate.Produit" not-null="true"> </many-to-one> <set name="DependanceArtsByIdArt" inverse="true" lazy="false" cascade="persist,save-update"> <key column="id_art" /> <one-to-many class="DependanceArt" /> </set> <set name="DependanceArtsByArtIdArt" inverse="true" lazy="false" cascade="persist,save-update"> <key column="id_art" /> <one-to-many class="com.oxia.hibernate.DependanceArt" /> </set> <set name="HistoriqueArts" inverse="true" lazy="false" cascade="persist,save-update"> <key column="id_art" /> <one-to-many class="com.oxia.hibernate.HistoriqueArt" /> </set> <set name="AttachmentArts" table="joint_piece" cascade="all"> <key column="id_art" /> <many-to-many column="id_attach" class="com.oxia.hibernate.AttachmentArt" /> </set> <set name="Utilisateurs" table="manip_art" cascade="all"> <key column="id_art" /> <many-to-many column="id_user" class="com.oxia.hibernate.Utilisateur" /> </set> </class> </hibernate-mapping>
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 <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" > <hibernate-mapping package="com.oxia.hibernate" default-lazy="false"> <joined-subclass name="com.oxia.hibernate.Feature" table="feature" extends="com.oxia.hibernate.Artifact" > <meta attribute="sync-DAO">true</meta> <key column="id_art"/> <property name="IdProd" type="java.lang.Long" > <column name="id_prod" sql-type="BIGINT" not-null="false"/> </property> <property name="NomArt" type="string" > <column name="nom_art" sql-type="varchar(20)" not-null="false"></column> </property> <property name="VerArt" type="string" > <column name="ver_art" sql-type="longtext" not-null="false"/> </property> <property name="StatutArt" type="string" > <column name="statut_art" sql-type="longtext" not-null="false"/> </property> <property name="DescriptionArt" type="string" > <column name="description_art" sql-type="longtext" not-null="false"/> </property> <property name="PrioriteFeat" type="string" > <column name="priorite_feat" sql-type="varchar(10)" not-null="false" /> </property> <property name="DetailsFeat" type="string" > <column name="details_feat" sql-type="longtext" not-null="false"/> </property> <many-to-one name="FeaIdArt" column="fea_id_art" class="com.oxia.hibernate.Feature" not-null="false" > </many-to-one> <set name="Features" inverse="true" lazy="false" cascade="persist,save-update"> <key column="id_art"/> <one-to-many class="com.oxia.hibernate.Feature"/> </set> </joined-subclass> </hibernate-mapping>
Les POJOs sont implémentés de Pojo.java par extends et implements et leur code se trouve dans les ficheirs Basepojo.java (que je poste ici) :
Produit.java :
Artifact.java :
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317 package com.oxia.hibernate.base; import java.io.Serializable; /** * This is an object that contains data related to the produit table. * Do not modify this class because it will be overwritten if the configuration file * related to this class is modified. * Modify by Laouini Moez(teamsware) * @hibernate.class * table="produit" */ public abstract class BaseProduit implements Serializable { public static String REF = "Produit"; public static String PROP_CHEF_PROJET = "ChefProjet"; public static String PROP_PRIORITE_PROD = "PrioriteProd"; public static String PROP_CHARGE_PROD = "ChargeProd"; public static String PROP_RESPONSABLE_PROD = "ResponsableProd"; public static String PROP_ID = "Id"; public static String PROP_DATE_ESTIM_LIVR = "DateEstimLivr"; public static String PROP_DATE_CREATION = "DateCreation"; public static String PROP_NOM_PROD = "NomProd"; public static String PROP_OBJECTIF_VENTE = "ObjectifVente"; // constructors public BaseProduit () { initialize(); } /** * Constructor for primary key */ public BaseProduit (java.lang.Long id) { this.setId(id); initialize(); } protected void initialize () {} private int hashCode = Integer.MIN_VALUE; // primary key private java.lang.Long id; // fields private java.lang.String nomProd; private java.util.Date dateCreation; private java.util.Date dateEstimLivr; private java.lang.String responsableProd; private java.lang.String chefProjet; private java.lang.String chargeProd; private java.lang.Long prioriteProd; private java.lang.String objectifVente; // collections Modify by laouini Moez (teamsware) private java.util.Set artifacts; private java.util.Set utilisateurs; /** * Return the unique identifier of this class * @hibernate.id * generator-class="sequence" * column="ID_PROD" */ public java.lang.Long getId () { return id; } /** * Set the unique identifier of this class * @param id the new ID */ public void setId (java.lang.Long id) { this.id = id; this.hashCode = Integer.MIN_VALUE; } /** * Return the value associated with the column: NOM_PROD *Modify by laouini Moez (teamsware) */ public java.lang.String getNomProd () { return nomProd; } /** * Set the value related to the column: NOM_PROD * @param nomProd the NOM_PROD value * Modify by laouini Moez (teamsware) */ public void setNomProd (java.lang.String nomProd) { this.nomProd = nomProd; } /** * Return the value associated with the column: DATE_CREATION *Modify by laouini Moez (teamsware) */ public java.util.Date getDateCreation () { return dateCreation; } /** * Set the value related to the column: DATE_CREATION * @param dateCreation the DATE_CREATION value * Modify by laouini Moez (teamsware) */ public void setDateCreation (java.util.Date dateCreation) { this.dateCreation = dateCreation; } /** * Return the value associated with the column: DATE_ESTIM_LIVR *Modify by laouini Moez (teamsware) */ public java.util.Date getDateEstimLivr () { return dateEstimLivr; } /** * Set the value related to the column: DATE_ESTIM_LIVR * @param dateEstimLivr the DATE_ESTIM_LIVR value * Modify by laouini Moez (teamsware) */ public void setDateEstimLivr (java.util.Date dateEstimLivr) { this.dateEstimLivr = dateEstimLivr; } /** * Return the value associated with the column: RESPONSABLE_PROD *Modify by laouini Moez (teamsware) */ public java.lang.String getResponsableProd () { return responsableProd; } /** * Set the value related to the column: RESPONSABLE_PROD * @param responsableProd the RESPONSABLE_PROD value * Modify by laouini Moez (teamsware) */ public void setResponsableProd (java.lang.String responsableProd) { this.responsableProd = responsableProd; } /** * Return the value associated with the column: CHEF_PROJET *Modify by laouini Moez (teamsware) */ public java.lang.String getChefProjet () { return chefProjet; } /** * Set the value related to the column: CHEF_PROJET * @param chefProjet the CHEF_PROJET value * Modify by laouini Moez (teamsware) */ public void setChefProjet (java.lang.String chefProjet) { this.chefProjet = chefProjet; } /** * Return the value associated with the column: CHARGE_PROD *Modify by laouini Moez (teamsware) */ public java.lang.String getChargeProd () { return chargeProd; } /** * Set the value related to the column: CHARGE_PROD * @param chargeProd the CHARGE_PROD value * Modify by laouini Moez (teamsware) */ public void setChargeProd (java.lang.String chargeProd) { this.chargeProd = chargeProd; } /** * Return the value associated with the column: PRIORITE_PROD *Modify by laouini Moez (teamsware) */ public java.lang.Long getPrioriteProd () { return prioriteProd; } /** * Set the value related to the column: PRIORITE_PROD * @param prioriteProd the PRIORITE_PROD value * Modify by laouini Moez (teamsware) */ public void setPrioriteProd (java.lang.Long prioriteProd) { this.prioriteProd = prioriteProd; } /** * Return the value associated with the column: OBJECTIF_VENTE *Modify by laouini Moez (teamsware) */ public java.lang.String getObjectifVente () { return objectifVente; } /** * Set the value related to the column: OBJECTIF_VENTE * @param objectifVente the OBJECTIF_VENTE value * Modify by laouini Moez (teamsware) */ public void setObjectifVente (java.lang.String objectifVente) { this.objectifVente = objectifVente; } /** * Return the value associated with the column: Artifacts *Modify by laouini Moez (teamsware) */ public java.util.Set getArtifacts () { return artifacts; } /** * Set the value related to the column: Artifacts * @param artifacts the Artifacts value * Modify by laouini Moez (teamsware) */ public void setArtifacts (java.util.Set artifacts) { this.artifacts = artifacts; } public void addToArtifacts (com.oxia.hibernate.Artifact artifact) { if (null == getArtifacts()) setArtifacts(new java.util.TreeSet()); getArtifacts().add(artifact); } /** * Return the value associated with the column: Utilisateurs *Modify by laouini Moez (teamsware) */ public java.util.Set getUtilisateurs () { return utilisateurs; } /** * Set the value related to the column: Utilisateurs * @param utilisateurs the Utilisateurs value * Modify by laouini Moez (teamsware) */ public void setUtilisateurs (java.util.Set utilisateurs) { this.utilisateurs = utilisateurs; } public void addToUtilisateurs (com.oxia.hibernate.Utilisateur utilisateur) { if (null == getUtilisateurs()) setUtilisateurs(new java.util.TreeSet()); getUtilisateurs().add(utilisateur); } public boolean equals (Object obj) { if (null == obj) return false; if (!(obj instanceof com.oxia.hibernate.Produit)) return false; else { com.oxia.hibernate.Produit produit = (com.oxia.hibernate.Produit) obj; if (null == this.getId() || null == produit.getId()) return false; else return (this.getId().equals(produit.getId())); } } public int hashCode () { if (Integer.MIN_VALUE == this.hashCode) { if (null == this.getId()) return super.hashCode(); else { String hashStr = this.getClass().getName() + ":" + this.getId().hashCode(); this.hashCode = hashStr.hashCode(); } } return this.hashCode; } public String toString () { return super.toString(); } }
Feature.java :
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331 package com.oxia.hibernate.base; import java.io.Serializable; /** * This is an object that contains data related to the artifact table. * Do not modify this class because it will be overwritten if the configuration file * related to this class is modified. * Modify by Laouini Moez(teamsware) * @hibernate.class * table="artifact" */ public abstract class BaseArtifact implements Serializable { public static String REF = "Artifact"; public static String PROP_DESCRIPTION_ART = "DescriptionArt"; public static String PROP_NOM_ART = "NomArt"; public static String PROP_ID_PROD = "IdProd"; public static String PROP_ID = "Id"; public static String PROP_VER_ART = "VerArt"; public static String PROP_STATUT_ART = "StatutArt"; // constructors public BaseArtifact () { initialize(); } /** * Constructor for primary key */ public BaseArtifact (java.lang.Long id) { this.setId(id); initialize(); } protected void initialize () {} private int hashCode = Integer.MIN_VALUE; // primary key private java.lang.Long id; // fields private java.lang.String nomArt; private java.lang.String verArt; private java.lang.String statutArt; private java.lang.String descriptionArt; // many to one private com.oxia.hibernate.Produit idProd; // collections Modify by laouini Moez (teamsware) private java.util.Set dependanceArtsByIdArt; private java.util.Set dependanceArtsByArtIdArt; private java.util.Set historiqueArts; private java.util.Set attachmentArts; private java.util.Set utilisateurs; /** * Return the unique identifier of this class * @hibernate.id * generator-class="sequence" * column="ID_ART" */ public java.lang.Long getId () { return id; } /** * Set the unique identifier of this class * @param id the new ID */ public void setId (java.lang.Long id) { this.id = id; this.hashCode = Integer.MIN_VALUE; } /** * Return the value associated with the column: NOM_ART *Modify by laouini Moez (teamsware) */ public java.lang.String getNomArt () { return nomArt; } /** * Set the value related to the column: NOM_ART * @param nomArt the NOM_ART value * Modify by laouini Moez (teamsware) */ public void setNomArt (java.lang.String nomArt) { this.nomArt = nomArt; } /** * Return the value associated with the column: VER_ART *Modify by laouini Moez (teamsware) */ public java.lang.String getVerArt () { return verArt; } /** * Set the value related to the column: VER_ART * @param verArt the VER_ART value * Modify by laouini Moez (teamsware) */ public void setVerArt (java.lang.String verArt) { this.verArt = verArt; } /** * Return the value associated with the column: STATUT_ART *Modify by laouini Moez (teamsware) */ public java.lang.String getStatutArt () { return statutArt; } /** * Set the value related to the column: STATUT_ART * @param statutArt the STATUT_ART value * Modify by laouini Moez (teamsware) */ public void setStatutArt (java.lang.String statutArt) { this.statutArt = statutArt; } /** * Return the value associated with the column: DESCRIPTION_ART *Modify by laouini Moez (teamsware) */ public java.lang.String getDescriptionArt () { return descriptionArt; } /** * Set the value related to the column: DESCRIPTION_ART * @param descriptionArt the DESCRIPTION_ART value * Modify by laouini Moez (teamsware) */ public void setDescriptionArt (java.lang.String descriptionArt) { this.descriptionArt = descriptionArt; } /** * Return the value associated with the column: ID_PROD *Modify by laouini Moez (teamsware) */ public com.oxia.hibernate.Produit getIdProd () { return idProd; } /** * Set the value related to the column: ID_PROD * @param idProd the ID_PROD value * Modify by laouini Moez (teamsware) */ public void setIdProd (com.oxia.hibernate.Produit idProd) { this.idProd = idProd; } /** * Return the value associated with the column: DependanceArtsByIdArt *Modify by laouini Moez (teamsware) */ public java.util.Set getDependanceArtsByIdArt () { return dependanceArtsByIdArt; } /** * Set the value related to the column: DependanceArtsByIdArt * @param dependanceArtsByIdArt the DependanceArtsByIdArt value * Modify by laouini Moez (teamsware) */ public void setDependanceArtsByIdArt (java.util.Set dependanceArtsByIdArt) { this.dependanceArtsByIdArt = dependanceArtsByIdArt; } public void addToDependanceArtsByIdArt (com.oxia.hibernate.DependanceArt dependanceArt) { if (null == getDependanceArtsByIdArt()) setDependanceArtsByIdArt(new java.util.TreeSet()); getDependanceArtsByIdArt().add(dependanceArt); } /** * Return the value associated with the column: DependanceArtsByArtIdArt *Modify by laouini Moez (teamsware) */ public java.util.Set getDependanceArtsByArtIdArt () { return dependanceArtsByArtIdArt; } /** * Set the value related to the column: DependanceArtsByArtIdArt * @param dependanceArtsByArtIdArt the DependanceArtsByArtIdArt value * Modify by laouini Moez (teamsware) */ public void setDependanceArtsByArtIdArt (java.util.Set dependanceArtsByArtIdArt) { this.dependanceArtsByArtIdArt = dependanceArtsByArtIdArt; } public void addToDependanceArtsByArtIdArt (com.oxia.hibernate.DependanceArt dependanceArt) { if (null == getDependanceArtsByArtIdArt()) setDependanceArtsByArtIdArt(new java.util.TreeSet()); getDependanceArtsByArtIdArt().add(dependanceArt); } /** * Return the value associated with the column: HistoriqueArts *Modify by laouini Moez (teamsware) */ public java.util.Set getHistoriqueArts () { return historiqueArts; } /** * Set the value related to the column: HistoriqueArts * @param historiqueArts the HistoriqueArts value * Modify by laouini Moez (teamsware) */ public void setHistoriqueArts (java.util.Set historiqueArts) { this.historiqueArts = historiqueArts; } public void addToHistoriqueArts (com.oxia.hibernate.HistoriqueArt historiqueArt) { if (null == getHistoriqueArts()) setHistoriqueArts(new java.util.TreeSet()); getHistoriqueArts().add(historiqueArt); } /** * Return the value associated with the column: AttachmentArts *Modify by laouini Moez (teamsware) */ public java.util.Set getAttachmentArts () { return attachmentArts; } /** * Set the value related to the column: AttachmentArts * @param attachmentArts the AttachmentArts value * Modify by laouini Moez (teamsware) */ public void setAttachmentArts (java.util.Set attachmentArts) { this.attachmentArts = attachmentArts; } public void addToAttachmentArts (com.oxia.hibernate.AttachmentArt attachmentArt) { if (null == getAttachmentArts()) setAttachmentArts(new java.util.TreeSet()); getAttachmentArts().add(attachmentArt); } /** * Return the value associated with the column: Utilisateurs *Modify by laouini Moez (teamsware) */ public java.util.Set getUtilisateurs () { return utilisateurs; } /** * Set the value related to the column: Utilisateurs * @param utilisateurs the Utilisateurs value * Modify by laouini Moez (teamsware) */ public void setUtilisateurs (java.util.Set utilisateurs) { this.utilisateurs = utilisateurs; } public void addToUtilisateurs (com.oxia.hibernate.Utilisateur utilisateur) { if (null == getUtilisateurs()) setUtilisateurs(new java.util.TreeSet()); getUtilisateurs().add(utilisateur); } public boolean equals (Object obj) { if (null == obj) return false; if (!(obj instanceof com.oxia.hibernate.Artifact)) return false; else { com.oxia.hibernate.Artifact artifact = (com.oxia.hibernate.Artifact) obj; if (null == this.getId() || null == artifact.getId()) return false; else return (this.getId().equals(artifact.getId())); } } public int hashCode () { if (Integer.MIN_VALUE == this.hashCode) { if (null == this.getId()) return super.hashCode(); else { String hashStr = this.getClass().getName() + ":" + this.getId().hashCode(); this.hashCode = hashStr.hashCode(); } } return this.hashCode; } public String toString () { return super.toString(); } }
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270 package com.oxia.hibernate.base; import java.io.Serializable; /** * This is an object that contains data related to the feature table. * Do not modify this class because it will be overwritten if the configuration file * related to this class is modified. * Modify by Laouini Moez(teamsware) * @hibernate.class * table="feature" */ public abstract class BaseFeature extends com.oxia.hibernate.Artifact implements Serializable { public static String REF = "Feature"; public static String PROP_DESCRIPTION_ART = "DescriptionArt"; public static String PROP_NOM_ART = "NomArt"; public static String PROP_ID_PROD = "IdProd"; public static String PROP_DETAILS_FEAT = "DetailsFeat"; public static String PROP_ID = "Id"; public static String PROP_FEA_ID_ART = "FeaIdArt"; public static String PROP_PRIORITE_FEAT = "PrioriteFeat"; public static String PROP_VER_ART = "VerArt"; public static String PROP_STATUT_ART = "StatutArt"; // constructors public BaseFeature () { initialize(); } /** * Constructor for primary key */ public BaseFeature (java.lang.Long id) { super(id); } private int hashCode = Integer.MIN_VALUE; // fields private java.lang.Long idProd; private java.lang.String nomArt; private java.lang.String verArt; private java.lang.String statutArt; private java.lang.String descriptionArt; private java.lang.String prioriteFeat; private java.lang.String detailsFeat; // many to one private com.oxia.hibernate.Feature feaIdArt; // collections Modify by laouini Moez (teamsware) private java.util.Set features; /** * Return the value associated with the column: ID_PROD *Modify by laouini Moez (teamsware) */ public java.lang.Long getIdProd () { //ici il y a une erreur : "The return type is incompatible with BaseArtifact.getIdProd()" return idProd; } /** * Set the value related to the column: ID_PROD * @param idProd the ID_PROD value * Modify by laouini Moez (teamsware) */ public void setIdProd (java.lang.Long idProd) { this.idProd = idProd; } /** * Return the value associated with the column: NOM_ART *Modify by laouini Moez (teamsware) */ public java.lang.String getNomArt () { return nomArt; } /** * Set the value related to the column: NOM_ART * @param nomArt the NOM_ART value * Modify by laouini Moez (teamsware) */ public void setNomArt (java.lang.String nomArt) { this.nomArt = nomArt; } /** * Return the value associated with the column: VER_ART *Modify by laouini Moez (teamsware) */ public java.lang.String getVerArt () { return verArt; } /** * Set the value related to the column: VER_ART * @param verArt the VER_ART value * Modify by laouini Moez (teamsware) */ public void setVerArt (java.lang.String verArt) { this.verArt = verArt; } /** * Return the value associated with the column: STATUT_ART *Modify by laouini Moez (teamsware) */ public java.lang.String getStatutArt () { return statutArt; } /** * Set the value related to the column: STATUT_ART * @param statutArt the STATUT_ART value * Modify by laouini Moez (teamsware) */ public void setStatutArt (java.lang.String statutArt) { this.statutArt = statutArt; } /** * Return the value associated with the column: DESCRIPTION_ART *Modify by laouini Moez (teamsware) */ public java.lang.String getDescriptionArt () { return descriptionArt; } /** * Set the value related to the column: DESCRIPTION_ART * @param descriptionArt the DESCRIPTION_ART value * Modify by laouini Moez (teamsware) */ public void setDescriptionArt (java.lang.String descriptionArt) { this.descriptionArt = descriptionArt; } /** * Return the value associated with the column: PRIORITE_FEAT *Modify by laouini Moez (teamsware) */ public java.lang.String getPrioriteFeat () { return prioriteFeat; } /** * Set the value related to the column: PRIORITE_FEAT * @param prioriteFeat the PRIORITE_FEAT value * Modify by laouini Moez (teamsware) */ public void setPrioriteFeat (java.lang.String prioriteFeat) { this.prioriteFeat = prioriteFeat; } /** * Return the value associated with the column: DETAILS_FEAT *Modify by laouini Moez (teamsware) */ public java.lang.String getDetailsFeat () { return detailsFeat; } /** * Set the value related to the column: DETAILS_FEAT * @param detailsFeat the DETAILS_FEAT value * Modify by laouini Moez (teamsware) */ public void setDetailsFeat (java.lang.String detailsFeat) { this.detailsFeat = detailsFeat; } /** * Return the value associated with the column: FEA_ID_ART *Modify by laouini Moez (teamsware) */ public com.oxia.hibernate.Feature getFeaIdArt () { return feaIdArt; } /** * Set the value related to the column: FEA_ID_ART * @param feaIdArt the FEA_ID_ART value * Modify by laouini Moez (teamsware) */ public void setFeaIdArt (com.oxia.hibernate.Feature feaIdArt) { this.feaIdArt = feaIdArt; } /** * Return the value associated with the column: Features *Modify by laouini Moez (teamsware) */ public java.util.Set getFeatures () { return features; } /** * Set the value related to the column: Features * @param features the Features value * Modify by laouini Moez (teamsware) */ public void setFeatures (java.util.Set features) { this.features = features; } public void addToFeatures (com.oxia.hibernate.Feature feature) { if (null == getFeatures()) setFeatures(new java.util.TreeSet()); getFeatures().add(feature); } public boolean equals (Object obj) { if (null == obj) return false; if (!(obj instanceof com.oxia.hibernate.Feature)) return false; else { com.oxia.hibernate.Feature feature = (com.oxia.hibernate.Feature) obj; if (null == this.getId() || null == feature.getId()) return false; else return (this.getId().equals(feature.getId())); } } public int hashCode () { if (Integer.MIN_VALUE == this.hashCode) { if (null == this.getId()) return super.hashCode(); else { String hashStr = this.getClass().getName() + ":" + this.getId().hashCode(); this.hashCode = hashStr.hashCode(); } } return this.hashCode; } public String toString () { return super.toString(); } }
Et enfinje vous poste la classe de Test et l'erreur :
TestArtifact.java : (juste affichage des enregistrements présents dans la base) :
l'erreur java est la suivante :
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 package com.oxia.service; import java.util.*; import org.hibernate.*; import org.hibernate.cfg.Configuration; import com.oxia.hibernate.Artifact; public class TestArtifact { public TestArtifact() { // TODO Auto-generated constructor stub } public static void main(String args[]) throws HibernateException{ selectHQL(); } public static void selectHQL(){ Session session = null; try{ // This step will read hibernate.cfg.xml and prepare hibernate for use SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); session =sessionFactory.openSession(); //Using from Clause String SQL_QUERY ="from Artifact artifact"; Query query = session.createQuery(SQL_QUERY); for(Iterator it=query.iterate(); it.hasNext();){ Artifact art = (Artifact)it.next(); System.out.println(" Id art : "+ art.getId()); System.out.println("Nom Artifact : "+art.getNomArt()); System.out.println("Version : "+art.getVerArt()); System.out.println("Statut : "+art.getStatutArt()); System.out.println("Description : "+art.getDescriptionArt()); System.out.println("autres details : "+art.getIdProd().getId()); } session.close(); } catch(Exception e){ System.out.println(e.getMessage()); } } }
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 ... INFO: schema update complete Hibernate: select ...... 17 juin 2009 17:17:39 org.hibernate.property.BasicPropertyAccessor$BasicSetter set GRAVE: IllegalArgumentException in class: com.oxia.hibernate.base.BaseFeature, setter method of property: IdProd 17 juin 2009 17:17:39 org.hibernate.property.BasicPropertyAccessor$BasicSetter set GRAVE: expected type: java.lang.Long, actual value: com.oxia.hibernate.Produit 17 juin 2009 17:17:39 org.hibernate.event.def.DefaultLoadEventListener onLoad INFO: Error performing load command org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.oxia.hibernate.base.BaseFeature.IdProd at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:104) at org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:337) at org.hibernate.tuple.entity.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:200) at org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3564) at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:129) at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:854) at org.hibernate.loader.Loader.doQuery(Loader.java:729) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236) at org.hibernate.loader.Loader.loadEntity(Loader.java:1860) at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48) at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42) at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3042) at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:395) at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375) at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139) at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:179) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103) at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878) at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:846) at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:557) at org.hibernate.type.EntityType.resolve(EntityType.java:379) at org.hibernate.type.EntityType.nullSafeGet(EntityType.java:204) at org.hibernate.impl.IteratorImpl.postNext(IteratorImpl.java:93) at org.hibernate.impl.IteratorImpl.<init>(IteratorImpl.java:58) at org.hibernate.loader.hql.QueryLoader.iterate(QueryLoader.java:405) at org.hibernate.hql.ast.QueryTranslatorImpl.iterate(QueryTranslatorImpl.java:380) at org.hibernate.engine.query.HQLQueryPlan.performIterate(HQLQueryPlan.java:224) at org.hibernate.impl.SessionImpl.iterate(SessionImpl.java:1192) at org.hibernate.impl.QueryImpl.iterate(QueryImpl.java:46) at com.oxia.service.TestArtifact.selectHQL(TestArtifact.java:36) at com.oxia.service.TestArtifact.main(TestArtifact.java:18) Caused by: java.lang.IllegalArgumentException: argument type mismatch 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.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:42) ... 30 more IllegalArgumentException occurred while calling setter of com.oxia.hibernate.base.BaseFeature.IdProd
J'espère que mon post est clair est bien rédigé, je vous remercie d'avance pour votre aide,
Cordialement
Partager