ups sorry.... that is the default in NH2.1.x 2009/10/15 Fabio Maulo <[email protected]>
> NH's transaction mean that you can inject ITransactionFactory working with > AmbientTransaction instead AdoTransaction.The conf property is: > transaction.factory_class > The impl is AdoNetWithDistrubtedTransactionFactory > > 2009/10/15 Mike Nichols <[email protected]> > > >> Fabio, I saw bits of that discussion on my google wandering. I was >> relying on ambient transactions (no nh transaction) and that worked >> fine until this issue where I am trying to write to another database >> (ie another SessionFactory) inside of a single transaction so that if >> there are problems everything gets tossed out. My assumption was that >> the ISession would itself enlist itself in the current >> transaction...it 'felt' like it would I guess. Since I am using a >> similar AOP transaction (castle's) management I just need to have the >> adapter open a NH transaction explicitly so no biggie. >> From an I-am-naive-and-I-havent-thought-about-this-as-much-as-Fabio >> standpoint, though, it seems like since NHibernate _strongly_ >> recommends everything should be done inside a transaction it would >> just enlist _any_ activity on a ISession in the current dtc trx. >> >> On Oct 15, 12:54 pm, Fabio Maulo <[email protected]> wrote: >> > This is an annoying matter in our dev-list. >> > In some moment, for various reasons since NH 2.0 (cache, lazy-extra and >> so >> > on), we said: each persistent action should be involved in a NH's >> > transaction. >> > >> > For me that's all: each persistent action should be involved in a NH's >> > transaction. >> > >> > So >> > [TransactionScope] >> > [PersistentConversation] >> > public void MyServiceMethod() >> > { >> > daoA.Save(something); >> > daoB.Save(something); >> > >> > } >> > >> > All is by AOP so the "PersistentConversation", who manage nh-sessions >> and >> > nh-transactions, does not know if it is working inside a DTC or not. >> > >> > 2009/10/15 Mike Nichols <[email protected]> >> > >> > >> > >> > >> > >> > > Hi Fabio >> > > That does work and I thank you for your guidance. >> > > I read this in ch 10 on transactions:"If the connection is enlisted >> > > with a distributed transaction, operations performed by the ISession >> > > are atomically part of the wider distributed transaction." so I >> > > thought the session would enlist itself in a dtc transaction if one is >> > > already present. This enlistment must be a part of the call in >> > > session.BeginTransaction() ? >> > >> > > On Oct 15, 11:57 am, Fabio Maulo <[email protected]> wrote: >> > > > What happen if you begin a NH's transaction (repeat a transaction of >> NH) >> > > > after open each session ? >> > > > Try to execute each save inside the corresponding NH's transaction >> and >> > > let >> > > > me know what happen. >> > >> > > > 2009/10/15 Mike Nichols <[email protected]> >> > >> > > > > This test fails. Within a single transaction, there may be >> multiple >> > > > > sessions trying to persist to different databases but I am not >> sure >> > > > > this is possible. >> > > > > I lifted the ForceEscalationToDistributedTx from NH DTC tests and >> it >> > > > > enlists itself to rollback the transaction. >> > > > > Is what I am trying to do here possible? >> > > > > [Observation] >> > > > > public void should_not_succeed_in_persisting() >> > > > > { >> > >> > > > > var tx = new TransactionScope(); >> > > > > var s1 = SessionFactory1.OpenSession(); >> > > > > var s2 = SessionFactory2.OpenSession(); >> > > > > s1.FlushMode = FlushMode.Commit; >> > > > > s2.FlushMode = FlushMode.Commit; >> > > > > s1.Save(new MyEntity1() >> > > > > { >> > > > > Agency = "ADOT", >> > > > > }); >> > > > > s2.Save(new MyEntity2() >> > > > > { >> > > > > Agency = "ADOT", >> > > > > }); >> > > > > new ForceEscalationToDistributedTx(true); >> > >> > > > > tx.Complete(); >> > > > > try >> > > > > { >> > >> > > > > tx.Dispose(); >> > >> > > > > throw new InvalidOperationException("Expected tx >> > > abort"); >> > > > > } >> > > > > catch (TransactionAbortedException) >> > > > > { >> > > > > //expected >> > > > > } >> > > > > s1.Dispose(); >> > > > > s2.Dispose(); >> > > > > using(var s=SessionFactory1.OpenSession()) >> > > > > { >> > > > > var pm = s.CreateCriteria(typeof >> > > > > (StandardSpecificationsPublicationPM)).List(); >> > > > > Assert.Equal(0, pm.Count); >> > > > > } >> > > > > } >> > > > > ////////////////////////////END TEST//////////////////////////// >> > >> > > > -- >> > > > Fabio Maulo >> > >> > -- >> > Fabio Maulo >> >> >> > > > -- > Fabio Maulo > -- Fabio Maulo --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
