Loading...

fluent-nhibernate@googlegroups.com

[Prev] Thread [Next]  |  [Prev] Date [Next]

[fluent-nhib] Re: Need some explanations about LazyLoad method James Gregory Mon Jan 26 07:01:03 2009

By default the "default-lazy" attribute is set to true on every mapping
created by Fluent NHibernate, so unless you've overridden this using the
conventions, that's what's getting set. As far as I understand, this infers
the class level setting.
How are you configuring your session factory? Could you write out your
mappings using the WriteMappingsTo method of the PersistenceModel, then we
can see what's actually being generated.
On Mon, Jan 26, 2009 at 1:58 PM, VisualHint <[EMAIL PROTECTED]> wrote:

>
> I use the latest FNH and it still doesn't work. I have to explicitely
> set LazyLoad on the classmap to get this behavior.
> I understand the difference between the 2 lazyload methods but I don't
> understand when you say:
>
> > however, the class gets precedence, so if your class isn't set
> > to lazy load (which was the default) then the references call won't have
> any
> > effect.
>
> Logically, if the entity is not forced to LazLoad then calling it or
> not on the association WOULD MAKE a difference.
> If you force it on the classmap then calling LazyLoad on the
> association would not change anything. If a NotLazyLoaded was possible
> on the association, then this one would make a difference. No?
>
> About trying with hbm, unfortunately, I tried to learn FNH before HBM
> so this is not something I can immediately try.
>
> N.
>
>
> On Jan 26, 7:14 am, James Gregory <[EMAIL PROTECTED]> wrote:
> > @Nicolas: How old is your copy of Fluent NHibernate? Originally it was
> the
> > default that all entities would be not lazy loaded; so if your copy is
> from
> > then, you won't see the lazy load behaviour.
> > The two different lazy load methods you spoke of do different things, the
> > lazy load on the class sets it at the entity level, so whenever that
> entity
> > is referenced anywhere it's lazy loaded, the other sets it for that
> specific
> > relationship; however, the class gets precedence, so if your class isn't
> set
> > to lazy load (which was the default) then the references call won't have
> any
> > effect.
> >
> > As Seb said, the reason the class lazy load requires virtual methods is
> > because it creates a proxy of the entity. If your methods aren't already
> > virtual, then your lazy loading won't be working because NHibernate won't
> > know how to track it.
> >
> > So what do you need to do? Update your copy of FNH and try again, failing
> > that, explicitly set lazy loading in your class and use virtuals; that's
> the
> > recommended approach.
> >
> > Please note, this isn't a Fluent NHibernate specific issue, you'd be
> seeing
> > the same behaviour for standard xml mapping too.
> >
> > On Mon, Jan 26, 2009 at 8:57 AM, Paul Batum <[EMAIL PROTECTED]>
> wrote:
> > > When it comes to issues such as this I am somewhat of a broken record -
> my
> > > suggestion is always the same:
> >
> > > See if you can get the desired behavior using HBM xml. Once you have
> > > working xml, we can compare it to what fluent nhibernate is generating
> and
> > > see where the problem lies.
> >
> > > Paul Batum
> >
> > > On Mon, Jan 26, 2009 at 9:16 AM, Chris Marisic <[EMAIL PROTECTED]>
> wrote:
> >
> > >> I noticed this also but I assumed I was handling the session
> > >> incorrectly making it fully load the object but maybe this actually is
> > >> an issue.
> >
> > >> On Jan 25, 9:20 am, VisualHint <[EMAIL PROTECTED]> wrote:
> > >> > Yes I know that Seb (thx anyway). This was just telling a fact.
> > >> > My question is about LazyLoad and why it has no effect when called
> on
> > >> > a References() call.
> >
> > >> > Nicolas
> >
> > >> > On Jan 25, 3:44 am, Sebastien Lambla <[EMAIL PROTECTED]> wrote:
> >
> > >> > > > But doing that has a consequence: All my properties in> the
> "one"
> > >> model must be virtual, even the ones that are not related to> fields
> in my
> > >> database.
> >
> > >> > > That's because the object is created as a proxy. Any of your
> property
> > >> may have access or rely on other properties that need to be hydrated
> from
> > >> the db. They all need to be virtual so that the first cal can trigger
> the
> > >> load. This is an nhibernate thing.
> >
> > >> > > --
> > >> > > Seb
> > >> > > _________________________________________________________________
> > >> > > Windows Live Messenger just got better .Video display pics,
> contact
> > >> updates & more.http://www.download.live.com/messenger
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" 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/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---