ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leonardo Kenji Shikida <shik...@gmail.com>
Subject how to commit a connection?
Date Mon, 05 Dec 2005 19:05:44 GMT
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