[DoItInAmbientTransaction]
[ItInvolvePersistence]
public void DoSomethingInControler()
{
   //Doing something in a request
}

When the method end its execution in general the session is closed (because
exception or not it should be closed).
During its execution you are inside a UnitOfWork where the session-cache
have place.

When I said "you can open the session outside the TS", mean that you *can*
and not "you must".

Depending on your taste and how you are working with NH's session and NH's
Transaction you can choose different implementation.

A Test should recreate/emulate a real-situation.
If I want pass your test I should say : "NH should't implements UoW and hit
DB for each Get".
Instead Get you can use Refresh if you really need a fresh state of an
entity.

If you want another example
[DoItInAmbientTransaction]
public void DoSomethingInControler()
{
  service.MakeSomething();
  SendAnEMail();
}

inside serivice
[NeedPeristence]
public void MakeSomething()
{
}

If SendAnMail fail with an exception the AmbientTransaction is rolled back
so the NH's transaction is rolled back.
And I can continue because there are a lot of interpretations of MVC and
DDD.

Try to explain how you are working and what you need or create a
test recreating/emulating a real-situation and perhaps our answers may will
be more concrete.
For example... what you are trying to emulate/recreate with that second
session.Get ?
If your intention is "check the state of the DB after TS-Abort"do it but not
using the same session. If you use the same session what is wrong is the
test and the concept of UoW.

P.S. "rude" is something I can't understand at work.

2010/1/15 HH <[email protected]>

> Hi Fabio,
>
> I don't want to sound rude, but I know that the get is comming from
> the cache. I am not sure what you are trying to say, but isn't it
> strange that NHibernate returns data from a cache based on a
> transaction which was rollbacked? Or should I manage the NHibernate
> cache by calling Clear() on the ISession?
>
> I find it very hard to find out to which extend NHibernate supports
> working with TS and where I should manage things myself.
>
> Henk
>
>
> On 15 jan, 18:35, Fabio Maulo <[email protected]> wrote:
> > 2010/1/15 HH <[email protected]>
> >
> >
> >
> > > -- statement #7
> > > begin transaction with isolation level: Unspecified
> >
> > > -- statement #8
> > > commit transaction
> >
> > > No select between statment #7 and #8.
> >
> > Now you know why your test is not working.
> > In the second session.Get NH will Get the instance from session-cache and
> > not from DB.
> >
> > --
> > 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]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>
>
>


-- 
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.

Reply via email to