spring的事务处理-01

假如事务拦截器设在 service包这层:
<aop:config>
  <aop:advisor pointcut="execution(* *..service.*.*(..))" advice-ref="txAdvice-hibernate" order="0"/>
 <!--<aop:advisor id="hibernateTx" advice-ref="txAdvice" pointcut="execution(* *..service.*Manager.*(..))" order="0"/>
 or 
 <aop:advisor pointcut="execution(* com.*..*Service.*(..))" advice-ref="txAdvice"/>-->
</aop:config>


那么 需要在一个事务里面处理的业务逻辑,就要写在一个 service的方法里面,而不是写在action里面,因为action对service的一次调用是一个事务。而且, 同一个service里面的方法之间的调用是在同一个事务里的。

参考:[spring tx:advice 和 aop:config 配置事务]
http://blog.csdn.net/xiafuyuan/article/details/8782569

猜你喜欢

转载自keren.iteye.com/blog/1869927