-->
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: Interceptor wrongly increases optlocking version on rollback
PostPosted: Wed May 06, 2009 8:22 am 
Beginner
Beginner

Joined: Wed Feb 23, 2005 11:32 am
Posts: 25
Location: Austria/Vienna
KEYWORDS: Interceptor, flushDirty, Rollback, Optlocking, Version

We are using an Interceptor to add updated by, change informations to our persisted objects. the objects are detatched, updated via session.save().

when we add the interceptor which then adds the change info to the currentState it works fine, except that when we get a StaleObjectException (or other exceptions) the version/optlocking flag is already increased by one within the Data Object !

This is of course a severe problem, because the version attribute should not increase at all if a rollback happens !!

how can we solve this correctly ?
or do we have to implement the interceptor differently?

thanks!

Example:
Interceptor:
public boolean onFlushDirty(...) {
// ... add for example changed by user xy and timestamp
return true;
}


methodXY(DataObject obj) {
// object is detatched here
try {
getSession().update(obj);
} catch(OptLockingException ex) {
connection.rolllback();
}
// now here obj.getVersion()
// is increased by one
// even if a rollback happened!
}


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.