-->
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: Nhibernate parent child
PostPosted: Wed Feb 11, 2009 12:27 pm 
Newbie

Joined: Tue Apr 08, 2008 11:29 pm
Posts: 3
Hi,
I am trying to use a parent child unidirectional association in Nhibernate. My scenario is something like this.

I have items and the associated bids. Bids cannot exist without the Item. Item knows about all the bids but not vice-versa. In the Item mapping, bids collection is configured with cascade attribute of cascade="all-delete-orphan"

<list name="bids" table="Bids" cascade="all-delete-orphan" lazy="true">
<key column="ItemID" />
<index column="Position" />
<one-to-many class="Bid" />
</list>

In the bids table, I want to set the ItemID and Position as "not-null" because a bid cannot exist without an item.

When I remove an item from the bid list and then update the item, it thows an ADO.Net exception saying not-null is not valid in the ItemID and Position column. Nhibernate tries to update the itemid and position to null before deleting the bid records.

Is there any way that will allow Nhibernate to delete the child record while honoring the non-null attribute on these column in the database?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 27, 2009 2:25 pm 
Newbie

Joined: Fri Feb 13, 2009 1:56 pm
Posts: 4
How do you remove the item? Can you post a script here?

You should remove the line from the object, something like parent.child.remove(lineobject) and only then you update the parent object.


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.