I'm using NHibernate 1.0.2
(fyi: I'm sure this is a bug in my mapping, but I want to confirm here)
Say you have a hierarchy (like in the book HIA) where you have:
Categories
Items
Bids
A category has many Items
An Item has many bids
---------------------------------
now if you delete a category it should delete every item and bid underneath it... so in the mapping you'd specify something like this:
Code:
//Category.hbm.xml
<bag name="Items" ...... cascade="all-delete-orphan"> ... </bag>
//Item.hbm.xml
<bag name="Bids" ........ cascade="all-delete-orphan">....</bag>
Is this correct?
I currently have a relationship just like this, but when I call delete on the root object, it sets the FK to NULL on the bottom object (bids here).
so the action goes like this:
Delete issued in code
SQL -> UPDATE Bids SET ItemId = NULL
SQL -> DELETE Item WHERE ...... //ERROR! FK VIOLATION
Are my assumptions correct?