Hi all,

Not so far ago Ayende pointed to very easy way to select all entities
of a tree at once in a single query -
http://ayende.com/Blog/archive/2009/08/28/nhibernate-tips-amp-tricks-efficiently-selecting-a-tree.aspx
. The solution is very interesting and useful. I tried to extend it to
load only some specific entities (filtered) and I filed.
My entity:
Employee
{
    public int Id {get; set;}
    public int Height {get; set;}
    public IList<Employee> ManagedEmployees{get; protected set;}
    public Employee Manager {get; set;}
}
where ManagedEmployees is one-to-many.

I tried to load a tree with employees that have height more than 180cm
(e.g. only employees with height more than 180cm will be selected and
the result tree will be constructed using only filtered employees).
Query "select e from Employee e join fetch e.ManagedEmployees where
e.Height>180" filters only top level employees and all childs are not
filtered.
Query "select e from Employee e join fetch e.ManagedEmployees as empl
where e.Height>180 and empl.Height > 180" is not working because "A
fetch join does not usually need to assign an alias, because the
associated objects should not be used in the where clause (or any
other clause). Also, the associated objects are not returned directly
in the query results. Instead, they may be accessed via the parent
object." ( http://nhforge.org/doc/nh/en/index.html#queryhql-joins ).
There are no way to use a nested select in from clause (e.g. "select e
from (select e2 from Employee e2 where e2.Height > 180) e");

And I wonder, is there any way to do such kung-fu? Can it be done
using Criteria api? At the moment I'm trying to play with filters and
I'll update this thread with results. Any help will be appreciated.

Regards,
zihotki
--~--~---------~--~----~------------~-------~--~----~
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