OpenLiberty / open-liberty

Open Liberty is a highly composable, fast to start, dynamic application server runtime environment
https://openliberty.io
Eclipse Public License 2.0
1.16k stars 597 forks source link

id(this) is not accepted as an argument to a function #29893

Open njr-11 opened 3 weeks ago

njr-11 commented 3 weeks ago

EclipseLink is not accepting the ID(THIS) operation when supplied as an argument to another JPQL function, such as LOWER,

FROM Vehicle WHERE LOWER(ID(THIS)) = ?1

The error raised is:

java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager: 
Exception Description: Syntax error parsing [ FROM Vehicle WHERE LOWER(ID(THIS)) = ?1]. 
[37, 45] The encapsulated expression is not a valid expression. (SELECT this FROM Vehicle WHERE LOWER( [ LOWER(ID(THIS)) ] ...
    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:1133)
    ... 38 more
Caused by: Exception [EclipseLink-0] (Eclipse Persistence Services - 5.0.0-B03.v202409121024-4a7149f0cd04d7466837d70f68abb743c88acb83): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Syntax error parsing [ FROM Vehicle WHERE LOWER(ID(THIS)) = ?1]. 
[37, 45] The encapsulated expression is not a valid expression. (SELECT this FROM Vehicle WHERE LOWER( [ LOWER(ID(THIS)) ] ...
    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
anija-anil commented 3 weeks ago

See EclipseLink Issue : 2286