首页 > 编程语言 > 详细

Spring自动事物代理

时间:2014-05-26 02:26:14      阅读:325      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
<!-- 定义事务管理器(声明式的事务) -->
<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> 
bubuko.com,布布扣

 

Spring自动事物代理,布布扣,bubuko.com

Spring自动事物代理

原文:http://www.cnblogs.com/mingf123/p/3749452.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!