Hi guys, I have the following three tables:
User (id, username)
Role (id, name, description)
User_Role (id, user_id, role_id)
In my user entity bean I have the following relationship:
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinTable(name="user_role",
joinColumns = @JoinColumn( name="user_id"),
inverseJoinColumns = @JoinColumn( name="role_id"))
public Set<Role > getRole() {
return role;
}
It all worked great until I had the need to have multiple roles per user. Now everytime I do a loadAll(User.class) and my user has two roles, hibernate returns two identical User objects. Am I doing something wrong? Is this the proper functionaility? If it is, how can I have hibernate return just one row per user?
Note: I also tried @ManyToMany without any luck...
Please heeeeeeeeeeelp :)
Thanks,
Julian.
|