Hibernate Criteria With Property Not In (Subquery)

hibernate, hibernate-criteria, subquery

Solution

Create a select-all criteria:

Criteria cr = session.createCriteria(Your.class); 
List list = cr.list(); 

Then you can add you restriction to it, i.e. where column 1=8 etc like this:

cr.add(Restrictions.eq("YourCondition", YourCondition));

Finally, you can provide the not in clause like this:

cr.add(Restrictions.not(Restrictions.in("YourNotInCondition", YourNotInCondition)));

Problem

I want to execute query something like ``` Select id, name from information where name not in (select firstname from contact where id = 1) Information Id Name 1 Test Contact id firstname 1 name 2 Test ``` If I am using neProperty() function, it will returns records as `name != Test.` How can I implement using hibernate criteria? Thanks

Original source