Hi there,
I have a class Order that contains a set of OrderSection's that itself contains a set of OrderItem's.
In SQL, one can use a SELECT statement in a JOIN clause as done in the following query:
SELECT
o.id,
o.amount,
sum(s.quantity*s.price),
sum(s.quantity*i.price)
FROM
orders AS o
JOIN ordersections AS s ON s.order_id=o.id
JOIN (SELECT section_id, sum(quantity*price) AS price FROM orderitems GROUP BY section_id) AS i ON i.section_id=s.id
GROUP BY o.id, o.amount
Would it be possible to express such a query in HQL?