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


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#

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

View raw message