auto-begin or "silent" is this an existing behavior/feature of nhibernate or 
would a jira feature request be in order?

-Carlos

 

Practice makes perfect, but if no one is perfect, why practice?




Date: Thu, 18 Feb 2010 13:29:56 -0300
Subject: Re: [nhibernate-development] Re: AdoNetWithDistrubtedTransactionFactory
From: [email protected]
To: [email protected]

auto-begin a "silent" transaction is possible; commit it at sessio.Flush and 
Rollback it a session.Close.btw it does not change the nature of the issue 
reported by Sathish Naga


2010/2/18 Carlos cubas <[email protected]>






Fabio,

Pardon my ignorance, but I lurk the google nh groups and I often see confusion 
around the correct way to use NHibernate w/ TransactionScope.

Is there a reason why NHibernate does not automatically open an ITransaction 
when calling session.Open() and it finds an ambient distributed transaction 
already started? Is this not a more intuitive pattern to follow?


-Carlos

 

Practice makes perfect, but if no one is perfect, why practice?




Date: Thu, 18 Feb 2010 11:53:45 -0300
Subject: Re: [nhibernate-development] Re: AdoNetWithDistrubtedTransactionFactory
From: [email protected]

To: [email protected]

In order to use NH correctly you should:1) throw away the session after an 
exception
2) use the NH's transaction
Use NH's transaction mean:1) open the session inside a transactionscope
2) after open the session begin a NH's transaction using 
session.BeginTransaction

2010/2/18 Sathish Naga <[email protected]>


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



-- 
Fabio Maulo


                                          


-- 
Fabio Maulo


                                          

Reply via email to