Bonjour, 
Comme vous m'avez suggeré et c'est bien ce que j'ai trouvé dans les livres, voici mon code:
TermProjPK.java
	
	| 12
 3
 4
 5
 
 | @Embeddable
public class TermProjPK implements Serializable {
private String auiw;
@Column(name = "AUIS", nullable = false)
private String auis; | 
 TermProj.java
	
	| 12
 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
 
 |  
public class TermProj implements Serializable {
@EmbeddedId
    private TermProjPK termProjPK;
//jointure avec la table TermSource
    @ManyToOne
    @JoinColumn (name = "AUIW")
    private TermSource  auiw;  
    public TermSource getAuiw() {
        return auiw;
    }
 
    public void setAuiw(TermSource auiw) {
        this.auiw = auiw;
    }    
 
 
    //jointure avec la table SnomedInter   
    @ManyToOne 
    @JoinColumn (name = "AUIS")
    private SnomedInter auis;
    public SnomedInter getAuis() {
        return auis;
    }
 
    public void setAuis(SnomedInter auis) {
        this.auis = auis;
    }
@Column(name = "MODIF")
    private String modif;
 
    @Column(name = "SRC", nullable = false)
    private String src; | 
 TermSource.java
	
	| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 
 | public class TermSource implements Serializable {
 @Id
    @Column(name = "AUIW", nullable = false)
    private String auiw;
@OneToMany(mappedBy="AUIW")
    private Collection<TermProj> termProjs;
 
     public Collection<TermProj> getTermProjs() {
        return termProjs;
    }
 
    public void setTermProjs(Collection<TermProj> termProjs) {
        this.termProjs = termProjs;
    } | 
 SnomedInter.java
	
	| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 
 | public class SnomedInter implements Serializable {
@Id
    @Column(name = "AUIS", nullable = false)
    private String auis;
@OneToMany(mappedBy="AUIS")
    private Collection<TermProj> termProjs;
 
    public Collection<TermProj> getTermProjs() {
        return termProjs;
    }
 
    public void setTermProjs(Collection<TermProj> termProjs) {
        this.termProjs = termProjs;
    } | 
 et j'ai toujours l'erreur suivante du à la session d'Hibernate:
	
	org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: ejb.entity.TermSource.termProjs, no session or session was closed
 Cette erreur vient du fait que je n'ai pas préchargé la collection : termProjs !
En effet, dans les EJB3, les relations de type OneToMany, ManyToMany se charge en mode "lazy" (ou à la demande).
ici je tente d'accéder à une collection à chagement "lazy" en dehors de la session (ici Hibernate) et bien il est impossible à la collection de se charger !
est ce que vous savez comment faire dans ce cas?!, je vous remercie d'avance
						
					
Partager