-->
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: How to make a <many-to-one> null if id is zero
PostPosted: Fri Nov 04, 2005 11:46 am 
Newbie

Joined: Fri Nov 04, 2005 11:40 am
Posts: 1
Hi,

I have a many-to-one mapping:
<many-to-one name="abc" column="abc_id" class="z.z.Abc"/>

Currently, if an entry has value 0 in column abc_id, as I have no Abc object whose id is 0, I get a UnresolvableObjectException: No row with the given identifier exists: 0.

What I would like is for my object's property's value to be null when the abc_id is 0.

Is this possible?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 05, 2005 6:14 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
Generally having 0 instead of NULL is a bad idea and will give you proglems in a lot of places. If you have a chance to change your 0 into NULL it's a very good idea to do so.

If you can't change it try to map the referencing property with
Code:
<many-to-one
     not-found="ignore
     ...


HTH
Ernst


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.