Hi,

I use Castle Dynamic Proxy to insert aspects in the system we are doing here
so that
we don´t have to repeat the exception and session management code block all
over the system.

However the managed session is replaced with null value when the actual
method gets called.
See the code listing below in my dynamic proxy interceptor.

Is there any restriction in using Castle Dynamic Proxy together with
NHibernate ?

*Interceptor:*

    public class SessionTransactionExceptionAspect : IInterceptor
    {
        public void Intercept(IInvocation invocation)
        {
            NHibernate.ITransaction tx = null;
            NHibernate.ISession s = null;
            try
            {
                s = NHDAOFactory.SessionFactory.OpenSession();
                CallSessionContext.Bind(s);
                tx =
NHDAOFactory.SessionFactory.GetCurrentSession().BeginTransaction();
                retorno = invocation.Proceed();*<**- When it gets called
then session (s) = NULL*
                tx.Commit();
            }
            catch (Exception exception)
            {
                if (tx != null) { tx.Rollback(); }
                throw exception;
            }
            finally
            {
                if (s != null) s.Close();
                CallSessionContext.Unbind(s.SessionFactory);
            }
        }
    }

Any ideas ?

-- 
Humberto C Marchezi
---------------------------------------------------------
Master in Electrical Engineering - Automation
Software Consultant and Developer
at the Town Hall of Vitória

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" 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/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to