Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2008-12-09 18:29:55 +0000
committerkmoore2008-12-09 18:29:55 +0000
commit997f2dbbcfa006c3701bfc9a0b85466583edd1e7 (patch)
tree6a3ebd254c5b76fd25a301dd044c64bd86ce200c
parentef39799e9c4dc6a0572eea61e5c242332cf1dc8b (diff)
downloadwebtools.dali-997f2dbbcfa006c3701bfc9a0b85466583edd1e7.tar.gz
webtools.dali-997f2dbbcfa006c3701bfc9a0b85466583edd1e7.tar.xz
webtools.dali-997f2dbbcfa006c3701bfc9a0b85466583edd1e7.zip
257742 - circular inheritance hierarchy causes infinite update
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaPersistentType.java24
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmPersistentType.java12
2 files changed, 30 insertions, 6 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) {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmPersistentType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmPersistentType.java
index e0c79984d2..d150a3e693 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmPersistentType.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmPersistentType.java
@@ -524,7 +524,17 @@ public class GenericOrmPersistentType
protected void updateParentPersistentType() {
JavaPersistentType javaPersistentType = getJavaPersistentType();
- setParentPersistentType(javaPersistentType == null ? null : javaPersistentType.getParentPersistentType());
+ PersistentType parentPersistentType = javaPersistentType == null ? null : javaPersistentType.getParentPersistentType();
+ if (parentPersistentType == null) {
+ setParentPersistentType(null);
+ }
+ else if (CollectionTools.contains(parentPersistentType.inheritanceHierarchy(), this)) {
+ //short-circuit in this case, we have circular inheritance
+ setParentPersistentType(null);
+ }
+ else {
+ setParentPersistentType(parentPersistentType);
+ }
}
protected void updatePersistentAttributes(AbstractXmlTypeMapping typeMapping) {

Back to the top