spring 中的声明式事务不回滚 请高手帮忙解决一下 谢谢!

来源:互联网 发布:nginx apache ssl 编辑:程序博客网 时间:2024/05/18 01:08
<?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">
          
    <!-- 配置事务的传播特性 -->
 <tx:advice id="txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
     <tx:method name="add*" propagation="REQUIRED" />
  <tx:method name="del*" propagation="REQUIRED" />
  <tx:method name="update*" propagation="REQUIRED" />
  <tx:method name="do*" propagation="REQUIRED" />
  <tx:method name="*" propagation="SUPPORTS"  read-only="true" />
    </tx:attributes>
 </tx:advice>
 <!-- 那些类的哪些方法参与事务 -->
 <aop:config>
    <aop:pointcut id="allManagerMethod" expression="execution(* com.hibernate.bankImpl.*.*(..))"/>
    <aop:advisor pointcut-ref="allManagerMethod" advice-ref="txAdvice"/>
 </aop:config>
 
 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
  <property name="driverClassName" value="com.microsoft.jdbc.sqlserver.SQLServerDriver" />
  <property name="url" value="jdbc:microsoft:sqlserver://localhost:1433" />
  <property name="username" value="admin" />
  <property name="password" value="adminsa" />
 </bean>
 
 <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
 <property name="dataSource" ref="dataSource" />
  <property name="mappingResources">
   <list>
    <value>com/hibernate/BankTab.hbm.xml</value>
   </list>
  </property>
  <property name="hibernateProperties">
   <props>
    <prop key="hibernate.dialect">
     org.hibernate.dialect.SQLServerDialect
    </prop>
    <prop key="hibernate.show_sql">true</prop>
   </props>
  </property>
 </bean>
 
 <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory">
     <ref bean="sessionFactory"/>
    </property>
    </bean>
原创粉丝点击