ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jagels, Steve E." <SEJag...@magellanhealth.com>
Subject RE: how to commit a connection?
Date Tue, 06 Dec 2005 15:46:32 GMT
So does that mean that if you force a commit, and there is an error,
that you are forcing it to rollback the transaction?

 

________________________________

From: Clinton Begin [mailto:clinton.begin@gmail.com] 
Sent: Tuesday, December 06, 2005 9:39 AM
To: user-java@ibatis.apache.org
Subject: Re: how to commit a connection?

 


Ahh...you'll want to force commits....

<transactionManager ....  commitRequired="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
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 =
SqlMapClientBuilder.buildSqlMapClient(sqlMapConfigFileReader);
Connection con = null;
try{
  dbclient.startTransaction();
  con = 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

 


Mime
View raw message