-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problems with Criteria: Restricitions.isEmpty(...)
PostPosted: Fri May 02, 2008 2:02 am 
Beginner
Beginner

Joined: Fri Apr 11, 2008 1:48 am
Posts: 36
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).


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.