tx标签配置事务却无法回滚
来源:互联网 发布:免费爆吧软件 编辑:程序博客网 时间:2024/05/15 16:18
xml配置如下:
<!-- 属性文件读入 --><bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><property name="locations"><list><value>classpath*:config/jdbc.properties</value></list></property></bean><!-- 支持 @Transactional 标记 --><tx:annotation-driven/><!-- 支持 @AspectJ 标记--><aop:aspectj-autoproxy/><!-- 以AspectJ方式 定义 AOP --><aop:config proxy-target-class="true"><aop:advisor pointcut="execution(* org.springside.core.dao.*Dao.*(..))" advice-ref="txAdvice"/></aop:config><!-- 基本事务定义,使用transactionManager作事务管理,默认get*方法的事务为readonly,其余方法按默认设置. 默认的设置请参考Spring文档事务一章. --><tx:advice id="txAdvice" ><tx:attributes> <tx:method name="query*" read-only="true" propagation="NOT_SUPPORTED"/><tx:method name="get*" read-only="true" propagation="NOT_SUPPORTED"/><tx:method name="save*" read-only="true" propagation="REQUIRED"/></tx:attributes></tx:advice>有时我们发现save方法插入数据库出现异常时并不会回滚,因为aop默认只捕获RunTimeException,如果要捕获异常并回滚,可以加上属性
rollback-for:"java.lang.Exception"
其他相关属性如下
属性 是否需要? 默认值 描述
name
是 与事务属性关联的方法名。通配符(*)可以用来指定一批关联到相同的事务属性的方法。 如:'get*'
、'handle*'
、'on*Event'
等等。
propagation
不REQUIRED事务传播行为isolation
不DEFAULT事务隔离级别timeout
不-1事务超时的时间(以秒为单位)read-only
不false事务是否只读?rollback-for
不 将被触发进行回滚的 Exception(s)
;以逗号分开。 如:'com.foo.MyBusinessException,ServletException'
no-rollback-for
不 不 被触发进行回滚的 Exception(s)
;以逗号分开。 如:'com.foo.MyBusinessException
0 0
- tx标签配置事务却无法回滚
- 事务无法回滚
- Spring 事务无法回滚
- spring tx标签配置事务的解析过程
- SPRING配置事务回滚
- spring aop事务配置,事务回滚
- spring3MVC 事务无法回滚问题
- MySql事务无法回滚的原因
- MySql事务无法回滚的原因
- MySql事务无法回滚的原因
- activiti流程无法随事务回滚
- spring tx:advice事务配置
- Spring <tx:advice>事务配置
- spring tx:advice事务配置
- spring tx:advice事务配置
- spring tx:advice事务配置
- spring tx:advice事务配置
- spring mybatis事务回滚配置
- Unity3D中摄像机常用技巧Dolly&nbs…
- The Zen of Python / Python之禅
- python\split\join
- 8051寄存器
- java中Map集合总结
- tx标签配置事务却无法回滚
- 【Python]五分钟理解元类(Metaclasses)【转载】
- 作业7.10
- 【笔记】Java与内存屏障
- matlab ndims 函数 与 expand 函数
- 数字逆序输出
- 教程——ZEDBoard简单PL实验
- android studio的使用心得
- 使用Android Studio遇到JAVA (TM) Platform SE binary stop working的问题