You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@shindig.apache.org by "Kai Feng Zhang (JIRA)" <ji...@apache.org> on 2010/09/04 03:44:32 UTC
[jira] Created: (SHINDIG-1420) count(*) is not supported in JPQL
spec
count(*) is not supported in JPQL spec
--------------------------------------
Key: SHINDIG-1420
URL: https://issues.apache.org/jira/browse/SHINDIG-1420
Project: Shindig
Issue Type: Bug
Components: Java
Affects Versions: 2.0.0-RC2
Environment: Shindig 2.0, OpenJPA 2.0
Reporter: Kai Feng Zhang
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-1781
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.