首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Spring中运用声明式事务

2012-09-02 
Spring中使用声明式事务1.首先,配置事务代理?!-- Transaction manager for a single Hibernate SessionFa

Spring中使用声明式事务

1.首先,配置事务代理

?

<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) --><bean id="hibernateTransactionManager"/><!-- Transactional proxy for the services --><bean id="baseTxProxy" lazy-init="true"/></property>  <property name="transactionAttributes"><!-- 此处对需要使用事务管理的方法进行配置 --><props><prop key="updateFrequency">PROPAGATION_REQUIRED</prop><prop key="saveStaff">PROPAGATION_REQUIRED</prop><prop key="saveSchenulingDetailed">PROPAGATION_REQUIRED</prop><prop key="delSchenuling">PROPAGATION_REQUIRED</prop></props></property></bean>

?2.对需要事务管理的业务逻辑类配置事务代理

<!-- 班次管理 --><bean id="frequencyDAO" autowire="byName"/><bean id="wfmFrequencyEntity" autowire="byName" />    <!--需要被事务管理的类-->    <bean id="frequencyService" autowire="byName" />    <!--配置业务逻辑类的事务代理-->    <bean id="frequencyServiceTrans" parent="baseTxProxy"><property name="target"><ref local="frequencyService" /></property></bean>    <!--让原来Action中的业务逻辑类指向事务代理类--><bean name="/frequencyAction" autowire="byName" ><property name="frequencyService" ref="frequencyServiceTrans" /></bean>

?

?

?

热点排行