openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Krishnaprasad Subbarao <krishnapras...@in.ibm.com>
Subject Is SELECT count(*) query syntax supported in OpenJPA
Date Thu, 14 Feb 2013 12:34:45 GMT
Hello,

I am trying to execute following JPQL query using OpenJPA

select count(*) from AttributeBean Attribute where Attribute.Id = :$id$ 
and  Attribute.deleted=false

Following exception is thrown wile executing this query,

Caused by: 
<openjpa-2.2.1-r422266:1396819 nonfatal user error> 
org.apache.openjpa.persistence.ArgumentException: "Encountered "count ( *" 
at character 8, but expected: ["(", "+", "-", ":", "?", "ABS", "AVG", 
"CASE", "COALESCE", "CONCAT", "COUNT", "CURRENT_DATE", "CURRENT_TIME", 
"CURRENT_TIMESTAMP", "DISTINCT", "ENTRY", "INDEX", "KEY", "LENGTH", 
"LOCATE", "LOWER", "MAX", "MIN", "MOD", "NEW", "NULLIF", "OBJECT", "SIZE", 
"SQRT", "SUBSTRING", "SUM", "TRIM", "TYPE", "UPPER", "VALUE", 
<BOOLEAN_LITERAL>, <DATE_LITERAL>, <DECIMAL_LITERAL>, <IDENTIFIER>,

<INTEGER_LITERAL>, <STRING_LITERAL2>, <STRING_LITERAL>, 
<TIMESTAMP_LITERAL>, <TIME_LITERAL>]." while parsing JPQL "select count(*) 
from AttributeBean Attribute where Attribute.Id = :$id$ and 
Attribute.deleted=false". See nested stack trace for original parse error.
        at 
org.apache.openjpa.kernel.jpql.JPQLParser.parse(JPQLParser.java:51)
        at 
org.apache.openjpa.kernel.ExpressionStoreQuery.newCompilation(ExpressionStoreQuery.java:154)
        at 
org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:672)
        at 
org.apache.openjpa.kernel.QueryImpl.compilationFromCache(QueryImpl.java:654)
        at 
org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:620)
        at 
org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:682)
        at org.apache.openjpa.kernel.QueryImpl.compile(QueryImpl.java:589)
        at 
org.apache.openjpa.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:997)
        at 
org.apache.openjpa.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:979)
        at 
org.apache.openjpa.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:102)
        at 
com.ibm.wdp.bsscfw.dataservice.dao.OpenJPADAOImpl.getEntity(OpenJPADAOImpl.java:171)
        ... 40 more
Caused by: 
<openjpa-2.2.1-r422266:1396819 nonfatal user error> 
org.apache.openjpa.persistence.ArgumentException: Encountered "count ( *" 
at character 8, but expected: ["(", "+", "-", ":", "?", "ABS", "AVG", 
"CASE", "COALESCE", "CONCAT", "COUNT", "CURRENT_DATE", "CURRENT_TIME", 
"CURRENT_TIMESTAMP", "DISTINCT", "ENTRY", "INDEX", "KEY", "LENGTH", 
"LOCATE", "LOWER", "MAX", "MIN", "MOD", "NEW", "NULLIF", "OBJECT", "SIZE", 
"SQRT", "SUBSTRING", "SUM", "TRIM", "TYPE", "UPPER", "VALUE", 
<BOOLEAN_LITERAL>, <DATE_LITERAL>, <DECIMAL_LITERAL>, <IDENTIFIER>,

<INTEGER_LITERAL>, <STRING_LITERAL2>, <STRING_LITERAL>, 
<TIMESTAMP_LITERAL>, <TIME_LITERAL>].
        at 
org.apache.openjpa.kernel.jpql.JPQL.generateParseException(JPQL.java:13162)
        at 
org.apache.openjpa.kernel.jpql.JPQL.jj_consume_token(JPQL.java:13036)
        at 
org.apache.openjpa.kernel.jpql.JPQL.select_expression(JPQL.java:1001)
        at 
org.apache.openjpa.kernel.jpql.JPQL.select_expressions(JPQL.java:930)
        at 
org.apache.openjpa.kernel.jpql.JPQL.select_clause(JPQL.java:865)
        at 
org.apache.openjpa.kernel.jpql.JPQL.select_statement(JPQL.java:87)
        at org.apache.openjpa.kernel.jpql.JPQL.parseQuery(JPQL.java:63)
        at 
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.parse(JPQLExpressionBuilder.java:2401)
        at 
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.<init>(JPQLExpressionBuilder.java:2388)
        at 
org.apache.openjpa.kernel.jpql.JPQLParser.parse(JPQLParser.java:49)
        ... 50 more

Is SELECT count(*) query syntax supported in OpenJPA? If yes what changes 
should be done to above query to get it working?

Thanks and Regards,

KRISHNAPRASAD SUBBARAO






Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message