Bonjour,
j'ai un petit souci avec la mise à jour de la base de donnée.
Lorsque j'insère un élément dans une base de donnée, la donnée est bien inséré mais elle ne s'affiche pas. Je dois redéployer mon application pour qu'elle s'affiche.
Il s'agit d'une application J2EE (JSP - EJB - JPA).
Par ex,
j'ai un artiste qui peut être dans une plusieurs groupes.
Je stocke dans l'entité Artiste, la liste des groupes sous forme de List.
Idem pour groupe, qui peut avoir plusieurs artistes.
Voici le code des deux entities :
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 public class Artiste implements Serializable { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE) private int idartiste; private String nom; private String prenom; private String email; private String role; private String motpasse; private static final long serialVersionUID = 1L; public Artiste() { super(); listeGroupe = new ArrayList<Groupe>(); } public int getIdartiste() { return this.idartiste; } public void setIdartiste(int idartiste) { this.idartiste = idartiste; } public String getNom() { return this.nom; } public void setNom(String nom) { this.nom = nom; } public String getPrenom() { return this.prenom; } public void setPrenom(String prenom) { this.prenom = prenom; } public String getEmail() { return this.email; } public void setEmail(String email) { this.email = email; } public String getRole() { return this.role; } public void setRole(String role) { this.role = role; } public String getMotpasse() { return this.motpasse; } public void setMotpasse(String motpasse) { this.motpasse = motpasse; } @OneToMany(cascade = CascadeType.REMOVE, fetch = FetchType.EAGER) @JoinTable (name="groupeartiste", joinColumns={@JoinColumn(name="idartiste")}, inverseJoinColumns=@JoinColumn (name="idgroupe")) private List<Groupe> listeGroupe; public List<Groupe>getListeGroupe(){ return this.listeGroupe; } public void setListeGroupe(List<Groupe> listeGroupe){ this.listeGroupe = listeGroupe; } }Je sais que le problème vient des listes de groupes ou artistes, car par ex
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 public class Groupe implements Serializable { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE) private int idgroupe; private String nom; private String photo; @Lob private String valide; @Lob private String informations; private static final long serialVersionUID = 1L; public Groupe() { super(); groupeGenre = new ArrayList<Genre>(); groupeArtiste = new ArrayList<Artiste>(); } public int getIdgroupe() { return this.idgroupe; } public void setIdgroupe(int idgroupe) { this.idgroupe = idgroupe; } public String getNom() { return this.nom; } public void setNom(String nom) { this.nom = nom; } public String getPhoto() { return this.photo; } public void setPhoto(String photo) { this.photo = photo; } public String getValide() { return this.valide; } public void setValide(String valide) { this.valide = valide; } public String getInformations() { return this.informations; } public void setInformations(String informations) { this.informations = informations; } @OneToMany(cascade = CascadeType.MERGE, fetch = FetchType.EAGER) @JoinTable (name="groupegenre", joinColumns={@JoinColumn(name="idgroupe")}, inverseJoinColumns=@JoinColumn (name="idgenre")) private List<Genre> groupeGenre; public List<Genre> getListGenre(){ return this.groupeGenre; } public void setListGenre(List<Genre> listGenre){ this.groupeGenre = listGenre; } @OneToMany(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER) @JoinTable (name="groupeartiste", joinColumns={@JoinColumn(name="idgroupe")}, inverseJoinColumns=@JoinColumn (name="idartiste")) private List<Artiste> groupeArtiste; public void setListArtiste(List<Artiste> listeArtiste){ this.groupeArtiste = listeArtiste; } public List<Artiste> getListArtiste(){ return this.groupeArtiste; } }
lorsque je modifie dans mon interface le nom du groupe, il est directement affiché alors que lorsque j'ajoute un artiste à la liste ou j'ajoute un groupe à la liste, l'affichage n'est pas fait, il récupère la liste de départ de l'application.
Partager