The test is reflecting the way I use the NH session and transaction scope. When I run the test with the default transaction factory(AdoNetWithDistrubtedTransactionFactory), it fails on first session.Clear.
When I override the Session Factory to use the AdoTransactionFactory, sample test didn't fail on first session.Clear(). I have the test as patch, if you want I can send/upload it. Thanks Sathish On Feb 17, 9:51 pm, Fabio Maulo <[email protected]> wrote: > Where is the NH's transaction ? (ITransaction) > I mean... you said you have a issue > with AdoNetWithDistrubtedTransactionFactory but in your code you haven't use > it, so... where is the issue ? > > 2010/2/17 Sathish Naga <[email protected]> > > > > > > > Hi, > > > I've a issue with NHibernate 2.1x and > > AdoNetWithDistrubtedTransactionFactory and SessionImpl. > > > To give you background of my Infrastructure, I have a NH session > > created per web request. > > > On Begin Request I create a Session and On End Request, I clear and > > dispose the NH session. > > > using (ISession s = sessions.OpenSession()) > > { > > s.FlushMode = FlushMode.Commit; > > > using (var tx = new > > TransactionScope(TransactionScopeOption.Required, > > new TimeSpan(0,0,0,0,10000))) > > > // > > Set timeout to 10 secs > > { > > try > > { > > s.Save(new Person { CreatedAt = DateTime.Now}); > > Thread.Sleep(20000); //Sleep for 20 secs to timeout > > the transaction > > s.Flush(); > > tx.Complete(); > > } > > catch (Exception ex) > > { > > //when this transaction fails, clear internal entity > > cache on > > session and move on > > s.Clear();// > > } > > } > > //This transaction expected to be successful > > using (var tx = new TransactionScope()) > > { > > try > > { > > s.Save(new Person { CreatedAt = DateTime.Now }); > > s.Flush(); > > tx.Complete(); > > } > > catch (Exception ex) > > { > > s.Clear(); > > } > > } > > } > > > As i reuse the same session for multiple transactions, when any of my > > transaction fails, I want to clear the session internal cache. In that > > case when the error is due to TransactionScope it fails on > > session.clear and brings whole application down. > > > Once JIRA is up, I'm going to add this defect. I have the test > > created, Looks like I cant attach the patch to this mail. > > -- > Fabio Maulo
