Bonjour,

J'ai une entité JPA appellée exigence qui est liée à plusieurs exigences dans une relation de parent/child.

le code de mon entité est le suivant:

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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500


/*
 * TExigence.java
 *
 * Created on 15 avril 2009, 01:42
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package ma.rcar.rdmtrack.mapping;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * Entity class TExigence
 * 
 * @author Amina
 */
@Entity
@Table(name = "t_exigence")
@NamedQueries( {
        @NamedQuery(name = "TExigence.findByIdentifiant", query = "SELECT t FROM TExigence t WHERE t.identifiant = :identifiant"),
        @NamedQuery(name = "TExigence.findByNumVersion", query = "SELECT t FROM TExigence t WHERE t.numVersion = :numVersion"),
        @NamedQuery(name = "TExigence.findByIntituleExigence", query = "SELECT t FROM TExigence t WHERE t.intituleExigence = :intituleExigence"),
        @NamedQuery(name = "TExigence.findByDateDebutPrevue", query = "SELECT t FROM TExigence t WHERE t.dateDebutPrevue = :dateDebutPrevue"),
        @NamedQuery(name = "TExigence.findByDateFinPrevue", query = "SELECT t FROM TExigence t WHERE t.dateFinPrevue = :dateFinPrevue"),
        @NamedQuery(name = "TExigence.findByDateDebutReelle", query = "SELECT t FROM TExigence t WHERE t.dateDebutReelle = :dateDebutReelle"),
        @NamedQuery(name = "TExigence.findByDateFinReelle", query = "SELECT t FROM TExigence t WHERE t.dateFinReelle = :dateFinReelle"),
        @NamedQuery(name = "TExigence.findByDescription", query = "SELECT t FROM TExigence t WHERE t.description = :description"),
        @NamedQuery(name = "TExigence.findByTExigenceID", query = "SELECT t FROM TExigence t WHERE t.tExigenceID = :tExigenceID"),
        @NamedQuery(name = "TExigence.findByTPrioritéID", query = "SELECT t FROM TExigence t WHERE t.tPrioritéID = :tPrioritéID")
    })
    
public class TExigence implements Serializable {
    private static final long serialVersionUID = 1L;
    
   //faire attention et changer nullable="false"

    @Id @GeneratedValue
    @Basic(optional = false)
    @Column(name = "T_Exigence_ID")
    private Integer tExigenceID;
    
    @Column(name = "Identifiant", nullable = true)
    private String identifiant;

    @Column(name = "NumVersion", nullable = true)
    private short numVersion;

    @Column(name = "IntituleExigence", nullable = true)
    private String intituleExigence;

    @Column(name = "DateDebutPrevue", nullable = true)
    @Temporal(TemporalType.DATE)
    private Date dateDebutPrevue;

    @Column(name = "DateFinPrevue", nullable = true)
    @Temporal(TemporalType.DATE)
    private Date dateFinPrevue;

    @Column(name = "DateDebutReelle", nullable = true)
    @Temporal(TemporalType.DATE)
    private Date dateDebutReelle;

    @Column(name = "DateFinReelle", nullable = true)
    @Temporal(TemporalType.DATE)
    private Date dateFinReelle;

    @Column(name = "Description", nullable = true)
    private String description;

    @Column(name = "T_Priorité_ID", nullable = true)
    private int tPrioritéID;

    @ManyToMany(mappedBy = "tExigenceIDCollection")
    private Collection<TDocument> tDocumentIDCollection;

    @JoinTable(name = "t_exigence_etatvalidation", joinColumns =  {
            @JoinColumn(name = "T_Exigence_ID", referencedColumnName = "T_Exigence_ID")
        }, inverseJoinColumns =  {
            @JoinColumn(name = "T_EtatValidation_ID", referencedColumnName = "T_EtatValidation_ID")
        })
    @ManyToMany
    private Collection<TEtatvalidation> tEtatValidationIDCollection;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tExigenceID")
    private Collection<TPlantest> tPlantestCollection;

    @JoinColumn(name = "T_TypeExigence_ID", referencedColumnName = "T_TypeExigence_ID")
    @ManyToOne
    private TTypeexigence tTypeExigenceID;

    @JoinColumn(name = "T_Projet_ID", referencedColumnName = "T_Projet_ID")
    @ManyToOne
    private TProjet tProjetID;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tExigenceTExigenceID")
    private Collection<TExigence> tExigenceCollection;
    @JoinColumn(name = "T_Exigence_T_Exigence_ID", referencedColumnName = "T_Exigence_ID")
    @ManyToOne
    private TExigence tExigenceTExigenceID;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tExigenceID")
    private Collection<TDemandechangement> tDemandechangementCollection;
    
    /** Creates a new instance of TExigence */
    public TExigence() {
    }

    /**
     * Creates a new instance of TExigence with the specified values.
     * @param tExigenceID the tExigenceID of the TExigence
     */
    public TExigence(Integer tExigenceID) {
        this.tExigenceID = tExigenceID;
    }

    /**
     * Creates a new instance of TExigence with the specified values.
     * @param tExigenceID the tExigenceID of the TExigence
     * @param identifiant the identifiant of the TExigence
     * @param numVersion the numVersion of the TExigence
     * @param intituleExigence the intituleExigence of the TExigence
     * @param dateDebutPrevue the dateDebutPrevue of the TExigence
     * @param dateFinPrevue the dateFinPrevue of the TExigence
     * @param dateDebutReelle the dateDebutReelle of the TExigence
     * @param dateFinReelle the dateFinReelle of the TExigence
     * @param description the description of the TExigence
     * @param tPrioritéID the tPrioritéID of the TExigence
     */
  /*  public TExigence(Integer tExigenceID, String identifiant, short numVersion, String intituleExigence, Date dateDebutPrevue, Date dateFinPrevue, Date dateDebutReelle, Date dateFinReelle, String description, int tPrioritéID) {
        this.tExigenceID = tExigenceID;
        this.identifiant = identifiant;
        this.numVersion = numVersion;
        this.intituleExigence = intituleExigence;
        this.dateDebutPrevue = dateDebutPrevue;
        this.dateFinPrevue = dateFinPrevue;
        this.dateDebutReelle = dateDebutReelle;
        this.dateFinReelle = dateFinReelle;
        this.description = description;
        this.tPrioritéID = tPrioritéID;
    }*/
   
    

    /**
     * Gets the identifiant of this TExigence.
     * @return the identifiant
     */
    public String getIdentifiant() {
        return this.identifiant;
    }

    /**
     * Sets the identifiant of this TExigence to the specified value.
     * @param identifiant the new identifiant
     */
    public void setIdentifiant(String identifiant) {
        this.identifiant = identifiant;
    }

    /**
     * Gets the numVersion of this TExigence.
     * @return the numVersion
     */
    public short getNumVersion() {
        return this.numVersion;
    }

    /**
     * Sets the numVersion of this TExigence to the specified value.
     * @param numVersion the new numVersion
     */
    public void setNumVersion(short numVersion) {
        this.numVersion = numVersion;
    }

    /**
     * Gets the intituleExigence of this TExigence.
     * @return the intituleExigence
     */
    public String getIntituleExigence() {
        return this.intituleExigence;
    }

    /**
     * Sets the intituleExigence of this TExigence to the specified value.
     * @param intituleExigence the new intituleExigence
     */
    public void setIntituleExigence(String intituleExigence) {
        this.intituleExigence = intituleExigence;
    }

    /**
     * Gets the dateDebutPrevue of this TExigence.
     * @return the dateDebutPrevue
     */
    public Date getDateDebutPrevue() {
        return this.dateDebutPrevue;
    }

    /**
     * Sets the dateDebutPrevue of this TExigence to the specified value.
     * @param dateDebutPrevue the new dateDebutPrevue
     */
    public void setDateDebutPrevue(Date dateDebutPrevue) {
        this.dateDebutPrevue = dateDebutPrevue;
    }

    /**
     * Gets the dateFinPrevue of this TExigence.
     * @return the dateFinPrevue
     */
    public Date getDateFinPrevue() {
        return this.dateFinPrevue;
    }

    /**
     * Sets the dateFinPrevue of this TExigence to the specified value.
     * @param dateFinPrevue the new dateFinPrevue
     */
    public void setDateFinPrevue(Date dateFinPrevue) {
        this.dateFinPrevue = dateFinPrevue;
    }

    /**
     * Gets the dateDebutReelle of this TExigence.
     * @return the dateDebutReelle
     */
    public Date getDateDebutReelle() {
        return this.dateDebutReelle;
    }

    /**
     * Sets the dateDebutReelle of this TExigence to the specified value.
     * @param dateDebutReelle the new dateDebutReelle
     */
    public void setDateDebutReelle(Date dateDebutReelle) {
        this.dateDebutReelle = dateDebutReelle;
    }

    /**
     * Gets the dateFinReelle of this TExigence.
     * @return the dateFinReelle
     */
    public Date getDateFinReelle() {
        return this.dateFinReelle;
    }

    /**
     * Sets the dateFinReelle of this TExigence to the specified value.
     * @param dateFinReelle the new dateFinReelle
     */
    public void setDateFinReelle(Date dateFinReelle) {
        this.dateFinReelle = dateFinReelle;
    }

    /**
     * Gets the description of this TExigence.
     * @return the description
     */
    public String getDescription() {
        return this.description;
    }

    /**
     * Sets the description of this TExigence to the specified value.
     * @param description the new description
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * Gets the tExigenceID of this TExigence.
     * @return the tExigenceID
     */
    public Integer getTExigenceID() {
        return this.tExigenceID;
    }

    /**
     * Sets the tExigenceID of this TExigence to the specified value.
     * @param tExigenceID the new tExigenceID
     */
    public void setTExigenceID(Integer tExigenceID) {
        this.tExigenceID = tExigenceID;
    }

    /**
     * Gets the tPrioritéID of this TExigence.
     * @return the tPrioritéID
     */
    public int getTPrioritéID() {
        return this.tPrioritéID;
    }

    /**
     * Sets the tPrioritéID of this TExigence to the specified value.
     * @param tPrioritéID the new tPrioritéID
     */
    public void setTPrioritéID(int tPrioritéID) {
        this.tPrioritéID = tPrioritéID;
    }

    /**
     * Gets the tDocumentIDCollection of this TExigence.
     * @return the tDocumentIDCollection
     */
    public Collection<TDocument> getTDocumentIDCollection() {
        return this.tDocumentIDCollection;
    }

    /**
     * Sets the tDocumentIDCollection of this TExigence to the specified value.
     * @param tDocumentIDCollection the new tDocumentIDCollection
     */
    public void setTDocumentIDCollection(Collection<TDocument> tDocumentIDCollection) {
        this.tDocumentIDCollection = tDocumentIDCollection;
    }

    /**
     * Gets the tEtatValidationIDCollection of this TExigence.
     * @return the tEtatValidationIDCollection
     */
    public Collection<TEtatvalidation> getTEtatValidationIDCollection() {
        return this.tEtatValidationIDCollection;
    }

    /**
     * Sets the tEtatValidationIDCollection of this TExigence to the specified value.
     * @param tEtatValidationIDCollection the new tEtatValidationIDCollection
     */
    public void setTEtatValidationIDCollection(Collection<TEtatvalidation> tEtatValidationIDCollection) {
        this.tEtatValidationIDCollection = tEtatValidationIDCollection;
    }

    /**
     * Gets the tPlantestCollection of this TExigence.
     * @return the tPlantestCollection
     */
    public Collection<TPlantest> getTPlantestCollection() {
        return this.tPlantestCollection;
    }

    /**
     * Sets the tPlantestCollection of this TExigence to the specified value.
     * @param tPlantestCollection the new tPlantestCollection
     */
    public void setTPlantestCollection(Collection<TPlantest> tPlantestCollection) {
        this.tPlantestCollection = tPlantestCollection;
    }

    /**
     * Gets the tTypeExigenceID of this TExigence.
     * @return the tTypeExigenceID
     */
    public TTypeexigence getTTypeExigenceID() {
        return this.tTypeExigenceID;
    }

    /**
     * Sets the tTypeExigenceID of this TExigence to the specified value.
     * @param tTypeExigenceID the new tTypeExigenceID
     */
    public void setTTypeExigenceID(TTypeexigence tTypeExigenceID) {
        this.tTypeExigenceID = tTypeExigenceID;
    }

    /**
     * Gets the tProjetID of this TExigence.
     * @return the tProjetID
     */
    public TProjet getTProjetID() {
        return this.tProjetID;
    }

    /**
     * Sets the tProjetID of this TExigence to the specified value.
     * @param tProjetID the new tProjetID
     */
    public void setTProjetID(TProjet tProjetID) {
        this.tProjetID = tProjetID;
    }

    /**
     * Gets the tExigenceCollection of this TExigence.
     * @return the tExigenceCollection
     */
    public Collection<TExigence> getTExigenceCollection() {
        return this.tExigenceCollection;
    }

    /**
     * Sets the tExigenceCollection of this TExigence to the specified value.
     * @param tExigenceCollection the new tExigenceCollection
     */
    public void setTExigenceCollection(Collection<TExigence> tExigenceCollection) {
        this.tExigenceCollection = tExigenceCollection;
    }

    /**
     * Gets the tExigenceTExigenceID of this TExigence.
     * @return the tExigenceTExigenceID
     */
    public TExigence getTExigenceTExigenceID() {
        return this.tExigenceTExigenceID;
    }

    /**
     * Sets the tExigenceTExigenceID of this TExigence to the specified value.
     * @param tExigenceTExigenceID the new tExigenceTExigenceID
     */
    public void setTExigenceTExigenceID(TExigence tExigenceTExigenceID) {
        this.tExigenceTExigenceID = tExigenceTExigenceID;
    }

    /**
     * Gets the tDemandechangementCollection of this TExigence.
     * @return the tDemandechangementCollection
     */
    public Collection<TDemandechangement> getTDemandechangementCollection() {
        return this.tDemandechangementCollection;
    }

    /**
     * Sets the tDemandechangementCollection of this TExigence to the specified value.
     * @param tDemandechangementCollection the new tDemandechangementCollection
     */
    public void setTDemandechangementCollection(Collection<TDemandechangement> tDemandechangementCollection) {
        this.tDemandechangementCollection = tDemandechangementCollection;
    }

    /**
     * Returns a hash code value for the object.  This implementation computes 
     * a hash code value based on the id fields in this object.
     * @return a hash code value for this object.
     */
      
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (tExigenceID != null ? tExigenceID.hashCode() : 0);
        return hash;
    }

    /**
     * Determines whether another object is equal to this TExigence.  The result is 
     * <code>true</code> if and only if the argument is not null and is a TExigence object that 
     * has the same id field values as this object.
     * @param object the reference object with which to compare
     * @return <code>true</code> if this object is the same as the argument;
     * <code>false</code> otherwise.
     */
    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TExigence)) {
            return false;
        }
        TExigence other = (TExigence)object;
        if ((this.tExigenceID == null && other.tExigenceID != null) || (this.tExigenceID != null && !this.tExigenceID.equals(other.tExigenceID))){
        return false;
        }
        return true;
    }

    /**
     * Returns a string representation of the object.  This implementation constructs 
     * that representation based on the id fields.
     * @return a string representation of the object.
     */
    @Override
    public String toString() {
        return "RDMTrack.TExigence[tExigenceID=" + tExigenceID + "]";
    }
    
}


je souhaiterais dans afficher dans mon application un arbre dans lequel figurera la liste des exigences pères et la liste des exigences fils qui leur sont attachées.

Je ne sais pas vraiment comment m'y prendre avec ce genre de relation père/fils.

veuillez please me filer un coup de main!!