Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 98864 invoked from network); 6 Dec 2005 15:39:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 6 Dec 2005 15:39:12 -0000 Received: (qmail 58323 invoked by uid 500); 6 Dec 2005 15:39:10 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 58284 invoked by uid 500); 6 Dec 2005 15:39:09 -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 58268 invoked by uid 99); 6 Dec 2005 15:39:09 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Dec 2005 07:39:09 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of clinton.begin@gmail.com designates 64.233.162.199 as permitted sender) Received: from [64.233.162.199] (HELO zproxy.gmail.com) (64.233.162.199) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Dec 2005 07:39:08 -0800 Received: by zproxy.gmail.com with SMTP id j2so72751nzf for ; Tue, 06 Dec 2005 07:38:47 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=MQn/fmlUbbPWGe1B1OOuwKICMTG1RV+JEPpWxqkxpxSmggSp1pLdCUougO1OxlX52d0Uj1Qshz03oMKurFJriEHhAEA0MkIf0DydiRd8HtHTKt5ksxV9j/fPdn3BKdT0MaJh6OwwfageidHGBB1q9xgvqhVaxChTz0jPWPM2fbk= Received: by 10.64.10.9 with SMTP id 9mr588255qbj; Tue, 06 Dec 2005 07:38:46 -0800 (PST) Received: by 10.65.230.18 with HTTP; Tue, 6 Dec 2005 07:38:45 -0800 (PST) Message-ID: <16178eb10512060738w5121b9d1wdbfd94ab17dad33c@mail.gmail.com> Date: Tue, 6 Dec 2005 08:38:45 -0700 From: Clinton Begin To: user-java@ibatis.apache.org Subject: Re: how to commit a connection? In-Reply-To: <1b4364400512051105v4c094512i651a6ceecc8b1de0@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_10305_24565248.1133883525985" References: <1b4364400512051105v4c094512i651a6ceecc8b1de0@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_10305_24565248.1133883525985 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Ahh...you'll want to force commits.... The problem is that iBATIS only commits if it is aware of an actual update. Bypassing the insert statement causes iBATIS to miss the fact that an updat= e has occurred. Cheers, Clinton On 12/5/05, Leonardo Kenji Shikida wrote: > > I have an application that uses ibatis and an older legacy database > schema, both in the same mysql database. > > I would like to share the same connection to ibatis methods and the > legacy code, so I could use transactions to control both applications > > I have a snippet as follows > > SqlMapClient dbclient =3D > SqlMapClientBuilder.buildSqlMapClient(sqlMapConfigFileReader); > Connection con =3D null; > try{ > dbclient.startTransaction(); > con =3D dbclient.getCurrentConnection(); > //////dbclient.insert("insertMyObject",new MyObject()); > myClass.executeSomeSqlWithoutIbatisHere(con); > dbclient.commitTransaction(); > }catch(Exception e){ > e.printStackTrace(); > }finally{ > try{ > dbclient.endTransaction(); > }catch(Exception e2){ > e2.printStackTrace(); > } > } > > this code does not commit, but if I uncomment the insert statement, it > commits. So maybe dbclient checks for some flag or configures some > scope or context in the insert method. > > no exception is raised in both situations > > how could I set this flag or what's the correct approach for this > situation? > > seems clear to me that I could open a session, get the datasource, > than get the connection, then close the connection, then close the > session, etc etc etc, but I am not sure if it's the best way to do > this. > > thanks in advance > > Kenji > _______________________ > http://kenjiria.blogspot.com > http://gaitabh.blogspot.com > ------=_Part_10305_24565248.1133883525985 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
Ahh...you'll want to force commits....

<transactionManager ....  commitRequired=3D"true">

The problem is that iBATIS only commits if it is aware of an actual update.  Bypassing the insert statement causes iBATIS to miss the fact that an update has occurred.

Cheers,
Clinton

On 12/5/05, Leonardo Kenji Shikida <shikida@gmail.com> wrote:
I have an application that uses ibatis and an older legacy database
sche= ma, both in the same mysql database.

I would like to share the same = connection to ibatis methods and the
legacy code, so I could use transac= tions to control both applications

I have a snippet as follows

SqlMapClient dbclient =3D
Sql= MapClientBuilder.buildSqlMapClient(sqlMapConfigFileReader);
Connection c= on =3D null;
try{
  dbclient.startTransaction();
 &= nbsp;con =3D dbclient.getCurrentConnection ();
  //////dbclient.insert("insertMyObject",new MyO= bject());
  myClass.executeSomeSqlWithoutIbatisHere(con);
&= nbsp; dbclient.commitTransaction();
}catch(Exception e){
 &= nbsp;e.printStackTrace();
}finally{
  try{
    dbclient.endTransaction();<= br>  }catch(Exception e2){
    e2.printSta= ckTrace();
  }
}

this code does not commit, but if I= uncomment the insert statement, it
commits. So maybe dbclient checks fo= r some flag or configures some
scope or context in the insert method.

no exception is raised in= both situations

how could I set this flag or what's the correct app= roach for this situation?

seems clear to me that I could open a sess= ion, get the datasource,
than get the connection, then close the connection, then close the
s= ession, etc etc etc, but I am not sure if it's the best way to do
this.<= br>
thanks in advance

Kenji
_______________________
http://kenjiria.blogspot.com
http://gaitabh.blogspot.com

------=_Part_10305_24565248.1133883525985--