ITeye博客

spring事务配置实例<1>

prodream · 2010-03-30 15:51 · 企业架构 · Markdown

<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  <property name="dataSource" ref="dataSource" />
 </bean>
 
 <aop:config proxy-target-class="true">
  <aop:pointcut id="transactionOperation"
   expression="execution(* com.oa..*Facade.*(..))" />
  <aop:advisor advice-ref="txAdvice" pointcut-ref="transactionOperation" order="1"/>
 </aop:config>
 
 <tx:advice id="txAdvice" transaction-manager="txManager">
  <tx:attributes>
   <tx:method name="update*" propagation="REQUIRED" rollback-for="Throwable"/>
   <tx:method name="insert*" propagation="REQUIRED" rollback-for="Throwable"/>
   <tx:method name="delete*" propagation="REQUIRED" rollback-for="Throwable"/>
   <tx:method name="save*" propagation="REQUIRED" rollback-for="Throwable"/>
   <!-- other methods use the default transaction settings (see below) -->
   <tx:method name="*" read-only="true" />
  </tx:attributes>
 </tx:advice>
 
 <tx:annotation-driven transaction-manager="txManager" order="0"/>
 <!-- 启用基于@AspectJ切面的驱动器 -->
 <aop:aspectj-autoproxy/>

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。