Bonjour à tous.
Au fait je me demande si quelqu'un pouvait m'aider .
j'ai un schemas sous cette forme
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
 
---------    --------------    -------- 
+ Archi +    +Archi_Forme+    +Forme+
---------    --------------   ---------
 -id             -idArchi            -id
 -nom            -idForme         -valeur
                  -actif
                  -couleur
voici le mapping que j'ai effectué
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
 
@Entity
@Table(name = "archi", catalog = "test")
public class Archi implements java.io.Serializable {
	private Integer id;
	private String nom;
	private Set<Forme> formes;
 
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	@Column(name = "nom", nullable = false, length = 50)
	public String getNom() {
		return this.nom;
	}
	public void setNom(String nom) {
		this.nom = nom;
	}
 
	@ManyToMany(fetch = FetchType.LAZY)
	@Cascade( { CascadeType.SAVE_UPDATE })
	@JoinTable(name = "archi_forme", catalog = "test", 
			joinColumns = { @JoinColumn(name = "idArchi", nullable = false) }, 
			inverseJoinColumns = { @JoinColumn(name = "idForme", nullable = false) })
	public Set<Forme> getFormes() {
		return this.formes;
	}
 
	public void setFormes(Set<Forme> formes) {
		this.formes = formes;
	}
 
	public void addForme(Forme forme){
		this.formes.add(forme);
	}
 
	public void delForme(Forme forme){
		this.formes.remove(forme);
	}
}
Archi_forme
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
 
public class ArchiForme implements java.io.Serializable {
	private ArchiFormeId id;
 
	public ArchiForme() {
	}
 
	public ArchiForme(ArchiFormeId id) {
		this.id = id;
	}
 
	@EmbeddedId
	@AttributeOverrides({
			@AttributeOverride(name = "idArchi", column = @Column(name = "idArchi", nullable = false)),
			@AttributeOverride(name = "idForme", column = @Column(name = "idForme", nullable = false)),
			@AttributeOverride(name = "actif", column = @Column(name = "actif")),
			@AttributeOverride(name = "couleur", column = @Column(name = "couleur", length = 10)) })
	public ArchiFormeId getId() {
		return this.id;
	}
 
	public void setId(ArchiFormeId id) {
		this.id = id;
	}
}
Forme
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
public class Forme implements java.io.Serializable {
	private Integer id;
	private String valeur;
	private Set<Archi> archis;
 
	public Forme() {
	}
 
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}
 
	public void setId(Integer id) {
		this.id = id;
	}
 
	@Column(name = "valeur", nullable = false, length = 20)
	public String getValeur() {
		return this.valeur;
	}
 
	public void setValeur(String valeur) {
		this.valeur= valeur;
	}
 
	@ManyToMany(fetch = FetchType.LAZY,mappedBy = "archis")
	public Set<Archi> getArchis() {
		return this.archis;
	}
 
	public void setArchis(Set<Archi> archis) {
		this.archis = archis;
	}
 
}
Le probleme quand je fait une
Archi archi=new Archi("blabla");
archi.addForme(new Forme("forme"));
archi.save();
archi est sauvée ainsi que forme mais la classe association n'est pas renseignée.
Quelqu'un peut me dire ou j'ai peché???