태그 : jpa

2009/07/10   Kraken JPA 1.0.0 Release
2009/03/31   JPA SELECT 생성자 문법과 Aggregate 함수 [2]

JPA SELECT 생성자 문법과 Aggregate 함수

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으로 하면 된다는 얘기.
by xeraph | 2009/03/31 13:04 | 학술 | 트랙백 | 덧글(2)
<< 이전 페이지 다음 페이지 >>