- This topic has 3 replies, 2 voices, and was last updated 17 years, 4 months ago by Riyad Kalla.
-
AuthorPosts
-
jdaggsMemberit appears that my Entity Relationships are causing a false positive with JPA Entity Validator
Here are two classes that have a relationship to each other:
import java.util.List; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinColumns; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.Table; @Entity @Table(name="USERS") public class User { @Id private long userId; private String userName; private String firstName; private String middleName; private String lastName; private String emailAddress; @ManyToMany @JoinTable( name="USERS_GROUPS" ,joinColumns={@JoinColumn(name="GROUPID")}, inverseJoinColumns={ @JoinColumn(name="USERID") }) private List<Group> groups; } import java.util.List; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.Table; @Entity @Table(name="GROUPS") public class Group { @Id private long groupId; private String groupName; @ManyToMany @JoinTable( name="USERS_GROUPS" ,joinColumns={@JoinColumn(name="USERID")}, inverseJoinColumns={ @JoinColumn(name="GROUPID") }) private List<User> users; }
The JPA Entity Validator indicates that it can not find the join columns USERID and GROUPID on both the user and group classes. The tables and columns do in fact exist in the database and no other errors occur on any of the other fields for these classes. I am using Myeclipseide 6.0 with the validation enabled. Is the JPA Entity Validator getting confused because of the Join Table? is this a bug in myeclipseide? Is there a work around for this error? Thanks in advance, Jason
Riyad KallaMemberJason,
What DB are you using? What driver?Also is the case any different in the DB? (UserID, userID, userid, etc)
jdaggsMemberOracle 10g JDBC Thin Driver the case in name attribute for @JoinColumn does in fact match that in the database. But does not as you can see match the case in the Entity class. However, upon further review and a restart of myecilpseide and re-enabling the JPA Entity Validator the errors that I indicated previously do not appear. It appears that the DB metadata analysis did not or could not run for some reason during my previous myeclipseide session. I will look into this a little bit more and report here If I can create a set of steps to reproduce this (perceived) issue.
Thanks
Jason
Riyad KallaMemberJason thank you for the heads up.
-
AuthorPosts