JPA 2, problem with ORDER BY AVG [message #644359] |
Fri, 10 December 2010 11:56  |
Eclipse User |
|
|
|
Hello all,
I have an application deployed on glassFish3 with EclipseLink as persistance Unit.
I want make a namedquery as follow :
@NamedQuery(name = "Produits.findTop", query = "SELECT a.produit FROM Avis a GROUP BY a.produit ORDER BY avg(a.note) DESC")})
But I obtain the folowing exception :
Caused by: Exception [EclipseLink-8025] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Syntax error parsing the query [Produits.findTop: SELECT a.produit FROM Avis a GROUP BY a.produit ORDER BY avg(a.note) DESC], line 1, column 57: unexpected token [avg].
Internal Exception: NoViableAltException(10!=[1328:1: orderByItem returns [Object node] : (n= stateFieldPathExpression (a= ASC | d= DESC | ) | i= IDENT (a= ASC | d= DESC | ) );])
I don't understand why...
In contrast, the following request work perfectly but don't correspond to my need :
SELECT avg(a.note) FROM Avis a GROUP BY a.produit
SELECT a.produit FROM Avis a GROUP BY a.produit ORDER BY a.note DESC
I use the following version : EclipseLink, version: Eclipse Persistence Services - 2.0.1.v20100213-r6600
How can I correct my request? Or make a method wich do similar?
Thanks
|
|
|
|
Re: JPA 2, problem with ORDER BY AVG [message #644520 is a reply to message #644367] |
Sun, 12 December 2010 16:09  |
Eclipse User |
|
|
|
Hello,
Thanks for your answer!
But I have an another problem, on my dev system, i can update my glassfish server, but I don't have the right to modify the production server (secuirty blablabla...) and the administrator don't want to update EclipseLink...
Is it a way to embed the new version of EclipseLink with the EJB?
I'm currently using maven, and netbeans.
Thanks in advance!
|
|
|
Powered by
FUDForum. Page generated in 0.05138 seconds