So are you saying that I should expect to see extra selects for leaf
nodes after querying with:
.Session.CreateQuery("from Resource r join fetch r.ChildResources")
Doesn't NH create empty collections on the leaf nodes when it finds no
child-results for them from the above query?
Is there anything I can do about this?
Thanks
Andrew
On Sep 15, 1:33 pm, Fabio Maulo <[email protected]> wrote:
> only some RDBMS does support a recursive load for a tree; each one in its
> way.Try to think to the SQL NH should run to upload en entirely tree in one
> shot.
>
> 2009/9/15 [email protected] <[email protected]>
>
>
>
>
>
>
>
> > Thanks, I've just added that but the behaviour hasnt changed :(
>
> > I still see the initial select loading all Resource objects, with
> > subsequent enumerations of the ChildResources property executing
> > selects of the format:
>
> > select from Resource where Parent_Id = 123
>
> > Ive added lazy=false to the relationship and to both classes, but its
> > still happening!
>
> > Any ideas?
>
> > Many thanks
>
> > Andrew
>
> > On Sep 15, 10:56 am, Ricardo Peres <[email protected]> wrote:
> > > That's because the ChildResources is lazy loaded. Add lazy="false" to
> > > the mapping.
>
> > > On Sep 14, 4:45 pm, "[email protected]"
>
> > > <[email protected]> wrote:
> > > > I have a tree where every node is a Resource class:
>
> > > > public abstract class Resource
> > > > {
> > > > public virtual Guid Id { get; set; }
> > > > public virtual Resource Parent { get; set; }
>
> > > > public virtual IList<Resource> ChildResources { get; set; }
>
> > > > }
>
> > > > as you can see this class is abstract and there are many different
> > > > derived classes from Resource (3 at the moment, more to come). In my
> > > > database i have a table for Resource, and a table for each class which
> > > > derives from Resource. These are mapped together with <joined-
> > > > subclass>.
>
> > > > I've read this:
>
> > > >http://ayende.com/Blog/archive/2009/08/28/nhibernate-tips-amp-tricks-.
> > ..
>
> > > > and i have exactly the same code as Ayende to load my tree, which is
> > > > all working fine (all Resources are returned with a single select)
>
> > > > However, I'm seeing extra selects occurring as I enumerate a
> > > > Resource's ChildResources list.
>
> > > > Is that because of this?:
>
> > > >http://ayende.com/Blog/archive/2009/09/03/answer-the-lazy-loaded-inhe.
> > ..
>
> > > > Either way, how do I prevent this from happening?
>
> > > > Here's the part of the mappings for the relationships (class names
> > > > trimmed for clarity):
>
> > > > <bag cascade="save-update" fetch="join" inverse="true"
> > > > name="ChildResources">
> > > > <key>
> > > > <column name="Parent_Id" />
> > > > </key>
> > > > <one-to-many class="Resource" />
> > > > </bag>
> > > > <many-to-one class="Resource" name="Parent">
> > > > <column name="Parent_Id" />
> > > > </many-to-one>
>
> > > > Thanks
>
> --
> 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
-~----------~----~----~----~------~----~------~--~---