Thomastik wrote:
Hi,
I'm trying to verify if some list element is equals to some element of another list. E.g.:
User has a list/collection of AccessPermition;
Place has a list/collection of AccessPermition;
To access a Place, a User must be any AccessPermition contained in Place list of AccessPermition.
i'ld like to implement it using Criteria, but, either solution is welcome ;)
thz...
Umm, you could do something like this:
Code:
select u.id from User u, Place p inner join p.accessPermission pap
where u.id = :user_id and p.id = :place_id and pap members of u.accessPermission
group by u.id
having count(pap) = (select count(pap2) from Place p2 inner join p2.accessPermission pap2 where p2.id = :place_id)
where user_id is the user in question and place_id is a place. If you remove the u.id = :user_id part you get the id of all the users that have access to the given place. There might be some small problems in the HQL since I didn't run it myself.
Farzad-