eclipselink icon indicating copy to clipboard operation
eclipselink copied to clipboard

Unable to omit optional entity identification variable from arguments to built-in aggregate functions

Open ajaypaul-ibm opened this issue 1 year ago • 0 comments

When attempting to invoke aggregate functions in JPQL and supplying an argument that omits the optional entity identification variable, such as,

SELECT MAX(price) FROM Item
SELECT MIN(price) FROM Item
SELECT AVG(price) FROM Item

EclipseLink is rejecting the JPQL claiming there is a syntax error,


Caused by: java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager: 
Exception Description: Syntax error parsing [SELECT MAX(price) FROM Item]. 
[11, 16] The encapsulated expression is not a valid expression.
	at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1848)
	at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1869)
	at io.openliberty.data.internal.persistence.RepositoryImpl.invoke(RepositoryImpl.java:871)
	... 38 more
Caused by: Exception [EclipseLink-0] (Eclipse Persistence Services - 5.0.0-B02.v202404111748): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Syntax error parsing [SELECT MAX(price) FROM Item]. 
[11, 16] The encapsulated expression is not a valid expression.
	at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildException(HermesParser.java:169)
	at org.eclipse.persistence.internal.jpa.jpql.HermesParser.validate(HermesParser.java:345)
	at org.eclipse.persistence.internal.jpa.jpql.HermesParser.populateQueryImp(HermesParser.java:292)
	at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildQuery(HermesParser.java:174)
	at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:144)
	at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:120)
	at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:107)
	at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:91)
	at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1846)
	... 40 more

ajaypaul-ibm avatar Jul 02 '24 06:07 ajaypaul-ibm