I need to build an HQL query that uses the same entity twice, but with different constaints coming from previous entities.
For example:
select count(distinct a.id),
count(disintct b.id),
count(distinct c.id)
from
EntityA a
left join a.Children b
left join a.Children c with c.SomeConstraint = b.SomConstraint
However, when I try to do this I get an exception saying that I have two entities in my with clause.
How can I express this concept in HQL?
You can’t do this in HQL right now.
If your with clause, the only things that are allowed currently are the joined entity and the entity that you’re joining from.