Hi Benny,
Using native queries would be the only portable solution that I can think of. I suggest you to send a note to the JPA 2.0 expert group to extend JPQL for support of aggregates in order by clause (and corresponding select).
Regards,
-marina
[Message sent by forum member 'mvatkina' (mvatkina)]
http://forums.java.net/jive/thread.jspa?messageID=237448