Announcement Announcement Module
Collapse
No announcement yet.
TransactionAwareDataSourceProxy And JtaTransactionManager Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • TransactionAwareDataSourceProxy And JtaTransactionManager

    Hi! im have some code that uses plain JDBC and wanna put that in the springframework. I want that code to participate in the spring's managed transaction using JtaTransactionManager , and for that i tried the TransactionAwareDataSourceProxy to wrap the original datasource. But something is wrong , JTA do rolback but the connection doesnt.
    Someone has made this work?

  • #2
    Can you post your configuration? Also has the connection datasource auto-commit turned on?

    Comment


    • #3
      Code:
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
      
      <beans>
        <!-- Other beans settings -->
          <bean id="dataSourceTarget" class="my.dataaccess.DataSourceImpl" factory-method="getInstance"/>
          <bean id="dataSource" class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy">
            <property name="targetDataSource" ref="dataSourceTarget"/>
          </bean>
          <bean id="testTxTarget" class="my.TestTx">
            <property name="dataSource" ref="dataSource"/>
          </bean>
          <bean id="txManager"    class="org.springframework.transaction.jta.JtaTransactionManager"/>
          <bean id="testTx" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
            <property name="transactionManager"><ref bean="txManager"/></property>
            <property name="target"><ref bean="testTxTarget"/></property>
            <property name="transactionAttributes">
               <props>
                  <prop key="handleRequest">PROPAGATION_REQUIRED,-DataAccessException</prop>
          	 </props>
             </property>
          </bean>
      </beans>

      Comment

      Working...
      X