您的位置:首页 > 编程语言 > Java开发

Spring Transaction Configuration.

2013-12-09 11:02 399 查看
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">

<bean id="test-txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="test-dataSource" />
</bean>

<tx:advice id="test-repeatedReadTxAdvice" transaction-manager="test-txManager">
<!-- the transactional semantics... -->
<tx:attributes>
<tx:method name="*" propagation="REQUIRED" isolation="REPEATABLE_READ" rollback-for="Throwable" />
</tx:attributes>
</tx:advice>

<tx:advice id="test-readCommitedTxAdvice" transaction-manager="test-txManager">
<!-- the transactional semantics... -->
<tx:attributes>
<tx:method name="*" propagation="REQUIRED" isolation="READ_COMMITTED" rollback-for="Throwable" />
</tx:attributes>
</tx:advice>

<tx:advice id="test-readCommitedTxAdvice-REQUIRES_NEW" transaction-manager="test-txManager">
<!-- the transactional semantics... -->
<tx:attributes>
<tx:method name="*" propagation="REQUIRES_NEW" isolation="READ_COMMITTED" rollback-for="Throwable" />
</tx:attributes>
</tx:advice>

<aop:config>
<aop:advisor pointcut="execution(* com.karl.test.TransactionService.*(..))" advice-ref="test-repeatedReadTxAdvice" />
</aop:config>

</beans>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: