Well, implementation doesn't look complex, and clients will not know all
that details. Clients just open sessions/starting transaction and
commit(rollback) transactions/closing sessions - common pattern when working
with NHibernate.
Yes ATM will definitely work in that case too, but i need more control over
transactions, for example, do some additional actions on transaction
rollback.
I'm just asking, if ISessionManager supports stack behavior for sessions,
why it doesn't do same for transactions, which is logical IMO?

On Tue, Feb 17, 2009 at 2:20 PM, Jason Meckley <[email protected]>wrote:

>
> you could implement this logic yourself by decorating the session
> manager, but this will get messy with tracking how many times open
> session is called, and then decrementing the count until you "really"
> commit the transaction.  Not to mention if you call transaction.commit
> (); the principle of least surprise would dictate that you are
> actually committing the transaction.
>
> ATM is very simple to use. add facility, put Transactional attribute
> on class, put Transaction attribute on member, Done. Depending on how
> you structure your code, you could even register the components to get
> a transaction attribute automatically, so you don't have to think
> about it. Set and Forget.
>
> Jason
>
> On Feb 17, 5:57 am, Andrew Melnichuk <[email protected]>
> wrote:
> > 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/transa.
> ..
> >
> > > 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/usingi....
> >
> > >> Is there a way to use with nested transactions?
> >
> > >> --
> > >> Best regards,
> > >> Andrew Melnichuk
> >
> > --
> > 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to