• Spring自动事物代理


    <!-- 定义事务管理器(声明式的事务) -->
    <bean id="transactionManager"
       class="org.springframework.orm.hibernate3.HibernateTransactionManager">
       <property name="sessionFactory">
        <ref local="sessionFactory" />
       </property>
    </bean> 
    
    <bean id="transactionInterceptor"
       class="org.springframework.transaction.interceptor.TransactionInterceptor"> 
       <property name="transactionManager">
        <ref bean="transactionManager" />
       </property>
       <!-- 配置事务属性 -->
       <property name="transactionAttributes">
        <props>
         <prop key="delete*">PROPAGATION_REQUIRED</prop>
         <prop key="add*">PROPAGATION_REQUIRED</prop>
         <prop key="update*">PROPAGATION_REQUIRED</prop>
         <prop key="save*">PROPAGATION_REQUIRED</prop>
         <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
        </props>
       </property>
    </bean>
    
    <!-- 自动代理 -->
    <bean id="autoproxy"
       class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
       <!-- 可以是Service或DAO层(最好是针对业务层*Service) -->
       <property name="beanNames">
        <list>
         <value>*Service</value>
        </list>
       </property>
       <property name="interceptorNames">
        <list>
            <value>transactionInterceptor</value>
        </list>
       </property>
    </bean> 
  • 相关阅读:
    linux远程文件、目录操作
    make update-api的使用
    android4.1设置系统 默认方向
    NAIPC2018-K-Zoning Houses
    ICPC2017 Urumqi
    牛客多校第十场-D- Rikka with Prefix Sum
    杭电多校第八场-A-Character Encoding
    杭电多校第七场-J-Sequence
    ConvexScore
    异或序列
  • 原文地址:https://www.cnblogs.com/mingf123/p/3749452.html
Copyright © 2020-2023  润新知