-->
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.  [ 3 posts ] 
Author Message
 Post subject: boolean VS Boolean
PostPosted: Tue Jun 29, 2010 11:53 am 
Newbie

Joined: Tue Jun 29, 2010 11:50 am
Posts: 10
What is the impact of declaring a boolean variable VS declaring it as Boolean on Hibernate.
Is it handled differently by hibernate?


Top
 Profile  
 
 Post subject: Re: boolean VS Boolean
PostPosted: Wed Jun 30, 2010 7:59 am 
Beginner
Beginner

Joined: Thu Feb 08, 2007 10:40 am
Posts: 46
If you declare a variable as boolean (primitive type), hibernate will not be able to load a NULL value from the database. It will throw an exception like this:
Code:
Null value was assigned to a property of primitive type ...
So, you would probably use the primitive boolean type, if your mapped database column has a Not-Null constraint. Otherwise, you should prefer the Boolean object type.


Top
 Profile  
 
 Post subject: Re: boolean VS Boolean
PostPosted: Wed Jun 30, 2010 10:39 am 
Newbie

Joined: Tue Jun 29, 2010 11:50 am
Posts: 10
etwcn wrote:
If you declare a variable as boolean (primitive type), hibernate will not be able to load a NULL value from the database. It will throw an exception like this:
Code:
Null value was assigned to a property of primitive type ...
So, you would probably use the primitive boolean type, if your mapped database column has a Not-Null constraint. Otherwise, you should prefer the Boolean object type.


cool thanks. makes sense.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.