我收到了Hibernate的消息,我在命名查询中出现了错误"错误。
以下是我试图执行的HQL语句。
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
我认为问题可能与外部查询或sum
运算符中的union
函数有关,但我无法缩小范围。
有没有人有任何想法?
答案 0 :(得分:3)
您不能在HQL中的 From
子句后使用子查询。我的建议是你可以使用 native query
。有关更多详细信息,请查看以下链接: -
Hibernate Query Limitation
答案 1 :(得分:2)
Hibernate does not support union
。
该功能请求已开放十年。