0

what i need:
requests are made out of stages, each stage has starts and ends at a certain time.
i need to know how many requests took the same amount of time to complete (sum of delta of all child stages which are in status finished)

the following sql query gives me the result i need, but it has a nested query in the from clause (which is not allowed in hql)

SELECT dist, count(*)
FROM
(
 SELECT S.parentRequestId, sum(S.finishedAt - S.startedAt) as dist
 FROM blarhg.Stage S
 WHERE S.status='FINISHED'
 GROUP BY S.parentRequestId
) qin
GROUP BY dist;

how can i achieve the same result in hql?

4

1 回答 1

0

每项技术都有其局限性。HQL 也不例外:有些查询不能表示为 HQL。

在这种情况下,我只使用createNativeQuery()接受常规 SQL 的 ,然后继续。

于 2013-06-15T21:07:34.597 回答