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! }
|