//ssh三个框架,spring中aop式声明事务
//事务回滚测试,如果addB()执行不成功,那么addA()执行的操作回被回滚
例:
public void save(){
addA();
addB();
请问这个怎么处理?刚用到事务这块,希望知道的帮帮忙!!!!!
事务声明:
- Java code
<aop:config proxy-target-class="true"> <aop:advisor pointcut="execution(* com.startsi.pk.service..*(..))" advice-ref="txAdvice"/> </aop:config><tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="get*" read-only="true"/> <tx:method name="find*" read-only="true"/> <tx:method name="*"/> </tx:attributes> </tx:advice>
------解决方案--------------------
楼主的配置正确 楼主有什么疑问?
------解决方案--------------------
配置正确
------解决方案--------------------
首先,spring中的事务管理器其实是个around advise
你需要对这个advise进行设置
配置,当发生XX时,回滚
而这个XX事件,就是你说的addB方法不成功,比如说抛出一个异常
------解决方案--------------------
注意你将proxy-target-class设置为true,将使用CGLIB做代理。
确定你的方法满足CGLIB代理要求。