Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaPersistentType.java')
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaPersistentType.java24
1 files changed, 19 insertions, 5 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaPersistentType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaPersistentType.java
index b52ed5a7d4..b883a5036e 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaPersistentType.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaPersistentType.java
@@ -466,10 +466,16 @@ public class GenericJavaPersistentType extends AbstractJavaJpaContextNode implem
}
protected PersistentType parentPersistentType(String fullyQualifiedTypeName) {
- PersistentType possibleParent = possibleParent(fullyQualifiedTypeName);
+ Collection<JavaResourcePersistentType> hierarchyTypes = new ArrayList<JavaResourcePersistentType>();
+ hierarchyTypes.add(this.resourcePersistentType);
+ PersistentType possibleParent = possibleParent(fullyQualifiedTypeName, hierarchyTypes);
if (possibleParent == null) {
return null;
}
+ if (CollectionTools.contains(possibleParent.inheritanceHierarchy(), this)) {
+ //short-circuit in this case, we have circular inheritance
+ return null;
+ }
if (possibleParent.isMapped()) {
return possibleParent;
}
@@ -479,15 +485,23 @@ public class GenericJavaPersistentType extends AbstractJavaJpaContextNode implem
/**
* JPA spec supports the case where there are non-persistent types in the hierarchy
* This will check for a PersistentType with the given name in this PersistenceUnit.
- * If it is not found then find the JavaPersistentTypeResource and look for its parent type
+ * If it is not found then find the JavaPersistentTypeResource and look for its parent type.
+ *
+ * The Collection hierarchyTypes is used to handle a cycle in the inheritance hierarchy and
+ * prevent stackoverflows in this case. You can still end up with cycles in the PersistentType hierarchy,
+ * this is handled in parentPersistentType(String)
*/
- protected PersistentType possibleParent(String fullyQualifiedTypeName) {
+ protected PersistentType possibleParent(String fullyQualifiedTypeName, Collection<JavaResourcePersistentType> hierarchyTypes) {
+ JavaResourcePersistentType jrpt = getJpaProject().getJavaResourcePersistentType(fullyQualifiedTypeName);
+ if (jrpt == null || hierarchyTypes.contains(jrpt)) {
+ return null;
+ }
+ hierarchyTypes.add(jrpt);
PersistentType possibleParent = getPersistentType(fullyQualifiedTypeName);
if (possibleParent != null) {
return possibleParent;
}
- JavaResourcePersistentType jrpt = getJpaProject().getJavaResourcePersistentType(fullyQualifiedTypeName);
- return (jrpt == null) ? null : this.possibleParent(jrpt.getSuperClassQualifiedName());
+ return this.possibleParent(jrpt.getSuperClassQualifiedName(), hierarchyTypes);
}
protected PersistentType getPersistentType(String fullyQualifiedTypeName) {

Back to the top