tags:

views:

338

answers:

1

Err, I can't think of better title. Basically I have a class called MarketGroups, this has a child collection Markgroups that has a collection of MarketTypes and MarketTypes has a collection of MetaGroups.

I would like to be able to, in one query, load the Parent, and only return Child MarketGroups that have MarketTypes with one specific MetaGroup in its MetaGroup collection.

I am aware of this question: http://stackoverflow.com/questions/247571/filter-child-collection-returned-with-aggregate-root-using-nhibernate but is not the solution I'm looking for, I want to do this in code ideally as one query, but I wouldn't mind splitting it.

:)

A: 

Unless you restrict the children that are loaded by default (using the method you linked to) you'll have to load the Parent in one query and the children in another. AFAIK there's no way to query an object and have only certain children loaded.

You could always use MultiQuery to submit them at the same time mind you.

HQL something like (this may be missing the mark a bit):

            select
                mt
            from 
                MarketGroup mg
            inner join
                mg.MarketTypes mt
            inner join
                mt.MetaGroups mg
            where 
               mg.ID=12312 and mg.ID=3214123
Dan Fish
I ended up with a multicritera, so I'm gonna take this as the answer :)
Chris Canal