-->
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.  [ 4 posts ] 
Author Message
 Post subject: query criteria question
PostPosted: Mon Aug 23, 2004 6:11 pm 
Beginner
Beginner

Joined: Wed Feb 25, 2004 10:58 am
Posts: 43
Hibernate version: 2.1.6

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

Debug level Hibernate log excerpt:


Example exGroup = Example.create(exampleGroup).ignoreCase().enableLike(MatchMode.ANYWHERE);

return session.createCriteria(Group.class).add(exGroup).createCriteria("roles").add(Expression.eq("isActive", new Boolean(true))).list();

I thought that I would get a group back with just a collection of active roles .. but the inactive roles still appear in the collection of the group ? Is the query wrong ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 23, 2004 6:29 pm 
Pro
Pro

Joined: Tue Aug 26, 2003 8:07 pm
Posts: 229
Location: Brisbane, Australia
Quote:
Expression.eq("isActive", new Boolean(true))


Shouldn't that be "active"?

The name of the property is "active", the name of the getter method is "isActive".

Also, watch out for Boolean Vs. boolean.

In the javabean spec, the "is" prefix (as opposed to the "get" prefix) for getter methods is only valid for javabean properties of type "boolean" (not Boolean).

_________________
Cheers,
Shorn.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 23, 2004 6:46 pm 
Beginner
Beginner

Joined: Wed Feb 25, 2004 10:58 am
Posts: 43
I don't think that's it , cause if I filter by a different column everything still comes back in the roles collection.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 24, 2004 3:16 am 
Newbie

Joined: Mon May 31, 2004 9:22 am
Posts: 5
Location: Austria
I think you can find an answer in:

http://www.hibernate.org/hib_docs/reference/en/html/querycriteria.html

at point 12.4. Associations

Quote:
Note that the kittens collections held by the Cat instances returned by the previous two queries are not pre-filtered by the criteria! If you wish to retrieve just the kittens that match the criteria, you must use returnMaps().


I think i've also read, that it would be possible to use a filter after the query...


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

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.