事物不回滚
2015-10-12 16:06
489 查看
<?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:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd"
default-autowire="byName" default-lazy-init="true">
<!-- 事务配置 -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<!-- 需要事务控制的业务方法配置 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="save*" rollback-for="Exception" />
<tx:method name="insert*" rollback-for="Exception" />
<tx:method name="create*" rollback-for="Exception" />
<tx:method name="edit*" rollback-for="Exception" />
<tx:method name="update*" rollback-for="Exception" />
<tx:method name="set*" rollback-for="Exception" />
<tx:method name="del*" rollback-for="Exception" />
<tx:method name="remove*" rollback-for="Exception" />
<tx:method name="clear*" rollback-for="Exception" />
<tx:method name="move*" rollback-for="Exception" />
<tx:method name="do*" rollback-for="Exception" />
<tx:method name="reset*" rollback-for="Exception" />
<tx:method name="start*" rollback-for="Exception" />
<tx:method name="add*" rollback-for="Exception" />
<tx:method name="change*" rollback-for="Exception" />
<tx:method name="admin*" rollback-for="Exception" />
<tx:method name="crt*" rollback-for="Exception" />
<tx:method name="send*" rollback-for="Exception" />
<tx:method name="cancel*" rollback-for="Exception" />
<tx:method name="publish*" rollback-for="Exception" />
<tx:method name="relevance*" rollback-for="Exception" />
<tx:method name="*" /><!-- 目前修改了一下,以后可以考虑该回来 -->
</tx:attributes>
</tx:advice>
<!-- 事务控制拦截器 -->
<aop:config proxy-target-class="true">
<aop:advisor pointcut="execution(* *..service..*Service.*(..))"
advice-ref="txAdvice" />
</aop:config>
<!-- 支持 @Transactional 标记 -->
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />
</beans>
但事物不回滚一定要抛出异常,
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd"
default-autowire="byName" default-lazy-init="true">
<!-- 事务配置 -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<!-- 需要事务控制的业务方法配置 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="save*" rollback-for="Exception" />
<tx:method name="insert*" rollback-for="Exception" />
<tx:method name="create*" rollback-for="Exception" />
<tx:method name="edit*" rollback-for="Exception" />
<tx:method name="update*" rollback-for="Exception" />
<tx:method name="set*" rollback-for="Exception" />
<tx:method name="del*" rollback-for="Exception" />
<tx:method name="remove*" rollback-for="Exception" />
<tx:method name="clear*" rollback-for="Exception" />
<tx:method name="move*" rollback-for="Exception" />
<tx:method name="do*" rollback-for="Exception" />
<tx:method name="reset*" rollback-for="Exception" />
<tx:method name="start*" rollback-for="Exception" />
<tx:method name="add*" rollback-for="Exception" />
<tx:method name="change*" rollback-for="Exception" />
<tx:method name="admin*" rollback-for="Exception" />
<tx:method name="crt*" rollback-for="Exception" />
<tx:method name="send*" rollback-for="Exception" />
<tx:method name="cancel*" rollback-for="Exception" />
<tx:method name="publish*" rollback-for="Exception" />
<tx:method name="relevance*" rollback-for="Exception" />
<tx:method name="*" /><!-- 目前修改了一下,以后可以考虑该回来 -->
</tx:attributes>
</tx:advice>
<!-- 事务控制拦截器 -->
<aop:config proxy-target-class="true">
<aop:advisor pointcut="execution(* *..service..*Service.*(..))"
advice-ref="txAdvice" />
</aop:config>
<!-- 支持 @Transactional 标记 -->
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />
</beans>
但事物不回滚一定要抛出异常,
相关文章推荐
- 用PHP正则表达式匹配中文
- 【codevs2800】送外卖 floyd+状压DP
- 解读ASP.NET 5 & MVC6系列(15):MvcOptions配置
- Hibernate List 转 Json 报错
- 基本STRUTS标签-学习笔记-Bean标签
- 强关联二维材料1T—TaS2晶体
- sass编译
- codeforces #568B Symmetric and Transitive 快速傅里叶变换
- 发散思维题——不用加减乘除做加法(剑指offer)
- iPhone手机安全指南
- iPhone手机安全指南
- sass安装
- 解读ASP.NET 5 & MVC6系列(14):View Component
- android 应用程序框架
- 《Cocos2d-JS开发之旅》重印在即,感谢大家的支持
- cocos2d-x入门三 分层设计框架
- mysql 远程访问
- qt error: C2001: 常量中有换行符
- 黑马程序员——Java基础--------IO流(二)
- Python Flask script 使用