Thanks for the reply.  I'll have to give this a try.

On Thu, Feb 25, 2010 at 10:41 PM, dinkelburt <[email protected]> wrote:

> The only way that you're going to load a large graph effectively is
> through using several queries like so (anyone please correct me if I'm
> wrong):
>
> var query = session.CreateCriteria<Entity>()
>  .Add(Restrictions.IdEq(42))
>  .SetFetchMode("ParentEntity", FetchMode.Join)
>  .FutureValue<Entity>();
> session.CreateCriteria<Entity>()
>  .Add(Restrictions.IdEq(42))
>  .SetFetchMode("ChildEntities", FetchMode.Join)
>  .SetFetchMode("ChildEntities.AnotherEntity", FetchMode.Join)
>  .SetFetchMode("ChildEntities.GrandChildEntities", FetchMode.Join)
>  .FutureValue<Entity>();
> session.CreateCriteria<Entity>()
>  .Add(Restrictions.IdEq(42))
>  .SetFetchMode("MoreChildEntities", FetchMode.Join)
>  .FutureValue<Entity>();
>
> Entity entity = query.Value;
>
> This will result in 3 queries that get sent down all at once.
> NHibernate will then be smart and load up the desired collections/
> entities.  Specifically, the result of this query would be an Entity
> entity with an ID of 42 with its many-to-one ParentEntity loaded, one-
> to-many MoreChildEntities loaded and one-to-many ChildEntities
> collection loaded with each one having its many-to-one AnotherEntity
> and one-to-many GrandChildEntities collections loaded.  This also
> works with using Future instead of FutureValue.
>
> From my experience this has been fairly performant for me (especially
> with the new Future calls), even with legacy databases with tables
> that have a ton of columns.
>
> On Feb 21, 12:45 am, cliff <[email protected]> wrote:
> > I just found this thread:
> >
> > http://groups.google.com/group/nhusers/browse_thread/thread/be7e0fb58...
> >
> > and I was wondering if there was a better solution than using a set.
> > The issue i have with sets is that all items must be loaded into it
> > before you can add a new item.  This is not very performant with a
> > large number of items.  Is there a way to achieve the non-duplication
> > without using a set?
> >
> > thanks
> >
> > cliff
>
> --
> 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]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>


-- 
thanks

cliff

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