Check Fabios blog at http://fabiomaulo.blogspot.com
Tuna Toksöz http://tunatoksoz.com Typos included to enhance the readers attention! On Thu, Jan 15, 2009 at 12:28 PM, Stuart Campbell < [email protected]> wrote: > 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 -~----------~----~----~----~------~----~------~--~---
