声明式事务2.0

来源:互联网 发布:申请淘宝账号注册官网 编辑:程序博客网 时间:2024/05/16 05:54

author:何桂坤

<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"

xmlns:p="http://www.springframework.org/schema/p"
 xmlns:aop="
http://www.springframework.org/schema/aop"

xmlns:tx="http://www.springframework.org/schema/tx"
 xsi:schemaLocation="
http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-2.5.xsd

http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd

http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-

2.5.xsd">
----------------------------------------事务管理2.0------------------------------------------   
 <bean id="transactionManager"
  class="org.springframework.orm.hibernate3.HibernateTransactionManager">
  <property name="sessionFactory" ref="sessionFactory"></property>
 </bean>

 <aop:config>
  <aop:pointcut id="bizMethods" expression="execution(* biz.*.*(..))" />
  <!-- 织入 -->
  <aop:advisor advice-ref="txAdvice" pointcut-ref="bizMethods" />
 </aop:config>

 <tx:advice id="txAdvice" transaction-manager="transactionManager">
  <tx:attributes>
   <tx:method name="do*" propagation="REQUIRED" />
   <tx:method name="delete*" propagation="REQUIRED" />
   <tx:method name="update*" propagation="REQUIRED" />
   <tx:method name="merge*" propagation="REQUIRED" />
   <tx:method name="*" propagation="NOT_SUPPORTED" />
  </tx:attributes>
 </tx:advice>

原创粉丝点击