Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arithemtic expressions in SELECT clause broken when entity identifier variable omitted #2247

Closed
Riva-Tholoor-Philip opened this issue Aug 22, 2024 · 0 comments · Fixed by #2254

Comments

@Riva-Tholoor-Philip
Copy link
Contributor

EclipseLink raises an error The left expression is not an arithmetic expression (same as #2183 but which was for UPDATE) when a SELECT query performs an arithmetic expression on entity attributes that have the optional entity identifier variable omitted.

JPQL:

SELECT publicDebt / numFullTimeWorkers  FROM DemographicInfo WHERE EXTRACT (YEAR FROM collectedOn) = ?1

Error:

java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager: 
Exception Description: Syntax error parsing [SELECT publicDebt / numFullTimeWorkers  FROM DemographicInfo WHERE EXTRACT (YEAR FROM collectedOn) = ?1]. 
[7, 17] The left expression is not an arithmetic expression. (SELECT  [ publicDebt / numFullTimeWorkers ] ...
[20, 38] The right expression is not an arithmetic expression. (SELECT publicDebt /  [ publicDebt / numFullTimeWorkers ] ...
	at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1848)
	at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1869)
	... 38 more
Caused by: Exception [EclipseLink-0] (Eclipse Persistence Services - 5.0.0.v202408200932-f556522e743c87b8097f78cefe2b8f24f68cf79e): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Syntax error parsing [SELECT publicDebt / numFullTimeWorkers  FROM DemographicInfo WHERE EXTRACT (YEAR FROM collectedOn) = ?1]. 
[7, 17] The left expression is not an arithmetic expression. (SELECT  [ publicDebt / numFullTimeWorkers ] ...
[20, 38] The right expression is not an arithmetic expression. (SELECT publicDebt /  [ publicDebt / numFullTimeWorkers ] ...
	at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildException(HermesParser.java:175)
	at org.eclipse.persistence.internal.jpa.jpql.HermesParser.validate(HermesParser.java:351)
	at org.eclipse.persistence.internal.jpa.jpql.HermesParser.populateQueryImp(HermesParser.java:298)
	at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildQuery(HermesParser.java:180)
	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
rfelcman added a commit to rfelcman/eclipselink that referenced this issue Sep 10, 2024
…e-ee4j#2192, eclipse-ee4j#2247 issues

JPQL SELECT not allowing entity attribute without optional entity identification variable eclipse-ee4j#2182 - bug fix (main + tests)
NullPointerException when JPQL UPDATE assignment operation omits optional identification variable eclipse-ee4j#2184 - bug fix (main + tests)
Unable to omit optional entity identification variable from arguments to built-in aggregate functions eclipse-ee4j#2192 - bug fix (main + tests)
Arithmetic expressions in SELECT clause broken when entity identifier variable omitted eclipse-ee4j#2247 - bug fix (main + tests)

Signed-off-by: Radek Felcman <[email protected]>
rfelcman added a commit that referenced this issue Sep 11, 2024
JPQL SELECT not allowing entity attribute without optional entity identification variable #2182 - bug fix (main + tests)
NullPointerException when JPQL UPDATE assignment operation omits optional identification variable #2184 - bug fix (main + tests)
Unable to omit optional entity identification variable from arguments to built-in aggregate functions #2192 - bug fix (main + tests)
Arithmetic expressions in SELECT clause broken when entity identifier variable omitted #2247 - bug fix (main + tests)

Signed-off-by: Radek Felcman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant