Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
  • Loading branch information...
commit 70a201a55dcc88e380e682685f4855d579405091 1 parent e617abd
Pinaki Poddar authored
View
9 openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/PathImpl.java
@@ -244,6 +244,9 @@ protected void traversePath(PathImpl<?,?> parent, org.apache.openjpa.kernel.exp
* 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 @@ protected void traversePath(PathImpl<?,?> parent, org.apache.openjpa.kernel.exp
* 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 @@ protected void traversePath(PathImpl<?,?> parent, org.apache.openjpa.kernel.exp
* 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());
}
Please sign in to comment.
Something went wrong with that request. Please try again.