-->
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: Optimistic locking in object graph
PostPosted: Wed Jul 18, 2007 12:35 pm 
Beginner
Beginner

Joined: Mon Apr 24, 2006 10:42 am
Posts: 23
Hi all,

Let's say I have a parent entity that has children entities, and I enable cascading. If I change one of the children and save the parent, then the child will be persisted, because of the cascade mechanism. All is well. However, Hibernate does not update the time-stamp (or version) column of the parent object - only the child's time-stamp is updated.

This is reasonable, since the child was the only one changed, but this makes it difficult for me to apply optimistic locking on the hierarchy as a whole.

Here's an example: if the application has an "edit X" screen, that allows changing the parent and/or its children, and user A and user B both load the same parent and work on it, then if user A changes a property of a child and saves, and afterwards user B changes a property of the parent and saves, then user B will succeed, although I would have preferred he failed, since the parent is stale as far as I'm concerned: a change anywhere down the graph, should count as a change. Or, shouldn't it?

I'd be interested in hearing opinions about this, and whether anyone has dealt with such a requirement, using a Hibernate feature, or some customized solution.

Thanks,
Naaman


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.