Hi, I'm having trouble expressing a query.
I have a User class where each user has roles. Then I want to find all users that have ALL of the selected roles (this is the input parameter for the query).
For example, if I have one user Alice with roles [Role1, Role2, Role3], and the selected role list is [Role1, Role4], the query should return no users (because Alice doesn't have Role4), but if the selected role list is [Role1, Role2], the query should return Alice.
I'm using this query:
Code:
from User u left join u.roles r where r in (:selectedRoleList)
but this return all users that have ANY of the selected roles, not ALL of them.
Is there a way to express this in HQL or Criteria?
Thanks.