tenwit wrote:
Then you can return the correct UserOrganisations from the query, and get the Roles and User from that:
Code:
from UserOrganisation where Organisation.id = :orgid
Or you could get a list of [User, Role] arrays:
Code:
select u, r
from UserOrganisation uo
join uo.Role r
join uo.User u
where uo.Organisation.id = :orgid
This will return one [User,Role] per Role, so the same User will be returned multiple times, or none if it has no roles. You could make the join to Role be a left join, that will return a [User, null] for Users with no Roles in the UserOrganisaiton.
I am assuming that you are not mapping UserRole explicitly, and just specifying it as a join table.
I appreciate your help.
Finally, based on your query, I came up with the following:
Code:
select u.userId,u.login,u.title,u.firstName,u.lastName, r from User u left join u.userOrganisations as uo left join uo.userOrganisationRoles as uor left join uor.role as r where uo.organisation.organisationId=?
Then I created the UserManageBean(userId,..., List<Role>) list from the list returned.
And it does work perfectly!
Thanks