1. 程式人生 > >spring事物配置

spring事物配置

 <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
  <property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
 </bean>
 
 <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"></property>
 </bean>
 
 <bean id="baseDao" class="com.accp.dao.impl.BaseImpDao" abstract="true">
    <property name="sessionFactory" ref="sessionFactory"></property>
 </bean>
 
 <tx:advice id="myAdvice" transaction-manager="transactionManager">
    <tx:attributes>
      <tx:method name="save*" propagation="REQUIRED"/>
      <tx:method name="delete*" propagation="REQUIRED"/>
      <tx:method name="update*" propagation="REQUIRED"/>
      <tx:method name="*" propagation="REQUIRED" read-only="true"/>
    </tx:attributes>
 </tx:advice>
 
 <aop:config>
   <aop:pointcut id="myPointCut" expression="execution(* com.accp.dao.impl.*.*(..))"/>
   <aop:advisor advice-ref="myAdvice" pointcut-ref="myPointCut"/>
 </aop:config>
 
</beans>