I would just create an alias for the collection and add restrictions.
var parentsWithKidName = session.CreateCriteria<Parent>()
.CreateAlias("Children", "c", JoinType.InnerJoin)
.Add(Restrictions.Eq("c.Name", childName))
.SetResultTransformer(Transformers.DistinctRootEntity())
.List<Parent>();
This will lead to
select p.*
from parent p
inner join child c on
where c.Name = ?
A separate root entity transformer processes the result set and removes duplicate parents. They still meet the wire though.
source
share