首页 > 代码库 > Spring AOP 管理事务

Spring AOP 管理事务

    <aop:config proxy-target-class="true">
        <aop:pointcut expression="execution(* com.jikexueyuan.dao.impl.*.*(..))" id="cut"/>
        <aop:advisor advice-ref="defaultTransactionAdvice" pointcut-ref="cut"/>        
    </aop:config>
    
    <bean id="transactionManager"
        class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
        <property name="dataSource" ref="datasource"></property>  
    </bean>
    <tx:advice transaction-manager="transactionManager" id="defaultTransactionAdvice">
             <tx:attributes>  
                  <tx:method name="add*" read-only="false"/> 
               <tx:method name="*"/>  
          </tx:attributes> 
    </tx:advice>

 

Spring AOP 管理事务