如何统计通过QueryDSL从JPASubQuery查询返回的所有行?

如何统计通过QueryDSL从JPASubQuery查询返回的所有行?,jpa,querydsl,Jpa,Querydsl,我的子查询返回一个名为“billingData”的表中所有ServiceTypeID及其各自计数的列表 我想对subQueryResult执行计数(*)操作 JPASubQuery subQuery = new JPASubQuery(); subQuery.from(billingData); subQuery.where( billingData.serviceTypeId.in(ServiceType.TYPE_ONE.getId(), ServiceType.TYPE_O

我的子查询返回一个名为“billingData”的表中所有ServiceTypeID及其各自计数的列表

我想对subQueryResult执行计数(*)操作

JPASubQuery subQuery = new JPASubQuery();
subQuery.from(billingData);
subQuery.where(
        billingData.serviceTypeId.in(ServiceType.TYPE_ONE.getId(), ServiceType.TYPE_ONE_TWO.getId())
                .and(billingData.accountId.isNull())
                .and(billingData.price.isNotNull())
                .and(billingData.numberId.eq(numbers.id)));//join condition
subQuery.groupBy(billingData.serviceTypeId);
subQuery.having(billingData.count().goe(1));
我的计数尝试

            subQuery
            .list(billingData.serviceTypeId, billingData.serviceTypeId.count())
            .count().eq(2L);
因错误而失败

java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: expecting CLOSE, found ','
如果未指定要计数的内容,则会发生错误

我只想执行一个简单的count(*),但找不到如何从子查询中提取列名作为count参数的方法


真的卡在这里了:/

下面的计数表达式可以工作

subQuery.list(billingData.serviceTypeId).count().eq(2L);

subQuery.count().eq(2L);

subQuery.unique(billingData.serviceTypeId.count()).eq(2L);

JPQL不支持多列计数

看起来问题不在计数中。你能提供整个查询吗?