You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Seth Helstrip <se...@yahoo.com> on 2007/03/29 16:23:10 UTC

Transaction Control across multiple datasources

I'm relatively new to iBatis and am hoping someone can
offer me some form of transaction management advise?

I'm using Spring MVC with iBatis, and so far, have
been mightily impressed with both technologies. 
Within my application I have the need to maintain
transactions across two datasources and daoconfig,
each pointing at a different db implementation - one
Oracle, one DB2.

Since I'm using Spring I was wondering whether the
best way to do this would be to use EXTERNAL
transaction management within iBatis and to somehow
span the two DAO activities using a Spring transaction
mechanism.

I'm not using Spring IoC - and as such, think this
approach may require some messy coding.

Any advise will be greatly appreciated.
Thanks in advance,
Seth


 
____________________________________________________________________________________
Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews at Yahoo! Games.
http://videogames.yahoo.com/platform?platform=120121

Re: Transaction Control across multiple datasources

Posted by Mark Volkmann <ma...@ociweb.com>.
On Mar 29, 2007, at 9:23 AM, Seth Helstrip wrote:

> I'm relatively new to iBatis and am hoping someone can
> offer me some form of transaction management advise?
>
> I'm using Spring MVC with iBatis, and so far, have
> been mightily impressed with both technologies.
> Within my application I have the need to maintain
> transactions across two datasources and daoconfig,
> each pointing at a different db implementation - one
> Oracle, one DB2.
>
> Since I'm using Spring I was wondering whether the
> best way to do this would be to use EXTERNAL
> transaction management within iBatis and to somehow
> span the two DAO activities using a Spring transaction
> mechanism.
>
> I'm not using Spring IoC - and as such, think this
> approach may require some messy coding.
>
> Any advise will be greatly appreciated.

I'm doing almost exactly the same thing as you. The only difference  
is that we are using Google Web Toolkit instead of Spring MVC. We're  
using Spring DAOs generated using Abator and plan to use Spring  
declarative transaction management as described in section 9.5 of the  
Spring reference manual. The great thing about this approach is that  
you just have to mark methods that should be run in a transaction  
with the @Transactional annotation and you're done! One thing I need  
to verify is that when one @Transactional method invokes another, the  
second one doesn't start a new transaction and the annotation is  
essentially ignore. I hope that's the behavior.

The key part of this seems to be the setup in context.xml that they  
describe in section 9.5.2. Check out the <tx:advice> and <aop:config>  
elements. We have this working with Oracle and DB2 now, but haven't  
yet setup a demo to show that we can have a transaction that spans  
both databases. Hopefully we will have that working in another week.  
We are going to attempt to get this to work with the transaction  
manager that is provided with JBoss and may also test out Atomikos  
Transactions later.