Richard Zowalla created OPENJPA-3103:
----------------------------------------

             Summary: Fully qualified enum literal whose package starts like an 
identifier is parsed as a path ("non-entity variable")
                 Key: OPENJPA-3103
                 URL: https://issues.apache.org/jira/browse/OPENJPA-3103
             Project: OpenJPA
          Issue Type: Bug
    Affects Versions: 4.2.0
            Reporter: Richard Zowalla


JPQL with a fully qualified enum literal whose package starts with a name that 
could be an identification variable fails to parse:

{noformat}
SELECT e FROM NaturalNumber e WHERE e.isOdd = false AND e.numType = 
ee.jakarta.tck.data.framework.read.only.NaturalNumber.NumberType.PRIME
{noformat}

{noformat}
An error occurred while parsing the query filter "SELECT e FROM NaturalNumber e 
WHERE e.isOdd = false AND e.numType = 
ee.jakarta.tck.data.framework.read.only.NaturalNumber.NumberType.PRIME".
Error message: Attempt to query field 
"ee.jakarta.tck.data.framework.read.only.NaturalNumber.NumberType.PRIME" from 
non-entity variable "ee". Perhaps you forgot to prefix the path in question 
with an identification variable from your FROM clause?
{noformat}

The literal is a nested enum (NaturalNumber.NumberType, a member of the entity 
class) in the package ee.jakarta.tck.data.framework.read.only. The parser 
resolves the first segment "ee" as a variable instead of treating the whole 
path as an enum literal (Jakarta Persistence: "An enum literal is written using 
its fully qualified name"). EclipseLink accepts the query.

Found with the Jakarta Data 1.0 TCK 
(EntityTests#testLiteralEnumAndLiteralFalse, assertion #458) on Apache TomEE 11 
Plus, which uses OpenJPA; Jakarta Data repositories pass JDQL enum literals 
through to the provider this way.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to