Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse')
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaElementCollectionMappingTests.java34
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/orm/EclipseLink2_0OrmElementCollectionMappingTests.java35
2 files changed, 68 insertions, 1 deletions
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaElementCollectionMappingTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaElementCollectionMappingTests.java
index 9b0df094c6..d5b35d2a62 100644
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaElementCollectionMappingTests.java
+++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaElementCollectionMappingTests.java
@@ -309,6 +309,31 @@ public class EclipseLink2_0JavaElementCollectionMappingTests
this.javaProject.createCompilationUnit(PACKAGE_NAME, "PropertyInfo.java", sourceWriter);
}
+ private void createSelfReferentialElementCollection() throws Exception {
+ SourceWriter sourceWriter = new SourceWriter() {
+ public void appendSourceTo(StringBuilder sb) {
+ sb.append("import ");
+ sb.append(JPA.EMBEDDABLE);
+ sb.append(";");
+ sb.append(CR);
+ sb.append("import ");
+ sb.append(JPA2_0.ELEMENT_COLLECTION);
+ sb.append(";");
+ sb.append(CR).append(CR);
+ sb.append("@Embeddable");
+ sb.append(CR);
+ sb.append("public class ").append("Foo").append(" ");
+ sb.append("{").append(CR);
+ sb.append(CR);
+ sb.append(" @ElementCollection").append(CR);
+ sb.append(" private java.util.List<Foo> elementCollection;").append(CR);
+ sb.append(CR);
+ sb.append("}").append(CR);
+ }
+ };
+ this.javaProject.createCompilationUnit(PACKAGE_NAME, "Foo.java", sourceWriter);
+ }
+
public EclipseLink2_0JavaElementCollectionMappingTests(String name) {
super(name);
}
@@ -2027,4 +2052,13 @@ public class EclipseLink2_0JavaElementCollectionMappingTests
assertEquals("city", specifiedOverrides.next().getName());
assertFalse(specifiedOverrides.hasNext());
}
+
+ public void testSelfReferentialElementCollection() throws Exception {
+ createSelfReferentialElementCollection();
+ addXmlClassRef(PACKAGE_NAME + ".Foo");
+
+ //If there is a StackOverflowError you will not be able to get the mapping
+ JavaElementCollectionMapping2_0 elementCollectionMapping = (JavaElementCollectionMapping2_0) getJavaPersistentType().getAttributeNamed("elementCollection").getMapping();
+ assertFalse(elementCollectionMapping.allOverrideableAttributeMappingNames().hasNext());
+ }
}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/orm/EclipseLink2_0OrmElementCollectionMappingTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/orm/EclipseLink2_0OrmElementCollectionMappingTests.java
index 02d92877b8..a757dec534 100644
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/orm/EclipseLink2_0OrmElementCollectionMappingTests.java
+++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/orm/EclipseLink2_0OrmElementCollectionMappingTests.java
@@ -244,7 +244,32 @@ public class EclipseLink2_0OrmElementCollectionMappingTests extends EclipseLink2
}
});
}
-
+
+ private void createSelfReferentialElementCollection() throws Exception {
+ SourceWriter sourceWriter = new SourceWriter() {
+ public void appendSourceTo(StringBuilder sb) {
+ sb.append("import ");
+ sb.append(JPA.EMBEDDABLE);
+ sb.append(";");
+ sb.append(CR);
+ sb.append("import ");
+ sb.append(JPA2_0.ELEMENT_COLLECTION);
+ sb.append(";");
+ sb.append(CR).append(CR);
+ sb.append("@Embeddable");
+ sb.append(CR);
+ sb.append("public class ").append("Foo").append(" ");
+ sb.append("{").append(CR);
+ sb.append(CR);
+ sb.append(" @ElementCollection").append(CR);
+ sb.append(" private java.util.List<Foo> elementCollection;").append(CR);
+ sb.append(CR);
+ sb.append("}").append(CR);
+ }
+ };
+ this.javaProject.createCompilationUnit(PACKAGE_NAME, "Foo.java", sourceWriter);
+ }
+
public void testUpdateName() throws Exception {
OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
@@ -1402,4 +1427,12 @@ public class EclipseLink2_0OrmElementCollectionMappingTests extends EclipseLink2
assertNull(ormColumn.getSpecifiedTable());
assertEquals(TYPE_NAME + "_addresses", ormColumn.getDefaultTable());
}
+
+ public void testSelfReferentialElementCollectionMapping() throws Exception {
+ createSelfReferentialElementCollection();
+ OrmPersistentType persistentType = getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Foo");
+
+ OrmElementCollectionMapping2_0 mapping = (OrmElementCollectionMapping2_0) persistentType.getAttributeNamed("elementCollection").getMapping();
+ assertFalse(mapping.allOverrideableAttributeMappingNames().hasNext());
+ }
} \ No newline at end of file

Back to the top