Reputation: 2720
I have two entity objects, USER and GROUP. GROUP contains a ManyToMany relationship to USER, but that relationship is not bidirectional.
My problem is that I need to find out all of the USERs that are members of a list of GROUPs. If I could reverse the relationship so that the USER contained the relationship to GROUP, I could do this easily, but I can't seem to figure out how to write the JPQL to go the other way.
Can someone out there point me in the right direction?
Thanks
Upvotes: 0
Views: 126
Reputation: 2720
The following seems to work:
select distinct u from User u, Group grp where grp in (?1) and u member of grp.users
Upvotes: 2