hi,
the original problem was, that lazy loading didn't work. Instead for
each object found, all associations where load eagerly.
After quite some more research, I found the answers. Answers, because
there are many things that prevented lazy loading in NHibernate.
1. Query vs. session.Load: When fetching an item via session.Load()
you get a proxy. But as soon as you access any property, lets say the
Url, the object is fetched including all it's associations that
doesn't support lazy loading.
2. property-ref: Lazy loading only works over a objects id. When an
property-association is resolved via a different column in the target
entity, NH fetches it eagerly. Not that this wouldn't be possible,
it's just not implemented:
http://nhjira.koah.net/secure/CreateIssue!default.jspa
3. not-found="ignore" allows invalid foreign keys, that is, if the
referenced entity isn't found NH will init the property with null. NH
doesn't intercept the property-access for lazy loading, but instead
assignes a object proxy. With not-found="ignore" it can't decide if
the property should be set to null or a proxy for the given, possibly
invalid, foreign key. This could possibly be solved by intercepting
the property access.
4. When disabling not-found="ignore" and property-ref the schema
export would generate constraints that enforce a circular reference.
Not good! The correct mapping would then be a constrained one-to-one
relationship, where the key for HippoAccountSync must have a generator
foreign.
Are these points right?
Could NH support lazy-loading for not-found="ignore" and property-ref
at some point, or is it impossible?
thanks!
- Lars
On 29 Okt., 22:54, Fabio Maulo <
fabioma...@gmail.com> wrote:
> I never seen his mapping....
>
> I can jump in another place to see an answer but not to read a question nor
> how recreate an issue.
>
> 2009/10/29 Diego Mijelshon <
di...@mijelshon.com.ar>
>
>
>
> > You're correct... that's the long answer :-)
>
> > But unless you specify that, the answer to "shouldn't each entity in a
> > list, when queried via the criteria API, be a proxy" is no, as that's not
> > the default behavior, nor the expected behavior with his mapping and query.
>
> > Diego
>
> > PD: quedó largo el disclaimer, pero vos me entendés :-)
>
> > On Thu, Oct 29, 2009 at 13:39, Fabio Maulo <
fabioma...@gmail.com> wrote:
>
> >> lazy=extra and some specific indexed collection (for example <map>
> >> IDictionary).
>
> >> 2009/10/29 Diego Mijelshon <
di...@mijelshon.com.ar>
>
> >> Short answer: no.
>
> >>> Diego
>
> >>> On Thu, Oct 29, 2009 at 11:22, lcorneliussen <
l...@corneliussen.de>wrote:
>
> >>>> Hi all together!
>
> >>>> I'm sure I am missing something, but shouldn't each entity in a list,
> >>>> when queried via the criteria API, be a proxy that enables lazy
> >>>> loading?
>
> >>>> I posted my question on stack overflow. The code is more readable over
> >>>> there:
>
> >>>>
http://stackoverflow.com/questions/1643905/nhibernate-creates-proxy-v...