ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Johnson" <jmjhn...@hotmail.com>
Subject update database followed by DO update
Date Wed, 19 Jul 2006 21:51:20 GMT
 

I have the following update SQL statement: update DOMAIN_OBJECT_TBL set SEQUENCE=SEQUENCE+1
where ID=#id#

 

Is it possible to have iBatis update the domain object, MyDomainObject, after executing this
operation?

 

For instance, I would like to have code that gives the following:

//domain object's sequence is 1

myDomainObjectDao.incrementSequence(myDomainObject); // domain object 's sequence is now 2

Integer sequence = new Integer(myDomainObject.getSequence()); //sequence is 2

 

However, the code currently does the following because the domain object was not updated to
reflect to the database update.

//domain object's sequence is 1

myDomainObjectDao.incrementSequence(myDomainObject); // domain object 's sequence is still
1

Integer sequence = new Integer(myDomainObject.getSequence()); //sequence is 1



I have the following statement sqlMap

<sqlMap>

<typeAlias type="com.example.MyDomainObject" alias="myDomainObject"/>

<resultMap class="MyDomainObject" id="result">

<result property="id" column="ID" />

<result property="sequence" column="SEQUENCE" />

</resultMap>

<update id="incrementSequence" parameterClass="myDomainObject">

update DOMAIN_OBJECT_TBL set SEQUENCE=SEQUENCE+1 where ID=#id#

</update>

</sqlMap>

Thanks in advance for your help.

Mime
View raw message