出错信息(1):
DEBUG http-8080-Processor24 com.rq.iqs.action.OperAction - doInsert 111
DEBUG http-8080-Processor24 org.springframework.orm.hibernate3.HibernateTransactionManager - Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@19f31de]
DEBUG http-8080-Processor24 org.springframework.orm.hibernate3.HibernateTransactionManager - Creating new transaction with name [com.rq.iqs.dbservice.OperManager.doInsert]
DEBUG http-8080-Processor24 org.hibernate.impl.SessionImpl - opened session at timestamp: 11654735921
DEBUG http-8080-Processor24 org.springframework.orm.hibernate3.HibernateTransactionManager - Opened new Session [org.hibernate.impl.SessionImpl@832226] for Hibernate transaction
DEBUG http-8080-Processor24 org.springframework.orm.hibernate3.HibernateTransactionManager - Preparing JDBC Connection of Hibernate Session [org.hibernate.impl.SessionImpl@832226]
DEBUG http-8080-Processor24 org.hibernate.transaction.JDBCTransaction - begin
DEBUG http-8080-Processor24 org.hibernate.jdbc.ConnectionManager - opening JDBC connection
DEBUG http-8080-Processor24 org.hibernate.transaction.JDBCTransaction - current autocommit status: true
DEBUG http-8080-Processor24 org.hibernate.transaction.JDBCTransaction - disabling autocommit
DEBUG http-8080-Processor24 org.hibernate.jdbc.JDBCContext - after transaction begin
DEBUG http-8080-Processor24 org.springframework.orm.hibernate3.HibernateTransactionManager - Exposing Hibernate transaction as JDBC transaction [org.apache.tomcat.dbcp.dbcp.PoolableConnection@1b6634c]
DEBUG http-8080-Processor24 org.springframework.transaction.support.TransactionSynchronizationManager - Bound value [org.springframework.jdbc.datasource.ConnectionHolder@137008a] for key [org.apache.tomcat.dbcp.dbcp.BasicDataSource@122d9c] to thread [http-8080-Processor24]
DEBUG http-8080-Processor24 org.springframework.transaction.support.TransactionSynchronizationManager - Bound value [org.springframework.orm.hibernate3.SessionHolder@49b03] for key [org.hibernate.impl.SessionFactoryImpl@d83365] to thread [http-8080-Processor24]
DEBUG http-8080-Processor24 org.springframework.transaction.support.TransactionSynchronizationManager - Initializing transaction synchronization
DEBUG http-8080-Processor24 org.springframework.transaction.interceptor.TransactionInterceptor - Getting transaction for [com.rq.iqs.dbservice.OperManager.doInsert]
DEBUG http-8080-Processor24 com.rq.iqs.dao.OperDao - OperDao start doInsert.............
DEBUG http-8080-Processor24 org.springframework.transaction.support.TransactionSynchronizationManager - Retrieved value [org.springframework.orm.hibernate3.SessionHolder@49b03] for key [org.hibernate.impl.SessionFactoryImpl@d83365] bound to thread [http-8080-Processor24]
DEBUG http-8080-Processor24 org.springframework.transaction.support.TransactionSynchronizationManager - Retrieved value [org.springframework.orm.hibernate3.SessionHolder@49b03] for key [org.hibernate.impl.SessionFactoryImpl@d83365] bound to thread [http-8080-Processor24]
DEBUG http-8080-Processor24 org.springframework.orm.hibernate3.HibernateTemplate - Found thread-bound Session for HibernateTemplate
DEBUG http-8080-Processor24 com.rq.iqs.dao.OperDao - dao 111111
DEBUG http-8080-Processor24 org.hibernate.event.def.DefaultSaveOrUpdateEventListener - saving transient instance
DEBUG http-8080-Processor24 org.hibernate.event.def.AbstractSaveEventListener - generated identifier: 9091, using strategy: org.hibernate.id.Assigned
DEBUG http-8080-Processor24 org.hibernate.event.def.AbstractSaveEventListener - saving [com.rq.iqs.business.Oper#9091]
DEBUG http-8080-Processor24 com.rq.iqs.dao.OperDao - dao 222222
DEBUG http-8080-Processor24 org.springframework.orm.hibernate3.HibernateTemplate - Not closing pre-bound Hibernate Session after HibernateTemplate
DEBUG http-8080-Processor24 org.springframework.transaction.interceptor.TransactionInterceptor - Completing transaction for [com.rq.iqs.dbservice.OperManager.doInsert]
DEBUG http-8080-Processor24 org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering beforeCommit synchronization
DEBUG http-8080-Processor24 org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering beforeCompletion synchronization
DEBUG http-8080-Processor24 org.springframework.orm.hibernate3.HibernateTransactionManager - Initiating transaction commit
DEBUG http-8080-Processor24 org.springframework.orm.hibernate3.HibernateTransactionManager - Committing Hibernate transaction on Session [org.hibernate.impl.SessionImpl@832226]
DEBUG http-8080-Processor24 org.hibernate.transaction.JDBCTransaction - commit
DEBUG http-8080-Processor24 org.hibernate.impl.SessionImpl - automatically flushing session
DEBUG http-8080-Processor24 org.hibernate.event.def.AbstractFlushingEventListener - flushing session
DEBUG http-8080-Processor24 org.hibernate.event.def.AbstractFlushingEventListener - processing flush-time cascades
DEBUG http-8080-Processor24 org.hibernate.event.def.AbstractFlushingEventListener - dirty checking collections
DEBUG http-8080-Processor24 org.hibernate.event.def.AbstractFlushingEventListener - Flushing entities and processing referenced collections
DEBUG http-8080-Processor24 org.hibernate.event.def.AbstractFlushingEventListener - Processing unreferenced collections
DEBUG http-8080-Processor24 org.hibernate.event.def.AbstractFlushingEventListener - Scheduling collection removes/(re)creates/updates
DEBUG http-8080-Processor24 org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 1 insertions, 0 updates, 0 deletions to 1 objects
DEBUG http-8080-Processor24 org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
DEBUG http-8080-Processor24 org.hibernate.pretty.Printer - listing entities:
...
DEBUG http-8080-Processor24 org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG http-8080-Processor24 org.hibernate.jdbc.AbstractBatcher - closing statement
DEBUG http-8080-Processor24 org.hibernate.jdbc.ConnectionManager - registering flush end
DEBUG http-8080-Processor24 org.hibernate.event.def.AbstractFlushingEventListener - post flush
DEBUG http-8080-Processor24 org.hibernate.jdbc.JDBCContext - before transaction completion
DEBUG http-8080-Processor24 org.hibernate.impl.SessionImpl - before transaction completion
DEBUG http-8080-Processor24 org.hibernate.transaction.JDBCTransaction - re-enabling autocommit
DEBUG http-8080-Processor24 org.hibernate.transaction.JDBCTransaction - committed JDBC Connection
DEBUG http-8080-Processor24 org.hibernate.jdbc.JDBCContext - after transaction completion
DEBUG http-8080-Processor24 org.hibernate.jdbc.ConnectionManager - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
DEBUG http-8080-Processor24 org.hibernate.impl.SessionImpl - after transaction completion
DEBUG http-8080-Processor24 org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering afterCommit synchronization
DEBUG http-8080-Processor24 org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering afterCompletion synchronization

解决方案 »

  1.   

    出错信息(2):
    DEBUG http-8080-Processor24 org.springframework.transaction.support.TransactionSynchronizationManager - Clearing transaction synchronization
    DEBUG http-8080-Processor24 org.springframework.transaction.support.TransactionSynchronizationManager - Removed value [org.springframework.orm.hibernate3.SessionHolder@49b03] for key [org.hibernate.impl.SessionFactoryImpl@d83365] from thread [http-8080-Processor24]
    DEBUG http-8080-Processor24 org.springframework.transaction.support.TransactionSynchronizationManager - Removed value [org.springframework.jdbc.datasource.ConnectionHolder@137008a] for key [org.apache.tomcat.dbcp.dbcp.BasicDataSource@122d9c] from thread [http-8080-Processor24]
    DEBUG http-8080-Processor24 org.springframework.orm.hibernate3.HibernateTransactionManager - Closing Hibernate Session [org.hibernate.impl.SessionImpl@832226] after transaction
    DEBUG http-8080-Processor24 org.springframework.orm.hibernate3.SessionFactoryUtils - Closing Hibernate Session
    DEBUG http-8080-Processor24 org.hibernate.impl.SessionImpl - closing session
    DEBUG http-8080-Processor24 org.hibernate.jdbc.ConnectionManager - performing cleanup
    DEBUG http-8080-Processor24 org.hibernate.jdbc.ConnectionManager - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
    DEBUG http-8080-Processor24 org.hibernate.jdbc.JDBCContext - after transaction completion
    DEBUG http-8080-Processor24 org.hibernate.jdbc.ConnectionManager - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
    DEBUG http-8080-Processor24 org.hibernate.impl.SessionImpl - after transaction completion
    DEBUG http-8080-Processor24 com.rq.iqs.action.OperAction - doInsert 222
    DEBUG http-8080-Processor24 org.springframework.orm.hibernate3.HibernateTransactionManager - Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@755df3]
    DEBUG http-8080-Processor24 org.springframework.orm.hibernate3.HibernateTransactionManager - Creating new transaction with name [com.rq.iqs.dbservice.OperManager.doInsert]
    DEBUG http-8080-Processor24 org.hibernate.impl.SessionImpl - opened session at timestamp: 11654735923
    DEBUG http-8080-Processor24 org.springframework.orm.hibernate3.HibernateTransactionManager - Opened new Session [org.hibernate.impl.SessionImpl@16b0c24] for Hibernate transaction
    DEBUG http-8080-Processor24 org.springframework.orm.hibernate3.HibernateTransactionManager - Preparing JDBC Connection of Hibernate Session [org.hibernate.impl.SessionImpl@16b0c24]
    DEBUG http-8080-Processor24 org.hibernate.transaction.JDBCTransaction - begin
    DEBUG http-8080-Processor24 org.hibernate.jdbc.ConnectionManager - opening JDBC connection
    DEBUG http-8080-Processor24 org.hibernate.transaction.JDBCTransaction - current autocommit status: true
    DEBUG http-8080-Processor24 org.hibernate.transaction.JDBCTransaction - disabling autocommit
    DEBUG http-8080-Processor24 org.hibernate.jdbc.JDBCContext - after transaction begin
    DEBUG http-8080-Processor24 org.springframework.orm.hibernate3.HibernateTransactionManager - Exposing Hibernate transaction as JDBC transaction [org.apache.tomcat.dbcp.dbcp.PoolableConnection@1b6634c]
    DEBUG http-8080-Processor24 org.springframework.transaction.support.TransactionSynchronizationManager - Bound value [org.springframework.jdbc.datasource.ConnectionHolder@ea25c1] for key [org.apache.tomcat.dbcp.dbcp.BasicDataSource@122d9c] to thread [http-8080-Processor24]
    DEBUG http-8080-Processor24 org.springframework.transaction.support.TransactionSynchronizationManager - Bound value [org.springframework.orm.hibernate3.SessionHolder@54a25f] for key [org.hibernate.impl.SessionFactoryImpl@d83365] to thread [http-8080-Processor24]
    DEBUG http-8080-Processor24 org.springframework.transaction.support.TransactionSynchronizationManager - Initializing transaction synchronization
    DEBUG http-8080-Processor24 org.springframework.transaction.interceptor.TransactionInterceptor - Getting transaction for [com.rq.iqs.dbservice.OperManager.doInsert]
    DEBUG http-8080-Processor24 com.rq.iqs.dao.OperDao - OperDao start
      

  2.   

    出错信息(3):
    doInsert.............
    DEBUG http-8080-Processor24 com.rq.iqs.dao.OperDao - dao 111111
    DEBUG http-8080-Processor24 org.hibernate.event.def.DefaultSaveOrUpdateEventListener - saving transient instance
    DEBUG http-8080-Processor24 org.hibernate.event.def.AbstractSaveEventListener - generated identifier: 9091, using strategy: org.hibernate.id.Assigned
    DEBUG http-8080-Processor24 org.hibernate.event.def.AbstractSaveEventListener - saving [com.rq.iqs.business.Oper#9091]
    DEBUG http-8080-Processor24 com.rq.iqs.dao.OperDao - dao 222222
    DEBUG http-8080-Processor24 org.springframework.orm.hibernate3.HibernateTemplate - Not closing pre-bound Hibernate Session after HibernateTemplate
    DEBUG http-8080-Processor24 org.springframework.transaction.interceptor.TransactionInterceptor - Completing transaction for [com.rq.iqs.dbservice.OperManager.doInsert]
    DEBUG http-8080-Processor24 org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering beforeCommit synchronization
    DEBUG http-8080-Processor24 org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering beforeCompletion synchronization
    DEBUG http-8080-Processor24 org.springframework.orm.hibernate3.HibernateTransactionManager - Initiating transaction commit
    DEBUG http-8080-Processor24 org.springframework.orm.hibernate3.HibernateTransactionManager - Committing Hibernate transaction on Session [org.hibernate.impl.SessionImpl@16b0c24]
    DEBUG http-8080-Processor24 org.hibernate.transaction.JDBCTransaction - commit
    DEBUG http-8080-Processor24 org.hibernate.impl.SessionImpl - automatically flushing session
    DEBUG http-8080-Processor24 org.hibernate.event.def.AbstractFlushingEventListener - flushing session
    DEBUG http-8080-Processor24 org.hibernate.event.def.AbstractFlushingEventListener - processing flush-time cascades
    DEBUG http-8080-Processor24 org.hibernate.event.def.AbstractFlushingEventListener - dirty checking collections
    DEBUG http-8080-Processor24 org.hibernate.event.def.AbstractFlushingEventListener - Flushing entities and processing referenced collections
    DEBUG http-8080-Processor24 org.hibernate.event.def.AbstractFlushingEventListener - Processing unreferenced collections
    DEBUG http-8080-Processor24 org.hibernate.event.def.AbstractFlushingEventListener - Scheduling collection removes/(re)creates/updates
    DEBUG http-8080-Processor24 org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 1 insertions, 0 updates, 0 deletions to 1 objects
    DEBUG http-8080-Processor24 org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
    DEBUG http-8080-Processor24 org.hibernate.pretty.Printer - listing entities:
    ...
    DEBUG http-8080-Processor24 org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
    DEBUG http-8080-Processor24 org.hibernate.jdbc.AbstractBatcher - closing statement
    java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]违反了 PRIMARY KEY 约束 'PK__oper_7A9C383C'。不能在对象 'oper' 中插入重复键。
    DEBUG http-8080-Processor24 org.springframework.orm.hibernate3.HibernateTransactionManager - Rolling back Hibernate transaction on Session [org.hibernate.impl.SessionImpl@16b0c24]
    DEBUG http-8080-Processor24 org.hibernate.transaction.JDBCTransaction - rollback
    DEBUG http-8080-Processor24 org.hibernate.transaction.JDBCTransaction - re-enabling autocommit
    DEBUG http-8080-Processor24 org.hibernate.transaction.JDBCTransaction - rolled back JDBC Connection
    DEBUG http-8080-Processor24 org.hibernate.jdbc.JDBCContext - after transaction completion
    DEBUG http-8080-Processor24 org.hibernate.jdbc.ConnectionManager - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
    DEBUG http-8080-Processor24 org.hibernate.impl.SessionImpl - after transaction completion
    DEBUG http-8080-Processor24 org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering afterCompletion synchronization
    DEBUG http-8080-Processor24 org.springframework.transaction.support.TransactionSynchronizationManager - Clearing transaction synchronization
    DEBUG http-8080-Processor24 org.springframework.transaction.support.TransactionSynchronizationManager - Removed value [org.springframework.orm.hibernate3.SessionHolder@54a25f] for key [org.hibernate.impl.SessionFactoryImpl@d83365] from thread [http-8080-Processor24]
    DEBUG http-8080-Processor24 org.springframework.transaction.support.TransactionSynchronizationManager - Removed value [org.springframework.jdbc.datasource.ConnectionHolder@ea25c1] for key [org.apache.tomcat.dbcp.dbcp.BasicDataSource@122d9c] from thread [http-8080-Processor24]
    DEBUG http-8080-Processor24 org.springframework.orm.hibernate3.HibernateTransactionManager - Closing Hibernate Session [org.hibernate.impl.SessionImpl@16b0c24] after transaction
    DEBUG http-8080-Processor24 org.springframework.orm.hibernate3.SessionFactoryUtils - Closing Hibernate Session
    DEBUG http-8080-Processor24 org.hibernate.impl.SessionImpl - closing session
    DEBUG http-8080-Processor24 org.hibernate.jdbc.ConnectionManager - performing cleanup
    DEBUG http-8080-Processor24 org.hibernate.jdbc.ConnectionManager - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
    DEBUG http-8080-Processor24 org.hibernate.jdbc.JDBCContext - after transaction completion
    DEBUG http-8080-Processor24 org.hibernate.jdbc.ConnectionManager - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
    DEBUG http-8080-Processor24 org.hibernate.impl.SessionImpl - after transaction completion
    ...
    从上述日志信息来看,似乎是每个doInsert都提交了事务,导致在出现异常时不能回滚之前第一次插入的记录。为什么不等到退出execute()时再统一处理事务呢?
      

  3.   

    太长了,以至于没看完。
    spring框架本身不支持事务,需要其它支持。你看下代码有没有什么问题。
      

  4.   

    代码上暂时看不出什么问题,但是每次doInsert函数结束后,都自动调用了commit,导致在后面出现异常时没能回滚,不知道是哪里不对啊
      

  5.   

    如果是自动调用commit,那就不能符合你的要求。你要不自己写代码来实现吧。
      

  6.   

    可如果在action中显式的管理事务,那还不如不要用spring算了。
      

  7.   

    各位XDJM帮忙看看,顶顶,都有分的哦:)
      

  8.   

    一看标题看成是:Spring+Hibernate中的事务不会的滚!
    吓我一跳。
      

  9.   

    m_OperManager.doInsert( m_Oper );//事务1
            logger.debug( "doInsert 222" );
            m_OperManager.doInsert( m_Oper );//新事务2
      

  10.   

    DEBUG http-8080-Processor24 org.hibernate.jdbc.AbstractBatcher - closing statement
    java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]违反了 PRIMARY KEY 约束 'PK__oper_7A9C383C'。不能在对象 'oper' 中插入重复键。异常在这一段啊,在“新事务2”中出错,但是在logger之前“新事务1”已经被提交了,导致没有回滚。nearsun(蓝冰)能再帮我看看么?
      

  11.   

    m_OperManager 这种命名方式,晕,楼主c++转过来的吧你配置的就是把operManager的方法作为事务边界,怎么回滚第一个?
    要么用一个facade类,要么把Action的excute方法加入事务管理。<bean id="operAction " ...>
    ...
            <property name="target">
                <ref local="operAction Target" />
            </property>
            <property name="transactionAttributes">
                <props>
                    <prop key="excute">PROPAGATION_REQUIRED,readOnly</prop>
                </props>
            </property>
        </bean>