spring的aop事務配置

Code:
  1. <!-- 配置事務管理器 -->  
  2. <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">  
  3.     <property name="sessionFactory">  
  4.         <ref bean="sessionFactory"/>  
  5.     </property>    
  6. </bean>  
  7.   
  8. <!-- 配置事務的傳播特性 -->  
  9. <tx:advice id="txAdvice" transaction-manager="transactionManager">  
  10.     <tx:attributes>  
  11.         <tx:method name="create*" propagation="REQUIRED"/>  
  12.         <tx:method name="delete*" propagation="REQUIRED"/>  
  13.         <tx:method name="updat*" propagation="REQUIRED" />  
  14.         <tx:method name="*" read-only="true"/>  
  15.     </tx:attributes>  
  16. </tx:advice>  
  17.   
  18. <!-- 那些類的哪些方法參與事務 -->  
  19. <aop:config>  
  20.     <aop:pointcut id="allManagerMethod" expression="execution(* com.ssh.service..*(..))"/>  
  21.     <aop:advisor pointcut-ref="allManagerMethod" advice-ref="txAdvice"/>  
  22. </aop:config>  

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章