-->
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: primitive boolean in Criteria restriction
PostPosted: Wed May 16, 2007 2:22 pm 
Newbie

Joined: Fri Apr 06, 2007 1:54 am
Posts: 14
Hibernate version:
3.2.x

Mapping documents:
...
<property name="active" not-null="true" />
...

Code between sessionFactory.openSession() and session.close():
criteria.add(Restrictions.eq("active", Boolean.TRUE)).

Name and version of the database you are using:
MySQL 5.x



Hello

I have a class Person with a boolean property active.
This is a primitive boolean and not a Boolean. I prefer boolean because I want it to be either true or false, and not true/false/null.

Is this ok? Or do you suggest using Boolean?

In addition, will the restriction above give me the correct result? Restrictions.eq does not offer a method for binding primitive values.

Also, would Restrictions.eq("active", "1") work? MySQL stores my boolean property as a bit which is stored as 0 or 1.

thanks


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.