-->
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.  [ 1 post ] 
Author Message
 Post subject: Child record not deleted from DB, but foreignkey=Null
PostPosted: Wed Jul 06, 2011 3:41 am 
Newbie

Joined: Thu Jul 31, 2008 2:09 am
Posts: 2
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.