Thanks a lot Anne !

I wouldn't normally wrap the transaction within all my save methods,
this was more because i'm learning nHibernate at the moment.

I've heard of these framework, I was told Spring.net is a good one
too. But I think for now I'll do without them, I have enough stuff to
learn with nHibernate alone... :)

Thanks

On 10 mar, 14:57, Anne Epstein <[email protected]> wrote:
> In reality, you won't actually wrap transactions around every Save call as
> you have demonstrated here (that is actively NOT recommended, actually.)
> It's much preferable to push the transaction much higher up-for instance, to
> set up your transaction at the page request level as an HTTPModule, so your
> saves are committed and transaction is closed when the request is
> finished-making the actions in the request a single unit of work.  Besides
> having a single, longer-running transaction, which is more efficient, it
> means you won't have to worry about wrapping things in transactions
> elsewhere in your code. If you're doing a desktop app, the recommendation is
> generally similar in concept, but you might be using something like user
> tasks for your units of work rather than the HTTP request.  There are
> frameworks out there that others have written that should be able to help
> get your infrastructure set up...Rhino Commons and Burrow are two that I can
> think of off the top of my head.
>
> Hope that helps!
>
> On Tue, Mar 10, 2009 at 6:57 AM, graphicsxp <[email protected]>wrote:
>
>
>
> > well i think i found the answer by myself, nhibernate only persist
> > entities when comit is  called.  Correct me if I'm wrong.....
>
> > On 10 mar, 11:47, graphicsxp <[email protected]> wrote:
> > > Hello,
>
> > > I have a very strange problem but maybe it's just that I'm not so
> > > experienced with nHibernate.
>
> > > I want to persist my entity so I call the .save() method like this :
>
> > >         _session.Save(pCutting);
>
> > > but it is not saved and when using log4net i can see there;s no update
> > > statement...
>
> > > Now if I use a transaction to save the same entity :
>
> > >  ITransaction tx = null;
>
> > >       try
> > >       {
> > >         tx = _session.BeginTransaction();
> > >         _session.Save(pCutting);
> > >         tx.Commit();
> > >       }
> > >       catch (Exception e)
> > >       {
> > >         tx.Rollback();
> > >         throw e;
> > >       }
>
> > > That works, the update statement is generated on the Commit line.
>
> > > Why is that ? I don't want to use transactions all the time...
--~--~---------~--~----~------------~-------~--~----~
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