HQL Multiple在select子句中选择

时间:2015-12-07 13:14:35

标签: java database hibernate hql

我想在单个查询中获得多个计数的结果。在本机查询中,我可以这样做:

`select (select count(*) from Foo where status = 1), (select count(*) from Foo where status = 2) ...`

如果我喜欢HQL:

select (select count(f) from Foo f where f.status = 1), (select count(f) from Foo f where f.status = 2)

我收到错误:

<AST>:0:0: unexpected end of subtree

我如何在HQL中执行此操作?

1 个答案:

答案 0 :(得分:1)

如果你完成它,你的第一个选择是不完整的,应该没问题。

select (select count(f) from Foo f where f.status = 1), (select count(f) from Foo f where f.status = 2) from Foo;
相关问题