Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 92368 invoked from network); 24 Jul 2006 15:22:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 24 Jul 2006 15:22:33 -0000 Received: (qmail 68246 invoked by uid 500); 24 Jul 2006 15:22:31 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 68032 invoked by uid 500); 24 Jul 2006 15:22:30 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 68021 invoked by uid 99); 24 Jul 2006 15:22:30 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Jul 2006 08:22:30 -0700 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=DNS_FROM_RFC_ABUSE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of larry.meadors@gmail.com designates 64.233.182.189 as permitted sender) Received: from [64.233.182.189] (HELO nf-out-0910.google.com) (64.233.182.189) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Jul 2006 08:22:29 -0700 Received: by nf-out-0910.google.com with SMTP id c31so1514635nfb for ; Mon, 24 Jul 2006 08:22:08 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=A9bHYlJI9ETMxbxXFJNmJbPyz7KJAlfqkHoZpzWCI2HVXf9/sOoRfQrRvF+N8c9Sdk41Hu49pz2icY2pgJ39nz/EfNuYm4m8hUa3kOv97SFeMkPmMyiUDqZ/b+jUoZ4WZeffNguIyFFCNLWQwbpu1n6+sh37xTnSMcImpH3fs4U= Received: by 10.78.178.5 with SMTP id a5mr1593747huf; Mon, 24 Jul 2006 08:22:07 -0700 (PDT) Received: by 10.78.148.20 with HTTP; Mon, 24 Jul 2006 08:22:07 -0700 (PDT) Message-ID: Date: Mon, 24 Jul 2006 09:22:07 -0600 From: "Larry Meadors" Reply-To: lmeadors@apache.org Sender: larry.meadors@gmail.com To: user-java@ibatis.apache.org Subject: Re: Same Connection Guaranteed during a Transaction? In-Reply-To: <44C4864A.8000304@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <252101c6adb0$88ea1790$0601a8c0@RIGCISERVER> <2fe5ef5b0607221311p23a14a55s89ed7521b2e3c911@mail.gmail.com> <256c01c6add2$ab28e800$0601a8c0@RIGCISERVER> <2fe5ef5b0607221904l208b57ebi631e2e37dbdbfc7@mail.gmail.com> <1d40f7c0607222306u17b499f9nb7610c8c45a1e5e4@mail.gmail.com> <25af01c6ae61$5a69ed30$0601a8c0@RIGCISERVER> <44C4864A.8000304@yahoo.com> X-Google-Sender-Auth: dfe0a9c2bae7e844 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Why not just use a selectKey element? Larry On 7/24/06, Fred Janon 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(); > > > >