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 854b51aec..014f11cbb 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 @@ -238,6 +238,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()); } @@ -245,6 +248,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()); } @@ -252,6 +258,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()); } diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AnnotationProcessor6.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AnnotationProcessor6.java index 50e6aac91..122a627a3 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AnnotationProcessor6.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AnnotationProcessor6.java @@ -99,7 +99,6 @@ import org.apache.openjpa.persistence.util.SourceCode; "openjpa.header", "openjpa.metamodel" }) -@SupportedSourceVersion(RELEASE_6) public class AnnotationProcessor6 extends AbstractProcessor { private SourceAnnotationHandler handler; diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/SourceAnnotationHandler.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/SourceAnnotationHandler.java index 2b3187975..4e7be94e0 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/SourceAnnotationHandler.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/SourceAnnotationHandler.java @@ -41,6 +41,7 @@ import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; import javax.lang.model.type.ArrayType; import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.NoType; import javax.lang.model.type.PrimitiveType; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; @@ -642,11 +643,11 @@ public class SourceAnnotationHandler } public TypeElement getPersistentSupertype(TypeElement cls) { + if (cls == null) return null; TypeMirror sup = cls.getSuperclass(); - if (sup == null || isRootObject(sup)) + if (sup == null || sup.getKind() == TypeKind.NONE || isRootObject(sup)) return null; - TypeElement supe = - (TypeElement) processingEnv.getTypeUtils().asElement(sup); + TypeElement supe = (TypeElement) processingEnv.getTypeUtils().asElement(sup); if (isAnnotatedAsEntity(supe)) return supe; return getPersistentSupertype(supe);