`
77tt77
  • 浏览: 26407 次
  • 性别: Icon_minigender_1
  • 来自: Luna
社区版块
存档分类
最新评论

spring ibatis 事务回滚配置

阅读更多
spring ibatis 事务回滚配置

applicationContext.xml 中 关于配置ibatis事务管理部分代码
<!-- 配置事务管理器 -->
 <bean id="transactionManager"
  class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  <property name="dataSource" ref="dataSource" />
 </bean>
 <!-- 管理事务操作 -->
  <aop:config>
  <aop:pointcut id="servicesPointcut" expression_r_r="execution(* cn.com.jiexun.dao.impl.*.*(..))" />
  <aop:advisor advice-ref="txAdvice" pointcut-ref="servicesPointcut" />
 </aop:config>
 <!-- 事务控制 -->
 <tx:advice id="txAdvice" transaction-manager="transactionManager">
  <tx:attributes>
   <tx:method name="save*" propagation="REQUIRED" />
   <tx:method name="update*" propagation="REQUIRED" />
   <tx:method name="remove*" propagation="REQUIRED" />
   <tx:method name="get*" read-only="true" />
  </tx:attributes>
 </tx:advice>
<aop:pointcut id="servicesPointcut" expression_r_r="execution(* cn.com.jiexun.dao.impl.*.*(..))" />

--------------------------------------
我是将事务代理指向了实现类(指向service层也是没有问题的),注意:千万不要在此方法中加try/catch,否则事务将不会自动回滚
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics