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.

Reply via email to