[
https://issues.apache.org/jira/browse/OPENJPA-3103?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18153379#comment-18153379
]
ASF subversion and git services commented on OPENJPA-3103:
----------------------------------------------------------
Commit 2a30828eb0a8f257d56bb4dc6b732a6606ce673f in openjpa's branch
refs/heads/OPENJPA-3103 from Richard Zowalla
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=2a30828eb ]
[OPENJPA-3103] Resolve fully qualified nested enum literals in JPQL, also in IN
lists
A literal such as pkg.Outer.Inner.CONSTANT was loaded as the class
pkg.Outer.Inner, which does not exist for a nested class, so the parser
fell back to a path and reported the first package segment as a
non-entity variable. Unless the path starts with a variable whose type
has a field named like the second element, the nested class names
pkg.Outer$Inner, pkg$Outer$Inner, ... are now tried. IN lists accept
enum literals; an IN item that is a path but no constant is rejected
with its own message. The no-field message gets its arguments in the
right order.
> 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
> Priority: Major
>
> 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)