I would like to translate a query like this one:
FROM Entity_1 obj
WHERE obj IN (FROM Entity2) OR
obj IN (FROM Entity3)
To hibernate Criteria form, and the official documentation of Hibernate is not enough because it doesn’t say how to apply the IN statement.
Any hint?
The criteria API does not have a provision to add another query as a restriction.. i think what @Niroshan Abayakoon was trying to say is that you need to execute the queries for the
INclause seperatly & add the result to theRestrictions.in()condition.this would get hibernate to consider the list within the
INclause.Its always better to fallback to HQL in situations like this.