-->
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: Extra Update when deleting class with version and bag
PostPosted: Wed Oct 17, 2007 7:05 pm 
Newbie

Joined: Wed Oct 17, 2007 6:41 pm
Posts: 4
NHibernate version: 1.2
[b]database:b]SQL Server 2005

I have a problem when deleting an object that has the following mapping settings:

1. A version field (generated=always)
2. A Bag (cascade=all-delete-orphan)

Right before the delete is done a NHibernate does an update on the object unnecessarily . AFAIK, the object is not dirty - I just want to delete it. NHibernate executes the following queries upon ISession.Delete():

1. A select is done on the object.
2. A select is done to fill the associated bag.
3. An update is done on the parent object causing the value in the version column to be changed.
4. A select query is done to retrieve the new value in the version column.
5. The objects in the bag are deleted.
6. The delete is executed on the parent object, but the WHERE clause does not have the version obtained in step 4, but the version value obtained in step 1.

This causes the delete to fail and throws the optimistic concurrency exception.

I would like to to know what is causing the extra update in step 3, and how I can avoid it and /or why is the version field in the object not set to the value returned in step 4.

If I turn off the cascade on the bag, the delete works as expected with the versioning, but I get no cascading operations. If I remove the version mapping, the cascading works perfectly, but no concurrency checking.


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.