I want to use Global transaction manager at my service layer.
eg.
namespace AssemblyName.Core.Service.Implementation
{
public class DemoService
{
public void demo()
{
save(model); //This is nHibernate transaction
SchedulerManager.GetInstance.save(id); //This is related to quartz.
}
}
}
What should I use?
If I used TransactionScope()
then it is giving me error as NHibernateTransaction can't be committed.
I have used
<object id="transactionManager"
type="Spring.Data.NHibernate.HibernateTransactionManager, Spring.Data.NHibernate33">
<property name="DbProvider" ref="DbProvider"/>
<property name="SessionFactory" ref="NHibernateSessionFactory"/>
</object>
in my sprin.config file.
Edited: Then I have used two transaction manager in spring.config file:
<object id="transactionManager"type="Spring.Data.NHibernate.HibernateTransactionManager,Spring.DataNHibernate33">
<property name="DbProvider" ref="DbProvider"/>
<property name="SessionFactory"ref="NHibernateSessionFactory"/>
</object>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*"/>
</tx:attributes>
</tx:advice>
<object id="serviceOperation" type="Spring.Aop.Support.SdkRegularExpressionMethodPointcut,Spring.Aop">
<property name="pattern" value="AssemblyName.Core.Service.Implementation.*"/>
</object>
<object id="transactionManagerGLobal" type="Spring.Data.Core.TxScopeTransactionManager, Spring.Data">
</object>
<tx:advice id="txAdviceGlobal" transaction-manager="transactionManagerGLobal">
<tx:attributes>
<tx:method name="demo"/>
</tx:attributes>
</tx:advice>
<object id="serviceOperationGlobal" type="Spring.Aop.Support.SdkRegularExpressionMethodPointcut, Spring.Aop">
<property name="pattern" value="AssemblyName.Core.Service.Implementation.DemoService"/>
</object>
<aop:config>
<aop:advisor pointcut-ref="serviceOperation" advice-ref="txAdvice"/>
<aop:advisor pointcut-ref="serviceOperationGlobal" advice-ref="txAdviceGlobal"/>
</aop:config>
Then also getting Error as: NHibernate Transaction is disconnected or not connected.