Hello,

We've recently upgraded a project to the latest RC versions of
NHibernateIntegration and its dependencies.

This project uses an NHibernate Interceptor to manage validation,
which indicates validation problems by throwing ApplicationExceptions
from the OnFlushDirty method.

The problem we have is that NHibernateIntegration does not seem to get
a chance to dispose of the session when this happens during the Commit
of an AutoTx transaction.  Calling ISessionManager.OpenSession from a
subsquent transaction (on the same thread) then gives you back a
session with the dirty objects still in it.  This isn't the behaviour
we want - we'd like the transaction to be properly rolled back and the
session discarded.

The problem is partly that the clear-up which NHibernateIntegration
normally does in SessionDisposeSynchronization.AfterCompletion doesn't
happen if the commit fails, because
Services.Transaction.TransactionBase doesn't call AfterCompletion in
this case.

For our project we've worked around this, but the solution is pretty
grim as we have had to build customised versions of AutoTx and
Transaction.  In our version, the AutoTx TransactionInterceptor
attempts to roll back the transaction in the event that the commit
fails, instead of just giving up and leaving the dirty session in
place.  The TransactionBase.Rollback then does call AfterCompletion
(and in fact does so even if the Rollback fails).

I've put together the simplest project I can which demonstrates this
failing (with the stock versions of the Castle libraries), which can
be downloaded here:

http://www.digimap.gg/sites/www.digimap.gg/files/NHibernateIntegrationProb.tar.gz

It assumes you have MS SQL server and creates a table called 'Thing'
in the tempdb.

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Development List" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-devel?hl=en.

Reply via email to