Java Mailing List Archive

Home » user-java.ibatis »

Concurrency Issue With Rollback



Author LoginPost Reply


I am using a timestamp to manage concurrency. But I'm having a problem when
a transaction is rolled back.

I update the timestamp when the object is saved. It works great. But if the
save is just one part of the transaction and the transaction fails and rolls
back, then the object is left with a timestamp that is not consistent with
what in the database. That is - the database save is rolled back, but the
timestamp in the object is not.

I think I must just be going about this the wrong way. I don't remember ever
having this issue in the past. Can anyone point me in the right direction?

My DAO method looks like this:

myObject.setUpdatedTime(new Date());
getSqlMapClientTemplate().update("updateQuery", myObject);

The Object looks like:

protected Date updatedTime = new Date();
protected Date oldUpdatedTime = null;
public void syncOldUpdatedTime() {
 this.oldUpdatedTime = this.updatedTime ;

The mapping and SQL look like:

    <resultMap id="thingResultMap" class="thingObject">
   <result property="id" column="id"/>
   <result property="code" column="code"/>
   <result property="name" column="name"/>
   <result property="updatedTime" column="updated_time"/>
   <result property="oldUpdatedTime" column="updated_time"/>

 <update id="update" parameterClass="thingObject">
   update $type$
     name = #name#,
     code = #code#,
     updated_time = #updatedTime#
     id = #id#
     updated_time = #oldUpdatedTime#

Sent from the iBATIS - User - Java mailing list archive at

To unsubscribe, e-mail: user-java-unsubscribe@(protected)
For additional commands, e-mail: user-java-help@(protected)

©2008 - Jax Systems, LLC, U.S.A.