<!-- 配置Hibernate的事务管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- 事务处理类型 -->
<bean id="baseTxProxy" lazy-init="true" abstract="true"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref local="transactionManager" />
</property>
<property name="transactionAttributes">
<props>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="need*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>
在service层的调用
<bean id="auctionService" parent="baseTransactionProxy">
<property name="target">
<bean class="services.Auctionservice">
<property name="auctionDao">
<ref bean="adminauctionDao" />
</property>
</bean>
</property>
</bean>
本文介绍如何使用Spring框架配置事务管理器及事务属性,通过具体的XML配置示例展示如何定义事务传播级别,并为业务层实现代理以应用事务管理。
5万+

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



