Hibernate Criteria for "in subselect"

criteria, hibernate, nhibernate, subquery

Solution

I finally found it. Turns out it wasn't so hard after all... once you know!

criteria = criteria.createCriteria(User.USER_DOMAINS).add(Restrictions.eq(UserDomain.DOMAIN, domain));

Yep, there is was, staring me right in the face in the Javadoc: http://www.dil.univ-mrs.fr/~massat/docs/hibernate-3.1/api/org/hibernate/Criteria.html

Problem

I'm trying to do something like this, but using `Criteria` instead of `HQL`: ``` select user from User where user in ( select user from UserDomain where domain.id = "XXX" ) ``` User being an entity having a `one-to-many` relationship to the join table UserDomain. The point here is simply to find Users that are linked to a `Domain` having id = "XXX". This seems like it should be very simple... but I'm having no luck so far turning up any useful docs.

Original source