Atomikos Forum

Spring, JTA and Custom Isolation Level per transaction

Hello,

Is it possible to set a custom isolation level per transaction when using JTA and Spring Transaction support?

I'm trying this:
@Transactional(propagation=Propagation.REQUIRED, isolation = Isolation.READ_UNCOMMITTED)


I'm noticing that Spring is logging:
[o.s.t.a.AnnotationTransactionAttributeSource] - Adding transactional method 'DummyServiceBean.write' with attribute: PROPAGATION_REQUIRED,ISOLATION_READ_UNCOMMITTED;

Even though it looks like the transaction-scoped isolation level wasn’t propagated to the underlying database connection.
I believe this is OK with JTA specification. Reference: http://java.dzone.com/articles/beginners-guide-transaction

Nevertheless, is there any way of achieving this, somewhat similar to this: http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/transaction/jta/WebLogicJtaTransactionManager.html
Rodrigo Ribeiro Send private email
Wednesday, March 25, 2015
 
 
Using org.springframework.jdbc.datasource.IsolationLevelDataSourceAdapter solved my problem:

<bean id="dataSource" class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy">
<property name="targetDataSource" >
  <bean class="org.springframework.jdbc.datasource.IsolationLevelDataSourceAdapter" >
    <property name="targetDataSource">
      <bean class="com.atomikos.jdbc.AtomikosDataSourceBean"
            init-method="init" destroy-method="close">
        <property name="uniqueResourceName" value="DataSource_Resource" />
        <property name="maxPoolSize" value="8" />
        <property name="xaDataSourceClassName" value="${XADataSourceClassName}" />
        <property name="xaProperties">
          <props>
            <prop key="databaseName">${databaseName}</prop>
            <prop key="createDatabase">${createDatabase}</prop>
            <prop key="connectionAttributes">${connectionAttributes}</prop>
          </props>
        </property>
      </bean>
    </property>
  </bean>
</property>
</bean>
Rodrigo Ribeiro Send private email
Wednesday, March 25, 2015
 
 
You could also try with declaring one datasource per desired isolation level and wiring those in your Spring config?

HTH
Guy Pardon Send private email
Wednesday, March 25, 2015
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics