facebook

JPA reference does load

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

    frankc01a
    Member

    Here is the user class (snippet) from the user class:

    
        @OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER, mappedBy = "userTable")
        public Set<UserDetail> getUserDetails()
        {
            return this.userDetails;
        }
    
        public void setUserDetails(Set<UserDetail> userDetails)
        {
            this.userDetails = userDetails;
        }
    
    

    And here is the UserDetailsId

    
        @ManyToOne(cascade = {}, fetch = FetchType.LAZY)
        @JoinColumn(name = "UserID", unique = true, nullable = false, insertable = false, updatable = false)
        public User getUserTable()
        {
            return this.userTable;
        }
    
        public void setUserTable(User userTable)
        {
            this.userTable = userTable;
        }
    

    When I try to fetch the user details (and I know the data is in the database), it returns an empty set:

    
    User user = new UserDAO().findByUserName("Monkey").get(0); // works fine
    UserDetail ud = user. getUserDetails().iterator().next(); // returns null
    

    Any suggestions?

    Thanks in advance
    Frank

    #279478 Reply

    frankc01a
    Member

    I found a cause (I believe) and a workaround:

    It appeared that if I have a null value for a row (e.g. Address2) that the EAGER and LAZY were failing. Once I set the value to a dummy ” it worked. I was able to debug and see that lazy loading worked as well.

    Am I missing something? I would imagine there are many tables that allow nulls for values only to fail on the load.
    Perhaps it is in how the reverse-engineering causes the entire UserDetails table to be refered to as an embedded ID?

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: JPA reference does load

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