Bonjour a tous j
J'ai ici 3 tables :
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
 
SfdPeriodePoste
@Entity
@Table(name = ..., catalog = ...)
public class SfdPeriode implements java.io.Serializable {
 
	/**
         * 
         */
	private Integer idsfdPeriode;
	private Periode periode;
	private Sfd sfd;
	private Set<SfdPeriodeRatio> sfdPeriodeRatios = new HashSet<SfdPeriodeRatio>(0);
	private Set<SfdPeriodeQuotient> sfdPeriodeQuotients = new HashSet<SfdPeriodeQuotient>(0);
	private Set<SfdPeriodePoste> sfdPeriodePostes = new HashSet<SfdPeriodePoste>(0);
	private Set<Score> scores = new HashSet<Score>(0);
 
	public SfdPeriode() {}
 
	public SfdPeriode(Periode periode, Sfd sfd) {
		this.periode = periode;
		this.sfd = sfd;
	}
 
	public SfdPeriode(Periode periode, Sfd sfd,
			Set<SfdPeriodeRatio> sfdPeriodeRatios,
			Set<SfdPeriodeQuotient> sfdPeriodeQuotients,
			Set<SfdPeriodePoste> sfdPeriodePostes, Set<Score> scores) {
		this.periode = periode;
		this.sfd = sfd;
		this.sfdPeriodeRatios = sfdPeriodeRatios;
		this.sfdPeriodeQuotients = sfdPeriodeQuotients;
		this.sfdPeriodePostes = sfdPeriodePostes;
		this.scores = scores;
	}
 
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "idsfd_periode", unique = true, nullable = false)
	public Integer getIdsfdPeriode() {
		return this.idsfdPeriode;
	}
 
	public void setIdsfdPeriode(Integer idsfdPeriode) {
		this.idsfdPeriode = idsfdPeriode;
	}
 
	@ManyToOne(fetch = FetchType.LAZY,cascade=CascadeType.ALL)
	@JoinColumn(name = "periode_idperiode", nullable = false)
	public Periode getPeriode() {
		return this.periode;
	}
 
	public void setPeriode(Periode periode) {
		this.periode = periode;
	}
 
	@ManyToOne(fetch = FetchType.LAZY,cascade=CascadeType.ALL)
	@JoinColumn(name = "sfd_id", nullable = false)
	public Sfd getSfd() {
		return this.sfd;
	}
 
	public void setSfd(Sfd sfd) {
		this.sfd= sfd;
	}
 
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "sfdPeriode",cascade=CascadeType.ALL)
	public Set<SfdPeriodeRatio> getSfdPeriodeRatios() {
		return this.sfdPeriodeRatios;
	}
 
	public void setSfdPeriodeRatios(Set<SfdPeriodeRatio> sfdPeriodeRatios) {
		this.sfdPeriodeRatios = sfdPeriodeRatios;
	}
 
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "sfdPeriode",cascade=CascadeType.ALL)
	public Set<SfdPeriodeQuotient> getSfdPeriodeQuotients() {
		return this.sfdPeriodeQuotients;
	}
 
	public void setSfdPeriodeQuotients(
			Set<SfdPeriodeQuotient> sfdPeriodeQuotients) {
		this.sfdPeriodeQuotients = sfdPeriodeQuotients;
	}
 
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "sfdPeriode",cascade=CascadeType.ALL)
	public Set<SfdPeriodePoste> getSfdPeriodePostes() {
		return this.sfdPeriodePostes;
	}
 
	public void setSfdPeriodePostes(Set<SfdPeriodePoste> sfdPeriodePostes) {
		this.sfdPeriodePostes = sfdPeriodePostes;
	}
 
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "sfdPeriode",cascade=CascadeType.ALL)
	public Set<Score> getScores() {
		return this.scores;
	}
 
	public void setScores(Set<Score> scores) {
		this.scores = scores;
	}
 
}
la table poste
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
@Entity
@Table(name = "", catalog = "...")
public class Poste implements java.io.Serializable {
	private Integer idPoste;
	private Quotient quotient;
	private Etat etat;
	private String codePoste;
	private String libelle;
	private String type;
	private Set<SfdPeriodePoste> sfdPeriodePostes = new HashSet<SfdPeriodePoste>(0);
 
	public Poste() {}
 
	public Poste(Quotient quotient, Etat etat, String codePoste,
			String libelle, String type, Set<SfdPeriodePoste> sfdPeriodePostes) {
		this.quotient = quotient;
		this.etat = etat;
		this.codePoste = codePoste;
		this.libelle = libelle;
		this.type = type;
		this.sfdPeriodePostes = sfdPeriodePostes;
	}
 
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "idPoste", unique = true, nullable = false)
	public Integer getIdPoste() {
		return this.idPoste;
	}
 
	public void setIdPoste(Integer idPoste) {
		this.idPoste = idPoste;
	}
 
	@ManyToOne(fetch = FetchType.LAZY,cascade=CascadeType.ALL)
	@JoinColumn(name = "Quotient_idQuotient")
	public Quotient getQuotient() {
		return this.quotient;
	}
 
	public void setQuotient(Quotient quotient) {
		this.quotient = quotient;
	}
 
	@ManyToOne(fetch = FetchType.LAZY,cascade=CascadeType.ALL)
	@JoinColumn(name = "Etat_idEtat")
	public Etat getEtat() {
		return this.etat;
	}
 
	public void setEtat(Etat etat) {
		this.etat = etat;
	}
 
	@Column(name = "codePoste", length = 5)
	public String getCodePoste() {
		return this.codePoste;
	}
 
	public void setCodePoste(String codePoste) {
		this.codePoste = codePoste;
	}
 
	@Column(name = "libelle", length = 100)
	public String getLibelle() {
		return this.libelle;
	}
 
	public void setLibelle(String libelle) {
		this.libelle = libelle;
	}
 
	@Column(name = "type", length = 7)
	public String getType() {
		return this.type;
	}
 
	public void setType(String type) {
		this.type = type;
	}
 
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "poste",cascade=CascadeType.ALL)
	public Set<SfdPeriodePoste> getSfdPeriodePostes() {
		return this.sfdPeriodePostes;
	}
 
	public void setSfdPeriodePostes(Set<SfdPeriodePoste> sfdPeriodePostes) {
		this.sfdPeriodePostes = sfdPeriodePostes;
	}
 
}
et sfdPeriodePoste
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
 
@Entity
@Table(name = "...", catalog = "...")
public class SfdPeriodePoste implements java.io.Serializable {
 
	private SfdPeriodePosteId id;
	private Poste poste;
	private Valeur valeur;
	private SfdPeriode sfdPeriode;
 
	public SfdPeriodePoste() {
	}
 
	public SfdPeriodePoste(SfdPeriodePosteId id, Poste poste, Valeur valeur,
			SfdPeriode sfdPeriode) {
		this.id = id;
		this.poste = poste;
		this.valeur = valeur;
		this.sfdPeriode = sfdPeriode;
	}
 
	@EmbeddedId
	@AttributeOverrides({
			@AttributeOverride(name = "sfdPeriodeIdsfdPeriode", column = @Column(name = "sfd_periode_idsfd_periode", nullable = false)),
			@AttributeOverride(name = "posteIdPoste", column = @Column(name = "Poste_idPoste", nullable = false)),
			@AttributeOverride(name = "valeurIdvaleur", column = @Column(name = "Valeur_idvaleur", nullable = false)) })
	public SfdPeriodePosteId getId() {
		return this.id;
	}
 
	public void setId(SfdPeriodePosteId id) {
		this.id = id;
	}
 
	@ManyToOne(fetch = FetchType.LAZY,cascade=CascadeType.ALL)
	@JoinColumn(name = "Poste_idPoste", nullable = false, insertable = false, updatable = false)
	public Poste getPoste() {
		return this.poste;
	}
 
	public void setPoste(Poste poste) {
		this.poste = poste;
	}
 
	@ManyToOne(fetch = FetchType.LAZY,cascade=CascadeType.ALL)
	@JoinColumn(name = "Valeur_idvaleur", nullable = false, insertable = false, updatable = false)
	public Valeur getValeur() {
		return this.valeur;
	}
 
	public void setValeur(Valeur valeur) {
		this.valeur = valeur;
	}
 
	@ManyToOne(fetch = FetchType.LAZY,cascade=CascadeType.ALL)
	@JoinColumn(name = "sfd_periode_idsfd_periode", nullable = false, insertable = false, updatable = false)
	public SfdPeriode getSfdPeriode() {
		return this.sfdPeriode;
	}
 
	public void setSfdPeriode(SfdPeriode sfdPeriode) {
		this.sfdPeriode = sfdPeriode;
	}
 
 
}
et la table sfdperiodePosteId
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
@Embeddable
public class SfdPeriodePosteId implements java.io.Serializable {
 
	private int sfdPeriodeIdsfdPeriode;
	private int posteIdPoste;
	private int valeurIdvaleur;
 
	public SfdPeriodePosteId() {
	}
 
	public SfdPeriodePosteId(int sfdPeriodeIdsfdPeriode, int posteIdPoste,
			int valeurIdvaleur) {
		this.sfdPeriodeIdsfdPeriode = sfdPeriodeIdsfdPeriode;
		this.posteIdPoste = posteIdPoste;
		this.valeurIdvaleur = valeurIdvaleur;
	}
 
	@EmbeddedId
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "sfd_periode_idsfd_periode", nullable = false)
	public int getSfdPeriodeIdsfdPeriode() {
		return this.sfdPeriodeIdsfdPeriode;
	}
 
	public void setSfdPeriodeIdsfdPeriode(int sfdPeriodeIdsfdPeriode) {
		this.sfdPeriodeIdsfdPeriode = sfdPeriodeIdsfdPeriode;
	}
 
	@Column(name = "Poste_idPoste", nullable = false)
	public int getPosteIdPoste() {
		return this.posteIdPoste;
	}
 
	public void setPosteIdPoste(int posteIdPoste) {
		this.posteIdPoste = posteIdPoste;
	}
 
	@Column(name = "Valeur_idvaleur", nullable = false)
	public int getValeurIdvaleur() {
		return this.valeurIdvaleur;
	}
 
	public void setValeurIdvaleur(int valeurIdvaleur) {
		this.valeurIdvaleur = valeurIdvaleur;
	}
 
	public boolean equals(Object other) {
		if ((this == other))
			return true;
		if ((other == null))
			return false;
		if (!(other instanceof SfdPeriodePosteId))
			return false;
		SfdPeriodePosteId castOther = (SfdPeriodePosteId) other;
 
		return (this.getSfdPeriodeIdsfdPeriode() == castOther
				.getSfdPeriodeIdsfdPeriode())
				&& (this.getPosteIdPoste() == castOther.getPosteIdPoste())
				&& (this.getValeurIdvaleur() == castOther.getValeurIdvaleur());
	}
 
	public int hashCode() {
		int result = 17;
 
		result = 37 * result + this.getSfdPeriodeIdsfdPeriode();
		result = 37 * result + this.getPosteIdPoste();
		result = 37 * result + this.getValeurIdvaleur();
		return result;
	}
 
}
leprobleme est qua chaque fois que je fais
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
 
SfdPeriodePoste spp= new SfdPeriodePoste ();
spp.setPoste(poste);
spp.setValeur(valeur)
spp.setSfdPeriode(sfdPeriode);
getSession.saveOrUpdate(spp)
il me met ne erreur du type
Code : Sélectionner tout - Visualiser dans une fenêtre à part
org.hibernate.id.IdentifierGenerationException: null id generated
maintenant si j'ajoute
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
SfdPeriodePoste spp= new SfdPeriodePoste ();
spp.setPoste(poste);
spp.setValeur(valeur)
spp.setSfdPeriode(sfdPeriode);
SfdPeriodePosteId sid=new SfdPeriodePosteId();
		sid.setPosteIdPoste(poste.getIdPoste());
		sid.setValeurIdvaleur(spp.getValeur().getIdvaleur());
		spp.setId(sid);
getSession.saveOrUpdate(spp)
il me srt une ereur du genre
Could not execute JDBC batch update [insert into sfd_periode_poste (sfd_periode_idsfd_periode, Poste_idPoste, Valeur_idvaleur) values (?, ?, ?)]
java.sql.BatchUpdateException: Cannot add or update a child row: a foreign key constraint fails (`sfd_periode_poste`, CONSTRAINT `fk_sfd_periode_has_Poste_sfd_periode1` FOREIGN KEY (`sfd_periode_idsfd_periode`) REFERENCES `sfd_periode` (`idsfd_periode`) ON DELETE NO ACTION ON UPDATE)
Quelqu'un pour m'aider svp merci