-->
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: How to bypass Optimistic Locking?
PostPosted: Tue Jul 22, 2008 3:50 am 
Newbie

Joined: Thu Nov 15, 2007 3:17 am
Posts: 19
Hi,

i'm using Hibernate Annotations with optimistic locking (@version) which works very well. The StaleObjectStateException will be thrown while trying to save an expired object graph.

Now in some circumstances I want to bypass optimistic locking. I want to save objects with expired versions so that no StaleObjectStateException will be thrown.

Is there any automatism for this usecase? Updating the versions manually before merging seems to be circular for complex objects.

TIA byto


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 29, 2008 5:02 am 
Newbie

Joined: Thu Nov 15, 2007 3:17 am
Posts: 19
any1? :/


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 29, 2008 8:07 am 
Regular
Regular

Joined: Wed Jan 11, 2006 12:49 pm
Posts: 64
Location: Campinas, Brazil
Well, what you are trying to do is actually violate a rule. Unfortunately there is no such thing. What you can do is to copy the current @Version value to the instance being saved. I recommend using a reflection helper class to do this recursevely on the graph being saved, although I cannot provide you any reference to such code -- I do have a reflection helper for other features, but it probably won't be of use to you.

Regards,

Henrique

_________________
Henrique Sousa
Don't forget to rate useful responses


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.