Thanks pointing to this. It would work. But what i thought is that it is logical to have this stack behavior of Begin/Commit calls right in ISessionManager - if only first BeginTransaction() starts new transaction and further calls return existing transaction, then only last Commit() commits transaction. Same like OpenSession()/Close() methods do. What you think?
On Tue, Feb 17, 2009 at 12:41 PM, Germán Schuager <[email protected]>wrote: > Use Automatic Transaction Management facility: > http://castleproject.org/container/facilities/trunk/nhibernate/transactions.html > > > On Tue, Feb 17, 2009 at 7:32 AM, Andrew Melnichuk < > [email protected]> wrote: > >> Hi All. >> >> I have several components, which use ISessionManager. >> Typical component method is: >> using (ISession s = sessMgr.OpenSession()) >> using (ITransaction tx = s.BeginTransaction()) >> { >> //save something here... >> tx.Commit(); >> } >> >> But some component methods call other component methods, so i need a kind >> of transaction stack behavior: >> public void Outer() >> { >> using (ISession s = sessMgr.OpenSession()) >> using (ITransaction tx = s.BeginTransaction()) >> { >> //save something here... >> Inner(); >> tx.Commit(); >> } >> } >> >> public void Inner() >> { >> using (ISession s = sessMgr.OpenSession()) >> using (ITransaction tx = s.BeginTransaction()) >> { >> //save something here... >> tx.Commit(); >> } >> } >> >> Inner's BeginTransaction() call returns existing transaction, its ok, but >> Inner's Commit() call commits it, so the Outer's Commit() raises exception. >> ISessionManager supports nested ISession's, as described here >> http://castleproject.org/container/facilities/trunk/nhibernate/usingit.html#SessManager. >> >> Is there a way to use with nested transactions? >> >> -- >> Best regards, >> Andrew Melnichuk >> >> >> > > > > -- Best regards, Andrew Melnichuk --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
