facebook

JPA Entity Validator

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #275186 Reply

    jdaggs
    Member

    it 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
    
    

    #275265 Reply

    Riyad Kalla
    Member

    Jason,
    What DB are you using? What driver?

    Also is the case any different in the DB? (UserID, userID, userid, etc)

    #275282 Reply

    jdaggs
    Member

    Oracle 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

    #275386 Reply

    Riyad Kalla
    Member

    Jason thank you for the heads up.

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: JPA Entity Validator

You must be logged in to post in the forum log in