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
|