-->
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.  [ 2 posts ] 
Author Message
 Post subject: Null value for foreign keys
PostPosted: Wed Jun 14, 2006 9:15 am 
Newbie

Joined: Wed Jun 14, 2006 9:05 am
Posts: 1
Hi,

I've defined a many-to-one relation between two tables A and B.
Can I specify the null value of a foreign key column. Usually this is 'null', but I need '0', i.e. if the foreign key column contains '0' the getter-method of A, which returns an object of type B, should return 'null'.

Thanks and best regards,
gerd


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 15, 2006 12:57 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
So long as there's no B object with id = 0, that's quite easy to do. Use the not-found="ignore" attribte of many-to-one to refer to that object.

You'll probably have to use the <sql-insert> and <sql-update> elements to correctly write that 0 value to the DB, though.

_________________
Code tags are your friend. Know them and use them.


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