-->
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: [BUG] many-to-one with non-null does not work with comp. key
PostPosted: Mon Dec 05, 2005 9:10 am 
Senior
Senior

Joined: Thu Aug 25, 2005 3:35 am
Posts: 160
When mapping a relation as such:

Code:
<many-to-one name="Parent" column="parent_id" not-null="false"  />


the parent is not retrieved when no parent_id is available in the database.

However, if the mapping is a composite key like so:
Code:
<many-to-one name="Parent" not-null="false" >
     <column name="parent_id1"  />
     <column name="parent_id2" />
</many-to-one>


I would expect that a null in any of the id's (p_id1 or id2) would also cause the relation to be not retrieved.
There does not seem to be a way to let nhibernate know that the relation does not exist!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 05, 2005 11:11 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
What does the composite key look like? If both columns are null, NH should probably consider the object non-existent.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 05, 2005 11:15 am 
Senior
Senior

Joined: Thu Aug 25, 2005 3:35 am
Posts: 160
one column is null, the other is not.

I can confirm that it will consider the object non-existent if both columns are null.
I guess then it might not be incorrect behavior. However, it would be great if there was some kind of strategy that you could choose here.

As a workaround, I have created a view that will expose another column that will either be a real value, or also null if the first column is null..


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.