I'm still stuck with this. I've done a more in depth investigation and
detailed my findings below - it's a little lengthy but if someone can
bear with me and take a look I'd really appreciate it.

As previously stated, I have a simple action method on a controller
that's been marked as [Transactional].  The action method has been
marked with [Transaction(TransactionMode.RequiresNew)].

Upon entering the transactional method the following is emitted in the
debug output:

------------------
Castle.Services.Transaction.DefaultTransactionManager: 2009-02-04
22:54:23,088 [7] DEBUG [(null)] <(null)> - Transaction 53179874
created
Castle.Services.Transaction.DefaultTransactionManager.Castle.Services.Transaction.StandardTransaction:
2009-02-04 22:54:23,098 [7] DEBUG [(null)] <(null)> - Transaction
'53179874' Begin
-------------------

This action method then calls into a repository object that is also
marked as [Transactional] where the target method on the repository is
marked [Transaction(TransactionMode.Requires)].  This method is the
first method in the call stack that requests a session from the
session manager and the debug seems to indicate that a child
transaction is created and that the session is opened afterward:

------------------
Castle.Services.Transaction.DefaultTransactionManager: 2009-02-04
22:55:07,812 [7] DEBUG [(null)] <(null)> - Child Transaction 10105378
created
NHibernate.Impl.SessionImpl: 2009-02-04 22:55:07,882 [7] DEBUG
[(null)] <(null)> - opened session
NHibernate.Transaction.AdoTransaction: 2009-02-04 22:55:07,882 [7]
DEBUG [(null)] <(null)> - Begin (Unspecified)
------------------

After the method on the repository has completed the child transaction
appears to be committed:

------------------
Castle.Facilities.AutomaticTransactionManagement.TransactionInterceptor:
2009-02-04 22:58:27,539 [7] DEBUG [(null)] <(null)> - Committing back
transaction 10105378
Castle.Services.Transaction.DefaultTransactionManager: 2009-02-04
22:58:27,539 [7] DEBUG [(null)] <(null)> - Transaction 10105378
disposed successfully
------------------

Any subsequent calls to other repository methods marked with
[Transaction(TransactionMode.Requires)] from the action method appear
to create a new child transactions and commit them afterward.

Finally, when the action method on the controller exits the root
transaction appears to be committed:

------------------
Castle.Facilities.AutomaticTransactionManagement.TransactionInterceptor:
2009-02-04 23:01:05,066 [7] DEBUG [(null)] <(null)> - Committing back
transaction 53179874
Castle.Services.Transaction.DefaultTransactionManager.Castle.Services.Transaction.StandardTransaction:
2009-02-04 23:01:05,066 [7] DEBUG [(null)] <(null)> - Transaction
'53179874' Commit
NHibernate.Transaction.AdoTransaction: 2009-02-04 23:01:05,066 [7]
DEBUG [(null)] <(null)> - Start Commit
NHibernate.Impl.SessionImpl: 2009-02-04 23:01:05,076 [7] DEBUG
[(null)] <(null)> - before transaction completion
NHibernate.Transaction.AdoTransaction: 2009-02-04 23:01:05,076 [7]
DEBUG [(null)] <(null)> - IDbTransaction Committed
NHibernate.Impl.SessionImpl: 2009-02-04 23:01:05,076 [7] DEBUG
[(null)] <(null)> - transaction completion
NHibernate.AdoNet.ConnectionManager: 2009-02-04 23:01:05,076 [7] DEBUG
[(null)] <(null)> - aggressively releasing database connection
NHibernate.Connection.ConnectionProvider: 2009-02-04 23:01:05,076 [7]
DEBUG [(null)] <(null)> - Closing connection
NHibernate.Transaction.AdoTransaction: 2009-02-04 23:01:05,076 [7]
DEBUG [(null)] <(null)> - IDbTransaction disposed.
NHibernate.Impl.SessionImpl: 2009-02-04 23:01:05,076 [7] DEBUG
[(null)] <(null)> - running ISession.Dispose()
NHibernate.Impl.SessionImpl: 2009-02-04 23:01:05,086 [7] DEBUG
[(null)] <(null)> - closing session
NHibernate.AdoNet.AbstractBatcher: 2009-02-04 23:01:05,086 [7] DEBUG
[(null)] <(null)> - running BatcherImpl.Dispose(true)
Castle.Services.Transaction.DefaultTransactionManager: 2009-02-04
23:01:05,086 [7] DEBUG [(null)] <(null)> - Transaction 53179874
disposed successfully
------------------

Note that when the root transaction is committed it appears to
actually close the session even though the SessionWebModule should be
keeping the session open for the duration of the request/response
cycle.  As a result of the session being closed prematurely any
NHibernate proxies that haven't been loaded will throw lazy loading
exceptions if accessed in the view.

Once again, is this the expected behavior or is it a bug?  I've taken
a look at the code but I have to admit that I'm pretty much completely
lost.

Help?

Cheers,

Symon.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" 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-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to