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: Dealing with columns whose default value is zero
PostPosted: Thu Sep 13, 2007 2:53 pm 
Newbie

Joined: Thu Sep 13, 2007 2:45 pm
Posts: 10
How to tell hibernate to treat db table columns with value zero as null if the column holds foreign key value from another table and in the other table there is no row with the identifier zero?

Strictly speaking there should be a constraint not to allow zero value on the columns if there doesn't exist foreign key with value zero.

In my case there is no constraint set and I am dealing with an old database.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 14, 2007 2:55 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
Use Wrapper classes .Like use Long for long.

_________________
Dharmendra Pandey


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 14, 2007 11:21 am 
Newbie

Joined: Tue Sep 04, 2007 2:21 pm
Posts: 14
Try using a custom value type that maps the zero Integers to null on a get and then map the null to zero on a set.

See Hibernate ref. chapter 5 - "Custom Value Types"

HTH
Tom


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.