Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2011-09-08 16:48:25 +0000
committerkmoore2011-09-08 16:48:25 +0000
commit019afd653b4f915ce46b8e3199c251092efbf734 (patch)
tree913885680292d1ea3ec723a802f68894650ffba1 /jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa
parent27a2da79ca464936e0ea474ba0cbf958bc8589a9 (diff)
downloadwebtools.dali-019afd653b4f915ce46b8e3199c251092efbf734.tar.gz
webtools.dali-019afd653b4f915ce46b8e3199c251092efbf734.tar.xz
webtools.dali-019afd653b4f915ce46b8e3199c251092efbf734.zip
356292 - Validation error for entities with @AttributeOverride on attribute marked as @Version in mapped superclass
Diffstat (limited to 'jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa')
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/java/JavaEntityTests.java62
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmEntityTests.java25
2 files changed, 67 insertions, 20 deletions
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/java/JavaEntityTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/java/JavaEntityTests.java
index e3c04c2d77..b865594e6c 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/java/JavaEntityTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/java/JavaEntityTests.java
@@ -1732,6 +1732,7 @@ public class JavaEntityTests extends ContextModelTestCase
Iterator<String> overridableAttributes = getJavaEntity().getAllOverridableAttributeNames().iterator();
assertEquals("foo", overridableAttributes.next());
assertEquals("basic", overridableAttributes.next());
+ assertEquals("version", overridableAttributes.next());
assertEquals("id", overridableAttributes.next());
assertEquals("name", overridableAttributes.next());
assertFalse(overridableAttributes.hasNext());
@@ -1790,6 +1791,7 @@ public class JavaEntityTests extends ContextModelTestCase
Iterator<String> overridableAttributes = getJavaEntity().getAllOverridableAttributeNames().iterator();
assertEquals("foo", overridableAttributes.next());
assertEquals("basic", overridableAttributes.next());
+ assertEquals("version", overridableAttributes.next());
assertEquals("id", overridableAttributes.next());
assertEquals("name", overridableAttributes.next());
assertFalse(overridableAttributes.hasNext());
@@ -1804,6 +1806,7 @@ public class JavaEntityTests extends ContextModelTestCase
Iterator<String> overridableAttributeNames = getJavaEntity().getAllOverridableAttributeNames().iterator();
assertEquals("foo", overridableAttributeNames.next());
assertEquals("basic", overridableAttributeNames.next());
+ assertEquals("version", overridableAttributeNames.next());
assertEquals("id", overridableAttributeNames.next());
assertEquals("name", overridableAttributeNames.next());
assertFalse(overridableAttributeNames.hasNext());
@@ -1891,7 +1894,7 @@ public class JavaEntityTests extends ContextModelTestCase
assertEquals(SUB_TYPE_NAME, resourceType.getName());
assertNull(resourceType.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
- assertEquals(4, overrideContainer.getVirtualOverridesSize());
+ assertEquals(5, overrideContainer.getVirtualOverridesSize());
VirtualAttributeOverride virtualAttributeOverride = overrideContainer.getVirtualOverrides().iterator().next();
assertEquals("foo", virtualAttributeOverride.getName());
assertEquals("foo", virtualAttributeOverride.getColumn().getName());
@@ -1923,7 +1926,7 @@ public class JavaEntityTests extends ContextModelTestCase
assertEquals(SUB_TYPE_NAME, resourceType.getName());
assertNull(resourceType.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
- assertEquals(4, overrideContainer.getVirtualOverridesSize());
+ assertEquals(5, overrideContainer.getVirtualOverridesSize());
virtualAttributeOverride = overrideContainer.getVirtualOverrides().iterator().next();
assertEquals("foo", virtualAttributeOverride.getName());
assertEquals("FOO", virtualAttributeOverride.getColumn().getName());
@@ -1964,7 +1967,7 @@ public class JavaEntityTests extends ContextModelTestCase
assertEquals(0, virtualAttributeOverride.getColumn().getScale());
virtualAttributeOverride.convertToSpecified();
- assertEquals(3, overrideContainer.getVirtualOverridesSize());
+ assertEquals(4, overrideContainer.getVirtualOverridesSize());
}
public void testVirtualAttributeOverridesEntityHierachy() throws Exception {
@@ -2046,6 +2049,9 @@ public class JavaEntityTests extends ContextModelTestCase
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
AttributeOverrideContainer overrideContainer = getJavaEntity().getAttributeOverrideContainer();
+ assertEquals(5, overrideContainer.getVirtualOverridesSize());
+
+ overrideContainer.getVirtualOverrides().iterator().next().convertToSpecified();
assertEquals(4, overrideContainer.getVirtualOverridesSize());
overrideContainer.getVirtualOverrides().iterator().next().convertToSpecified();
@@ -2069,20 +2075,20 @@ public class JavaEntityTests extends ContextModelTestCase
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
AttributeOverrideContainer overrideContainer = getJavaEntity().getAttributeOverrideContainer();
- assertEquals(4, overrideContainer.getOverridesSize());
+ assertEquals(5, overrideContainer.getOverridesSize());
overrideContainer.getVirtualOverrides().iterator().next().convertToSpecified();
- assertEquals(4, overrideContainer.getOverridesSize());
+ assertEquals(5, overrideContainer.getOverridesSize());
overrideContainer.getVirtualOverrides().iterator().next().convertToSpecified();
- assertEquals(4, overrideContainer.getOverridesSize());
+ assertEquals(5, overrideContainer.getOverridesSize());
JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_SUB_TYPE_NAME, Kind.TYPE);
AttributeOverrideAnnotation annotation = (AttributeOverrideAnnotation) resourceType.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
annotation.setName("bar");
getJpaProject().synchronizeContextModel();
- assertEquals(5, overrideContainer.getOverridesSize());
+ assertEquals(6, overrideContainer.getOverridesSize());
}
public void testAttributeOverrideSetVirtual() throws Exception {
@@ -2139,35 +2145,49 @@ public class JavaEntityTests extends ContextModelTestCase
overrideContainer.getVirtualOverrides().iterator().next().convertToSpecified();
overrideContainer.getVirtualOverrides().iterator().next().convertToSpecified();
overrideContainer.getVirtualOverrides().iterator().next().convertToSpecified();
+ overrideContainer.getVirtualOverrides().iterator().next().convertToSpecified();
JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_SUB_TYPE_NAME, Kind.TYPE);
- assertEquals(3, CollectionTools.size(resourceType.getAnnotations(AttributeOverrideAnnotation.ANNOTATION_NAME)));
+ assertEquals(4, CollectionTools.size(resourceType.getAnnotations(AttributeOverrideAnnotation.ANNOTATION_NAME)));
overrideContainer.getSpecifiedOverrides().iterator().next().convertToVirtual();
Iterator<NestableAnnotation> attributeOverrideResources = resourceType.getAnnotations(AttributeOverrideAnnotation.ANNOTATION_NAME).iterator();
assertEquals("basic", ((AttributeOverrideAnnotation) attributeOverrideResources.next()).getName());
+ assertEquals("version", ((AttributeOverrideAnnotation) attributeOverrideResources.next()).getName());
assertEquals("id", ((AttributeOverrideAnnotation) attributeOverrideResources.next()).getName());
assertFalse(attributeOverrideResources.hasNext());
Iterator<JavaAttributeOverride> attributeOverrides = overrideContainer.getSpecifiedOverrides().iterator();
assertEquals("basic", attributeOverrides.next().getName());
+ assertEquals("version", attributeOverrides.next().getName());
assertEquals("id", attributeOverrides.next().getName());
assertFalse(attributeOverrides.hasNext());
overrideContainer.getSpecifiedOverrides().iterator().next().convertToVirtual();
attributeOverrideResources = resourceType.getAnnotations(AttributeOverrideAnnotation.ANNOTATION_NAME).iterator();
+ assertEquals("version", ((AttributeOverrideAnnotation) attributeOverrideResources.next()).getName());
assertEquals("id", ((AttributeOverrideAnnotation) attributeOverrideResources.next()).getName());
assertFalse(attributeOverrideResources.hasNext());
attributeOverrides = overrideContainer.getSpecifiedOverrides().iterator();
+ assertEquals("version", attributeOverrides.next().getName());
assertEquals("id", attributeOverrides.next().getName());
assertFalse(attributeOverrides.hasNext());
overrideContainer.getSpecifiedOverrides().iterator().next().convertToVirtual();
attributeOverrideResources = resourceType.getAnnotations(AttributeOverrideAnnotation.ANNOTATION_NAME).iterator();
+ assertEquals("id", ((AttributeOverrideAnnotation) attributeOverrideResources.next()).getName());
+ assertFalse(attributeOverrideResources.hasNext());
+
+ attributeOverrides = overrideContainer.getSpecifiedOverrides().iterator();
+ assertEquals("id", attributeOverrides.next().getName());
+ assertFalse(attributeOverrides.hasNext());
+
+ overrideContainer.getSpecifiedOverrides().iterator().next().convertToVirtual();
+ attributeOverrideResources = resourceType.getAnnotations(AttributeOverrideAnnotation.ANNOTATION_NAME).iterator();
assertFalse(attributeOverrideResources.hasNext());
attributeOverrides = overrideContainer.getSpecifiedOverrides().iterator();
assertFalse(attributeOverrides.hasNext());
@@ -2186,35 +2206,40 @@ public class JavaEntityTests extends ContextModelTestCase
overrideContainer.getVirtualOverrides().iterator().next().convertToSpecified();
overrideContainer.getVirtualOverrides().iterator().next().convertToSpecified();
overrideContainer.getVirtualOverrides().iterator().next().convertToSpecified();
+ overrideContainer.getVirtualOverrides().iterator().next().convertToSpecified();
JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_SUB_TYPE_NAME, Kind.TYPE);
Iterator<NestableAnnotation> javaAttributeOverrides = resourceType.getAnnotations(AttributeOverrideAnnotation.ANNOTATION_NAME).iterator();
- assertEquals(3, CollectionTools.size(javaAttributeOverrides));
+ assertEquals(4, CollectionTools.size(javaAttributeOverrides));
overrideContainer.moveSpecifiedOverride(2, 0);
ListIterator<JavaAttributeOverride> attributeOverrides = overrideContainer.getSpecifiedOverrides().iterator();
assertEquals("basic", attributeOverrides.next().getName());
- assertEquals("id", attributeOverrides.next().getName());
+ assertEquals("version", attributeOverrides.next().getName());
assertEquals("foo", attributeOverrides.next().getName());
+ assertEquals("id", attributeOverrides.next().getName());
javaAttributeOverrides = resourceType.getAnnotations(AttributeOverrideAnnotation.ANNOTATION_NAME).iterator();
assertEquals("basic", ((AttributeOverrideAnnotation) javaAttributeOverrides.next()).getName());
- assertEquals("id", ((AttributeOverrideAnnotation) javaAttributeOverrides.next()).getName());
+ assertEquals("version", ((AttributeOverrideAnnotation) javaAttributeOverrides.next()).getName());
assertEquals("foo", ((AttributeOverrideAnnotation) javaAttributeOverrides.next()).getName());
+ assertEquals("id", ((AttributeOverrideAnnotation) javaAttributeOverrides.next()).getName());
overrideContainer.moveSpecifiedOverride(0, 1);
attributeOverrides = overrideContainer.getSpecifiedOverrides().iterator();
- assertEquals("id", attributeOverrides.next().getName());
+ assertEquals("version", attributeOverrides.next().getName());
assertEquals("basic", attributeOverrides.next().getName());
assertEquals("foo", attributeOverrides.next().getName());
+ assertEquals("id", attributeOverrides.next().getName());
javaAttributeOverrides = resourceType.getAnnotations(AttributeOverrideAnnotation.ANNOTATION_NAME).iterator();
- assertEquals("id", ((AttributeOverrideAnnotation) javaAttributeOverrides.next()).getName());
+ assertEquals("version", ((AttributeOverrideAnnotation) javaAttributeOverrides.next()).getName());
assertEquals("basic", ((AttributeOverrideAnnotation) javaAttributeOverrides.next()).getName());
assertEquals("foo", ((AttributeOverrideAnnotation) javaAttributeOverrides.next()).getName());
+ assertEquals("id", ((AttributeOverrideAnnotation) javaAttributeOverrides.next()).getName());
}
public void testUpdateSpecifiedAttributeOverrides() throws Exception {
@@ -2288,6 +2313,10 @@ public class JavaEntityTests extends ContextModelTestCase
assertTrue(virtualAttributeOverride.isVirtual());
virtualAttributeOverride = virtualAttributeOverrides.next();
+ assertEquals("version", virtualAttributeOverride.getName());
+ assertTrue(virtualAttributeOverride.isVirtual());
+
+ virtualAttributeOverride = virtualAttributeOverrides.next();
assertEquals("id", virtualAttributeOverride.getName());
assertTrue(virtualAttributeOverride.isVirtual());
@@ -2307,6 +2336,10 @@ public class JavaEntityTests extends ContextModelTestCase
assertTrue(virtualAttributeOverride.isVirtual());
virtualAttributeOverride = virtualAttributeOverrides.next();
+ assertEquals("version", virtualAttributeOverride.getName());
+ assertTrue(virtualAttributeOverride.isVirtual());
+
+ virtualAttributeOverride = virtualAttributeOverrides.next();
assertEquals("id", virtualAttributeOverride.getName());
assertTrue(virtualAttributeOverride.isVirtual());
@@ -3299,7 +3332,7 @@ public class JavaEntityTests extends ContextModelTestCase
assertNull(resourceType.getAnnotation(IdClassAnnotation.ANNOTATION_NAME));
assertNull(getJavaEntity().getIdClassReference().getIdClass());
}
-
+
public void testGetPrimaryKeyColumnNameWithAttributeOverride() throws Exception {
createTestMappedSuperclass();
createTestSubType();
@@ -3319,6 +3352,7 @@ public class JavaEntityTests extends ContextModelTestCase
ListIterator<JavaVirtualAttributeOverride> virtualAttributeOverrides = javaEntity.getAttributeOverrideContainer().getVirtualOverrides().iterator();
virtualAttributeOverrides.next();
virtualAttributeOverrides.next();
+ virtualAttributeOverrides.next();
JavaVirtualAttributeOverride virtualOverride = virtualAttributeOverrides.next();
assertEquals("id", virtualOverride.getName());
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmEntityTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmEntityTests.java
index ccb0c071d4..d62222a79a 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmEntityTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmEntityTests.java
@@ -1673,13 +1673,15 @@ public class OrmEntityTests extends ContextModelTestCase
OrmEntity entity = (OrmEntity) persistentType.getMapping();
OrmAttributeOverrideContainer overrideContainer = entity.getAttributeOverrideContainer();
- assertEquals(4, overrideContainer.getVirtualOverridesSize());
+ assertEquals(5, overrideContainer.getVirtualOverridesSize());
ListIterator<OrmVirtualAttributeOverride> virtualAttributeOverrides = overrideContainer.getVirtualOverrides().iterator();
OrmVirtualAttributeOverride virtualOverride = virtualAttributeOverrides.next();
assertEquals("foo", virtualOverride.getName());
virtualOverride = virtualAttributeOverrides.next();
assertEquals("basic", virtualOverride.getName());
virtualOverride = virtualAttributeOverrides.next();
+ assertEquals("version", virtualOverride.getName());
+ virtualOverride = virtualAttributeOverrides.next();
assertEquals("id", virtualOverride.getName());
virtualOverride = virtualAttributeOverrides.next();
assertEquals("name", virtualOverride.getName());
@@ -1696,21 +1698,25 @@ public class OrmEntityTests extends ContextModelTestCase
overrideContainer.getVirtualOverrides().iterator().next().convertToSpecified();
- assertEquals(3, overrideContainer.getVirtualOverridesSize());
+ assertEquals(4, overrideContainer.getVirtualOverridesSize());
virtualAttributeOverrides = overrideContainer.getVirtualOverrides().iterator();
virtualOverride = virtualAttributeOverrides.next();
assertEquals("basic", virtualOverride.getName());
virtualOverride = virtualAttributeOverrides.next();
+ assertEquals("version", virtualOverride.getName());
+ virtualOverride = virtualAttributeOverrides.next();
assertEquals("id", virtualOverride.getName());
virtualOverride = virtualAttributeOverrides.next();
assertEquals("name", virtualOverride.getName());
entity.setSpecifiedMetadataComplete(Boolean.TRUE);
- assertEquals(3, overrideContainer.getVirtualOverridesSize());
+ assertEquals(4, overrideContainer.getVirtualOverridesSize());
virtualAttributeOverrides = overrideContainer.getVirtualOverrides().iterator();
virtualOverride = virtualAttributeOverrides.next();
assertEquals("basic", virtualOverride.getName());
virtualOverride = virtualAttributeOverrides.next();
+ assertEquals("version", virtualOverride.getName());
+ virtualOverride = virtualAttributeOverrides.next();
assertEquals("id", virtualOverride.getName());
virtualOverride = virtualAttributeOverrides.next();
assertEquals("name", virtualOverride.getName());
@@ -1730,7 +1736,7 @@ public class OrmEntityTests extends ContextModelTestCase
javaColumn.setSpecifiedPrecision(Integer.valueOf(8));
javaColumn.setSpecifiedScale(Integer.valueOf(9));
- assertEquals(4, overrideContainer.getVirtualOverridesSize());
+ assertEquals(5, overrideContainer.getVirtualOverridesSize());
virtualAttributeOverrides = overrideContainer.getVirtualOverrides().iterator();
virtualOverride = virtualAttributeOverrides.next();
assertEquals("foo", virtualOverride.getName());
@@ -1751,6 +1757,8 @@ public class OrmEntityTests extends ContextModelTestCase
assertNull(virtualOverride.getColumn().getSpecifiedName());
assertEquals("basic", virtualOverride.getColumn().getDefaultName());
virtualOverride = virtualAttributeOverrides.next();
+ assertEquals("version", virtualOverride.getName());
+ virtualOverride = virtualAttributeOverrides.next();
assertEquals("id", virtualOverride.getName());
virtualOverride = virtualAttributeOverrides.next();
assertEquals("name", virtualOverride.getName());
@@ -1770,7 +1778,7 @@ public class OrmEntityTests extends ContextModelTestCase
- assertEquals(4, overrideContainer.getVirtualOverridesSize());
+ assertEquals(5, overrideContainer.getVirtualOverridesSize());
virtualAttributeOverrides = overrideContainer.getVirtualOverrides().iterator();
virtualOverride = virtualAttributeOverrides.next();
assertEquals("foo", virtualOverride.getName());
@@ -1798,6 +1806,8 @@ public class OrmEntityTests extends ContextModelTestCase
assertEquals(6, virtualOverride.getColumn().getPrecision());
assertEquals(7, virtualOverride.getColumn().getScale());
virtualOverride = virtualAttributeOverrides.next();
+ assertEquals("version", virtualOverride.getName());
+ virtualOverride = virtualAttributeOverrides.next();
assertEquals("id", virtualOverride.getName());
}
@@ -1812,13 +1822,15 @@ public class OrmEntityTests extends ContextModelTestCase
OrmAttributeOverrideContainer overrideContainer = entity.getAttributeOverrideContainer();
persistentType.getJavaPersistentType().setMappingKey(MappingKeys.NULL_TYPE_MAPPING_KEY);
- assertEquals(4, overrideContainer.getVirtualOverridesSize());
+ assertEquals(5, overrideContainer.getVirtualOverridesSize());
ListIterator<OrmVirtualAttributeOverride> virtualAttributeOverrides = overrideContainer.getVirtualOverrides().iterator();
OrmVirtualAttributeOverride attributeOverride = virtualAttributeOverrides.next();
assertEquals("foo", attributeOverride.getName());
attributeOverride = virtualAttributeOverrides.next();
assertEquals("basic", attributeOverride.getName());
attributeOverride = virtualAttributeOverrides.next();
+ assertEquals("version", attributeOverride.getName());
+ attributeOverride = virtualAttributeOverrides.next();
assertEquals("id", attributeOverride.getName());
attributeOverride = virtualAttributeOverrides.next();
assertEquals("name", attributeOverride.getName());
@@ -1921,6 +1933,7 @@ public class OrmEntityTests extends ContextModelTestCase
Iterator<String> overridableAttributes = entity.getAllOverridableAttributeNames().iterator();
assertEquals("foo", overridableAttributes.next());
assertEquals("basic", overridableAttributes.next());
+ assertEquals("version", overridableAttributes.next());
assertEquals("id", overridableAttributes.next());
assertEquals("name", overridableAttributes.next());
assertFalse(overridableAttributes.hasNext());

Back to the top