first imagine the sql query you'd write to pull this off:
Code:
select * from cats where cat_id not in
(select cat_id from kittens where name = 'Moggy')
so in order to do this with criteria you'll need to perform a subselect:
Code:
DetachedCriteria kittenCriteria = DetachedCriteria.forClass(Kittens.class);
kittenCriteria.add(Restrictions.eq("name", "Moggy")).setProjection(Projections.property("catId");
DetachedCriteria catCriteria = DetachedCriteria.forClass(Cats.class);
catCriteria.add(Property.forName("catId").notIn(kittenCriteria));