声明式事务2.0

    技术2022-06-29  72

    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>


    最新回复(0)