Hi there, It is many-to-many relationship so the reverse version of the Person.getRoles annotation will help you I guess.
private List<User> users; @ManyToMany(fetch = FetchType.EAGER) @JoinTable( name = "user_role", joinColumns = [EMAIL PROTECTED](name = "role_id")}, inverseJoinColumns = @JoinColumn(name = "user_id") ) public List<User> getUsers(){ return users; } Luke McLean wrote: > > Easter Greetings, > > I am encountering a small problem that is driving me a little insane... I > wish to be able to have a bidirectional Many-to-Many relationship between > Users and Roles. At the moment it is only defined in one side of the > relationship (User.class) but as an administrator I wish to be able to see > which Users belong to which Roles by querying the Role.class (i.e. list > all the users who have the admin role). Very useful when you have more > than a couple of thousand users. > > I have followed the advice found in the hibernate manual, added the > @Many-to-Many(mappedBy="xxxx") annotations where the manual said to add > them in the Role.class. In my Junit test I can add two roles to different > users successfully but when I check to see how many users are now in that > role in the same test it always returns 0! > > Has anyone else managed to do this? I'm obviously doing something wrong > but every example I can find on the net appears to be the same as what I > have done. > > Luke. > -- View this message in context: http://www.nabble.com/Many-to-Many-Users-Roles-tf3533962s2369.html#a9867896 Sent from the AppFuse - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]