我已经有一段时间试图解决我的问题,但我真的不能......
问题是,当我制作一个JPA(由Netbeans生成)时,我发现很多问题,例如:
我有: Class USER :
public class User implements Serializable {
@EmbeddedId
protected UserPK userPK;
...
@ManyToMany(mappedBy = "userList")
private List<Meeting> meetingList;
@JoinTable(name = "contact", joinColumns = {
@JoinColumn(name = "ID_USER2", referencedColumnName = "ID_USER")}, inverseJoinColumns = {
@JoinColumn(name = "ID_USER", referencedColumnName = "ID_USER")})
@ManyToMany
private List<User> userList;
@ManyToMany(mappedBy = "userList")
private List<User> userList1;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "idUser")
private List<Invitation> invitationList;
@OneToMany(mappedBy = "idUser")
private List<Coordonnees> coordonneesList;
...
}
课堂邀请
public class Invitation implements Serializable {
...
@JoinColumn(name = "ID_USER", referencedColumnName = "ID_USER")
@ManyToOne(optional = false)
private User idUser;
@JoinColumn(name = "ID_MEETING", referencedColumnName = "ID_MEETING")
@ManyToOne(optional = false)
private Meeting idMeeting;
...
}
班级会议
public class Meeting implements Serializable {
...
@JoinTable(name = "user_meeting", joinColumns = {
@JoinColumn(name = "ID_MEETING", referencedColumnName = "ID_MEETING")}, inverseJoinColumns = {
@JoinColumn(name = "ID_USER", referencedColumnName = "ID_USER")})
@ManyToMany
private List<User> userList;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "idMeeting")
private List<Invitation> invitationList;
...
}
班级Coordonnees
public class Coordonnees implements Serializable {
...
@JoinColumn(name = "ID_USER", referencedColumnName = "ID_USER")
@ManyToOne
private User idUser;
...
}
当我部署我的项目时,我发现很多问题,如:
javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [GpsPU] failed.
Internal Exception: Exception [EclipseLink-7220] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The @JoinColumns on the annotated element [field idUser] from the entity class [class Jpa_gps.Coordonnees] is incomplete. When the source entity class uses a composite primary key, a @JoinColumn must be specified for each join column using the @JoinColumns. Both the name and the referencedColumnName elements must be specified in each such @JoinColumn.
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createPredeployFailedPersistenceException(EntityManagerSetupImpl.java:1950)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1941)
...