Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2008-05-09 12:42:57 +0000
committerkmoore2008-05-09 12:42:57 +0000
commit99bf3e6db865edf74bad8bfb09f41d4d97c0c719 (patch)
tree5665ebe720e3d8af931ee9c40bea222cd2a7df68
parentc55019e9f4f6e08ee10025d152a21ab9156eb62d (diff)
downloadwebtools.dali-99bf3e6db865edf74bad8bfb09f41d4d97c0c719.tar.gz
webtools.dali-99bf3e6db865edf74bad8bfb09f41d4d97c0c719.tar.xz
webtools.dali-99bf3e6db865edf74bad8bfb09f41d4d97c0c719.zip
229423 - incorrect validation for join column referencing attribute override
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaEntity.java34
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmEntity.java119
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEntityTests.java31
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEntityTests.java64
4 files changed, 191 insertions, 57 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaEntity.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaEntity.java
index 4feb77fd1a..9faaa496ef 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaEntity.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaEntity.java
@@ -265,7 +265,7 @@ public class GenericJavaEntity extends AbstractJavaTypeMapping implements JavaEn
protected void initializeVirtualAttributeOverrides(JavaResourcePersistentType persistentTypeResource) {
for (PersistentAttribute persistentAttribute : CollectionTools.iterable(allOverridableAttributes())) {
- JavaAttributeOverride attributeOverride = attributeOverrideNamed(persistentAttribute.getName());
+ JavaAttributeOverride attributeOverride = getAttributeOverrideNamed(persistentAttribute.getName());
if (attributeOverride == null) {
this.virtualAttributeOverrides.add(buildVirtualAttributeOverride(persistentTypeResource, persistentAttribute));
}
@@ -283,7 +283,7 @@ public class GenericJavaEntity extends AbstractJavaTypeMapping implements JavaEn
protected void initializeDefaultAssociationOverrides(JavaResourcePersistentType resourcePersistentType) {
for (Iterator<String> i = allOverridableAssociationNames(); i.hasNext(); ) {
String associationName = i.next();
- JavaAssociationOverride associationOverride = associationOverrideNamed(associationName);
+ JavaAssociationOverride associationOverride = getAssociationOverrideNamed(associationName);
if (associationOverride == null) {
this.virtualAssociationOverrides.add(buildAssociationOverride(new NullAssociationOverride(resourcePersistentType, associationName)));
}
@@ -855,8 +855,8 @@ public class GenericJavaEntity extends AbstractJavaTypeMapping implements JavaEn
removeItemFromList(attributeOverride, this.virtualAttributeOverrides, Entity.VIRTUAL_ATTRIBUTE_OVERRIDES_LIST);
}
- public JavaAttributeOverride attributeOverrideNamed(String name) {
- return (JavaAttributeOverride) overrideNamed(name, attributeOverrides());
+ public JavaAttributeOverride getAttributeOverrideNamed(String name) {
+ return (JavaAttributeOverride) getOverrideNamed(name, attributeOverrides());
}
public boolean containsAttributeOverride(String name) {
@@ -871,8 +871,8 @@ public class GenericJavaEntity extends AbstractJavaTypeMapping implements JavaEn
return containsOverride(name, specifiedAttributeOverrides());
}
- public JavaAssociationOverride associationOverrideNamed(String name) {
- return (JavaAssociationOverride) overrideNamed(name, associationOverrides());
+ public JavaAssociationOverride getAssociationOverrideNamed(String name) {
+ return (JavaAssociationOverride) getOverrideNamed(name, associationOverrides());
}
public boolean containsAssociationOverride(String name) {
@@ -887,7 +887,7 @@ public class GenericJavaEntity extends AbstractJavaTypeMapping implements JavaEn
return containsOverride(name, virtualAssociationOverrides());
}
- private BaseOverride overrideNamed(String name, ListIterator<? extends BaseOverride> overrides) {
+ private BaseOverride getOverrideNamed(String name, ListIterator<? extends BaseOverride> overrides) {
for (BaseOverride override : CollectionTools.iterable(overrides)) {
String overrideName = override.getName();
if (overrideName == null && name == null) {
@@ -901,7 +901,7 @@ public class GenericJavaEntity extends AbstractJavaTypeMapping implements JavaEn
}
private boolean containsOverride(String name, ListIterator<? extends BaseOverride> overrides) {
- return overrideNamed(name, overrides) != null;
+ return getOverrideNamed(name, overrides) != null;
}
@@ -1168,14 +1168,23 @@ public class GenericJavaEntity extends AbstractJavaTypeMapping implements JavaEn
}
public String getPrimaryKeyColumnName() {
- return primaryKeyColumnName(getPersistentType().allAttributes());
+ return getPrimaryKeyColumnName(getPersistentType().allAttributes());
}
- public static String primaryKeyColumnName(Iterator<PersistentAttribute> attributes) {
+ //copied in GenericOrmEntity to avoid an API change for fixing bug 229423 in RC1
+ public String getPrimaryKeyColumnName(Iterator<PersistentAttribute> attributes) {
String pkColumnName = null;
for (Iterator<PersistentAttribute> stream = attributes; stream.hasNext();) {
PersistentAttribute attribute = stream.next();
String name = attribute.getPrimaryKeyColumnName();
+ if (name != null) {
+ //if the attribute is a primary key then we need to check if there is an attribute override
+ //and use its column name instead (bug 229423)
+ AttributeOverride attributeOverride = getAttributeOverrideNamed(attribute.getName());
+ if (attributeOverride != null) {
+ name = attributeOverride.getColumn().getName();
+ }
+ }
if (pkColumnName == null) {
pkColumnName = name;
}
@@ -1186,7 +1195,6 @@ public class GenericJavaEntity extends AbstractJavaTypeMapping implements JavaEn
}
// if we encounter only a single primary key column name, return it
return pkColumnName;
-
}
@Override
@@ -1541,7 +1549,7 @@ public class GenericJavaEntity extends AbstractJavaTypeMapping implements JavaEn
protected void updateVirtualAttributeOverrides(JavaResourcePersistentType resourcePersistentType) {
for (PersistentAttribute persistentAttribute : CollectionTools.iterable(allOverridableAttributes())) {
- JavaAttributeOverride attributeOverride = attributeOverrideNamed(persistentAttribute.getName());
+ JavaAttributeOverride attributeOverride = getAttributeOverrideNamed(persistentAttribute.getName());
if (attributeOverride == null) {
addVirtualAttributeOverride(buildVirtualAttributeOverride(resourcePersistentType, persistentAttribute));
}
@@ -1589,7 +1597,7 @@ public class GenericJavaEntity extends AbstractJavaTypeMapping implements JavaEn
protected void updateVirtualAssociationOverrides(JavaResourcePersistentType resourcePersistentType) {
for (Iterator<String> i = allOverridableAssociationNames(); i.hasNext(); ) {
String associationName = i.next();
- JavaAssociationOverride associationOverride = associationOverrideNamed(associationName);
+ JavaAssociationOverride associationOverride = getAssociationOverrideNamed(associationName);
if (associationOverride == null) {
associationOverride = buildAssociationOverride(new NullAssociationOverride(resourcePersistentType, associationName));
addVirtualAssociationOverride(associationOverride);
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmEntity.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmEntity.java
index a58765e987..773b8248d1 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmEntity.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmEntity.java
@@ -54,7 +54,6 @@ import org.eclipse.jpt.core.context.orm.OrmSecondaryTable;
import org.eclipse.jpt.core.context.orm.OrmSequenceGenerator;
import org.eclipse.jpt.core.context.orm.OrmTable;
import org.eclipse.jpt.core.context.orm.OrmTableGenerator;
-import org.eclipse.jpt.core.internal.context.java.GenericJavaEntity;
import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.core.resource.orm.Inheritance;
@@ -703,29 +702,10 @@ public class GenericOrmEntity extends AbstractOrmTypeMapping<XmlEntity> implemen
public int specifiedAttributeOverridesSize() {
return this.specifiedAttributeOverrides.size();
}
-//
-// public OrmAttributeOverride addSpecifiedAttributeOverride(int index) {
-// XmlAttributeOverride xmlAttributeOverride = OrmFactory.eINSTANCE.createXmlAttributeOverrideImpl();
-// OrmAttributeOverride attributeOverride = buildAttributeOverride(xmlAttributeOverride);
-// this.specifiedAttributeOverrides.add(index, attributeOverride);
-// this.typeMappingResource().getAttributeOverrides().add(index, xmlAttributeOverride);
-// this.fireItemAdded(Entity.SPECIFIED_ATTRIBUTE_OVERRIDES_LIST, index, attributeOverride);
-// return attributeOverride;
-// }
protected void addSpecifiedAttributeOverride(int index, OrmAttributeOverride attributeOverride) {
addItemToList(index, attributeOverride, this.specifiedAttributeOverrides, Entity.SPECIFIED_ATTRIBUTE_OVERRIDES_LIST);
}
-//
-// public void removeSpecifiedAttributeOverride(AttributeOverride attributeOverride) {
-// removeSpecifiedAttributeOverride(this.specifiedAttributeOverrides.indexOf(attributeOverride));
-// }
-//
-// public void removeSpecifiedAttributeOverride(int index) {
-// OrmAttributeOverride removedAttributeOverride = this.specifiedAttributeOverrides.remove(index);
-// this.typeMappingResource().getAttributeOverrides().remove(index);
-// fireItemRemoved(Entity.SPECIFIED_ATTRIBUTE_OVERRIDES_LIST, index, removedAttributeOverride);
-// }
protected void removeSpecifiedAttributeOverride_(OrmAttributeOverride attributeOverride) {
removeItemFromList(attributeOverride, this.specifiedAttributeOverrides, Entity.SPECIFIED_ATTRIBUTE_OVERRIDES_LIST);
@@ -761,29 +741,10 @@ public class GenericOrmEntity extends AbstractOrmTypeMapping<XmlEntity> implemen
public int specifiedAssociationOverridesSize() {
return this.specifiedAssociationOverrides.size();
}
-//
-// public OrmAssociationOverride addSpecifiedAssociationOverride(int index) {
-// XmlAssociationOverride xmlAssociationOverride = OrmFactory.eINSTANCE.createXmlAssociationOverride();
-// OrmAssociationOverride associationOverride = buildAssociationOverride(xmlAssociationOverride);
-// this.specifiedAssociationOverrides.add(index, associationOverride);
-// this.typeMappingResource().getAssociationOverrides().add(index, xmlAssociationOverride);
-// this.fireItemAdded(Entity.SPECIFIED_ASSOCIATION_OVERRIDES_LIST, index, associationOverride);
-// return associationOverride;
-// }
protected void addSpecifiedAssociationOverride(int index, OrmAssociationOverride associationOverride) {
addItemToList(index, associationOverride, this.specifiedAssociationOverrides, Entity.SPECIFIED_ASSOCIATION_OVERRIDES_LIST);
}
-
-// public void removeSpecifiedAssociationOverride(AssociationOverride associationOverride) {
-// removeSpecifiedAssociationOverride(this.specifiedAssociationOverrides.indexOf(associationOverride));
-// }
-//
-// public void removeSpecifiedAssociationOverride(int index) {
-// OrmAssociationOverride removedAssociationOverride = this.specifiedAssociationOverrides.remove(index);
-// this.typeMappingResource().getAssociationOverrides().remove(index);
-// fireItemRemoved(Entity.SPECIFIED_ASSOCIATION_OVERRIDES_LIST, index, removedAssociationOverride);
-// }
protected void removeSpecifiedAssociationOverride_(OrmAssociationOverride associationOverride) {
removeItemFromList(associationOverride, this.specifiedAssociationOverrides, Entity.SPECIFIED_ASSOCIATION_OVERRIDES_LIST);
@@ -795,6 +756,56 @@ public class GenericOrmEntity extends AbstractOrmTypeMapping<XmlEntity> implemen
fireItemMoved(Entity.SPECIFIED_ASSOCIATION_OVERRIDES_LIST, targetIndex, sourceIndex);
}
+ public OrmAttributeOverride getAttributeOverrideNamed(String name) {
+ return (OrmAttributeOverride) getOverrideNamed(name, attributeOverrides());
+ }
+
+ public boolean containsAttributeOverride(String name) {
+ return containsOverride(name, attributeOverrides());
+ }
+
+ public boolean containsDefaultAttributeOverride(String name) {
+ return containsOverride(name, virtualAttributeOverrides());
+ }
+
+ public boolean containsSpecifiedAttributeOverride(String name) {
+ return containsOverride(name, specifiedAttributeOverrides());
+ }
+
+ public OrmAssociationOverride getAssociationOverrideNamed(String name) {
+ return (OrmAssociationOverride) getOverrideNamed(name, associationOverrides());
+ }
+
+ public boolean containsAssociationOverride(String name) {
+ return containsOverride(name, associationOverrides());
+ }
+
+ public boolean containsSpecifiedAssociationOverride(String name) {
+ return containsOverride(name, specifiedAssociationOverrides());
+ }
+
+ public boolean containsDefaultAssociationOverride(String name) {
+ return containsOverride(name, virtualAssociationOverrides());
+ }
+
+ private BaseOverride getOverrideNamed(String name, ListIterator<? extends BaseOverride> overrides) {
+ for (BaseOverride override : CollectionTools.iterable(overrides)) {
+ String overrideName = override.getName();
+ if (overrideName == null && name == null) {
+ return override;
+ }
+ if (overrideName != null && overrideName.equals(name)) {
+ return override;
+ }
+ }
+ return null;
+ }
+
+ private boolean containsOverride(String name, ListIterator<? extends BaseOverride> overrides) {
+ return getOverrideNamed(name, overrides) != null;
+ }
+
+
public ListIterator<OrmNamedQuery> namedQueries() {
return new CloneListIterator<OrmNamedQuery>(this.namedQueries);
}
@@ -1499,9 +1510,35 @@ public class GenericOrmEntity extends AbstractOrmTypeMapping<XmlEntity> implemen
// *************************************************************************
public String getPrimaryKeyColumnName() {
- return GenericJavaEntity.primaryKeyColumnName(getPersistentType().allAttributes());
+ return getPrimaryKeyColumnName(getPersistentType().allAttributes());
+ }
+
+ //copied in GenericJavaEntity to avoid an API change for fixing bug 229423 in RC1
+ public String getPrimaryKeyColumnName(Iterator<PersistentAttribute> attributes) {
+ String pkColumnName = null;
+ for (Iterator<PersistentAttribute> stream = attributes; stream.hasNext();) {
+ PersistentAttribute attribute = stream.next();
+ String name = attribute.getPrimaryKeyColumnName();
+ if (name != null) {
+ //if the attribute is a primary key then we need to check if there is an attribute override
+ //and use its column name instead (bug 229423)
+ AttributeOverride attributeOverride = getAttributeOverrideNamed(attribute.getName());
+ if (attributeOverride != null) {
+ name = attributeOverride.getColumn().getName();
+ }
+ }
+ if (pkColumnName == null) {
+ pkColumnName = name;
+ }
+ else if (name != null) {
+ // if we encounter a composite primary key, return null
+ return null;
+ }
+ }
+ // if we encounter only a single primary key column name, return it
+ return pkColumnName;
}
-
+
//********** Validation **************************
@Override
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEntityTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEntityTests.java
index 7b57b25965..311f899b94 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEntityTests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEntityTests.java
@@ -35,6 +35,7 @@ import org.eclipse.jpt.core.context.Table;
import org.eclipse.jpt.core.context.java.JavaAssociationOverride;
import org.eclipse.jpt.core.context.java.JavaAttributeOverride;
import org.eclipse.jpt.core.context.java.JavaEntity;
+import org.eclipse.jpt.core.context.java.JavaIdMapping;
import org.eclipse.jpt.core.context.java.JavaPersistentType;
import org.eclipse.jpt.core.context.java.JavaPrimaryKeyJoinColumn;
import org.eclipse.jpt.core.context.java.JavaSecondaryTable;
@@ -2898,5 +2899,33 @@ public class JavaEntityTests extends ContextModelTestCase
javaEntity().setIdClass(null);
assertNull(javaEntity().getIdClass());
assertNull(typeResource.getAnnotation(IdClassAnnotation.ANNOTATION_NAME));
- }
+ }
+
+ public void testGetPrimaryKeyColumnNameWithAttributeOverride() throws Exception {
+ createTestMappedSuperclass();
+ createTestSubType();
+ addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ Iterator<ClassRef> classRefs = persistenceUnit().specifiedClassRefs();
+ JavaPersistentType entityPersistentType = classRefs.next().getJavaPersistentType();
+ JavaEntity javaEntity = (JavaEntity) entityPersistentType.getMapping();
+ JavaPersistentType mappedSuperclassPersistentType = classRefs.next().getJavaPersistentType();
+
+ assertNull(javaEntity.getPrimaryKeyColumnName());
+
+ mappedSuperclassPersistentType.getAttributeNamed("id").setSpecifiedMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
+ assertEquals("id", javaEntity.getPrimaryKeyColumnName());
+
+ ((JavaIdMapping) mappedSuperclassPersistentType.getAttributeNamed("id").getMapping()).getColumn().setSpecifiedName("MY_ID");
+ assertEquals("MY_ID", javaEntity.getPrimaryKeyColumnName());
+
+ JavaAttributeOverride javaAttributeOverride = javaEntity.virtualAttributeOverrides().next();
+ assertEquals("id", javaAttributeOverride.getName());
+
+ javaAttributeOverride = (JavaAttributeOverride) javaAttributeOverride.setVirtual(false);
+ javaAttributeOverride.getColumn().setSpecifiedName("ID");
+ assertEquals("ID", javaEntity.getPrimaryKeyColumnName());
+ }
+
}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEntityTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEntityTests.java
index 1b3e0e13f0..918b66f937 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEntityTests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEntityTests.java
@@ -23,6 +23,7 @@ import org.eclipse.jpt.core.context.orm.OrmAssociationOverride;
import org.eclipse.jpt.core.context.orm.OrmAttributeOverride;
import org.eclipse.jpt.core.context.orm.OrmEmbeddable;
import org.eclipse.jpt.core.context.orm.OrmEntity;
+import org.eclipse.jpt.core.context.orm.OrmIdMapping;
import org.eclipse.jpt.core.context.orm.OrmMappedSuperclass;
import org.eclipse.jpt.core.context.orm.OrmNamedNativeQuery;
import org.eclipse.jpt.core.context.orm.OrmNamedQuery;
@@ -64,6 +65,10 @@ public class OrmEntityTests extends ContextModelTestCase
this.createAnnotationAndMembers("Id", "");
}
+ private void createMappedSuperclassAnnotation() throws Exception{
+ this.createAnnotationAndMembers("MappedSuperclass", "");
+ }
+
private IType createTestEntityDefaultFieldAccess() throws Exception {
createEntityAnnotation();
@@ -137,7 +142,37 @@ public class OrmEntityTests extends ContextModelTestCase
return this.javaProject.createType(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter);
}
-
+
+ private IType createTestMappedSuperclass() throws Exception {
+ createMappedSuperclassAnnotation();
+
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS, JPA.ONE_TO_ONE);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@MappedSuperclass");
+ }
+
+ @Override
+ public void appendGetIdMethodAnnotationTo(StringBuilder sb) {
+ sb.append("private String foo;").append(CR);
+ sb.append(CR);
+ sb.append(" @OneToOne");
+ sb.append(CR);
+ sb.append(" private int address;").append(CR);
+ sb.append(CR);
+ sb.append(" @OneToOne");
+ sb.append(CR);
+ sb.append(" private int address2;").append(CR);
+ sb.append(CR);
+ sb.append(" ");
+ }
+ });
+ }
+
public void testUpdateSpecifiedName() throws Exception {
OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo");
OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
@@ -1277,7 +1312,7 @@ public class OrmEntityTests extends ContextModelTestCase
entityResource.getPrimaryKeyJoinColumns().remove(0);
assertFalse(ormEntity.specifiedPrimaryKeyJoinColumns().hasNext());
}
-
+
// public void testAddSpecifiedAttributeOverride() throws Exception {
// OrmPersistentType persistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
// OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
@@ -1906,4 +1941,29 @@ public class OrmEntityTests extends ContextModelTestCase
assertNull(entityResource.getIdClass());
}
+
+ public void testGetPrimaryKeyColumnNameWithAttributeOverride() throws Exception {
+ createTestMappedSuperclass();
+ createTestSubType();
+ OrmPersistentType parentPersistentType = entityMappings().addOrmPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ OrmPersistentType childPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".AnnotationTestTypeChild");
+ OrmEntity childXmlEntity = (OrmEntity) childPersistentType.getMapping();
+
+ assertNull(childXmlEntity.getPrimaryKeyColumnName());
+
+ parentPersistentType.getAttributeNamed("id").makeSpecified(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
+ assertEquals("id", childXmlEntity.getPrimaryKeyColumnName());
+
+ ((OrmIdMapping) parentPersistentType.getAttributeNamed("id").getMapping()).getColumn().setSpecifiedName("MY_ID");
+ assertEquals("MY_ID", childXmlEntity.getPrimaryKeyColumnName());
+
+ //TODO once bug 228718 is fixed
+// OrmAttributeOverride ormAttributeOverride = childXmlEntity.virtualAttributeOverrides().next();
+// assertEquals("id", ormAttributeOverride.getName());
+//
+// ormAttributeOverride = (OrmAttributeOverride) ormAttributeOverride.setVirtual(false);
+// ormAttributeOverride.getColumn().setSpecifiedName("ID");
+// assertEquals("ID", childXmlEntity.getPrimaryKeyColumnName());
+ }
+
} \ No newline at end of file

Back to the top