67,513
社区成员
发帖
与我相关
我的任务
分享
<property name="nestedTransactionAllowed" value="true"></property>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:hibernate.cfg.xml">
</property>
</bean>
<bean id="dao" class="TreeDAO.TreeDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="userDao" class="TreeDAO.UsersDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean class="service.TreeService" id="service">
<property name="dao">
<ref bean="dao" />
</property>
</bean>
<bean class="service.UsersService" id="usersService">
<property name="usersDao" ref="userDao"></property>
</bean>
<bean id="treeAction" class="action.TreeAction">
<property name="dao" ref="dao"></property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<!-- 依赖注入上面定义的sessionFactory -->
<property name="sessionFactory" ref="sessionFactory" />
<property name="nestedTransactionAllowed" value="true"></property>
</bean>
<tx:advice id="transactionAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="get*" read-only="true" />
<tx:method name="query*" read-only="true" />
<tx:method name="is*" read-only="true" />
<tx:method name="*" propagation="NESTED" rollback-for="Exception" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:advisor advice-ref="transactionAdvice"
pointcut="execution(* service.*Service.*(..))" />
</aop:config>
</beans>