Bonsoir,

Lorsque j'effectue l'opération suivante dans mon Action:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
 
Patient lePatient = new Patient();	
IPatientDAO IPDao = new HibernateDAOFactory().getPatientDAO();
Patient monPatient = IPDao.getPatientById(4);
BeanUtils.copyProperties(lePatient, monPatient);
j'ai le message d'erreur suivant quand il exécute copyProperties :
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: db.Patient.consultations, no session or session was closed
org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:343)
org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
org.hibernate.collection.PersistentSet.toString(PersistentSet.java:309)
org.apache.commons.beanutils.BeanUtilsBean.copyProperty(BeanUtilsBean.java:328)
org.apache.commons.beanutils.BeanUtilsBean.copyProperties(BeanUtilsBean.java:261)
org.apache.commons.beanutils.BeanUtils.copyProperties(BeanUtils.java:114)
action.ChoosePatient.execute(ChoosePatient.java:51)
org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
Mon fichier Patient.hbm :
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
<hibernate-mapping>
    <class name="db.Patient" table="patient">
        <id name="id" type="java.lang.Integer">
            <column name="id" />
            <generator class="increment" />
        </id>
        <property name="nom" type="string">
            <column name="nom" length="45" not-null="true" />
        </property>
        <property name="prenom" type="string">
            <column name="prenom" length="45" not-null="true" />
        </property>
        <property name="dateNaissance" type="timestamp">
            <column name="date_naissance" length="19" not-null="true" />
        </property>
        <set name="consultations" inverse="true">
            <key>
                <column name="idpatient" not-null="true" />
            </key>
            <one-to-many class="db.Consultation" />
        </set>
    </class>
</hibernate-mapping>

ma classe Patient :
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
public class Patient implements java.io.Serializable {
 
	private Integer id;
	private String nom;
	private String prenom;
	private Date dateNaissance;
	private Set<Consultation> consultations = new HashSet<Consultation>(0);
 
	public Patient() {
	}
 
	public Patient(String nom, String prenom, Date dateNaissance) {
		this.nom = nom;
		this.prenom = prenom;
		this.dateNaissance = dateNaissance;
	}
 
	public Patient(String nom, String prenom, Date dateNaissance,
			Set<Consultation> consultations) {
		this.nom = nom;
		this.prenom = prenom;
		this.dateNaissance = dateNaissance;
		this.consultations = consultations;
	}
 
	public Integer getId() {
		return this.id;
	}
 
	public void setId(Integer id) {
		this.id = id;
	}
 
	public String getNom() {
		return this.nom;
	}
 
	public void setNom(String nom) {
		this.nom = nom;
	}
 
	public String getPrenom() {
		return this.prenom;
	}
 
	public void setPrenom(String prenom) {
		this.prenom = prenom;
	}
 
	public Date getDateNaissance() {
		return this.dateNaissance;
	}
 
	public void setDateNaissance(Date dateNaissance) {
		this.dateNaissance = dateNaissance;
	}
 
	public Set<Consultation> getConsultations() {
		return this.consultations;
	}
 
	public void setConsultations(Set<Consultation> consultations) {
		this.consultations = consultations;
	}
 
}
Merci d'avance pour votre aide!