2014-11-19 3 views
1

내 subQuery는 'billingData'라는 테이블에서 모든 serviceTypeIds 및 해당 개수의 목록을 반환합니다.QueryDSL을 통해 JPASubQuery 쿼리에서 반환 된 모든 행 수를 계산하는 방법은 무엇입니까?

나는 subQueryResult에 카운트 (*) 작업을 수행하고자하는

내 카운트 시도

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

오류

java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: expecting CLOSE, found ',' 

실패

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)); 

오류는 때 발생 셀 수를 지정하지 마십시오.

간단한 계산 (*)을 수행하고 싶지만 하위 매개 변수에서 열 이름을 계수 매개 변수로 추출하는 방법을 찾지 못했습니다.

정말 여기 붙어 :/

+0

지원하지 않습니다. 전체 쿼리를 제공 할 수 있습니까? –

답변

1

다음 카운트 표현은 여러 열

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

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

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

수를 작업에 문제가 카운트처럼 보이지 않는 JPQL