set transaction must be first statement of transaction With Spring.Data.NHibernate12
I am using Spring.Data.NHibernate12 on my database level.my application connection with database is not getting released.Sometime in Nhibernate log i am getting set transaction must be first statement of transaction .Setting transaction tag on top of the function. Underneath given is 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 k开发者_运维技巧ey="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>
First of all, you need to update the NHibernate to 3 version.
Instead of using Spring.Data.NHibernate12, you must use Spring.Data.NHibernate30.
I am working with it very well.
Regards,
精彩评论