我在我的数据库级别使用Spring.Data.NHibernate12。我的应用程序与数据库的连接没有被释放。在Nhibernate日志中的某些时间我得到了 设置事务必须是第一个事务声明。在函数顶部设置事务标记。 给定的是Dataconfiguration.xml
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net"
xmlns:db="http://www.springframework.net/database">
<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"/>
<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=amsbvt; Password=amsuser1234;"/>
<!-- 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.Mapping</value>
<value>Risco.Rsp.Ac.Logging.Appenders</value>
<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>
<!-- To make use of spring's + nHibernate transaction management-->
<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="CategoryDAOTx" type="Spring.Transaction.Interceptor.TransactionProxyFactoryObject,Spring.Data">
<property name="PlatformTransactionManager" ref="transactionManager"/>
<property name="Target" ref="SendConfigDataDAO"/>
<property name="TransactionAttributes">
<name-values>
<add key="Save" value="PROPAGATION_REQUIRED"/>
<add key="Delete" value="PROPAGATION_REQUIRED"/>
<add key="SaveOrUpdate" value="PROPAGATION_REQUIRED"/>
<add key="FetchForUpdate" value="PROPAGATION_REQUIRED"/>
</name-values>
</property>
</object>
<object id="SendConfigDataDAO" type="Risco.Rsp.Ac.AMAC.DAO.SendConfigDataMgmt.SendConfigDataDAO,Risco.Rsp.Ac.AMAC.DAO.SendConfigDataMgmt">
<property name="HibernateTemplate" ref="HibernateTemplate" />
<property name="SessionFactory" ref="NHibernateSessionFactory"/>
</object>
<!--<tx:attribute-driven/>-->
</objects>
答案 0 :(得分:1)
首先,您需要将NHibernate更新为3版本。
不必使用Spring.Data.NHibernate12,而必须使用Spring.Data.NHibernate30。
我正在努力工作。
此致