Bonjour à tous,
Quand je vais un run as serveur sur mon projet web dynamic project il me dit cela :
Voici la classe LigneDeCommande
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 Exception Description: The mapping [commande] from the embedded ID class [class model.LigneDeCommandePK] is an invalid mapping for this class. An embeddable class that is used with an embedded ID specification (attribute [id] from the source [class model.LigneDeCommande]) can only contain basic mappings. Either remove the non basic mapping or change the embedded ID specification on the source to be embedded.
voici la classe LigneDeCommandePK :
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 package model; import java.io.Serializable; import javax.persistence.*; /** * The persistent class for the ligne_de_commande database table. * */ @Entity @Table(name="ligne_de_commande") @NamedQuery(name="LigneDeCommande.findAll", query="SELECT l FROM LigneDeCommande l") public class LigneDeCommande implements Serializable { private static final long serialVersionUID = 1L; @EmbeddedId private LigneDeCommandePK id; private int quantite; //bi-directional many-to-one association to Commande @ManyToOne @JoinColumn(name="commande") private Commande commandeBean; //bi-directional many-to-one association to Livre @ManyToOne @JoinColumn(name="livre") private Livre livreBean; public LigneDeCommande() { } public LigneDeCommandePK getId() { return this.id; } public void setId(LigneDeCommandePK id) { this.id = id; } public int getQuantite() { return this.quantite; } public void setQuantite(int quantite) { this.quantite = quantite; } public Commande getCommandeBean() { return this.commandeBean; } public void setCommandeBean(Commande commandeBean) { this.commandeBean = commandeBean; } public Livre getLivreBean() { return this.livreBean; } public void setLivreBean(Livre livreBean) { this.livreBean = livreBean; } }
voici la classe Commande :
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 package model; import java.io.Serializable; import javax.persistence.*; /** * The primary key class for the ligne_de_commande database table. * */ @Embeddable public class LigneDeCommandePK implements Serializable { //default serial version id, required for serializable classes. private static final long serialVersionUID = 1L; @Column(insertable=false, updatable=false) private Livre livre; @Column(insertable=false, updatable=false) private Commande commande; public LigneDeCommandePK() { } public Livre getLivre() { return this.livre; } public void setLivre(Livre livre) { this.livre = livre; } public Commande getCommande() { return this.commande; } public void setCommande(Commande commande) { this.commande = commande; } public boolean equals(Object other) { if (this == other) { return true; } if (!(other instanceof LigneDeCommandePK)) { return false; } LigneDeCommandePK castOther = (LigneDeCommandePK)other; return (this.livre == castOther.livre) && (this.commande == castOther.commande); } /*public int hashCode() { final int prime = 31; int hash = 17; hash = hash * prime + this.livre; hash = hash * prime + this.commande; return hash; }*/ }
voici la classe livre :
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 package model; import java.io.Serializable; import javax.persistence.*; import java.util.Date; import java.util.List; /** * The persistent class for the commande database table. * */ @Entity @NamedQuery(name="Commande.findAll", query="SELECT c FROM Commande c") public class Commande implements Serializable { private static final long serialVersionUID = 1L; @Id private int id; @Temporal(TemporalType.DATE) @Column(name="date_commande") private Date dateCommande; @Column(name="total_commande") private double totalCommande; //bi-directional many-to-one association to Client @ManyToOne @JoinColumn(name="client") private Client clientBean; //bi-directional many-to-one association to LigneDeCommande @OneToMany(mappedBy="commandeBean") private List<LigneDeCommande> ligneDeCommandes; public Commande() { } public int getId() { return this.id; } public void setId(int id) { this.id = id; } public Date getDateCommande() { return this.dateCommande; } public void setDateCommande(Date dateCommande) { this.dateCommande = dateCommande; } public double getTotalCommande() { return this.totalCommande; } public void setTotalCommande(double totalCommande) { this.totalCommande = totalCommande; } public Client getClientBean() { return this.clientBean; } public void setClientBean(Client clientBean) { this.clientBean = clientBean; } public List<LigneDeCommande> getLigneDeCommandes() { return this.ligneDeCommandes; } public void setLigneDeCommandes(List<LigneDeCommande> ligneDeCommandes) { this.ligneDeCommandes = ligneDeCommandes; } public LigneDeCommande addLigneDeCommande(LigneDeCommande ligneDeCommande) { getLigneDeCommandes().add(ligneDeCommande); ligneDeCommande.setCommandeBean(this); return ligneDeCommande; } public LigneDeCommande removeLigneDeCommande(LigneDeCommande ligneDeCommande) { getLigneDeCommandes().remove(ligneDeCommande); ligneDeCommande.setCommandeBean(null); return ligneDeCommande; } }
Voilà donc ci-avant les classe qui concerne la table ligne_de_commande contenant les composites livre avec commande et un champs normal quantité avec les tables Livre et Commande en relation avec celle-ci.
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255 package model; import java.io.Serializable; import javax.persistence.*; import java.util.List; /** * The persistent class for the livre database table. * */ @Entity @NamedQueries ({ @NamedQuery(name="Livre.findAll", query="SELECT l FROM Livre l") }) public class Livre implements Serializable { private static final long serialVersionUID = 1L; @Id private int id; @Column(name="annee_parution") private int anneeParution; @Lob private String description; private int ecrivain; private String image; private String isbn; private String langue; @Column(name="prix_neuf") private double prixNeuf; @Column(name="prix_numerique") private double prixNumerique; @Column(name="prix_occasion_physique") private double prixOccasionPhysique; private int quantite; @Column(name="sujet_livre") private String sujetLivre; private boolean telechargement; private String titre; //bi-directional many-to-many association to Auteur @ManyToMany(mappedBy="livres") private List<Auteur> auteurs; //bi-directional many-to-one association to LigneDeCommande @OneToMany(mappedBy="livreBean") private List<LigneDeCommande> ligneDeCommandes; //bi-directional many-to-one association to Editeur @ManyToOne @JoinColumn(name="editeur") private Editeur editeurBean; //bi-directional many-to-one association to Genre @ManyToOne @JoinColumn(name="genre") private Genre genreBean; //bi-directional many-to-many association to FormatLivre @ManyToMany @JoinTable( name="support" , joinColumns={ @JoinColumn(name="livre") } , inverseJoinColumns={ @JoinColumn(name="format_livre") } ) private List<FormatLivre> formatLivres; public Livre() { } public int getId() { return this.id; } public void setId(int id) { this.id = id; } public int getAnneeParution() { return this.anneeParution; } public void setAnneeParution(int anneeParution) { this.anneeParution = anneeParution; } public String getDescription() { return this.description; } public void setDescription(String description) { this.description = description; } public int getEcrivain() { return this.ecrivain; } public void setEcrivain(int ecrivain) { this.ecrivain = ecrivain; } public String getImage() { return this.image; } public void setImage(String image) { this.image = image; } public String getIsbn() { return this.isbn; } public void setIsbn(String isbn) { this.isbn = isbn; } public String getLangue() { return this.langue; } public void setLangue(String langue) { this.langue = langue; } public double getPrixNeuf() { return this.prixNeuf; } public void setPrixNeuf(double prixNeuf) { this.prixNeuf = prixNeuf; } public double getPrixNumerique() { return this.prixNumerique; } public void setPrixNumerique(double prixNumerique) { this.prixNumerique = prixNumerique; } public double getPrixOccasionPhysique() { return this.prixOccasionPhysique; } public void setPrixOccasionPhysique(double prixOccasionPhysique) { this.prixOccasionPhysique = prixOccasionPhysique; } public int getQuantite() { return this.quantite; } public void setQuantite(int quantite) { this.quantite = quantite; } public String getSujetLivre() { return this.sujetLivre; } public void setSujetLivre(String sujetLivre) { this.sujetLivre = sujetLivre; } public boolean getTelechargement() { return this.telechargement; } public void setTelechargement(boolean telechargement) { this.telechargement = telechargement; } public String getTitre() { return this.titre; } public void setTitre(String titre) { this.titre = titre; } public List<Auteur> getAuteurs() { return this.auteurs; } public void setAuteurs(List<Auteur> auteurs) { this.auteurs = auteurs; } public List<LigneDeCommande> getLigneDeCommandes() { return this.ligneDeCommandes; } public void setLigneDeCommandes(List<LigneDeCommande> ligneDeCommandes) { this.ligneDeCommandes = ligneDeCommandes; } public LigneDeCommande addLigneDeCommande(LigneDeCommande ligneDeCommande) { getLigneDeCommandes().add(ligneDeCommande); ligneDeCommande.setLivreBean(this); return ligneDeCommande; } public LigneDeCommande removeLigneDeCommande(LigneDeCommande ligneDeCommande) { getLigneDeCommandes().remove(ligneDeCommande); ligneDeCommande.setLivreBean(null); return ligneDeCommande; } public Editeur getEditeurBean() { return this.editeurBean; } public void setEditeurBean(Editeur editeurBean) { this.editeurBean = editeurBean; } public Genre getGenreBean() { return this.genreBean; } public void setGenreBean(Genre genreBean) { this.genreBean = genreBean; } public List<FormatLivre> getFormatLivres() { return this.formatLivres; } public void setFormatLivres(List<FormatLivre> formatLivres) { this.formatLivres = formatLivres; } }
Petit coup de pouce svp...
Partager