Hello venkatpuru,
you could try to use DetachedCriteria's. Have a look at my example:
Code:
List<Person> result = new ArrayList<Person>();
_session = ((HibernateEntityManager) em).getSession();
Criteria crit = _session.createCriteria(Person.class);
DetachedCriteria noShirts=
DetachedCriteria.forClass(Person.class)
.createAlias("clothes ", "bi")
.add(Restrictions.eq("bi.name", "shirt"))
.setProjection(Projections.id());
crit.add(Subqueries.notExists(noShirts));
result = crit.list();
There is even a Subqueries.exists(dc) method which you will need. Please let me know if this post was helpful.
EDIT: You will nee following Subquery: Subqueries.propertyEq(String propertyName, DetachedCriteria dc)