Modified IsExistingTransaction, included uncommented code to check for transactions hibernateTransactionObject.HasTransaction() to check that Transaction.Current is not null and that the HibernateTransactionObject has a transaction too. Un-commenting this will by pass HandleExistingTransaction() on the second service call, Unit Test ->ServiceMethodWithNotSupported1 -> ServiceMethodWithNotSupported2, Forcing to create an "empty transaction" for the ServiceMethodWithNotSupported2 call. This seems to make sense since The the call to ServiceMethodWithNotSupported1 suspended the existing transaction, by the call to ServiceMethodWithNotSupported2, there is no transaction to suspend. Please advice on this potential solution.
This commit is contained in:
@@ -342,10 +342,12 @@ namespace Spring.Data.NHibernate
|
||||
/// </exception>
|
||||
protected override bool IsExistingTransaction(object transaction)
|
||||
{
|
||||
return
|
||||
((HibernateTransactionObject)transaction).PromotableTxScopeTransactionObject.TxScopeAdapter.
|
||||
IsExistingTransaction;
|
||||
//return ((HibernateTransactionObject) transaction).HasTransaction();
|
||||
var hibernateTransactionObject = ((HibernateTransactionObject) transaction);
|
||||
|
||||
var hasExistingPromotableTxScopeTransaction = hibernateTransactionObject.PromotableTxScopeTransactionObject.TxScopeAdapter.IsExistingTransaction;
|
||||
var hasExistingTransaction = hibernateTransactionObject.HasTransaction();
|
||||
|
||||
return hasExistingPromotableTxScopeTransaction && hasExistingTransaction;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -951,12 +953,14 @@ namespace Spring.Data.NHibernate
|
||||
}
|
||||
*/
|
||||
ISession session = txObject.SessionHolder.Session;
|
||||
|
||||
if (txObject.NewSessionHolder)
|
||||
{
|
||||
if (log.IsDebugEnabled)
|
||||
{
|
||||
log.Debug("Closing Hibernate Session [" + session + "] after transaction");
|
||||
}
|
||||
|
||||
SessionFactoryUtils.CloseSessionOrRegisterDeferredClose(session, SessionFactory);
|
||||
}
|
||||
else
|
||||
@@ -970,9 +974,8 @@ namespace Spring.Data.NHibernate
|
||||
session.FlushMode = txObject.SessionHolder.PreviousFlushMode;
|
||||
}
|
||||
}
|
||||
|
||||
txObject.SessionHolder.Clear();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private class HibernateTransactionObject : AdoTransactionObjectSupport
|
||||
|
||||
Reference in New Issue
Block a user