openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pinaki Poddar <ppod...@apache.org>
Subject Re: [jira] Created: (OPENJPA-730) Error when I add "ORDER BY count(f.report.id)" to my query
Date Thu, 10 Sep 2009 16:35:04 GMT

Hi,

  Try aliasing:

SELECT  f.report.id,count(f.report.id) as c FROM FavReports f, User u,
Report r WHERE f.report.id=r.id and  f.user.id = u.id and UPPER(u.userName)=
UPPER('USERNAME1') GROUP BY f.report.id  ORDER BY c DESC






JIRA jira@apache.org wrote:
> 
> Error when I add "ORDER BY count(f.report.id)"  to my query
> -----------------------------------------------------------
> 
>                  Key: OPENJPA-730
>                  URL: https://issues.apache.org/jira/browse/OPENJPA-730
>              Project: OpenJPA
>           Issue Type: Question
>           Components: query
>     Affects Versions: 1.0.0
>          Environment: WIN
>             Reporter: teto
> 
> 
> I'm getting error when i added  "ORDER BY count(column) " to my  JPQL
> query.
> 
>  ERROR:
> ----------------
> <openjpa-1.0.0-r420667:568756 nonfatal user error>
> org.apache.openjpa.persistence.ArgumentException: An error occurred while
> parsing the query filter 'SELECT  f.report.id FROM FavReports f, User u,
> Report r WHERE f.report.id=r.id and  f.user.id = u.id and
> UPPER(u.userName)= UPPER('USERNAME1') GROUP BY f.report.id  ORDER BY
> count(f.report.id) DESC'. 
> Error message: <openjpa-1.0.0-r420667:568756 nonfatal user error>
> org.apache.openjpa.kernel.jpql.ParseException: Encountered "count" at
> character 175, but expected: [<IDENTIFIER>].
> 	at
> org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.parse(JPQLExpressionBuilder.java:1666)
> 
> ++++++++++++++++++++++
> The query :
> ------------
> String jpql = "SELECT  f.report.id FROM FavReports f, User u, Report r
> WHERE f.report.id=r.id and  f.user.id = u.id and UPPER(u.userName)=
> UPPER('" + userName
> 				+ "') GROUP BY f.report.id  ORDER BY count(f.report.id) DESC";
> 
> 
> Does JPQL support the  ORDER BY COUNT(id)   ????????
> 
> 
> -- 
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
> 
> 
> 


-----
Pinaki 
-- 
View this message in context: http://n2.nabble.com/jira-Created-OPENJPA-730-Error-when-I-add-ORDER-BY-count-f-report-id-to-my-query-tp1099837p3617817.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.

Mime
View raw message