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 (凯峰)