Bonjour, je travail sur une application web et j'ai donc besoin de desactiver le lazy loading pour recuperer mon graph d'objet.
Voici mon fichier de mappin (je test sur collaborateur):
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
 
<?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="fr.planning.pojo">
	<class
		name="Profil"
		table="PROFIL"
		lazy="false"
	>
		<id
			name="id"
			type="integer"
			column="PRO_ID"
		>
			<generator class="native"/>
		</id>
 
		<property
			name="dateDispo"
			column="PRO_DATE_DISPO"
			type="date"
			not-null="false"
			length="10"
		/>
		<property
			name="droit"
			column="PRO_DROIT"
			type="integer"
			not-null="false"
			length="11"
		/>
		<property
			name="type_utilisateur"
			column="PRO_UTILISATEUR"
			type="java.lang.Boolean"
			not-null="false"
			length="1"
		/>
		<property
			name="commercial"
			column="PRO_COMMERCIAL"
			type="java.lang.Boolean"
			not-null="false"
			length="1"
		/>
		<property
			name="reserver"
			column="PRO_RESERVER"
			type="java.lang.Boolean"
			not-null="false"
			length="1"
		/>
 
		<property
			name="siege"
			column="PRO_SIEGE"
			type="java.lang.Boolean"
			not-null="false"
			length="1"
		/>
		<property
			name="mobilite"
			column="PRO_MOBILITE"
			type="java.lang.Boolean"
			not-null="false"
			length="1"
		/>
 
		<many-to-one
			name="situation"
			column="SIT_ID"
			class="Situation"
			not-null="false"
		>
 
		</many-to-one>
		<many-to-one
			name="client"
			column="CLT_ID"
			class="Client"
			not-null="false"
		>
		</many-to-one>
		<many-to-one
			name="societe"
			column="SOC_ID"
			class="Societe"
			not-null="false"
		>
		</many-to-one>
		<many-to-one
			name="fonction"
			column="RFN_ID"
			class="Fonction"
			not-null="false"
		>
		</many-to-one>
		<many-to-one
			name="collaborateur"
			column="COL_ID"
			class="Collaborateur"
			not-null="false"
			fetch="join"
		>
		</many-to-one>
		<many-to-one
			name="statut"
			column="STT_ID"
			class="Statut"
			not-null="false"
		>
		</many-to-one>
		<many-to-one
			name="utilisateur"
			column="UTL_ID"
			class="Utilisateur"
			not-null="false"
		>
		</many-to-one>
 
		<set
			name="entites"
			table="PREFERENCE"
			cascade="all"
		>
			<key column="PRO_ID"/>
			<many-to-many column="RTT_ID" class="Entite"/>
		</set>
		<set
			name="utilisateurs"
			table="RESERVATION"
			cascade="all"
		>
			<key column="PRO_ID"/>
			<many-to-many column="UTL_ID" class="Utilisateur"/>
		</set>
 
 
	</class>	
</hibernate-mapping>
Et voici mon code de test :
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
 
	public static void main(String[] args){
 
		Session session = HibernateUtil.currentSession();
		Transaction tx = session.beginTransaction();		
		Profil profil = ProfilDAO.getInstance().getByCollaborateurId(Integer.valueOf(24),session);
		System.out.println(profil.toString());
 
		tx.commit();
		session.close();		
 
		String nom = profil.getCollaborateur().getNom();
		System.err.println(nom);	
 
	}
Qd je ferme la session a la fin, pas de probleme, je recupere le nom, alors que qd je ferme la session zvznt la fin, j'ai un probleme de connection : en gros le lazy loading est toujours activé. Pourquoi?
Merci.