If a query having a subselect for the highest money payed and the lowest money payed in example:
SELECT p.firstname,
p.lastname,
(SELECT MAX(pmt.amount)
FROM Payment pmt
WHERE pmt.person.id = p.id) maxAmount,
(SELECT MIN(pmt.amount)
FROM Payment pmt
WHERE pmt.person.id = p.id) minAmount,
FROM Person p
We need to write two subqueries. This have a bad performance on huge databases.
Any solutions in plain JPQL?