Author: ppoddar
Date: Thu Mar 14 19:04:44 2013
New Revision: 1456614

URL: http://svn.apache.org/r1456614
Log:
OPENJPA-2305: Downcast the attribute, if necessary, while navigating a path 

Modified:
    
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/PathImpl.java

Modified: 
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/PathImpl.java
URL: 
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/PathImpl.java?rev=1456614&r1=1456613&r2=1456614&view=diff
==============================================================================
--- 
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/PathImpl.java
 (original)
+++ 
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/PathImpl.java
 Thu Mar 14 19:04:44 2013
@@ -244,6 +244,9 @@ class PathImpl<Z,X> extends ExpressionIm
      *  Gets a new path that represents the given single-valued attribute from 
this path.
      */
     public <Y> Path<Y> get(SingularAttribute<? super X, Y> attr) {
+       if (getType() != attr.getDeclaringType()) {
+               attr = 
(SingularAttribute)((ManagedType)getType()).getAttribute(attr.getName());
+       }
         return new PathImpl<X,Y>(this, (Members.SingularAttributeImpl<? super 
X, Y>)attr, attr.getJavaType());
     }
     
@@ -251,6 +254,9 @@ class PathImpl<Z,X> extends ExpressionIm
      *  Gets a new path that represents the given multi-valued attribute from 
this path.
      */
     public <E, C extends java.util.Collection<E>> Expression<C>  
get(PluralAttribute<X, C, E> coll) {
+       if (getType() != coll.getDeclaringType()) {
+               coll = 
(PluralAttribute)((ManagedType)getType()).getAttribute(coll.getName());
+       }
         return new PathImpl<X,C>(this, (Members.PluralAttributeImpl<? super X, 
C, E>)coll, coll.getJavaType());
     }
 
@@ -258,6 +264,9 @@ class PathImpl<Z,X> extends ExpressionIm
      *  Gets a new path that represents the given map-valued attribute from 
this path.
      */
     public <K, V, M extends java.util.Map<K, V>> Expression<M> 
get(MapAttribute<X, K, V> map) {
+       if (getType() != map.getDeclaringType()) {
+               map = 
(MapAttribute)((ManagedType)getType()).getAttribute(map.getName());
+       }
         return new PathImpl<X,M>(this, (Members.MapAttributeImpl<? super 
X,K,V>)map, (Class<M>)map.getJavaType());
     }
     


Reply via email to