Hello,
I got some problems with the method above. I have an entity "Person", which has an many to many relation to an entity "Interests". I got a list of interests in my person object.
I am searching now for persons, who dont have any interests:
Code:
CreateCriteria(Person.class).createAlias("Interests", "Interests").add(Restrictions.isEmpty("Interests"))
I don't get any error message. I get as result an empty list! Even if I try this:
Code:
CreateCriteria(Person.class).createAlias("Interests", "Interests").add(Restrictions.isNull("Interests.name"))
I do get an empty list as result. I am sure that there are many Persons in the database without interests!
I am wondering why this works::
Code:
CreateCriteria(Person.class).createAlias("Interests", "Interests").add(Restrictions.isNotNull("Interests.name"))
This criteria returns a list of persons, who does have at minimum one interest.
Does anybody knows another solution to check if that list is empty with criteria? I could see in debug modus, that in my object person there is an empty list of hobbies (null at every index).