-->
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: Default values for new columns
PostPosted: Mon Jul 26, 2010 11:09 am 
Beginner
Beginner

Joined: Tue Jun 30, 2009 7:05 am
Posts: 29
Location: Italy
Hi everybody
I have a problem with an old schema that I had to update.
I added a boolean property to an entity. Hibernate updated the schema, but when loading data it fails because NULL is found where a bit value was expected.
Is there a trick or workaround to have Hibernate set false when updating the schema, or alternatively transform the NULL values in false when fetches data from DB?

Any suggestion will be appreciated!

Stefano


Top
 Profile  
 
 Post subject: Re: Default values for new columns
PostPosted: Tue Jul 27, 2010 8:50 am 
Newbie

Joined: Mon Jul 26, 2010 6:50 am
Posts: 6
Hi,

i always set it in the database with an update statement, but you could make your own boolean class which converts null into false @PostLoad.

br


Top
 Profile  
 
 Post subject: Re: Default values for new columns
PostPosted: Tue Jul 27, 2010 8:59 am 
Beginner
Beginner

Joined: Tue Jun 30, 2009 7:05 am
Posts: 29
Location: Italy
Thanks looney.
So you are saying to use a wrapper class that treats NULL as false.
Do you think that using java.lang.Boolean instead of the primitive type could work (just to avoid to re-invent the wheel.... :-) )?

Bye,
Stefano


Top
 Profile  
 
 Post subject: Re: Default values for new columns
PostPosted: Tue Jul 27, 2010 9:05 am 
Beginner
Beginner

Joined: Tue Jun 30, 2009 7:05 am
Posts: 29
Location: Italy
I confirm that it works with java.lang.Boolean.

Thanks again looney!

Stefano


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.