Hi
I am bit confused with BAG implementation. Here is the hbm.xml code I used, <class name="Order" table="dbo.Orders" lazy="false"> <id name="OrderId" column="OrderID" type="Int32"> <generator class="identity" /> </id> ........ <bag name="OrderItems" inverse="false" lazy="false" cascade="all-delete-orphan"> <key column="OrderID"/> <one-to-many class="OrderItems" /> </bag> </class>
Inside method : ord--> Order variable passed to the method.I have total of 4 orderItems and after filtering using LINQ we will have 2 OrderItems and I am assigning them to OrderDetails.
ord.OrderDetails= (from OrdItm in ord.OrderDetails where OrdItm .Date<> '07/06/2011' select OrdItm ).ToList()
session.saveorupdate(ord);
The Orphaned child items are not getting deleted in database ,only the reference key is removed.
Is there any thing that I need to change in my mapping or code to delete the record in Database when I save the Parent Object rather than just making the reference NULL.
Thank You. Regards, Chaitanya
|