bonjour j’espère que quelqu'un peut m'aider
voici mon entity
le mapping de cette entity
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 package Entity; // Generated 7 juil. 2011 14:33:26 by Hibernate Tools 3.2.1.GA import java.util.HashSet; import java.util.Set; /** * Profil generated by hbm2java */ public class Profil implements java.io.Serializable { private String libelleprofil; private String statusp; private Set droitprofils = new HashSet(0); private Set agents = new HashSet(0); public Profil() { } public Profil(String libelleprofil) { this.libelleprofil = libelleprofil; } public Profil(String libelleprofil, String statusp, Set droitprofils, Set agents) { this.libelleprofil = libelleprofil; this.statusp = statusp; this.droitprofils = droitprofils; this.agents = agents; } public String getLibelleprofil() { return this.libelleprofil; } public void setLibelleprofil(String libelleprofil) { this.libelleprofil = libelleprofil; } public String getStatusp() { return this.statusp; } public void setStatusp(String statusp) { this.statusp = statusp; } public Set getDroitprofils() { return this.droitprofils; } public void setDroitprofils(Set droitprofils) { this.droitprofils = droitprofils; } public Set getAgents() { return this.agents; } public void setAgents(Set agents) { this.agents = agents; } }
j'ai une interface qui contient un formulaire ou je saisie les informations d'un agent plus d'une liste déroulante de profil .
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 <hibernate-mapping> <class name="Entity.Profil" schema="EBANKING" table="PROFIL"> <id name="libelleprofil" type="string"> <column length="254" name="LIBELLEPROFIL"/> <generator class="assigned"/> </id> <property name="statusp" type="string"> <column length="6" name="STATUSP"/> </property> <set inverse="true" name="droitprofils"> <key> <column length="254" name="LIBELLEPROFIL"/> </key> <one-to-many class="Entity.Droitprofil"/> </set> <set inverse="true" name="agents"> <key> <column length="254" name="LIBELLEPROFIL"/> </key> <one-to-many class="Entity.Agent"/> </set> </class> </hibernate-mapping>
voici le bean de l'agent
l'entité
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 /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package Beans; import Entity.Agent; import Entity.Profil; import Interfaces.InterfaceService; import java.io.Serializable; import java.util.ArrayList; import java.util.Hashtable; import java.util.Iterator; import java.util.List; import org.richfaces.component.UIDataTable; /** * * @author Administrateur */ public class AgentBean extends messageBean implements Serializable{ /** Creates a new instance of AgentBean */ private Agent agn; private InterfaceService agnService; private InterfaceService prfService; private List agent_list = new ArrayList(); private List profil_list = new ArrayList(); private Hashtable prflist = new Hashtable(); private String current_service; private boolean init; private Integer index = 0; private String message; private boolean nouveau; private UIDataTable dataTable; public void viderchamps() { setMessage(""); changeretat(); this.setAgn(new Agent()); setNouveau(true); } public void annuler() { setMessage(""); setAgent_list((List) getAgent_list()); setAgn((Agent) agent_list.get(getIndex())); changeretat(); } public void chargercombo() { setCurrent_service(this.getAgn().getProfil().getLibelleprofil()); } public boolean isInit() { setMessage(""); getPrflist(); getAgent_list(); if (!(agent_list.isEmpty())) { setAgent_list((List) getAgent_list()); setAgn((Agent) agent_list.get(0)); chargercombo(); } etat = true; invetat = !etat; return init; } public AgentBean() { this.agn = new Agent(); this.agn.setProfil(new Profil()); } public void create() { if (isNouveau()) { try { this.getAgn().setProfil((Profil) prflist.get(getCurrent_service())); this.getAgnService().save(this.getAgn()); setMessage(mess_insert_true); style_message = "valid_message"; chargercombo(); } catch (Exception hx) { hx.printStackTrace(); setMessage(mess_op_false); style_message = "err_message"; } } else { try { this.getAgn().setProfil((Profil) prflist.get(getCurrent_service())); this.getAgnService().modify(getAgn()); setMessage(mess_modif_true); style_message = "valid_message"; chargercombo(); } catch (Exception hx) { hx.printStackTrace(); setMessage(mess_op_false); style_message = "err_message"; } } changeretat(); } public void modifierligne() { this.setAgn((Agent) getDataTable().getRowData()); chargercombo(); setMessage(""); setNouveau(false); changeretat();} public void modifier() { setMessage(""); setNouveau(false); changeretat(); } public void supprimer() { try { this.getAgnService().delete(getAgn()); setMessage(mess_del_true); style_message = "valid_message"; if (getIndex() > 0) { setIndex((Integer) (getIndex() - 1)); } setAgent_list((List) getAgent_list()); if (!agent_list.isEmpty()) { setAgn((Agent) agent_list.get(getIndex())); chargercombo(); } else { viderchamps(); changeretat(); } } catch (Exception hx) { hx.printStackTrace(); setMessage(mess_op_false); } } public List getAgent_list() { setAgent_list(this.getAgnService().findAll()); return agent_list; } public Hashtable getPrflist() { getProfil_list().clear(); prflist.clear(); List l = this.getPrfService().findAll(); for (Iterator it = l.iterator(); it.hasNext();) { Profil pr= (Profil) l.get(l.indexOf(it.next())); getProfil_list().add(pr.getLibelleprofil()); prflist.put(pr.getLibelleprofil(), pr); } return prflist; } /** * @return the agn */ public Agent getAgn() { return agn; } /** * @param agn the agn to set */ public void setAgn(Agent agn) { this.agn = agn; } /** * @return the agnService */ public InterfaceService getAgnService() { return agnService; } /** * @param agnService the agnService to set */ public void setAgnService(InterfaceService agnService) { this.agnService = agnService; } /** * @return the prfService */ public InterfaceService getPrfService() { return prfService; } /** * @param prfService the prfService to set */ public void setPrfService(InterfaceService prfService) { this.prfService = prfService; } /** * @param agent_list the agent_list to set */ public void setAgent_list(List agent_list) { this.agent_list = agent_list; } /** * @return the profil_list */ public List getProfil_list() { return profil_list; } /** * @param profil_list the profil_list to set */ public void setProfil_list(List profil_list) { this.profil_list = profil_list; } /** * @param prflist the prflist to set */ public void setPrflist(Hashtable prflist) { this.prflist = prflist; } /** * @return the current_service */ public String getCurrent_service() { return current_service; } /** * @param current_service the current_service to set */ public void setCurrent_service(String current_service) { this.current_service = current_service; } /** * @param init the init to set */ public void setInit(boolean init) { this.init = init; } /** * @return the index */ public Integer getIndex() { return index; } /** * @param index the index to set */ public void setIndex(Integer index) { this.index = index; } /** * @return the message */ public String getMessage() { return message; } /** * @param message the message to set */ public void setMessage(String message) { this.message = message; } /** * @return the nouveau */ public boolean isNouveau() { return nouveau; } /** * @param nouveau the nouveau to set */ public void setNouveau(boolean nouveau) { this.nouveau = nouveau; } /** * @return the dataTable */ public UIDataTable getDataTable() { return dataTable; } /** * @param dataTable the dataTable to set */ public void setDataTable(UIDataTable dataTable) { this.dataTable = dataTable; } }
et le mapping de l'agent
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 package Entity; // Generated 7 juil. 2011 14:33:26 by Hibernate Tools 3.2.1.GA import java.util.HashSet; import java.util.Set; /** * Agent generated by hbm2java */ public class Agent implements java.io.Serializable { private String login; private Profil profil; private String password; private String nom; private String prenom; private String statusagent; private String job; private Set smsemails = new HashSet(0); private Set operations = new HashSet(0); private Set reclamations = new HashSet(0); public Agent() { } public Agent(String login) { this.login = login; } public Agent(String login, Profil profil, String password, String nom, String prenom, String statusagent, String job, Set smsemails, Set operations, Set reclamations) { this.login = login; this.profil = profil; this.password = password; this.nom = nom; this.prenom = prenom; this.statusagent = statusagent; this.job = job; this.smsemails = smsemails; this.operations = operations; this.reclamations = reclamations; } public String getLogin() { return this.login; } public void setLogin(String login) { this.login = login; } public Profil getProfil() { return this.profil; } public void setProfil(Profil profil) { this.profil = profil; } public String getPassword() { return this.password; } public void setPassword(String password) { this.password = password; } 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 String getStatusagent() { return this.statusagent; } public void setStatusagent(String statusagent) { this.statusagent = statusagent; } public String getJob() { return this.job; } public void setJob(String job) { this.job = job; } public Set getSmsemails() { return this.smsemails; } public void setSmsemails(Set smsemails) { this.smsemails = smsemails; } public Set getOperations() { return this.operations; } public void setOperations(Set operations) { this.operations = operations; } public Set getReclamations() { return this.reclamations; } public void setReclamations(Set reclamations) { this.reclamations = reclamations; } }
j'ai suivi ce tutoriel http://dghaies-jihed.developpez.com/javaee/spring/
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 <hibernate-mapping> <class name="Entity.Agent" schema="EBANKING" table="AGENT"> <id name="login" type="string"> <column length="254" name="LOGIN"/> <generator class="assigned"/> </id> <many-to-one class="Entity.Profil" fetch="select" name="profil"> <column length="254" name="LIBELLEPROFIL"/> </many-to-one> <property name="password" type="string"> <column length="254" name="PASSWORD"/> </property> <property name="nom" type="string"> <column length="254" name="NOM"/> </property> <property name="prenom" type="string"> <column length="254" name="PRENOM"/> </property> <property name="statusagent" type="string"> <column length="6" name="STATUSAGENT"/> </property> <property name="job" type="string"> <column length="254" name="JOB"/> </property> <set inverse="true" name="smsemails"> <key> <column length="254" name="LOGIN"/> </key> <one-to-many class="Entity.Smsemail"/> </set> <set inverse="true" name="operations"> <key> <column length="254" name="LOGIN"/> </key> <one-to-many class="Entity.Operation"/> </set> <set inverse="true" name="reclamations"> <key> <column length="254" name="LOGIN"/> </key> <one-to-many class="Entity.Reclamation"/> </set> </class> </hibernate-mapping>
il marche très bien ça s’exécute comme je veux ,je les tester plusieurs fois et ça marche super
mais maintement lorsque je run la jsp soit ile medonne cette erreur
ou bien celle là nullpointeurexeption
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 ATTENTION: StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception org.hibernate.LazyInitializationException: could not initialize proxy - no Session at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:57) at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111) at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:150) at Entity.Profil$$EnhancerByCGLIB$$faee40bc.toString(<generated>) at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getFormattedValue(HtmlBasicRenderer.java:498) at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getFormattedValue(HtmlBasicRenderer.java:5 .....
java.lang.NullPointerException
at Beans.AgentBean.chargercombo(AgentBean.java:51)
at Beans.AgentBean.isInit(AgentBean.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:302)
....
et des erreur de type
java.io.InvalidClassException: Beans.AgentBean; local class incompatible: stream classdesc serialVersionUID = 3714718194222328188, local class serialVersionUID = 4686147252346932713
at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:562)
.......
.
.
.
.
je ne sais pas d'ou viens l'erreur s'il vous plais aidez moi je suis vraiment en retard à cause de cà
et merciii
Partager