-->
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.  [ 7 posts ] 
Author Message
 Post subject: Null values for Boolean becomes false when persisted
PostPosted: Thu Sep 30, 2004 4:29 pm 
Newbie

Joined: Wed Oct 01, 2003 1:51 am
Posts: 8
I have a problem with Boolean properties and null values in these. I want them to remain as null when the class is persisted. What happens now is that they get persisted as "false", which is definitly not what I intended. Anybody had this problem. I am using SQLAnywhere 6.4 as database and the Boolean is mapped to tinyint, which supports null.


Top
 Profile  
 
 Post subject: Re: Null values for Boolean becomes false when persisted
PostPosted: Fri Oct 01, 2004 2:10 am 
Newbie

Joined: Wed Oct 01, 2003 1:51 am
Posts: 8
hermodo wrote:
I have a problem with Boolean properties and null values in these. I want them to remain as null when the class is persisted. What happens now is that they get persisted as "false", which is definitly not what I intended. Anybody had this problem. I am using SQLAnywhere 6.4 as database and the Boolean is mapped to tinyint, which supports null.


Addendum : Looking at the sqlstatement that gets sent to the database, a null boolen value is represented as en empty string ''


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 01, 2004 3:25 pm 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
You could writ a UserType which takes the null values into acount.

HTH
Ernst


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 4:44 am 
Newbie

Joined: Wed Oct 01, 2003 1:51 am
Posts: 8
Yeah you could, but i think Hibernate should store it as null, not an empty string. I gor around this, by adding a pre-insert/pre-update trigger in the database.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 5:00 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
There are pros and cons, this is the reason for user type: let the user choose what he wants. Note that user types are portable (not triggers)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 4:47 pm 
Newbie

Joined: Wed Oct 01, 2003 1:51 am
Posts: 8
Yes, I know. But why does Hibernate threat Boolean nulls differently that say Integer nulls ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 06, 2004 6:08 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Does all DB support tree-state boolean?

_________________
Emmanuel


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