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 Re: Multiple DaoManagers + transactions
Date Thu, 11 Aug 2005 20:05:18 GMT
Actually, you made me reallise that I misread the code.
The contextInTransactionList kept in the StandardDaoManager in non-static ThreadLocal.

non-static is the keyword here.

Which means that each DaoManager will have their instances of the context.
But, it also means, that each of DaoManager instance will have a different value in every
thread.

contextInTransactionList instances = DaoManagerInstances * number of threads in which they
are used.

Which is exactly what we want.

Thanks for helping me see the light.
Louis


Prashanth Sukumaran wrote:
> Hi Louis,
> 
> Logically it should not.  Coz., they are two different instances.  Each DAOManger will
have their
> own Connection object when they started respective transactions.  So the commit will
happen
> respectively connection objects. Right.
> 
> For ex., when you say startTransaction() deep inside the ibatis code you have
> 
>          new JdbcDaoTransaction(dataSource); for a JDBC and similarly for JTA, SQLMap
etc.
> 
> Each of these hold a connection object and hence should not colide with each other.
> 
> Rgds
> 
> Prashanth Sukumaran.
> 
> --- Louis Letourneau <louis.letourneau@mail.mcgill.ca> wrote:
> 
> 
>>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
>>
>>
>>
> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 

Mime
View raw message