From 3f9dcdbb761fa29847e028db7cc6309966028659 Mon Sep 17 00:00:00 2001 From: Catalina Wei Date: Thu, 8 May 2008 21:24:47 +0000 Subject: [PATCH] OPENJPA-595 A common path() action in JPQL.jjt being used for Enum literal causes a simple aliase resolution to fail git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@654626 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/openjpa/kernel/jpql/JPQLExpressionBuilder.java | 7 +++++-- .../main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/jpql/JPQLExpressionBuilder.java b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/jpql/JPQLExpressionBuilder.java index dbbc5381f..5678aed24 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/jpql/JPQLExpressionBuilder.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/jpql/JPQLExpressionBuilder.java @@ -1322,8 +1322,11 @@ public class JPQLExpressionBuilder Object value = field.get(null); return factory.newLiteral(value, Literal.TYPE_UNKNOWN); } catch (NoSuchFieldException nsfe) { - throw parseException(EX_USER, "no-field", - new Object[]{ c.getName(), fieldName }, nsfe); + if (node.parser.inEnumPath) + throw parseException(EX_USER, "no-field", + new Object[]{ c.getName(), fieldName }, nsfe); + else + return getPath(node, false, true); } catch (Exception e) { throw parseException(EX_USER, "unaccessible-field", new Object[]{ className, fieldName }, e); diff --git a/openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt b/openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt index 9a40e45fb..a77d7ba16 100644 --- a/openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt +++ b/openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt @@ -64,6 +64,7 @@ import java.io.*; public class JPQL { String jpql; + boolean inEnumPath; public JPQL (String jpql) @@ -968,7 +969,9 @@ void enum_primary() : { } void enum_literal() : { } { + { inEnumPath = true; } path() + { inEnumPath = false; } }