Hi,

Just confirmed from OpenJPA, count(*) is not supported. So if we use openjpa
as JPA API, we would encounter the issue.

https://issues.apache.org/jira/browse/OPENJPA-1781.

So I created an issue under Shindig:

https://issues.apache.org/jira/browse/SHINDIG-1420

Thanks,

Kevin Zhang (凯峰)
Gtalk:   [email protected]
Blog:    http://www.zhangkf.com
Twitter: http://twitter.com/zhangkf


On Fri, Sep 3, 2010 at 5:47 PM, Kai Feng Zhang <[email protected]> wrote:

> Hi,
>
> I found there is a hardcoded 'count(*)' in JPQLUtils.java,
>
>   public static Long getTotalResults(EntityManager entityManager, String
> query,
>       List<?> parametersValues) {
>     int fromIndex = 0;
>     String queryInUpperCase = query.toUpperCase();
>     // If JPA query starts with FROM then fromIndex as 0 is correct,
>     // otherwise find where FROM keyword starts in the query string and set
> the fromIndex.
>     if (!queryInUpperCase.startsWith("FROM ")) {
>       fromIndex = queryInUpperCase.indexOf(" FROM ");
>       if (fromIndex == -1) {
>         // Couldn't find the FROM keyword in the query
>         throw new
> ProtocolException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Invalid
> query [" + query + ']');
>       }
>     }
>     query = "select count(*) " + query.substring(fromIndex,
> query.length());
>     Query q = createQuery(entityManager, query, parametersValues);
>     return (Long) q.getSingleResult();
>   }
>
>
> The generated jpql will be parsed by OpenJPA 2.0 as invalid, since this is
> not supported in JPQL spec[?], see:
>
> https://issues.apache.org/jira/browse/OPENJPA-566
>
> So would you please check and fix this?
>
> Thanks,
>
> Kevin Zhang (凯峰)
>
>

Reply via email to