Thanks Luis,

The thing is, I don't really want to have a dependency on MSDTC, which I
believe would be the case if I used TransactionScope. After all, my
transactions aren't distributed - just nested.

I'm hoping there is an alternative to this.

cheers

Stu


On Thu, Jan 15, 2009 at 11:35 AM, Luis Abreu <[email protected]> wrote:

>  I think that using a TransactionScope object to wrap all your method
> calls should work in this case.
>
>
>
> *From:* [email protected] [mailto:[email protected]] *On
> Behalf Of *Stuart Campbell
> *Sent:* quinta-feira, 15 de Janeiro de 2009 10:29
> *To:* [email protected]
> *Subject:* [nhusers] Nested transactions
>
>
>
> What's the recommended way to support nested transactions in NH?
>
> Basically, I'm using session-per-request and my repository methods wrap all
> calls in a transaction like this...
>
> var tran = session.BeginTransaction();
> try
> {
>     // do work here
>
>     tran.Commit();
> }
> catch
> {
>     tran.Rollback();
>     throw;
> }
>
> But I also want multiple repository calls to be contained in a logical
> "business" transaction, like this (note that all repositories expose
> BeginTransaction which returns an ITransaction wrapper):
>
> var outerTran = accountRepository.BeginTransaction();
> try
> {
>     accountRepository.Save(account);
>
>     notificationRepository.Save(notification);
>
>     outerTran.Commit();
> }
> catch
> {
>     outerTran.Rollback();
>     throw;
> }
>
> This doesn't work because outerTran reports that it has been committed as
> soon as the first Save() operation commits. I'm obviously missing something
> fundamental here and would be grateful if someone could point me in the
> right direction.
>
> If I have some time today I'll try looking through the NH code to try and
> understand the internals better. In the meantime any pointers would be
> welcome.
>
> thanks
>
> Stu
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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