[英]HQL Error in Named Query
I'm getting Hibernate's message that I have an "Error in named query". 我收到Hibernate消息,提示“命名查询错误”。
Below is the HQL statement I'm trying to execute. 以下是我要执行的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
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. 我认为问题可能与外部查询或union
运算符中的sum
函数有关,但我无法缩小范围。
Does anyone have any ideas? 有人有什么想法吗?
You can't use a subquery after From
clause in HQL. 您不能在HQL中的From
子句之后使用子查询。 My suggestion is that you can use native query
. 我的建议是您可以使用native query
。 For more detail you should look at following link :- Hibernate Query Limitation 有关更多详细信息,请查看以下链接:- 休眠查询限制
Hibernate does not support union
. Hibernate 不支持union
。
A feature request for that is open for a decade. 对此功能的要求已开放十年。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.