當前位置:編程學習大全網 - 網站源碼 - SSH框架中如何處理事務回滾

SSH框架中如何處理事務回滾

<!--放到Spring的applicationContext.xml中-->

<!-- 配置事務管理器 -->

<bean id="transactionManager"

class="org.springframework.orm.hibernate3.HibernateTransactionManager">

<property name="sessionFactory" ref="sessionFactory" />

</bean>

<!-- 那些類那些方法使用事務 -->

<aop:config>

<aop:pointcut id="allManagerMethod"

expression="execution(* com.jj.service.impl.*.*(..))" /><!--這個填寫妳要處理事務的方法-->

<aop:advisor pointcut-ref="allManagerMethod" advice-ref="txAdvice" />

</aop:config>

<!-- 事務的傳播特性 -->

<tx:advice id="txAdvice" transaction-manager="transactionManager">

<tx:attributes>

<!--下面就是增刪改的事務了。-->

<tx:method name="save*" propagation="REQUIRED" />

<tx:method name="delete*" propagation="REQUIRED" />

<tx:method name="update*" propagation="REQUIRED" />

<tx:method name="*" propagation="REQUIRED" read-only="true" />

</tx:attributes>

</tx:advice>

  • 上一篇:我用易語言寫了個小程序,現在想把它做成開機自動啟動的 那個代碼怎麽寫,最好詳細點,本人小白
  • 下一篇:請老師幫忙寫下這個指標:統計股價在年線以上的a股占a股總量的百分比。
  • copyright 2024編程學習大全網