Ayende, what scenario(s) does the current implementation support and where does it fall short?
Thank you! -Michael From: [email protected] [mailto:[email protected]] On Behalf Of Ayende Rahien Sent: Tuesday, March 24, 2009 3:51 AM To: [email protected] Subject: [nhibernate-development] Re: More DTC issues Okay, I tried using the "flush on dispose" method, but it wouldn't work, since by the time we flush the session, we already completed the transaction, so we cannot do anything with it. I played around with the other options (promotable transaction and other not fun stuff) but I don't think that they are worth the complexity. For now, I am committing the change as discussed so far. On Tue, Mar 24, 2009 at 6:19 AM, Ayende Rahien <[email protected]<mailto:[email protected]>> wrote: Yes, this works, but that is not a good programming model. It means that we have to manually manage things that TransactionScope should handle. More than that, I _really_ don't like calling flush explicitly. For now, I am going to commit the fix using EnglistRegisterDuringPrepare. On Mon, Mar 23, 2009 at 7:34 PM, Fabio Maulo <[email protected]<mailto:[email protected]>> wrote: I don't understand using (var tx = new TransactionScope()) using (var s = sessions.OpenSession()) using(s.BeginTransaction()) { s.Delete(s.Get<Person>(id)); s.Flush(); s.Transaction.Commit(); tx.Complete(); } This is working ? 2009/3/23 Ayende Rahien <[email protected]<mailto:[email protected]>> yes On Mon, Mar 23, 2009 at 3:12 PM, Michael Teper <[email protected]<mailto:[email protected]>> wrote: Ayende, I am not sure what you meant by this comment, but from your other replies, it sound like you agree with me that it would be better if explicit session.BeginTransaction was not requried, correct? Thanks! -Michael ________________________________ From: [email protected]<mailto:[email protected]> [[email protected]<mailto:[email protected]>] On Behalf Of Ayende Rahien [[email protected]<mailto:[email protected]>] Sent: Monday, March 23, 2009 11:48 AM To: [email protected]<mailto:[email protected]> Subject: [nhibernate-development] Re: More DTC issues We don't really care for that, we let the DTC infrastructure take care of this. On Mon, Mar 23, 2009 at 12:57 PM, Michael Teper <[email protected]<mailto:[email protected]>> wrote: Fabio, Ayende, Another thing to consider is the nested transaction scenario like this: using (var scopeOuter = new TransactionScope()) { // load / change some object(s) using (var innerScope = new TransactionScope()) { try { // load / change something else innerScope.complete(); } catch { // do something } } outerScope.complete(); } This may look silly but if the inner transaction is encapsulated in a different class, this is a very plausible scenario. Wherever NH keeps track of the current transaction scope, it needs to be aware of potential for nesting. Thanks! -Michael ________________________________ From: [email protected]<mailto:[email protected]> [[email protected]<mailto:[email protected]>] On Behalf Of Fabio Maulo [[email protected]<mailto:[email protected]>] Sent: Monday, March 23, 2009 9:45 AM To: [email protected]<mailto:[email protected]> Subject: [nhibernate-development] Re: More DTC issues 2009/3/23 Ayende Rahien <[email protected]<mailto:[email protected]>> The problem is that usually the DTC is opened by a lower level component, and my code has no control over it. More than that, I usually don't have control over NH's code as well. It goes like this: 1/ low level infrastructure - dtc 2/ high level infarstruture - nh 3/ business code - my stuff and then 3 -end 2- end 1-end If 2 don't know about 1, 2 should use session.BeginTransaction and session.Transaction.Commit(). I don't want to be aware of all of this issues, I just want to make this work. So explicitly flushing is an option that I would generally be against. Making NH's transaction equal to the dtc is also not a good option, because the use of the DTC is to manage several resources, not just NH. You know... I never said dtc=nhTx What I would like to avoid is If(DTC) {something} else {somethingelse} inside NH-Core. -- Fabio Maulo -- Fabio Maulo
