Bonjour à tous, j'aimerais solliciter votre aide pour résoudre un problème en JPA.
En fait j'ai une table Participation en MySQL qui contient une une clé primaire composite referant la clé primaire de la table Utilisateur et la clé primaire de la table EspaceTravail. Dans mon projet j'ai déjà créé les entités Utilisateur et EspaceTravail mais pour l'entité Participation j'ai créé une classe MyParticipationKey
Alors quand je fais et que j'execute Eclipse m'affiche ce message:
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 @Embeddable public class MyParticipationKey implements Serializable { /** * */ private static final long serialVersionUID = 1L; @Column(name=" pkIduser") private Utilisateur utilisateur; @Column(name=" pkIdet") private EspaceTravail espaceTravail; public Utilisateur getUtilisateur() { return utilisateur; } public void setUtilisateur(Utilisateur utilisateur) { this.utilisateur = utilisateur; } public EspaceTravail getEspaceTravail() { return espaceTravail; } public void setEspaceTravail(EspaceTravail espaceTravail) { this.espaceTravail = espaceTravail; } } @Entity @ManagedBean public class Participation { @EmbeddedId MyParticipationKey myParticipationKey; public MyParticipationKey getMyParticipationKey() { return myParticipationKey; } public void setMyParticipationKey(MyParticipationKey myParticipationKey) { this.myParticipationKey = myParticipationKey; } }
Exception Description: The mapping [espaceTravail] from the embedded ID class [class gct.entities.MyParticipationKey] is an invalid mapping for this class. An embeddable class that is used with an embedded ID specification (attribute [myParticipationKey] from the source [class gct.entities.Participation]) can only contain basic mappings. Either remove the non basic mapping or change the embedded ID specification on the source to be embedded.
Je vous remercie pour vos différentes suggestions.Merci
Partager