ITeye博客

spring事务配置实例<2>拦截式

prodream · 2010-03-30 16:38 · Java · 企业架构 · Spring · 配置管理 · AOP · ORM · Bean · Markdown

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

    
     <!-- 配置事务拦截bean -->
       <bean id="transactionInterceptor"  class="org.springframework.transaction.interceptor.TransactionInterceptor">

       <!-- 事务拦截bean需要注入一个事务管理器 -->
             <property name="transactionManager" ref="transactionManager"/>
             <property name="transactionAttributes">
                   <props>
                       <prop key="insert*">PROPAGATION_REQUIRED</prop>
                       <prop key="find*">PROPAGATION_REQUIRED</prop>
                       <prop key="add*">PROPAGATION_REQUIRED</prop>
                        <prop key="save">PROPAGATION_REQUIRED</prop>
                        <prop key="Print*">PROPAGATION_REQUIRED</prop>
                   </props>
             </property>
       </bean>
     
        <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">  
                <property name="beanNames"> 
                    <value>validateUserBean,authorDaoImp</value>
                
                </property> 
                <property name="interceptorNames">  
                        <list>  
                                <value>transactionInterceptor</value>  
                                <!--此处增加新的Interceptor-->  
                        </list>  
                </property>  
        </bean>

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。