It is the same matter of few months ago...I'm using what we (both you and me) said is a best practice: enclose each NH action in a NH transaction ;)
2009/10/7 Ayende Rahien <[email protected]> > yes > > > On Thu, Oct 8, 2009 at 12:05 AM, Fabio Maulo <[email protected]> wrote: > >> And if you abort the DTC nothing happen to db, right ? >> >> >> 2009/10/7 Ayende Rahien <[email protected]> >> >>> This works: >>> >>> using (var tx = new TransactionScope()) >>> >>> using (ISession s = sessions.OpenSession()) >>> >>> using(s.BeginTransaction()) >>> >>> { >>> >>> s.Get<Person>(id); >>> >>> >>> new ForceEscalationToDistributedTx(); >>> >>> >>> s.Save(new Person >>> >>> { >>> >>> CreatedAt = DateTime.Now >>> >>> }); >>> >>> >>> s.Transaction.Commit(); >>> >>> tx.Complete(); >>> >>> } >>> >>> >>> But the reason that it works is that the Commit() will force a flush, and >>> then in the DTC commit, we aren't flushing. >>> >>> The actual issue is that we fail to flush on the DTC commit. >>> >>> On Wed, Oct 7, 2009 at 11:30 PM, Fabio Maulo <[email protected]>wrote: >>> >>>> question.does it work if you put a BeginTransaction after the >>>> OpenSession ? >>>> >>>> 2009/10/7 Ayende Rahien <[email protected]> >>>> >>>> I am trying to figure out why this is failing, but I can't figure it out >>>>> (attached is a patch against trunk for this test). >>>>> Any ideas? >>>>> >>>>> [Test] >>>>> >>>>> public void CanLoadAndSaveWithDtc() >>>>> >>>>> { >>>>> >>>>> object id; >>>>> >>>>> using (ISession s = sessions.OpenSession()) >>>>> >>>>> using(s.BeginTransaction()) >>>>> >>>>> { >>>>> >>>>> var person = new Person {CreatedAt = DateTime.Now}; >>>>> >>>>> id = s.Save(person); >>>>> >>>>> >>>>> s.Transaction.Commit(); >>>>> >>>>> } >>>>> >>>>> using (var tx = new TransactionScope()) >>>>> >>>>> using (ISession s = sessions.OpenSession()) >>>>> >>>>> { >>>>> >>>>> s.Get<Person>(id); >>>>> >>>>> >>>>> new ForceEscalationToDistributedTx(); >>>>> >>>>> >>>>> s.Save(new Person >>>>> >>>>> { >>>>> >>>>> CreatedAt = DateTime.Now >>>>> >>>>> }); >>>>> >>>>> tx.Complete(); >>>>> >>>>> } >>>>> >>>>> >>>>> using (ISession s = sessions.OpenSession()) >>>>> >>>>> using (s.BeginTransaction()) >>>>> >>>>> { >>>>> >>>>> s.Delete("from Person"); >>>>> >>>>> s.Transaction.Commit(); >>>>> >>>>> } >>>>> >>>>> >>>>> } >>>>> >>>> >>>> >>>> >>>> -- >>>> Fabio Maulo >>>> >>> >>> >> >> >> -- >> Fabio Maulo >> > > -- Fabio Maulo
