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

EclipseLink Snapshot 5.0.0.20240807 failed in Regression Test with Jakarta Data #2235

Closed
ajaypaul-ibm opened this issue Aug 12, 2024 · 7 comments

Comments

@ajaypaul-ibm
Copy link
Contributor

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:

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)
	... 126 more
@ajaypaul-ibm
Copy link
Contributor Author

ajaypaul-ibm commented Aug 13, 2024

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)

@rfelcman
Copy link
Contributor

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

@rfelcman
Copy link
Contributor

See Jakarta Persistence 3.2 Specification - 4.5. WHERE Clause chapter

@rfelcman
Copy link
Contributor

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.

@pzygielo
Copy link

See Jakarta Persistence 3.2 Specification - 4.5. WHERE Clause chapter

Strange, what about 4.6.1?

@ajaypaul-ibm
Copy link
Contributor Author

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

rfelcman added a commit to rfelcman/eclipselink that referenced this issue Aug 16, 2024
rfelcman added a commit that referenced this issue Aug 20, 2024
…WHERE condition enclosed by braces (#2240)

Fixes #2234 #2235

Signed-off-by: Radek Felcman <[email protected]>
@rfelcman
Copy link
Contributor

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

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.

3 participants