-->
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.  [ 3 posts ] 
Author Message
 Post subject: requesting clarification of cascading and versioning
PostPosted: Tue Dec 05, 2006 3:08 pm 
Newbie

Joined: Tue Aug 29, 2006 2:10 pm
Posts: 11
I've been doing some testing and want to validate that my findings are correct behavior for Hibernate.

I'm finding that cascade="merge, delete-orphan" on a one-to-many causes version updates on the parent object only if the membership of the collection representing the one-to-many changes. If I update a property on a member of the collection and call merge on the parent, no version update on the parent happens. If I remove or add a member to the collection, the version on the parent gets updated. Is this intended behavior. I could see an argument to update the version of the parent on any changes to the collection, for the sake of consistency (i.e. the business meaning of fields in the parent may be related to the contents of the collection, hence you want a stale state exception if the collection has changed), but only updating the version for collection size changes but not for updates to the members of the collection doesn't make a whole lot of sense to me.

Also, does Hibernate support some way to explicitly control this (whether the parent's version gets updated)?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 05, 2006 3:09 pm 
Newbie

Joined: Tue Aug 29, 2006 2:10 pm
Posts: 11
forgot to mention, I'm using Hibernate 3.2.1.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 05, 2006 6:37 pm 
Newbie

Joined: Tue Aug 29, 2006 2:10 pm
Posts: 11
I've done a bit more perusing of the Hibernate documentation and found that the parent entity's version is updated if the "state of the collection" is changed, which I can take to mean if you add or delete an item from the collection. I've also noticed that an update to a many-to-one causes an update to the version of the parent entity. It seem for consistency that one would want to update the version of the parent of a collection (one-to-many) not only if something was added to or removed from the collecton, but also if any of the objects in the collection were updated. Does Hibernate not support this?


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

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.