What is the best / preferred way to select a (separate) list of parent objects that has a child collection containing matches for ALL entries in the child parameter list?
I execute the "any" version of my search as follows:
select p.Id, p.Name from parent p
where exists(from p.Children c where c in (:childList))
However, I am a little puzzled by how best to perform the “all” version of this search. I am currently creating hql "on the fly" for every child that interests me in comparing; something like that:
select p.Id, p.Name from parent p
where :child1 in elements(p.Children)
and :child2 in elements(p.Children)
I cannot help but think that there is a better way to do this; can someone point me in the right direction?
For reference, I am using NHibernate 2.1.2
source
share