Reputation: 381
I'm getting Hibernate's message that I have an "Error in named query".
Below is the HQL statement I'm trying to execute.
select sum(subtotal)
from (
select sum(coalesce(sum(t2.amount), 0) - coalesce(sum(t3.amount), 0)) subtotal
from submission t1
left join t1.bills t2
left join t1.payments t3
where t1.id = 10
group by t1.id
union
select sum(coalesce(sum(t2.amount), 0) - coalesce(sum(t3.amount), 0)) subtotal
from submission t1
left join t1.otherBills t2
left join t1.payments t3
where t1.id = 10
group by t1.id
) a1
I think the problem might be related to the sum
function in the outer query or the union
operator but I haven't been able to narrow it down.
Does anyone have any ideas?
Upvotes: 0
Views: 417
Reputation: 23552
Hibernate does not support union
.
A feature request for that is open for a decade.
Upvotes: 2
Reputation: 1007
You can't use a subquery after From
clause in HQL. My suggestion is that you can use native query
. For more detail you should look at following link :-
Hibernate Query Limitation
Upvotes: 3