展开全部
<beans>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation"
value="classpath:hibernate.cfg.xml">
</property>
</bean>
<bean id="hibernateTemplate"
class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- 声明式事务配置 -->
<!-- 事务管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
<!-- 打开事务管理器的嵌套事务 -->
<property name="nestedTransactionAllowed">
<value>true</value>
</property>
</bean>
<!-- spring事务拦截器 -->
<bean id="springTransactionInterceptor"
class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="transactionAttributes">
<props>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="list*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="do*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<!-- spring用于给所有的业务对象自动生成代理的代理对象生成器-->
<bean id="bizAutoProxyCreator"
class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="proxyTargetClass">
<value>true</value>
</property>
<property name="interceptorNames">
<list>
<value>springTransactionInterceptor</value>
</list>
</property>
<property name="beanNames">
<value>*Biz</value>
</property>
</bean>
<!-- base模块 -->
<bean id="baseAction"
class="com.fosoft.foes.module.base.bean.BaseBean" abstract="true"
singleton="false">
</bean>
<bean id="baseBiz" class="com.fosoft.foes.module.base.biz.BaseBiz"
singleton="true" abstract="true">
<property name="hibernateTemplate">
<ref local="hibernateTemplate" />
</property>
</bean>
</beans>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation"
value="classpath:hibernate.cfg.xml">
</property>
</bean>
<bean id="hibernateTemplate"
class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- 声明式事务配置 -->
<!-- 事务管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
<!-- 打开事务管理器的嵌套事务 -->
<property name="nestedTransactionAllowed">
<value>true</value>
</property>
</bean>
<!-- spring事务拦截器 -->
<bean id="springTransactionInterceptor"
class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="transactionAttributes">
<props>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="list*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="do*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<!-- spring用于给所有的业务对象自动生成代理的代理对象生成器-->
<bean id="bizAutoProxyCreator"
class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="proxyTargetClass">
<value>true</value>
</property>
<property name="interceptorNames">
<list>
<value>springTransactionInterceptor</value>
</list>
</property>
<property name="beanNames">
<value>*Biz</value>
</property>
</bean>
<!-- base模块 -->
<bean id="baseAction"
class="com.fosoft.foes.module.base.bean.BaseBean" abstract="true"
singleton="false">
</bean>
<bean id="baseBiz" class="com.fosoft.foes.module.base.biz.BaseBiz"
singleton="true" abstract="true">
<property name="hibernateTemplate">
<ref local="hibernateTemplate" />
</property>
</bean>
</beans>
更多追问追答
追问
有没有切入业务逻辑的例子 (不是事务的)
追答
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询