ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Volkmann <m...@ociweb.com>
Subject Re: XA transactions
Date Fri, 20 Apr 2007 14:22:17 GMT
On Apr 20, 2007, at 9:06 AM, Chris Lamey wrote:
> Do you want to use Spring for everything?
Yes.
>   If so, then you don't need to do anything iBATIS-wise if your  
> transaction setup is already done.  You will need to read the  
> Spring docs on XA transaction management, but it'll be transparent  
> to iBATIS.  If you don't want to use Spring, then you need to  
> configure the transactionmanager on the SqlMapClient bean itself.
So if I'm using Spring to manage transactions then I don't need a  
transactionManager element in my SqlMapConfig.xml at all? I thought I  
at least needed to include that to tell iBATIS that I was using an  
"EXTERNAL" transaction manager.
>   I'm pretty sure the transactionmanager element in the sqlmap  
> config file is effectively ignored if you're using the Spring  
> SqlMapClient (it's overridden Spring, which defaults to EXTERNAL so  
> Spring can manage the txns by default).
Ahh ... I guess that default gives me the answer to my previous  
question.

I am using org.springframework.orm.ibatis.SqlMapClientFactoryBean.  
Here's the setup in my spring-beans.xml file for the two databases  
I'm accessing.

   <bean id="oracleDataSource"
     class="org.springframework.jndi.JndiObjectFactoryBean">
     <property name="jndiName" value="java:jdbc/GWT_Test_OracleDB"/>
   </bean>

   <bean id="sqlServerDataSource"
     class="org.springframework.jndi.JndiObjectFactoryBean">
     <property name="jndiName" value="java:jdbc/GWT_Test_SqlServerDB"/>
   </bean>

   <bean id="oracleSqlMapClient"
     class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
     <property name="configLocation" value="/WEB-INF/ 
OracleSqlMapConfig.xml"/>
     <property name="dataSource" ref="oracleDataSource"/>
   </bean>

   <bean id="sqlServerSqlMapClient"
     class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
     <property name="configLocation" value="/WEB-INF/ 
SqlServerSqlMapConfig.xml"/>
     <property name="dataSource" ref="sqlServerDataSource"/>
   </bean>

Does this look okay?
>   Even in this case, I'd recommend that you use Spring to pull in  
> the JBoss manager via JNDI as the transaction manager or something  
> rather than configuring iBATIS directly.
Like this?

   <bean id="transactionManager"
     class="org.springframework.transaction.jta.JtaTransactionManager">
     <property name="transactionManagerName" value="java:/ 
TransactionManager"/>
   </bean>
   <tx:annotation-driven transaction-manager="transactionManager"/>

>
> -----Original Message-----
> From: Mark Volkmann [mailto:mark@ociweb.com]
> Sent: Fri 4/20/2007 7:14 AM
> To: user-java@ibatis.apache.org
> Subject: XA transactions
>
> I'm using JBoss, Spring transactions, iBATIS and Spring DAOs
> generated by Abator. I need to global transactions that span
> operations in two databases. When I specify the <transactionManager>
> element in my SqlMapConfig.xml file, should I use type="JTA" where
> iBATIS will actively manage transactions or type="EXTERNAL" where
> iBATIS will allow Spring to manage transactions?
>
>


Mime
View raw message