Hi.
Currently I need to do the ordering on the subquery like this:
Code:
select ord, (select sum(pays.income) from ord.payments pays) as sumIncome from Order as ord order by sumIncome
This looks pretty simple, but hibernate fails to parse the query as the
sumIncome column is not found. The workaround I found is putting the generated name of the subquery result to the order by clause (pay attention to the last
col_1_0_ alias):
Code:
select ord, (select sum(pays.income) from ord.payments pays) as sumIncome from Order as ord order by col_1_0_
Strange, but this works! Although, I don't like such code and don't want to rely on the generated aliases.
Any thoughts?