and the mapping is ?

2009/8/16 Luke Bakken <[email protected]>

>
> Anyone? Is this expected behavior?
>
> On Fri, Aug 14, 2009 at 9:21 AM, Luke Bakken<[email protected]> wrote:
> > Well, you could build the DTOs after the commit, since the Session
> > would still be open.
> >
> > In the example code I provided, here's how the version is set:
> >
> >            using (ISession s = sessionFactory.OpenSession())
> >            {
> >                using (ITransaction t = s.BeginTransaction())
> >                {
> >                    b = new ClassB();
> >                    var a = s.Get<ClassA>(aID);
> >                    b.AddClassA(a);
> >                    bver1 = b.EntityVersion; // version is 0
> >                    s.Save(b);
> >                    bver1 = b.EntityVersion; // version is 1
> >                    s.Flush();
> >                    bver1 = b.EntityVersion; // version is 1
> >                    t.Commit();
> >                }
> >                bver2 = b.EntityVersion; // version is 2 !!!
> >             }
> >
> > Thanks for looking at this,
> > Luke
> >
> > On Fri, Aug 14, 2009 at 1:07 AM, Stefan
> > Steinegger<[email protected]> wrote:
> >>
> >> I wouldn't build dtos after the commit, because you can't use lazy
> >> loading then.
> >>
> >> Flush should actually synchronize all the changes. So I'm also
> >> wondering ...
> >>
> >> On 13 Aug., 22:42, Luke Bakken <[email protected]> wrote:
> >>> Hello everyone,
> >>>
> >>> Just wanted to check that this is expected behavior in NHibernate. I
> >>> have services that, basically use this pattern to build DTOs:
> >>>
> >>> Start transaction
> >>>     Do stuff with entities
> >>>     Flush
> >>>     Build DTOs from entites
> >>> Commit transaction
> >>>
> >>> The problem is that certain operations update the version of the
> >>> entity when the Commit happens, not the Flush, so my DTOs won't have
> >>> the correct entity version. The attached solution demonstrates this.
> >>> If this is expected behavior, I can just build the DTOs after the
> >>> Commit, but I thought I'd just ask the group, as it seems all other
> >>> pending work is flushed when Flush() is called.
> >>>
> >>> Thanks,
> >>> Luke
> >>>
> >>>  TestNHibernate.zip
> >>> 11KAnzeigenHerunterladen
> >> >>
> >>
> >
>
> >
>


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