ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From quinya <y.qui...@ilocal.nl>
Subject Concurrency Issue With Rollback
Date Mon, 12 Oct 2009 13:41:25 GMT

Hi,

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);
myObject.syncOldUpdatedTime();


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"/>
	</resultMap>

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


-- 
View this message in context: http://www.nabble.com/Concurrency-Issue-With-Rollback-tp25855992p25855992.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Mime
View raw message