Atomikos Forum |
|
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
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> |