Bonsoir,
je m'en remet une nouvelle fois à vous, car je bloque sur un bout de programme depuis pas mal de temps.
Je débute en Java EE, et je galère un peu.
En fait, j'ai créé une base de données MySQL, et dans mon projet j'ai généré les entités avec les tables existantes.
Le petit souci, c'est que certaines tables contiennent 2 clés primaires. Dans ce cas Eclipse me génère une classe MatablePK.java en plus, ce qui semble normal.
Mais quand j'exporte mon projet dans Jonas j'obtiens toujours l'erreur suivante :
Voila par exemple des entités générés qui posent problèmes :
Code : Sélectionner tout - Visualiser dans une fenêtre à part Repeated column in mapping for entity: database.Usermovy column: movieid (should be mapped with insert="false" update="false")
Usermovy :
et UsermovyPK :
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 package database; import java.io.Serializable; import javax.persistence.*; import java.math.BigDecimal; /** * The persistent class for the usermovies database table. * */ @Entity @Table(name="usermovies") @NamedQuery(name="Usermovy.findAll", query="SELECT u FROM Usermovy u") public class Usermovy implements Serializable { private static final long serialVersionUID = 1L; // Primary keys @EmbeddedId private UsermovyPK id; private String comment; private BigDecimal rank; //bi-directional many-to-one association to Movy @ManyToOne @JoinColumn(name="movieid") private Movy movy; //bi-directional many-to-one association to User @ManyToOne @JoinColumn(name="userid") private User user; public Usermovy() { } public UsermovyPK getId() { return this.id; } public void setId(UsermovyPK id) { this.id = id; } public String getComment() { return this.comment; } public void setComment(String comment) { this.comment = comment; } public BigDecimal getRank() { return this.rank; } public void setRank(BigDecimal rank) { this.rank = rank; } public Movy getMovy() { return this.movy; } public void setMovy(Movy movy) { this.movy = movy; } public User getUser() { return this.user; } public void setUser(User user) { this.user = user; } }
Bien-sur la table Usermovy est lié à la table User et à la table Movy, mais je pense pas que le problème vienne de ces 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 package database; import java.io.Serializable; import javax.persistence.*; /** * The primary key class for the usermovies database table. * */ @Embeddable public class UsermovyPK implements Serializable { //default serial version id, required for serializable classes. private static final long serialVersionUID = 1L; @Column(insertable=false, updatable=false) private int userid; private int movieid; public UsermovyPK() { } public int getUserid() { return this.userid; } public void setUserid(int userid) { this.userid = userid; } public int getMovieid() { return this.movieid; } public void setMovieid(int movieid) { this.movieid = movieid; } public boolean equals(Object other) { if (this == other) { return true; } if (!(other instanceof UsermovyPK)) { return false; } UsermovyPK castOther = (UsermovyPK)other; return (this.userid == castOther.userid) && (this.movieid == castOther.movieid); } public int hashCode() { final int prime = 31; int hash = 17; hash = hash * prime + this.userid; hash = hash * prime + this.movieid; return hash; } }
Voila, si quelqu'un pourrait m'expliquer ce qui cloche je suis preneur![]()
Partager