eclipse-ee4j / eclipselink

Eclipselink project
https://eclipse.dev/eclipselink/
Other
198 stars 168 forks source link

EclipseLink Snapshot 5.0.0.20240807 failing with JPQLException #2234

Closed ajaypaul-ibm closed 1 month ago

ajaypaul-ibm commented 1 month ago

We have identified a regression caused by the recent snapshot update. This regression specifically affects the more JPQL query, and it is currently blocking our ability to integrate the snapshot into Open Liberty. Consequently, we are unable to proceed with testing other critical fixes. An exception occurred while creating a query in EntityManager. Syntax error parsing [ FROM Prime WHERE (( numberId<=:max AND UPPER(romanNumeral) NOT LIKE '%VII' AND MOD(numberId,10)<>3 AND numberId >= :min)) ORDER BY even DESC, name]. Refer the logs:

Caused by: java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager: 
Exception Description: Syntax error parsing [ FROM Prime WHERE (( numberId<=:max AND UPPER(romanNumeral) NOT LIKE '%VII' AND MOD(numberId,10)<>3 AND    numberId    >= :min)) ORDER BY even DESC, name]. 
[58, 70] The encapsulated expression is not a valid expression. (SELECT this FROM Prime WHERE ((numberId <= :max AND UPPER( [ UPPER(romanNumeral) ] ...
[96, 104] The first argument is not a valid expression. (SELECT this FROM Prime WHERE ((numberId <= :max AND UPPER(romanNumeral) NOT LIKE '%VII' AND MOD( [ MOD(numberId,10) ] ...
    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.CursoredPageImpl.<init>(CursoredPageImpl.java:80)
Caused by: Exception [EclipseLink-0] (Eclipse Persistence Services - 5.0.0.v202408071314-43356e84b79e71022b1656a5462b0a72d70787a4): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Syntax error parsing [ FROM Prime WHERE (( numberId<=:max AND UPPER(romanNumeral) NOT LIKE '%VII' AND MOD(numberId,10)<>3 AND    numberId    >= :min)) ORDER BY even DESC, name]. 
[58, 70] The encapsulated expression is not a valid expression. (SELECT this FROM Prime WHERE ((numberId <= :max AND UPPER( [ UPPER(romanNumeral) ] ...
[96, 104] The first argument is not a valid expression. (SELECT this FROM Prime WHERE ((numberId <= :max AND UPPER(romanNumeral) NOT LIKE '%VII' AND MOD( [ MOD(numberId,10) ] ...
    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)

    at componenttest.topology.utils.FATServletClient.assertTestResponse(FATServletClient.java:106)
    at componenttest.topology.utils.FATServletClient.runTest(FATServletClient.java:91)
    at componenttest.custom.junit.runner.SyntheticServletTest.invokeExplosively(SyntheticServletTest.java:49)
    at componenttest.custom.junit.runner.FATRunner$1.evaluate(FATRunner.java:204)
    at org.testcontainers.containers.FailureDetectingExternalResource$1.evaluate(FailureDetectingExternalResource.java:29)
    at componenttest.custom.junit.runner.FATRunner$2.evaluate(FATRunner.java:364)
    at componenttest.custom.junit.runner.FATRunner.run(FATRunner.java:178)
rfelcman commented 1 month ago

Sorry, but I see issue in Your query. FROM Prime WHERE (( numberId<=:max AND UPPER(romanNumeral) NOT LIKE '%VII' AND MOD(numberId,10)<>3 AND numberId >= :min)) ORDER BY even DESC, name should be FROM Prime WHERE numberId<=:max AND UPPER(romanNumeral) NOT LIKE '%VII' AND MOD(numberId,10)<>3 AND numberId >= :min ORDER BY even DESC, name - no braces there

See attached testcase com.oracle.jpa.bugtest.TestNoAliasJPQL#queryTestThisWhere01 JakartaPersistence32POC.tar.gz

rfelcman commented 1 month ago

See Jakarta Persistence 3.2 Specification - 4.5. WHERE Clause chapter

rfelcman commented 1 month ago

About missing braces There is Jakarta Persistence 3.2 TCK test result against EclipseLink - 5.0.0.v202408081554-efbce400392c65c9440641ceae74889e157173fd https://ci.eclipse.org/eclipselink/job/TCK_JakartaEE11_JPA_run/39/artifact/SUMMARY_JDK21.TXT/*view*/ as You can see latest snapshot passed thru tests.

ajaypaul-ibm commented 1 month ago

@rfelcman This test is still failing in the latest Snapshot version (5.0.0-20240808) . Please check

rfelcman commented 1 month ago

Nighty build with mentioned PR #2240 passed. You can try latest snapshot 5.0.0-20240820.093222-62.