ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Louis Letourneau <louis.letourn...@mail.mcgill.ca>
Subject Multiple DaoManagers + transactions
Date Thu, 11 Aug 2005 19:17:30 GMT
Hello,
  I'm trying to understand the problems/issues of using multiple DaoManagers in the same application.

Say I have 2 jars:
MyApp.jar
TheirLib.jar

Both use Ibatis DAO. So, somewhere in their initialization, each makes a call to DaoManagerBuilder.buildDaoManager(...)
and keeps their DaoManager instance somewhere.

If in a thread I call a method that uses the daomanager of MyApp and in the same method I
use the daomanager of TheirLib, won't the first commit of the 2 commit everything?

ie:
// Code in MyApp.jar
public void testMethod() {
  daoManager_.startTransaction();
  try{
    doSomethingWithTheAppDaos();
    TheirLibMethod(); <--- Somewhere in here there is a theirLibDaoManager.commitTransaction();
    daoManager_.commitTransaction();
  }
  finally {
    daoManager.endTransaction();
  }
}

Since the contexts/transactions are kept in the TLS (thread local storage) doesn't multiple
daomanager instances step on eachother (as long as they are used in the same thread)?

Thanks
Louis



Mime
View raw message