JSR 220 문서를 보면 아래 구절이 있다.
4.8.4. Aggregate Functions in the SELECT Clause
The Java type that is contained in the result of a query using an aggregate function is as follows:
- COUNT returns Long.
- MAX, MIN return the type of the state-field to which they are applied.
- AVG returns Double.
- SUM returns Long when applied to state-fields of integral types (other than BigInteger); Double
when applied to state-fields of floating point types; BigInteger when applied to state-fields of type BigInteger; and BigDecimal when applied to state-fields of type BigDecimal. If SUM, AVG, MAX, or MIN is used, and there are no values to which the aggregate function c
그래서 SELECT 생성자 문법 (select new full-qualified-classname) 써서 COUNT 결과 받는답시고,
int로 매개변수를 쓰면
Unable to locate appropriate constructor on class 예외만 받고 삽질하게 된다. -_-
결론은 long으로 하면 된다는 얘기.