【问题标题】:HQL Error in Named Query命名查询中的 HQL 错误
【发布时间】:2015-09-20 02:49:23
【问题描述】:

我收到 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 运算符有关,但我无法缩小范围。

有人有什么想法吗?

【问题讨论】:

    标签: java hibernate hql


    【解决方案1】:

    您不能在 HQL 中的 From 子句之后使用子查询。我的建议是你可以使用native query。有关更多详细信息,您应该查看以下链接:- Hibernate Query Limitation

    【讨论】:

      【解决方案2】:

      休眠does not support union.

      对此的功能请求开放十年。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-01-14
        • 2012-02-08
        • 2014-07-02
        • 2013-05-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-02-03
        相关资源
        最近更新 更多