<bean id="HibernateTransaction" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory"></ref>
</property>
</bean>
<tx:advice id="txAdvice" transaction-manager="HibernateTransaction">
<tx:attributes>
<tx:method name="find*" propagation="SUPPORTS" />
<tx:method name="*" propagation="REQUIRED" rollback-for="Exception" />
</tx:attributes>
</tx:advice>
<aop:config>
<!-- 切入点 -->
<aop:pointcut id="findMethods_resourceface" expression="execution(* com.itstudysite.resourceface.service.*.*(..))" />
<!-- 织入 -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="findMethods_resourceface" />
</aop:config>
Spring事务配置
本文介绍了一个使用Spring框架进行事务管理的配置示例。该配置通过定义事务管理器`HibernateTransaction`来管理Hibernate会话,并设置了两种传播行为:对于查询操作采用`SUPPORTS`,对于其他操作采用`REQUIRED`,并在出现`Exception`时回滚事务。
184

被折叠的 条评论
为什么被折叠?



