Hi all,
I have two entity classes: User and Role. There is an unidirectional many-to-many relationship between users and roles. Each user holds a collection of roles in its 'roles' property.
Is there a simple way of expressing the following HQL with the Hibernate Criteria API?
Code:
"from User user where :role in elements (user.roles)"
It would be easy if there was something like
Code:
Role role;
// ...
session.createCriteria(User.class).add(Restrictions.contains("roles", role));
which is somewhat the opposite of the existing Restrictions.in(...). There is probably another solution and I'm just to blind to figure it out. I'd appreciate any hints into the right direction.
Beset regards,
Volker
Environment:
Java 1.5
Hibernate 3.1
Oracle 10g XE