<!-- 使用HibernateTransactionManager管理hibernate事务 -->

    <bean 
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">
         <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>

        
    <!-- 创建事务规则 -->
    <!-- 表示我们要控制事务的地方,如果方法名开头是add、update和delete,那么使用REQUIRED事务传播方式。那么其他的方法使用REQUIRED事务传播方式,并且是只读 -->
    <tx:advice >
        <tx:attributes>
           <tx:method name="add*" propagation="REQUIRED"
          rollback-for="Exception" />
          <tx:method name="delete*" propagation="REQUIRED"
          rollback-for="Exception" />
          <tx:method name="update*" propagation="REQUIRED"
          rollback-for="Exception" />
          <tx:method name="*" propagation="REQUIRED" read-only="true" />
       </tx:attributes>
    </tx:advice>

    <!-- 告知事务的切入点 -->
    <aop:config>
    <aop:advisor advice-ref="txAdvice" pointcut="execution(* com.tiema..service..*.*(..))" />

    </aop:config>

 

相关文章:

  • 2021-10-26
  • 2022-12-23
  • 2022-12-23
  • 2021-06-01
  • 2021-06-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-02
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-06
  • 2022-12-23
  • 2022-12-23
  • 2022-02-12
  • 2021-10-04
相关资源
相似解决方案