You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Tom Henricksen <To...@A-t-g.com> on 2010/01/26 22:29:08 UTC

Execute in the same transaction

 

I'm calling the select statement selectTestObject in a transaction but
it is very surprising that select="TEMPVsp.selectById" runs on a
different connection. Is there a way that select="TEMPVsp.selectById"
executes in the same transaction as selectTestObject. 

 

<resultMap class="Test" id="TestMap">

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

            <result column="TEMPID" property="temp"
select="TEMPVsp.selectById"/>

</resultMap>

 

<select id="selectTestObject" parameterClass="map" resultMap="TestMap">

            

                  SELECT 

                        ID,

                        TEMPID                        

                  FROM 

                        TESTTABLE                                       

                  WHERE                   

                      ID = #id#

                                          

</select>

 

Thanks,

PK


Re: Execute in the same transaction

Posted by Andrea Selva <se...@gmail.com>.
Hi,
i think that the statements are executed in 2 transaction because your
connection pool contains more than one connection.
To execute the two in the same transaction i suppose you should do something
like this:
<your_sqlMap_cleint_instance>.startTransaction();
<your_sqlMap_cleint_instance>.queryForList("*selectTestObject*");
<your_sqlMap_cleint_instance>.endTransaction();

This is what i will do, i hope this coul help
 Andrea

On Tue, Jan 26, 2010 at 1:29 PM, Tom Henricksen <To...@a-t-g.com> wrote:

>
>
> I’m calling the select statement *selectTestObject* in a transaction but
> it is very surprising that select=*"TEMPVsp.selectById" *runs on a
> different connection. Is there a way that* *select=*"TEMPVsp.selectById” *executes
> in the same transaction as* selectTestObject. *
>
>
>
> <resultMap class=*"Test"* id=*"TestMap"*>
>
>             <result column=*"ID"* property=*"id"*/>
>
>             <result column=*"TEMPID"* property=*"temp"* select=*
> "TEMPVsp.selectById"*/>
>
> </resultMap>
>
>
>
> <select id=*"selectTestObject"* parameterClass=*"map"* resultMap=*
> "TestMap"*>
>
>
>
>                   SELECT
>
>                         ID,
>
>                         *TEMPID*
>
>                   FROM
>
>                         TESTTABLE
>
>                   WHERE
>
>                       ID = #id#
>
>
>
> </select>
>
>
>
> Thanks,
>
> PK
>