Closed ajaypaul-ibm closed 1 month ago
I was able to reproduce this issue in Open Liberty. Steps/resources to reproduce the behaviour. EclipseLink Snapshot version: 5.0.0.20240807
Entity Source
@Entity
public class Product {
public String description;
public String name;
@Id
@GeneratedValue
public UUID pk;
public float price;
@Version
public long version;
public static Product of(String description, String name, float price) {
Product inst = new Product();
inst.name = name;
inst.description = description;
inst.price = price;
return inst;
}
}
Application code/Query:
@Test
public void testSnapshot() throws Exception{
Product p = Product.of("testSnapshot","Bat",10.50f);
tx.begin();
em.persist(p);
tx.commit();
tx.begin();
try{
em.createQuery("FROM Product WHERE (:rate * price <= :max AND :rate * price >= :min) ORDER BY name", Product.class)
.setParameter("rate",4)
.setParameter("max",10)
.setParameter("min",1)
.getSingleResult();
tx.commit();
}
catch(Exception e){
tx.rollback();
throw e;
}
}
Trace:
Caused by: Exception [EclipseLink-0] (Eclipse Persistence Services - 5.0.0.v202408071314-43356e84b79e71022b1656a5462b0a72d70787a4): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Syntax error parsing [FROM Product WHERE (:rate * price <= :max AND :rate * price >= :min) ORDER BY name].
[40, 45] The right expression is not an arithmetic expression. (SELECT this FROM Product WHERE (:rate * [ :rate * price ] ...
[66, 71] The right expression is not an arithmetic expression. (SELECT this FROM Product WHERE (:rate * price <= :max AND :rate * [ :rate * price ] ...
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 componenttest.custom.junit.runner.FATRunner$2.evaluate(FATRunner.java:364) at componenttest.custom.junit.runner.FATRunner.run(FATRunner.java:178) at org.testcontainers.containers.FailureDetectingExternalResource$1.evaluate(FailureDetectingExternalResource.java:29) at componenttest.rules.repeater.RepeatTests$CompositeRepeatTestActionStatement.evaluate(RepeatTests.java:145)
Sorry, but I see issue in Your query.
FROM Product WHERE (:rate * price <= :max AND :rate * price >= :min) ORDER BY name
should be
FROM Product WHERE :rate * price <= :max AND :rate * price >= :min ORDER BY name
- no braces in where.
See attached testcase com.oracle.jpa.bugtest.TestNoAliasJPQL#queryTestThisWhere02 JakartaPersistence32POC.tar.gz
See Jakarta Persistence 3.2 Specification - 4.5. WHERE Clause chapter
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.
See Jakarta Persistence 3.2 Specification - 4.5. WHERE Clause chapter
Strange, what about 4.6.1?
@rfelcman This test is still failing in the latest Snapshot version (5.0.0-20240808) . Please check
Nighty build with mentioned PR #2240 passed. You can try latest snapshot 5.0.0-20240820.093222-62.
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.
Please refer the logs: