ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brandon Goodin" <brandon.goo...@gmail.com>
Subject Re: update database followed by DO update
Date Thu, 20 Jul 2006 12:42:37 GMT
You would have to perform a select and do that in your DAO. There would be
no reason for iBATIS to take up that kind of assumption. To iBATIS you are
updating the database. If you want to update your domain object you would
need to call a select of that value.

Brandon

On 7/19/06, James Johnson <jmjhnsn1@hotmail.com> wrote:
>
>
>
> 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