本帖最后由 rl0806 于 2011-08-04 15:05:35 编辑

解决方案 »

  1.   

    TransactionStatus  status = transactionManager.getTransaction(def);                    //获得事务状态
    try{
       ……………..
       transactionManager.commit(status); //提交事务;
    }catch(…..){
       transactionManager.rollback(status); //回滚事务;
    }
      

  2.   

    public void doSaveOrUpdate(Object domain,Object obj){
    TransactionStatus status = transactionManager.getTransaction(def); //获得事务状态
      try{
        getBaseDAO().saveOrUpdate(domain); 
        getBaseDAO().saveOrUpdate(obj); 
        transactionManager.commit(status); //提交事务;
      }catch(…..){
        transactionManager.rollback(status); //回滚事务;
      }
    }
    是这个意思么??
      

  3.   

    用这种方式呢
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource">
    <ref bean="chnds" />
    </property>
         <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
    <prop key="hibernate.use_outer_join">false</prop>
    <prop key="hibernate.show_sql">true</prop>
    <prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
    </props>
    </property>
    </bean>

    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory">
    <ref bean="sessionFactory" />
    </property>
    </bean>
    <bean id="beanproxy" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
    <property name="beanNames">
    <value>*Svr,*svr</value>
    </property>
    <property name="interceptorNames">
    <list>
    <value>transactionAdvisor</value>
    </list>
    </property>
    </bean>
    <bean id="transactionAdvisor" class="org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor">
    <property name="transactionInterceptor" ref="transactionInterceptor" />
    </bean>
    <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
    <property name="transactionManager" ref="transactionManager" />
    <property name="transactionAttributes">
    <props>
    <prop key="*">PROPAGATION_REQUIRED,-Exception</prop>
    <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
    <prop key="query*">PROPAGATION_REQUIRED,readOnly</prop>
    <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>

    </props>

    </property>
    </bean>