Bonjour les jeunes
j’espère que tout le monde va bien et je tiens à remercier d’abord tous les membres du forum qui m'ont aidé à résoudre les problèmes dont j'avais précédemment
Bon je rencontre actuellement une erreur que j'ai pas pu savoir d'ou vient-elle , en fait lorsque j'affiche dans une formulaire les données pour les modifier , quand je clique sur le bouton modifier , les champs se modifient très bien sauf l'identifiant et les données qui sont dans le select one menu . et quand je teste sur main une erreur se lance comme suit :
voici l'entity personnel
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 Exception in thread "main" org.hibernate.HibernateException: identifier of an instance of entity.Personnel was altered from T244868 to MonCin at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:58) at org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:164) at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:120) at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:196) at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000) at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338) at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106) at controller.PersonnelController.main(PersonnelController.java:253)
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 @Entity @Table(name="personnel" ,catalog="derichebourg" ) public class Personnel implements java.io.Serializable { private String cin; private Statut statut; private Agence agence; private String nomPersonnel; private String prenom; private String numTelephone; private String adresse; private String fonction; private String login; private String motDePasse; private String mail; private Set<Conducteur> conducteurs = new HashSet<Conducteur>(0); private Set<Responsableconducteur> responsableconducteurs = new HashSet<Responsableconducteur>(0); public Personnel() { } public Personnel(String cin, Statut statut, Agence agence) { this.cin = cin; this.statut = statut; this.agence = agence; } public Personnel(String cin, Statut statut, Agence agence, String nomPersonnel, String prenom, String numTelephone, String adresse, String fonction, String login, String motDePasse, String mail, Set<Conducteur> conducteurs, Set<Responsableconducteur> responsableconducteurs) { this.cin = cin; this.statut = statut; this.agence = agence; this.nomPersonnel = nomPersonnel; this.prenom = prenom; this.numTelephone = numTelephone; this.adresse = adresse; this.fonction = fonction; this.login = login; this.motDePasse = motDePasse; this.mail = mail; this.conducteurs = conducteurs; this.responsableconducteurs = responsableconducteurs; } @Id @Column(name="cin", unique=true, nullable=false, length=700) public String getCin() { return this.cin; } public void setCin(String cin) { this.cin = cin; } @ManyToOne(fetch=FetchType.EAGER) @JoinColumn(name="statut", nullable=true) public Statut getStatut() { return this.statut; } public void setStatut(Statut statut) { this.statut = statut; } @ManyToOne(fetch=FetchType.EAGER) @JoinColumn(name="numAgence", nullable=true) public Agence getAgence() { return this.agence; } public void setAgence(Agence agence) { this.agence = agence; } @Column(name="nomPersonnel", length=700) public String getNomPersonnel() { return this.nomPersonnel; } public void setNomPersonnel(String nomPersonnel) { this.nomPersonnel = nomPersonnel; } @Column(name="prenom", length=700) public String getPrenom() { return this.prenom; } public void setPrenom(String prenom) { this.prenom = prenom; } @Column(name="numTelephone", length=500) public String getNumTelephone() { return this.numTelephone; } public void setNumTelephone(String numTelephone) { this.numTelephone = numTelephone; } @Column(name="adresse", length=900) public String getAdresse() { return this.adresse; } public void setAdresse(String adresse) { this.adresse = adresse; } @Column(name="fonction", length=700) public String getFonction() { return this.fonction; } public void setFonction(String fonction) { this.fonction = fonction; } @Column(name="login", length=700) public String getLogin() { return this.login; } public void setLogin(String login) { this.login = login; } @Column(name="mot_de_passe", length=900) public String getMotDePasse() { return this.motDePasse; } public void setMotDePasse(String motDePasse) { this.motDePasse = motDePasse; } @Column(name="mail", length=500) public String getMail() { return this.mail; } public void setMail(String mail) { this.mail = mail; } @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="personnel") public Set<Conducteur> getConducteurs() { return this.conducteurs; } public void setConducteurs(Set<Conducteur> conducteurs) { this.conducteurs = conducteurs; } @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="personnel") public Set<Responsableconducteur> getResponsableconducteurs() { return this.responsableconducteurs; } public void setResponsableconducteurs(Set<Responsableconducteur> responsableconducteurs) { this.responsableconducteurs = responsableconducteurs; } @Override public String toString() { return "Personnel{" + "cin=" + cin + ", statut=" + statut + ", agence=" + agence + ", nomPersonnel=" + nomPersonnel + ", prenom=" + prenom + ", numTelephone=" + numTelephone + ", fonction=" + fonction + ", login=" + login + ", motDePasse=" + motDePasse + '}'; }
les méthodes edit () et edita() une pour remplir les champs dans une formulaire et la deuxieme pour modifier les champs
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 /* Remplir les champs dans le formulaire pour modifier un personnel */ public String edita (Personnel personnage){ this.p=personnage; return "modifier"; } /* modifier un personnel */ public void edit (){ personnelDAO dao = new personnelDAO() ; dao.edit(this.p); }
la vue :
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 <h:form rendered="#{show.verificarSesion()}"> <!-- update --> <h:panelGrid columns="2" id="editGrid"> <h:outputText value="Cin"/> <h:inputText label="Cin" id="Cin" value="#{show.p.cin}"> </h:inputText> <h:outputText value="Agence"/> <rich:select defaultLabel="Liste des Agences" value="#{show.numA}"> <f:selectItems value="#{showA.agences}" var ="ag" itemValue="#{ag.numAgence}" itemLabel="#{ag.nomAgence}"/> </rich:select> <h:outputText value="Statut"/> <rich:select defaultLabel="Liste des Statuts" value="#{show.numS}" > <f:selectItems value="#{showS.statuts}" var="st" itemValue="#{st.numStatut}" itemLabel="#{st.nomstatut}" /> </rich:select> <h:outputText value="Nom"/> <h:inputText label="nom" id="nom" value="#{show.p.nomPersonnel}"> </h:inputText> <h:outputText value="Prenom:" /> <h:inputText label="prenom" id="prenom" value="#{show.p.prenom}"> </h:inputText> <h:outputText value="Num :" /> <h:inputText label="pum" id="num" value="#{show.p.numTelephone}"> </h:inputText> <h:outputText value="Fonction:" /> <h:inputText label="fonction" id="fonction" value="#{show.p.fonction}"> </h:inputText> <h:outputText value="Login :" /> <h:inputText label="login" id="login" value="#{show.p.login}"> </h:inputText> <h:outputText value=" passe :" /> <h:inputText label="passe" id="passe" value="#{show.p.motDePasse}"> </h:inputText> <f:facet name="footer"> <a4j:commandButton value="Modifier" onclick="myFunction()" action="#{show.edit()}" render="popupM" execute="@this" resetValues="true" oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('popupM')}.hide();}" /> </f:facet> <f:facet name="footer"> <a4j:commandButton action="#{show.clear()}" value="Cancel" oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('popupM')}.hide();}" render="popup" execute="@this" resetValues="true" /> </f:facet> </h:panelGrid> </h:form>
Partager