Can you write a SQL to eagerly load recursive relation ?

2009/8/3 HappyNomad <[email protected]>

>
> I have a recursive one-to-many relationship that has the default lazy
> value of true. How can I execute a query which recursively retrieves
> the ENTIRE tree?
>
> Here's the recursive one-to-many relationship:
>
> <class name="Category" lazy="false">
>        ...
>        <list name="SubCategories" fetch="subselect">
>                <key column="ParentCategoryID"/>
>                <index column="PositionInList"/>
>                <one-to-many class="Category"/>
>        </list>
>
> I don't specify lazy="false" on the list since laziness is required in
> about half the queries I need to run.  I have fetch="subselect" on the
> list as an optimization for when I do manage to retrieve the entire
> tree.
>
> I've tried the ICriteria API:
>  session.CreateCriteria<Category>().SetFetchMode( "SubCategories",
> FetchMode.Eager ).Add( Restrictions.IsNull
> ("ParentCategory") ).SetResultTransformer
> ( CriteriaSpecification.DistinctRootEntity ).List<Category>();
>
> but that only eagerly loaded only the first level in the hierarchy.
>
> >
>


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