ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Larry Meadors" <lmead...@apache.org>
Subject Re: Same Connection Guaranteed during a Transaction?
Date Mon, 24 Jul 2006 15:47:23 GMT
Ouch, ok.

On 7/24/06, Fred Janon <fjanon@yahoo.com> wrote:
> I am using iBatis v1 not v2, there is no <selectKey> in V1...
>
> Larry Meadors wrote:
> > Why not just use a selectKey element?
> >
> > Larry
> >
> >
> > On 7/24/06, Fred Janon <fjanon@yahoo.com> wrote:
> >> I am trying to get the last_insert_id() in mySQL after an insert. I read
> >> in a forum that during a transaction, the same connection was guaranteed
> >> to be used for the duration of the transaction. That's not my experience
> >> using Spring and iBatis 1.3.1. Using the code below, I get 2 different
> >> connection ids. I am a bit lost with the concept of a transaction if the
> >> connection is not maintained.
> >>
> >> Any comments?
> >>
> >> Thanks
> >>
> >> Fred
> >>
> >> getSqlMap().startTransaction();
> >> connectionId =
> >> (Integer)getSqlMapTemplate().executeQueryForObject("ConnectionId",null);
> >> System.out.println("iBatisTasks createTask connectionId: " +
> >> connectionId);
> >>
> >> getSqlMapTemplate().executeUpdate("createTask", task);
> >>
> >> Integer taskId = new Integer(0);
> >> taskId =
> >> (Integer)getSqlMapTemplate().executeQueryForObject("lastTaskId",null);
> >> System.out.println(">>>>>>>>>> iBatisTasks createTask
id: " + taskId);
> >>
> >> connectionId =
> >> (Integer)getSqlMapTemplate().executeQueryForObject("ConnectionId",null);
> >> System.out.println("iBatisTasks createTask connectionId: " +
> >> connectionId);
> >>
> >> getSqlMap().commitTransaction();
> >>
> >>
> >>
> >>
> >
>
>
>

Mime
View raw message