异常无法打开Hibernate Session进行事务处理

时间:2010-05-25 06:13:35

标签: nhibernate transactions spring.net

有时我在NHibernate日志中遇到这个问题。我的应用程序在那一刻就停止了。

更新了wityh数据配置。

即使成功完成了Transaction.Application与数据库的连接persist.in

Nhibernate日志显示

Nhibernate Log

  

2010-05-21 14:45:08,428 [Worker] [0] DEBUG NHibernate.Impl.SessionImpl   [(null)]<(null)> -

     

执行flush

     

2010-05-21 14:45:08,428 [工人] [0]调试   NHibernate.Impl.ConnectionManager [(null)]<

     

(空)> - 注册flush begin

     

2010-05-21 14:45:08,428 [工人] [0]调试   NHibernate.Impl.ConnectionManager [(null)]<

     

(空)> - 注册刷新结束

     

2010-05-21 14:45:08,428 [Worker] [0] DEBUG NHibernate.Impl.SessionImpl   [(null)]<(null)> -

     

后冲

     

2010-05-21 14:45:08,428 [Worker] [0] DEBUG NHibernate.Impl.SessionImpl   [(null)]<(null)> -

     交易完成前

     

2010-05-21 14:45:08,428 [工人] [0]调试   NHibernate.Impl.ConnectionManager [(null)]<

     

(空)> - 积极释放数据库连接

     

2010-05-21 14:45:08,428 [工人] [0]调试   NHibernate.Connection.ConnectionProvider

     

[(null)]<(null)> - 关闭连接

     

2010-05-21 14:45:08,428 [Worker] [0] DEBUG NHibernate.Impl.SessionImpl   [(null)]<(null)> -

     

交易完成

     

2010-05-21 14:45:08,428 [工人] [0]调试   NHibernate.Transaction.AdoTransaction [(null)]<

     

(空)> - 运行AdoTransaction.Dispose()

     

2010-05-21 14:45:08,428 [Worker] [0] DEBUG NHibernate.Impl.SessionImpl   [(null)]<(null)> -

     

结束会议

     

2010-05-21 14:45:08,428 [Worker] [0] DEBUG NHibernate.Impl.BatcherImpl   [(null)]<(null)> -

     

运行BatcherImpl.Dispose(true)

下面给出的是我的dataconfiguration文件

   <?xml version="1.0" encoding="utf-8" ?>

<objects 
xmlns="http://www.springframework.net" 

         xmlns:db="http://www.springframework.net/database"

     xmlns:tx="http://www.springframework.net/tx">

  <object id="AuditLogger" type="Risco.Rsp.Ac.Audit.AuditLogger, Risco.Rsp.Ac.Audit" singleton="false"> 

    <property name="CacheSettings" ref="CacheSettings"  />
  </object>


  <object id="CacheSettings"

          type="Risco.Rsp.Ac.AMAC.CacheMgmt.Utilities.UpdateEntityCacheHelper, 

Risco.Rsp.Ac.AMAC.CacheMgmt.Utilities" singleton="false"/>

  <!-- Property placeholder configurer for database settings-->

  <object type="Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer, Spring.Core">

    <property name="ConfigSections" value="databaseSettings"/>
  </object>

  <db:provider id="AMACDbProvider"

                provider="OracleClient-2.0"

    connectionString="Data Source=RISCODEVDB;User ID=amacdevuser; Password=amacuser1234;"/>

  <!-- For creating Factory objects -->
  <object id="NHibernateSessionFactory" 

  type="Spring.Data.NHibernate.LocalSessionFactoryObject,Spring.Data.NHibernate12">

    <property name="DbProvider" ref="AMACDbProvider"/>

    <property name="MappingAssemblies">
      <list>
              <value>
    Risco.Rsp.Ac.AMAC.CacheMappings

       </value>

      </list>

    </property>

    <property name="HibernateProperties">

      <dictionary>

        <entry key="hibernate.connection.provider"

               value="NHibernate.Connection.DriverConnectionProvider"
         />

        <entry key="hibernate.dialect"

               value="NHibernate.Dialect.Oracle9Dialect"
              />


        <entry key="hibernate.connection.driver_class"


               value="NHibernate.Driver.OracleClientDriver"/>

      </dictionary>


    </property>

  </object>


  <object id="HibernateTemplate" type="Spring.Data.NHibernate.HibernateTemplate"

singleton="false">

    <property name="SessionFactory"

 ref="NHibernateSessionFactory" />

    <property name="TemplateFlushMode" 
value="Auto" />

    <property name="CacheQueries" value="true" />

    <property name="EntityInterceptor" ref="AuditLogger"/>

  </object>


  ><object id="transactionManager" singleton="true"  

    type="Spring.Data.NHibernate.HibernateTransactionManager, >Spring.Data.NHibernate12">  

    <property name="DbProvider" ref="AMACDbProvider"/>

    <property name="SessionFactory" ref="NHibernateSessionFactory"/>

    <property name="EntityInterceptor" ref="AuditLogger"/>

  </object>


  <object id="EventPubSubDAOTx" 

type="Spring.Transaction.Interceptor.TransactionProxyFactoryObject,Spring.Data">

    <property name="PlatformTransactionManager" ref="transactionManager"/>

    <property name="Target" ref="EventPubSubDAO"/>

    <property name="TransactionAttributes">
       <name-values>

        <add key="Save*" value="PROPAGATION_REQUIRES_NEW"/>

        <add key="Delete*" value="PROPAGATION_REQUIRED"/>

      </name-values>

    </property>

  </object>


  <object id="EventPubSubDAO"  

    type="Risco.Rsp.Ac.AMAC.DAO.EventPubSubMgmt.EventPubSubDAO, 

   Risco.Rsp.Ac.AMAC.DAO.EventPubSubMgmt">

    <property name="HibernateTemplate" ref="HibernateTemplate" />

    <property name="SessionFactory" ref="NHibernateSessionFactory"/>

  </object>

  <!-- EventPubSubMgmt DAO -->


  <tx:attribute-driven/>

  </objects>

请帮我解决这个问题。谢谢

1 个答案:

答案 0 :(得分:0)

例外通常是由使用已关闭的会话引起的。您的other question也指出您可能需要重新考虑您的连接和会话使用情况。

由于您的问题中没有太多信息,因此很难提出改进建议。