jpa - How to count all rows returned from a JPASubQuery query via QueryDSL? -
my subquery returns list of servicetypeids , respective counts in table called 'billingdata'.
i perform count(*) operation on 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));
my count attempt
subquery .list(billingdata.servicetypeid, billingdata.servicetypeid.count()) .count().eq(2l);
fails error
java.lang.illegalargumentexception: org.hibernate.hql.internal.ast.querysyntaxexception: expecting close, found ','
the error occurs when don't specify count.
i perform simple count(*), failing find way how extract column name subquery count parameter.
really stuck here :/
the following count expressions work
subquery.list(billingdata.servicetypeid).count().eq(2l); subquery.count().eq(2l); subquery.unique(billingdata.servicetypeid.count()).eq(2l);
count multiple columns not supported jpql
Comments
Post a Comment