Bonjour tout le monde

je travaille avec hibernate + jsf et mysql comme sgbd et j'ai un petit problème de l'insertion , en fait sur la classe personnel j'ai deux champs agence et statut de type agence et statut .
j'arrive pas à insérer dans la table personnel . aider moi s'il vous plait à résoudre ce probleme

voici la class personnel

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
 
 
@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.LAZY)
    @JoinColumn(name="statut", nullable=false)
    public Statut getStatut() {
        return this.statut;
    }
 
    public void setStatut(Statut statut) {
        this.statut = statut;
    }
@ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="numAgence", nullable=false)
    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;
    }
 
}

et la méthode ajouter sur DAO :

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
 
 
      /* Ajouter un personnel */
 
    public void create(Personnel p){
        Session s = HibernateUtil.getSessionFactory().getCurrentSession();
 
        try{
            s.beginTransaction();
            s.save(p);
            s.getTransaction().commit();
        }catch(Exception e){
            e.printStackTrace();
            s.getTransaction().rollback();
        }
 
    }


et la méthode insert sur personnelController.java :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
 
 
   public String insert () {
 
         personnelDAO dao = new personnelDAO() ;
         dao.create(p); 
         return "succes" ;
    }




et sur la vue :

NB: show = personnelController.java

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
 
 
<h:form>
     <h:panelGrid columns="2">
 
         <h:outputText value="Cin"/>
         <h:inputText label="Cin" id="Cin"  value="#{show.p.cin}">  
                </h:inputText>
 
 
                <h:outputText value="Agence"/>
                <h:inputText label="agence" id="agence"  value="#{show.p.agence.numAgence}">
 
                </h:inputText>
 
                <h:outputText value="Statut"/>
                <h:inputText label="statut" id="statut"  value="#{show.p.statut.numStatut}">
 
                </h:inputText>
 
 
                <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>
 
                      <h:outputText value="Adresse :" />
                      <h:inputText label="adresse" id="adresse"  value="#{show.p.adresse}">
 
                </h:inputText>
 
                         <h:outputText value=" Mail :" />
                         <h:inputText label="mail" id="mail" value="#{show.p.mail}">
 
                </h:inputText>
 
                <f:facet name="footer">
                    <a4j:commandButton value="Ajouter"  action="#{show.insert()}" execute="popup" />
                </f:facet>
            </h:panelGrid>
        </h:form>
    </rich:popupPanel>
 
    </h:form>