Problème foreign key avec hibernate :Formulaire struts:
bonjour tt le monde :j'ai besoin de votre aide svp

Voici mon problème j'ai un formulaire qui se compose de champs de ma table "ressource" et de ma table "conge" tel qe la table ressource a une clé etrangère qui reprèsente la clé primaire de la table "conge"

Problème : l'insertion ne se fait pas pourtant je crois que ce que j'ai ds mon Action est logique.

voici ma page jsp_________________________
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
 
<h:form action="/affectconge" style="text-align:center">
 
<p>&nbsp;</p>
 
<table width="361" align="center">
 
<tr><td width="56"><p class="Style23">Lastname </p></td>
 
<td> <h:text property="nomRessource" /></td></tr>
 
<tr> <td><p class="Style23">first name</p></td>
 
<td> <h:text property="prenomRessource" /></td></tr>
 
<tr> <td> <p class="Style23">Country</p></td>
 
<td> <h:text property="paysRessource" /></td></tr>
 
<tr><td><p class="Style23">Phone</p></td>
 
<td> <h:text property="numTelephone" /></td></tr>
 
<tr><td><p class="Style23">Days off Type</p></td>
 
<td> <h:text property="typeConge" /></td></tr>
 
<td><span class="Style23 Style2 Style1 Style4">Date starting</span></td>
 
<td width="144">
 
<input type="text" name="ddconge" onFocus="view_microcal(true,'ddconge','microcal',-1,0);" onBlur="view_microcal(false,'ddconge','microcal',-1,0);" onKeyUp="this.style.color=testTypeDate(this.value)?'black':'red" /></td>
 
<div id="microcal" name="microcal" style="visibility:hidden;position:absolute;border:1px gray dashed;background:#ffffff; margin-left: 70px;"> </div>
 
<tr> <td><span class="Style23 Style2 Style1 Style4">Date ending</span></td>
 
<td>
 
<input type="text" name="dfconge" onFocus="view_microcal(true,'dfconge','microcal',-1,0);" onBlur="view_microcal(false,'dfconge','microcal',-1,0);" onKeyUp="this.style.color=testTypeDate(this.value)?'black':'red" /></td>
 
<div id="microcal" name="microcal" style="visibility:hidden;position:absolute;border:1px gray dashed;background:#ffffff; margin-left: 70px;"> </div>
 
</tr>
 
<tr>
 
<td><span class="Style23 Style2">Dury</span></td>
 
<td><input type="text" name="dureeconge" value="0" readonly onFocus="calculer()" />
 
<span class="Style2"> days</span></td>
 
</tr>
 
</table>
 
<table width="110" align="center">
 
<tr>
 
<td width="154"><input name="Submit" type="submit" class="top" value="Add" style="text-align:center"/>
 
<input name="cancel" type="reset" class="top" value="Reset"/></td></tr>
 
</table>
</h:form>
voici mon action _________________________
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
 
package com.struts.controleur;
import com.struts.data.AddmissionForm;
import com.struts.data.AffectcongeForm;
import com.basenew.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.util.HibernateUtil;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.*;
import org.hibernate.*;
public final class AffectcongeAction extends Action
{
    public AffectcongeAction()
    {
    }
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res)
        throws Exception
    {
        String resultat = null;
 
        String prenomRessource = ((AffectcongeForm)form).getPrenomRessource();
        String nomRessource = ((AffectcongeForm)form).getNomRessource();
        String paysRessource = ((AffectcongeForm)form).getPaysRessource();
        String numTelephone = ((AffectcongeForm)form).getNumTelephone();
        String typeConge = ((AffectcongeForm)form).getTypeConge();
        String dateValue1 = ((AffectcongeForm)form).getDdconge();
        String dateValue2= ((AffectcongeForm)form).getDfconge();
        Double dureeconge =((AffectcongeForm)form).getDureeconge();
 
 
        try
        {
            Session session = HibernateUtil.getSessionFactory().getCurrentSession();
            session.beginTransaction();
            Ressource r1 = new Ressource();
            Conge c1=new Conge();
           // Profil p1=new Profil();
          //r1.setIdSeuil(Integer.valueOf(idSeuil));
            //r1.setIdProfil(Integer.valueOf(idProfil));
            r1.setNomRessource(nomRessource);
            r1.setPrenomRessource(prenomRessource);
            r1.setPaysRessource(paysRessource);
            r1.setNumTelephone(numTelephone);
            SimpleDateFormat dd = new SimpleDateFormat("dd-MM-yyyy");
            SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy");
            java.util.Date  ddconge = dd.parse(dateValue1);
            java.util.Date  dfconge= df.parse(dateValue2);
            r1.setDdconge(ddconge);
            r1.setDfconge(dfconge);
            r1.setDureeconge(dureeconge);
 
            c1.setTypeConge(typeConge);
            c1.setIdConge(0);
            System.out.println("je conserve le type conge ds conge");
 
 
            session.save(c1);
            System.out.println("après save c1 le type conge ds conge");
            //session.save(p1);
 
            r1.setConge(c1);
            System.out.println("c1 ds ressource");
 
 
            session.save(r1);
            //r1.setIdRessource(0);
            System.out.println("r1 saved");
 
            session.getTransaction().commit();
 
            HibernateUtil.getSessionFactory().close();
 
            resultat = "succes";
 
        }
        catch(Exception ex)
        {
            HibernateUtil.getSessionFactory().close();
            resultat = "echec";
        }
        return mapping.findForward(resultat);
    }
}
voici mon bean______________________________
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
 
package com.struts.data;
 
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.*;
import com.basenew.Conge;
 
public class AffectcongeForm extends ActionForm
{
 private static final long serialVersionUID = 1L;
private int idRessource;
private int idConge;
private String nomRessource;
private String prenomRessource;
private String numTelephone;
private String paysRessource;
private String ddconge;
private String dfconge;
private Double dureeconge;
private Conge conge;
private String typeConge;
   public AffectcongeForm()
{
}
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
{
    ActionErrors errors = new ActionErrors();
    return errors;
}
public void reset(ActionMapping mapping, HttpServletRequest request)
{
     idRessource = 0;
    idConge=0;
    nomRessource = null;
    prenomRessource = null;
    dureeconge=null;
    dfconge=null;
    ddconge=null;
    paysRessource=null;
    numTelephone=null;
    conge=null;
 
}
public int getIdRessource() {
 return this.idRessource;
}
public void setIdRessource(int idRessource) {
 this.idRessource = idRessource;
}
public Conge getConge() {
 return this.conge;
}
public void setConge(Conge conge) {
 this.conge = conge;
}
public String getNomRessource() {
 return this.nomRessource;
}
public void setNomRessource(String nomRessource) {
 this.nomRessource = nomRessource;
}
public String getPrenomRessource() {
 return this.prenomRessource;
}
public void setPrenomRessource(String prenomRessource) {
 this.prenomRessource = prenomRessource;
}
public String getNumTelephone() {
 return this.numTelephone;
}
public void setNumTelephone(String numTelephone) {
 this.numTelephone = numTelephone;
}
public String getPaysRessource() {
 return this.paysRessource;
}
public void setPaysRessource(String paysRessource) {
 this.paysRessource = paysRessource;
}
public String getDdconge() {
 return this.ddconge;
}
public void setDdconge(String ddconge) {
 this.ddconge = ddconge;
}
public String getDfconge() {
 return this.dfconge;
}
public void setDfconge(String dfconge) {
 this.dfconge = dfconge;
}
public Double getDureeconge() {
 return this.dureeconge;
}
public void setDureeconge(Double dureeconge) {
 this.dureeconge = dureeconge;
}
public String getTypeConge() {
 return this.typeConge;
}
public void setTypeConge(String typeConge) {
 this.typeConge = typeConge;
}
public int getIdConge() {
 return this.conge.getIdConge();
}
public void setIdConge(int idConge) {
 this.conge.setIdConge(idConge);
}
}
Merci pour votre aide