this where-clause cannot be done directly with Criteria API:
where collectionA is empty
or collectionA.typeId != 1
or collectionA.typeId != 2
or collectionA.typeId != 3
However with a bit of lateral thinking from my brainy colleague Bob Boothby (who's not on this list unfortunately - but you can find his blog here:
http://bbboblog.blogspot.com/ if I'm allowed to do that) I implemented the where-clause differently:
where not exists(select id from collectionA where typeId != .....etc)
using a detached criteria on a subquery so:
Code:
DetachedCriteria detachedCriteria = DetachedCriteria
.forClass(RetentionActivity.class, "previouslyAccessed");
detachedCriteria.setProjection(Property.forName("id"));
Disjunction disjunction = Expression.disjunction();
disjunction.add(Property.forName("retentionActivityType.id").eq(
RetentionActivityType.RENOTIFICATION_DONE.getId()));
detachedCriteria.add(disjunction);
detachedCriteria.add(Property
.forName("reportSchedule.id")
.eqProperty(criteria.getAlias() + ".id"));
criteria.add(Subqueries.notExists(detachedCriteria));