From 70a201a55dcc88e380e682685f4855d579405091 Mon Sep 17 00:00:00 2001 From: Pinaki Poddar Date: Thu, 14 Mar 2013 19:04:44 +0000 Subject: [PATCH] OPENJPA-2305: Downcast the attribute, if necessary, while navigating a path git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1456614 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/openjpa/persistence/criteria/PathImpl.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/PathImpl.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/PathImpl.java index 8e99c52c9..6cd65cc81 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/PathImpl.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/PathImpl.java @@ -244,6 +244,9 @@ class PathImpl extends ExpressionImpl implements Path { * Gets a new path that represents the given single-valued attribute from this path. */ public Path get(SingularAttribute attr) { + if (getType() != attr.getDeclaringType()) { + attr = (SingularAttribute)((ManagedType)getType()).getAttribute(attr.getName()); + } return new PathImpl(this, (Members.SingularAttributeImpl)attr, attr.getJavaType()); } @@ -251,6 +254,9 @@ class PathImpl extends ExpressionImpl implements Path { * Gets a new path that represents the given multi-valued attribute from this path. */ public > Expression get(PluralAttribute coll) { + if (getType() != coll.getDeclaringType()) { + coll = (PluralAttribute)((ManagedType)getType()).getAttribute(coll.getName()); + } return new PathImpl(this, (Members.PluralAttributeImpl)coll, coll.getJavaType()); } @@ -258,6 +264,9 @@ class PathImpl extends ExpressionImpl implements Path { * Gets a new path that represents the given map-valued attribute from this path. */ public > Expression get(MapAttribute map) { + if (getType() != map.getDeclaringType()) { + map = (MapAttribute)((ManagedType)getType()).getAttribute(map.getName()); + } return new PathImpl(this, (Members.MapAttributeImpl)map, (Class)map.getJavaType()); }