zoukankan      html  css  js  c++  java
  • 事务管理简单

    一、添加事务管理者的bean

    <bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
    -- 为事务管理者类中的sessionFactory属性注入一个具体的实例 
    <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>

    二、通知配置


     <tx:advice id="txAdvice" transaction-manager="transactionManager">
            <tx:attributes>
                <!-- 指定需要开启并提交事务的方法 -->
                <tx:method name="add*" propagation="REQUIRED" />
                <tx:method name="del*" propagation="REQUIRED" />
                <tx:method name="mod*" propagation="REQUIRED" />
                <!-- 指定以上方法除外的方法是只读的    read-only -->
                <tx:method name="*" propagation="REQUIRED" read-only="true" />
            </tx:attributes>
        </tx:advice>

    三、声明一个切入点

    <aop:pointcut id="interceptorPointCuts" expression="execution(* app.dao.*.*(..))" />

    四、引用一个通知并且同时引用一个需要执行的切入点

      <aop:advisor advice-ref="txAdvice" pointcut-ref="interceptorPointCuts" />
        </aop:config>

    五、概述



    
    
  • 相关阅读:
    14.3 Go iris
    14.2 Go性能优化
    14.1 Go数据结构
    13.3 Go章节练习题
    13.2 Go练习题答案
    13.1 Go练习题
    12.1 Go nsq
    11.3 Go 开发博客
    11.2Go gin
    11.1 Go Http
  • 原文地址:https://www.cnblogs.com/Sosowu/p/5993510.html
Copyright © 2011-2022 走看看