日期:2014-05-20  浏览次数:20644 次

spring hibernate 事务不回滚 !!?
applicationContext.xml 内配置:
XML code
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory">
            <ref bean="sessionFactory"/>
        </property>
    </bean>
    <!-- 事务拦截器 -->
    <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor"> 
        <property name="transactionManager"> 
            <ref bean="transactionManager" /> 
        </property>  
        <!-- 配置事务属性 --> 
        <property name="transactionAttributes"> 
           <props> 
              <prop key="delete*">PROPAGATION_REQUIRED</prop> 
              <prop key="add*">PROPAGATION_REQUIRED</prop> 
              <prop key="update*">PROPAGATION_REQUIRED</prop> 
              <prop key="save*">PROPAGATION_REQUIRED</prop> 
              <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
              <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
              <prop key="set*">PROPAGATION_REQUIRED</prop> 
          </props> 
       </property> 
     </bean> 
     <!-- 自动代理 -->
     <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"> 
        <property name="beanNames"> 
           <list> 
              <value>BizFlRecVouch</value> 
           </list> 
        </property> 
        <property name="interceptorNames"> 
           <list> 
              <value>transactionInterceptor</value> 
           </list> 
        </property> 
     </bean>
<bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource">
            <ref bean="dataSource"></ref>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
                <prop key="hibernate.show_sql">true</prop>
                <!--自动生成表结构 <prop key="hibernate.hbm2ddl.auto">create</prop>-->
                <!-- 是否在日志中输出的SQL 语句格式化成易读形式 -->
                <prop key="hibernate.format_sql">true</prop> 
                <!-- 是否显示统计形式,一般在测试阶段使用 -->
                <prop key="hibernate.generate_statistics">true</prop>
            </props>
        </property>
        <property name="mappingResources">
            <list>
                <value>com/flsoft/hgjlserver/module/Code.hbm.xml</value>
                <value>com/flsoft/hgjlserver/module/Customer.hbm.xml</value>
.........
</list>
        </property>
    </bean>
<bean id="BizFlRecVouch" class="com.flsoft.hgjlserver.serverImpl.BizFlRecVouchImpl">
        
        <property name="isyssetDao">
            <ref bean="FlSysSetDAO"/>
        </property>        
        <property name="itaskDao">
            <ref bean="TaskDAO"/>
        </property>
    </bean>


interface IBizFlRecVouch :
Java code
public boolean test();

BizFlRecVouchImpl 实现: