users@glassfish.java.net

Re: How to create EQL with aggregation function count, SELECT new DTO

From: <glassfish_at_javadesktop.org>
Date: Mon, 26 Feb 2007 09:58:10 PST

Hi Fafi,

I filed an issue for the SQLException caused by the generated COUNT():
https://glassfish.dev.java.net/issues/show_bug.cgi?id=2496

As a workaround you can try counting the id field, so doing a COUNT(f.id) instead of COUNT(f):
  SELECT new dto.PersonDTO(res.id,res.firstname,res.surname, count(f))
  FROM Person res JOIN res.friends f WHERE res.id=:id
  GROUP BY res.id, res.firstname, res.surname

Regards Michael
[Message sent by forum member 'mb124283' (mb124283)]

http://forums.java.net/jive/thread.jspa?messageID=205282