Hello,
In my application a have a Project class with a collection of Persons.
I want to present a list of Persons in the database which are not in this collection, so if I have 4 Persons in the database and I have a project which has person1 in it's collection, I want to show person2 till person4.
Therefore, I've made a collection of Person ID's which belong to my Project, and tried to create a Criteria query as follows:
Collection persons =
session
.createCriteria(Person.class)
.add(Expression.not(Expression.in("ID", personIDs)))
.list();
But here the returned collection is empty, so this doesn't work.
I've also tried this query:
Collection persons =
session
.createCriteria(Person.class)
.add(Expression.in("ID", personIDs))
.list();
- the query I want to negate - and this works fine, here person1 is returned.
So my question is: how can I negate the above query?
Best regards,
Arjan
|