diff options
Diffstat (limited to 'jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa')
30 files changed, 1411 insertions, 1202 deletions
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/GenericOrmPersistentAttributeTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/GenericOrmPersistentAttributeTests.java index ce45b8a0d2..0d507b4a56 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/GenericOrmPersistentAttributeTests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/GenericOrmPersistentAttributeTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2011 Oracle. All rights reserved. + * Copyright (c) 2008, 2012 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -99,23 +99,23 @@ public class GenericOrmPersistentAttributeTests extends ContextModelTestCase createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - assertEquals(2, ormPersistentType.getVirtualAttributesSize()); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); - OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); assertEquals("id", ormPersistentAttribute.getName()); assertTrue(ormPersistentAttribute.isVirtual()); - ormPersistentAttribute.convertToSpecified(); + ormPersistentAttribute.addToXml(); - assertEquals(1, ormPersistentType.getVirtualAttributesSize()); + assertEquals(1, ormPersistentType.getDefaultAttributesSize()); assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); OrmPersistentAttribute specifiedOrmPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); assertEquals("id", specifiedOrmPersistentAttribute.getName()); assertFalse(specifiedOrmPersistentAttribute.isVirtual()); - ormPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); - ormPersistentAttribute.convertToSpecified(); + ormPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); + ormPersistentAttribute.addToXml(); - assertEquals(0, ormPersistentType.getVirtualAttributesSize()); + assertEquals(0, ormPersistentType.getDefaultAttributesSize()); assertEquals(2, ormPersistentType.getSpecifiedAttributesSize()); Iterator<OrmPersistentAttribute> specifiedAttributes = ormPersistentType.getSpecifiedAttributes().iterator(); specifiedOrmPersistentAttribute = specifiedAttributes.next(); @@ -131,16 +131,16 @@ public class GenericOrmPersistentAttributeTests extends ContextModelTestCase createTestTypeNullAttributeMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); + assertEquals(3, ormPersistentType.getDefaultAttributesSize()); //take a virtual mapping with a mapping type and make it specified - OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); assertEquals("address", ormPersistentAttribute.getName()); assertTrue(ormPersistentAttribute.isVirtual()); assertNull(ormPersistentAttribute.getMapping().getKey()); - ormPersistentAttribute.convertToSpecified(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); + ormPersistentAttribute.addToXml(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); - assertEquals(2, ormPersistentType.getVirtualAttributesSize()); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); OrmPersistentAttribute specifiedOrmPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); assertEquals("address", specifiedOrmPersistentAttribute.getName()); @@ -148,10 +148,10 @@ public class GenericOrmPersistentAttributeTests extends ContextModelTestCase assertTrue(specifiedOrmPersistentAttribute.getMapping() instanceof GenericOrmOneToOneMapping); - ormPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); - ormPersistentAttribute.convertToSpecified(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); + ormPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); + ormPersistentAttribute.addToXml(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); - assertEquals(1, ormPersistentType.getVirtualAttributesSize()); + assertEquals(1, ormPersistentType.getDefaultAttributesSize()); assertEquals(2, ormPersistentType.getSpecifiedAttributesSize()); Iterator<OrmPersistentAttribute> specifiedAttributes = ormPersistentType.getSpecifiedAttributes().iterator(); @@ -169,27 +169,27 @@ public class GenericOrmPersistentAttributeTests extends ContextModelTestCase createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - assertEquals(2, ormPersistentType.getVirtualAttributesSize()); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); - ormPersistentType.getVirtualAttributes().iterator().next().convertToSpecified(); - ormPersistentType.getVirtualAttributes().iterator().next().convertToSpecified(); + ormPersistentType.getDefaultAttributes().iterator().next().addToXml(); + ormPersistentType.getDefaultAttributes().iterator().next().addToXml(); - assertEquals(0, ormPersistentType.getVirtualAttributesSize()); + assertEquals(0, ormPersistentType.getDefaultAttributesSize()); assertEquals(2, ormPersistentType.getSpecifiedAttributesSize()); OrmPersistentAttribute specifiedOrmPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); assertEquals("id", specifiedOrmPersistentAttribute.getName()); assertFalse(specifiedOrmPersistentAttribute.isVirtual()); - specifiedOrmPersistentAttribute.convertToVirtual(); - assertEquals(1, ormPersistentType.getVirtualAttributesSize()); + specifiedOrmPersistentAttribute.removeFromXml(); + assertEquals(1, ormPersistentType.getDefaultAttributesSize()); assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); specifiedOrmPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); - specifiedOrmPersistentAttribute.convertToVirtual(); - assertEquals(2, ormPersistentType.getVirtualAttributesSize()); + specifiedOrmPersistentAttribute.removeFromXml(); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); assertEquals(0, ormPersistentType.getSpecifiedAttributesSize()); - Iterator<OrmReadOnlyPersistentAttribute> virtualAttributes = ormPersistentType.getVirtualAttributes().iterator(); + Iterator<OrmReadOnlyPersistentAttribute> virtualAttributes = ormPersistentType.getDefaultAttributes().iterator(); OrmReadOnlyPersistentAttribute virtualAttribute = virtualAttributes.next(); assertEquals("id", virtualAttribute.getName()); virtualAttribute = virtualAttributes.next(); @@ -200,23 +200,23 @@ public class GenericOrmPersistentAttributeTests extends ContextModelTestCase createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - assertEquals(2, ormPersistentType.getVirtualAttributesSize()); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); - ormPersistentType.getVirtualAttributes().iterator().next().convertToSpecified(); - ormPersistentType.getVirtualAttributes().iterator().next().convertToSpecified(); + ormPersistentType.getDefaultAttributes().iterator().next().addToXml(); + ormPersistentType.getDefaultAttributes().iterator().next().addToXml(); ormPersistentType.getSpecifiedAttributes().iterator().next().getMapping().setName("noJavaAttribute"); - assertEquals(1, ormPersistentType.getVirtualAttributesSize()); + assertEquals(1, ormPersistentType.getDefaultAttributesSize()); assertEquals(2, ormPersistentType.getSpecifiedAttributesSize()); OrmPersistentAttribute specifiedOrmPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); - specifiedOrmPersistentAttribute.convertToVirtual(); - assertEquals(1, ormPersistentType.getVirtualAttributesSize()); + specifiedOrmPersistentAttribute.removeFromXml(); + assertEquals(1, ormPersistentType.getDefaultAttributesSize()); assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); - assertEquals("id", ormPersistentType.getVirtualAttributes().iterator().next().getName()); + assertEquals("id", ormPersistentType.getDefaultAttributes().iterator().next().getName()); assertEquals("name", ormPersistentType.getSpecifiedAttributes().iterator().next().getName()); } @@ -224,7 +224,7 @@ public class GenericOrmPersistentAttributeTests extends ContextModelTestCase createTestEntityIdMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); assertEquals("id", ormPersistentAttribute.getName()); assertEquals(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMappingKey()); assertEquals("FOO", ((IdMapping) ormPersistentAttribute.getMapping()).getColumn().getName()); @@ -242,7 +242,7 @@ public class GenericOrmPersistentAttributeTests extends ContextModelTestCase createTestEntityOneToOneMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); assertEquals("address", ormPersistentAttribute.getName()); assertEquals(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMappingKey()); @@ -273,7 +273,7 @@ public class GenericOrmPersistentAttributeTests extends ContextModelTestCase //specified orm attribute, access type matches java : FIELD, name matches java //javaPersistentAttribute should be == to java context model object - ormPersistentAttribute.convertToSpecified(); + ormPersistentAttribute.addToXml(); ormPersistentAttribute = ormPersistentType.getAttributeNamed("id"); assertFalse(ormPersistentAttribute.isVirtual()); assertEquals(javaPersistentAttribute, ormPersistentAttribute.getJavaPersistentAttribute()); @@ -282,7 +282,7 @@ public class GenericOrmPersistentAttributeTests extends ContextModelTestCase //virtual orm attribute, java access type FIELD, orm access type PROPERTY, name matches java //verify both the property java resource attribute and the field java resource attribute are used in orm //because the field is annotated and property is specified - ((OrmPersistentAttribute) ormPersistentAttribute).convertToVirtual(); + ((OrmPersistentAttribute) ormPersistentAttribute).removeFromXml(); ormPersistentAttribute = ormPersistentType.getAttributeNamed("id"); ormPersistentType.setSpecifiedAccess(AccessType.PROPERTY); ListIterator<OrmReadOnlyPersistentAttribute> attributes = ormPersistentType.getAttributes().iterator(); @@ -302,7 +302,7 @@ public class GenericOrmPersistentAttributeTests extends ContextModelTestCase ormPersistentType.setSpecifiedAccess(null);//default access will be field ormPersistentAttribute = ormPersistentType.getAttributeNamed("id"); - OrmPersistentAttribute ormPersistentAttribute2 = ormPersistentAttribute.convertToSpecified(); + OrmPersistentAttribute ormPersistentAttribute2 = ormPersistentAttribute.addToXml(); ormPersistentAttribute2.getMapping().setName("id2"); assertEquals(null, ormPersistentAttribute2.getJavaPersistentAttribute()); diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/GenericOrmPersistentTypeTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/GenericOrmPersistentTypeTests.java index b35ba86429..cfe190a4a2 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/GenericOrmPersistentTypeTests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/GenericOrmPersistentTypeTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Oracle. All rights reserved. + * Copyright (c) 2007, 2012 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -164,135 +164,63 @@ public class GenericOrmPersistentTypeTests extends ContextModelTestCase assertEquals("model.Foo3", getXmlEntityMappings().getEmbeddables().get(1).getClassName()); } - public void testAddSpecifiedPersistentAttribute() throws Exception { - OrmPersistentType entityPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo2"); - - entityPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicAttribute"); - - XmlEntity entity = getXmlEntityMappings().getEntities().get(0); - XmlBasic basic = entity.getAttributes().getBasics().get(0); - assertEquals("basicAttribute", basic.getName()); - - entityPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embeddedAttribute"); - - XmlEmbedded embedded = entity.getAttributes().getEmbeddeds().get(0); - assertEquals("embeddedAttribute", embedded.getName()); - - entityPersistentType.addSpecifiedAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "transientAttribute"); - - XmlTransient transientResource = entity.getAttributes().getTransients().get(0); - assertEquals("transientAttribute", transientResource.getName()); - - entityPersistentType.addSpecifiedAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "versionAttribute"); - - XmlVersion version = entity.getAttributes().getVersions().get(0); - assertEquals("versionAttribute", version.getName()); - - entityPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idAttribute"); - - XmlId id = entity.getAttributes().getIds().get(0); - assertEquals("idAttribute", id.getName()); - - - Iterator<OrmPersistentAttribute> persistentAttributes = entityPersistentType.getSpecifiedAttributes().iterator(); - assertEquals("idAttribute", persistentAttributes.next().getName()); - assertEquals("basicAttribute", persistentAttributes.next().getName()); - assertEquals("versionAttribute", persistentAttributes.next().getName()); - assertEquals("embeddedAttribute", persistentAttributes.next().getName()); - assertEquals("transientAttribute", persistentAttributes.next().getName()); - assertFalse(persistentAttributes.hasNext()); - } - - public void testRemoveSpecifiedPersistentAttribute() throws Exception { - OrmPersistentType entityPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo2"); - - entityPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicAttribute"); - entityPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embeddedAttribute"); - entityPersistentType.addSpecifiedAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "versionAttribute"); - entityPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idAttribute"); - entityPersistentType.addSpecifiedAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "transientAttribute"); - - XmlEntity entity = getXmlEntityMappings().getEntities().get(0); - assertEquals("basicAttribute", entity.getAttributes().getBasics().get(0).getName()); - assertEquals("embeddedAttribute", entity.getAttributes().getEmbeddeds().get(0).getName()); - assertEquals("versionAttribute", entity.getAttributes().getVersions().get(0).getName()); - assertEquals("idAttribute", entity.getAttributes().getIds().get(0).getName()); - assertEquals("transientAttribute", entity.getAttributes().getTransients().get(0).getName()); - - ((OrmPersistentAttribute) entityPersistentType.getAttributeNamed("basicAttribute")).convertToVirtual(); - assertEquals("embeddedAttribute", entity.getAttributes().getEmbeddeds().get(0).getName()); - assertEquals("versionAttribute", entity.getAttributes().getVersions().get(0).getName()); - assertEquals("idAttribute", entity.getAttributes().getIds().get(0).getName()); - assertEquals("transientAttribute", entity.getAttributes().getTransients().get(0).getName()); - - ((OrmPersistentAttribute) entityPersistentType.getAttributeNamed("embeddedAttribute")).convertToVirtual(); - assertEquals("versionAttribute", entity.getAttributes().getVersions().get(0).getName()); - assertEquals("idAttribute", entity.getAttributes().getIds().get(0).getName()); - assertEquals("transientAttribute", entity.getAttributes().getTransients().get(0).getName()); - - ((OrmPersistentAttribute) entityPersistentType.getAttributeNamed("versionAttribute")).convertToVirtual(); - assertEquals("idAttribute", entity.getAttributes().getIds().get(0).getName()); - assertEquals("transientAttribute", entity.getAttributes().getTransients().get(0).getName()); - - ((OrmPersistentAttribute) entityPersistentType.getAttributeNamed("idAttribute")).convertToVirtual(); - assertEquals("transientAttribute", entity.getAttributes().getTransients().get(0).getName()); - - ((OrmPersistentAttribute) entityPersistentType.getAttributeNamed("transientAttribute")).convertToVirtual(); - assertNull(entity.getAttributes()); - } - public void testRemoveId() throws Exception { - OrmPersistentType entityPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo2"); + createTestType(); + OrmPersistentType entityPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + entityPersistentType.addAttributeToXml(entityPersistentType.getAttributeNamed("id"), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); XmlEntity entity = getXmlEntityMappings().getEntities().get(0); - entityPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idAttribute"); - assertEquals("idAttribute", entity.getAttributes().getIds().get(0).getName()); + assertEquals("id", entity.getAttributes().getIds().get(0).getName()); - ((OrmPersistentAttribute) entityPersistentType.getAttributeNamed("idAttribute")).convertToVirtual(); + ((OrmPersistentAttribute) entityPersistentType.getAttributeNamed("id")).removeFromXml(); assertNull(entity.getAttributes()); } public void testRemoveBasic() throws Exception { - OrmPersistentType entityPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo2"); + createTestType(); + OrmPersistentType entityPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + entityPersistentType.addAttributeToXml(entityPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); XmlEntity entity = getXmlEntityMappings().getEntities().get(0); - entityPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicAttribute"); - assertEquals("basicAttribute", entity.getAttributes().getBasics().get(0).getName()); + assertEquals("id", entity.getAttributes().getBasics().get(0).getName()); - ((OrmPersistentAttribute) entityPersistentType.getAttributeNamed("basicAttribute")).convertToVirtual(); + ((OrmPersistentAttribute) entityPersistentType.getAttributeNamed("id")).removeFromXml(); assertNull(entity.getAttributes()); } public void testRemoveVersion() throws Exception { - OrmPersistentType entityPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo2"); + createTestType(); + OrmPersistentType entityPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + entityPersistentType.addAttributeToXml(entityPersistentType.getAttributeNamed("id"), MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY); XmlEntity entity = getXmlEntityMappings().getEntities().get(0); - entityPersistentType.addSpecifiedAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "versionAttribute"); - assertEquals("versionAttribute", entity.getAttributes().getVersions().get(0).getName()); + assertEquals("id", entity.getAttributes().getVersions().get(0).getName()); - ((OrmPersistentAttribute) entityPersistentType.getAttributeNamed("versionAttribute")).convertToVirtual(); + ((OrmPersistentAttribute) entityPersistentType.getAttributeNamed("id")).removeFromXml(); assertNull(entity.getAttributes()); } public void testRemoveEmbedded() throws Exception { - OrmPersistentType entityPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo2"); + createTestType(); + OrmPersistentType entityPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + entityPersistentType.addAttributeToXml(entityPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); XmlEntity entity = getXmlEntityMappings().getEntities().get(0); - entityPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embeddedAttribute"); - assertEquals("embeddedAttribute", entity.getAttributes().getEmbeddeds().get(0).getName()); + assertEquals("id", entity.getAttributes().getEmbeddeds().get(0).getName()); - ((OrmPersistentAttribute) entityPersistentType.getAttributeNamed("embeddedAttribute")).convertToVirtual(); + ((OrmPersistentAttribute) entityPersistentType.getAttributeNamed("id")).removeFromXml(); assertNull(entity.getAttributes()); } public void testRemoveTransient() throws Exception { - OrmPersistentType entityPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo2"); + createTestType(); + OrmPersistentType entityPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + entityPersistentType.addAttributeToXml(entityPersistentType.getAttributeNamed("id"), MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY); XmlEntity entity = getXmlEntityMappings().getEntities().get(0); - entityPersistentType.addSpecifiedAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "transientAttribute"); - assertEquals("transientAttribute", entity.getAttributes().getTransients().get(0).getName()); + assertEquals("id", entity.getAttributes().getTransients().get(0).getName()); - ((OrmPersistentAttribute) entityPersistentType.getAttributeNamed("transientAttribute")).convertToVirtual(); + ((OrmPersistentAttribute) entityPersistentType.getAttributeNamed("id")).removeFromXml(); assertNull(entity.getAttributes()); } @@ -548,8 +476,6 @@ public class GenericOrmPersistentTypeTests extends ContextModelTestCase assertFalse(entityPersistentType.getAttributes().iterator().hasNext()); assertNotNull(entity.getAttributes()); } - - public void testInheritedAttributesResolve() throws Exception { createModelType(); @@ -558,9 +484,11 @@ public class GenericOrmPersistentTypeTests extends ContextModelTestCase OrmPersistentType employeePersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_EMPLOYEE_TYPE_NAME); - employeePersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "id"); - employeePersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "name"); - OrmPersistentAttribute startDateAttribute = employeePersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "startDate"); + OrmPersistentAttribute attribute = employeePersistentType.addAttributeToXml(employeePersistentType.getAttributeNamed("startDate"), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); + attribute.getMapping().setName("id"); + attribute = employeePersistentType.addAttributeToXml(employeePersistentType.getAttributeNamed("startDate"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); + attribute.getMapping().setName("name"); + OrmPersistentAttribute startDateAttribute = employeePersistentType.addAttributeToXml(employeePersistentType.getAttributeNamed("startDate"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); ((OrmBasicMapping) startDateAttribute.getMapping()).setConverter(TemporalConverter.class); ((TemporalConverter) ((OrmBasicMapping) startDateAttribute.getMapping()).getConverter()).setTemporalType(TemporalType.DATE); diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmBasicMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmBasicMappingTests.java index d3b18d40a3..65e40de006 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmBasicMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmBasicMappingTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Oracle. All rights reserved. + * Copyright (c) 2007, 2012 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -85,13 +85,14 @@ public class OrmBasicMappingTests extends ContextModelTestCase } public void testUpdateName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); XmlBasic basicResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0); - assertEquals("basicMapping", ormBasicMapping.getName()); - assertEquals("basicMapping", basicResource.getName()); + assertEquals("id", ormBasicMapping.getName()); + assertEquals("id", basicResource.getName()); //set name in the resource model, verify context model updated basicResource.setName("newName"); @@ -105,13 +106,14 @@ public class OrmBasicMappingTests extends ContextModelTestCase } public void testModifyName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); XmlBasic basicResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0); - assertEquals("basicMapping", ormBasicMapping.getName()); - assertEquals("basicMapping", basicResource.getName()); + assertEquals("id", ormBasicMapping.getName()); + assertEquals("id", basicResource.getName()); //set name in the context model, verify resource model updated ormBasicMapping.setName("newName"); @@ -125,8 +127,9 @@ public class OrmBasicMappingTests extends ContextModelTestCase } public void testUpdateSpecifiedFetch() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); XmlBasic basicResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0); @@ -149,8 +152,9 @@ public class OrmBasicMappingTests extends ContextModelTestCase } public void testModifySpecifiedFetch() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); XmlBasic basicResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0); @@ -173,8 +177,9 @@ public class OrmBasicMappingTests extends ContextModelTestCase } public void testUpdateSpecifiedEnumerated() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); XmlBasic basicResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0); @@ -197,8 +202,9 @@ public class OrmBasicMappingTests extends ContextModelTestCase } public void testModifySpecifiedEnumerated() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); XmlBasic basicResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0); @@ -222,8 +228,9 @@ public class OrmBasicMappingTests extends ContextModelTestCase } public void testUpdateSpecifiedOptional() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); XmlBasic basicResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0); @@ -246,8 +253,9 @@ public class OrmBasicMappingTests extends ContextModelTestCase } public void testModifySpecifiedOptional() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); XmlBasic basicResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0); @@ -270,8 +278,9 @@ public class OrmBasicMappingTests extends ContextModelTestCase } public void testUpdateSpecifiedLob() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); XmlBasic basicResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0); @@ -290,8 +299,9 @@ public class OrmBasicMappingTests extends ContextModelTestCase } public void testModifySpecifiedLob() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); XmlBasic basicResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0); @@ -310,8 +320,9 @@ public class OrmBasicMappingTests extends ContextModelTestCase } public void testUpdateTemporal() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); XmlBasic basicResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0); @@ -338,8 +349,9 @@ public class OrmBasicMappingTests extends ContextModelTestCase } public void testModifyTemporal() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); XmlBasic basicResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0); @@ -374,11 +386,12 @@ public class OrmBasicMappingTests extends ContextModelTestCase createTestEntityBasicMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "foo"); - assertEquals(2, ormPersistentType.getVirtualAttributesSize()); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); + assertEquals(1, ormPersistentType.getDefaultAttributesSize()); OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); + ormBasicMapping.setName("foo"); assertEquals("foo", ormBasicMapping.getName()); assertNull(ormBasicMapping.getConverter().getType()); @@ -422,8 +435,8 @@ public class OrmBasicMappingTests extends ContextModelTestCase public void testVirtualMappingMetadataCompleteFalse() throws Exception { createTestEntityBasicMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - assertEquals(2, ormPersistentType.getVirtualAttributesSize()); - OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); + OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); BasicMapping basicMapping = (BasicMapping) ormPersistentAttribute.getMapping(); assertEquals("id", basicMapping.getName()); @@ -449,8 +462,8 @@ public class OrmBasicMappingTests extends ContextModelTestCase createTestEntityBasicMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE); - assertEquals(2, ormPersistentType.getVirtualAttributesSize()); - OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); + OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); BasicMapping basicMapping = (BasicMapping) ormPersistentAttribute.getMapping(); assertEquals("id", basicMapping.getName()); @@ -475,8 +488,8 @@ public class OrmBasicMappingTests extends ContextModelTestCase createTestEntityBasicMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "id"); - assertEquals(1, ormPersistentType.getVirtualAttributesSize()); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); + assertEquals(1, ormPersistentType.getDefaultAttributesSize()); OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); @@ -521,7 +534,7 @@ public class OrmBasicMappingTests extends ContextModelTestCase public void testBasicMorphToIdMapping() throws Exception { createTestEntityBasicMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basic"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); BasicMapping basicMapping = (BasicMapping) ormPersistentAttribute.getMapping(); assertFalse(basicMapping.isDefault()); @@ -536,14 +549,14 @@ public class OrmBasicMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof IdMapping); - assertEquals("basic", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); assertEquals("FOO", ((IdMapping) ormPersistentAttribute.getMapping()).getColumn().getSpecifiedName()); } public void testBasicMorphToVersionMapping() throws Exception { createTestEntityBasicMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basic"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); BasicMapping basicMapping = (BasicMapping) ormPersistentAttribute.getMapping(); assertFalse(basicMapping.isDefault()); @@ -558,14 +571,14 @@ public class OrmBasicMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof VersionMapping); - assertEquals("basic", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); assertEquals("FOO", ((VersionMapping) ormPersistentAttribute.getMapping()).getColumn().getSpecifiedName()); } public void testBasicMorphToTransientMapping() throws Exception { createTestEntityBasicMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basic"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); BasicMapping basicMapping = (BasicMapping) ormPersistentAttribute.getMapping(); assertFalse(basicMapping.isDefault()); @@ -580,13 +593,13 @@ public class OrmBasicMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof TransientMapping); - assertEquals("basic", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testBasicMorphToEmbeddedMapping() throws Exception { createTestEntityBasicMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basic"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); BasicMapping basicMapping = (BasicMapping) ormPersistentAttribute.getMapping(); assertFalse(basicMapping.isDefault()); @@ -601,13 +614,13 @@ public class OrmBasicMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedMapping); - assertEquals("basic", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testBasicMorphToEmbeddedIdMapping() throws Exception { createTestEntityBasicMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basic"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); BasicMapping basicMapping = (BasicMapping) ormPersistentAttribute.getMapping(); assertFalse(basicMapping.isDefault()); @@ -622,13 +635,13 @@ public class OrmBasicMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedIdMapping); - assertEquals("basic", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testBasicMorphToOneToOneMapping() throws Exception { createTestEntityBasicMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basic"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); BasicMapping basicMapping = (BasicMapping) ormPersistentAttribute.getMapping(); assertFalse(basicMapping.isDefault()); @@ -643,13 +656,13 @@ public class OrmBasicMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof OneToOneMapping); - assertEquals("basic", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testBasicMorphToOneToManyMapping() throws Exception { createTestEntityBasicMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basic"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); BasicMapping basicMapping = (BasicMapping) ormPersistentAttribute.getMapping(); assertFalse(basicMapping.isDefault()); @@ -664,13 +677,13 @@ public class OrmBasicMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof OneToManyMapping); - assertEquals("basic", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testBasicMorphToManyToOneMapping() throws Exception { createTestEntityBasicMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basic"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); BasicMapping basicMapping = (BasicMapping) ormPersistentAttribute.getMapping(); assertFalse(basicMapping.isDefault()); @@ -685,13 +698,13 @@ public class OrmBasicMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToOneMapping); - assertEquals("basic", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testBasicMorphToManyToManyMapping() throws Exception { createTestEntityBasicMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basic"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); BasicMapping basicMapping = (BasicMapping) ormPersistentAttribute.getMapping(); assertFalse(basicMapping.isDefault()); @@ -706,6 +719,6 @@ public class OrmBasicMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToManyMapping); - assertEquals("basic", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } }
\ No newline at end of file diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmCascadeTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmCascadeTests.java index c7cc548907..e22566cfc9 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmCascadeTests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmCascadeTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * Copyright (c) 2007, 2012 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -39,8 +39,9 @@ public class OrmCascadeTests extends ContextModelTestCase } public void testUpdateCascadeAll() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); XmlOneToOne oneToOne = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); Cascade cascade = ormOneToOneMapping.getCascade(); @@ -65,8 +66,9 @@ public class OrmCascadeTests extends ContextModelTestCase } public void testModifyCascadeAll() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); XmlOneToOne oneToOne = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); @@ -87,8 +89,9 @@ public class OrmCascadeTests extends ContextModelTestCase } public void testUpdateCascadePersist() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); XmlOneToOne oneToOne = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); Cascade cascade = ormOneToOneMapping.getCascade(); @@ -113,8 +116,9 @@ public class OrmCascadeTests extends ContextModelTestCase } public void testModifyCascadePersist() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); XmlOneToOne oneToOne = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); @@ -135,8 +139,9 @@ public class OrmCascadeTests extends ContextModelTestCase } public void testUpdateCascadeMerge() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); XmlOneToOne oneToOne = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); Cascade cascade = ormOneToOneMapping.getCascade(); @@ -161,8 +166,9 @@ public class OrmCascadeTests extends ContextModelTestCase } public void testModifyCascadeMerge() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); XmlOneToOne oneToOne = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); @@ -183,8 +189,9 @@ public class OrmCascadeTests extends ContextModelTestCase } public void testUpdateCascadeRemove() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); XmlOneToOne oneToOne = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); Cascade cascade = ormOneToOneMapping.getCascade(); @@ -209,8 +216,9 @@ public class OrmCascadeTests extends ContextModelTestCase } public void testModifyCascadeRemove() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); XmlOneToOne oneToOne = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); @@ -231,8 +239,9 @@ public class OrmCascadeTests extends ContextModelTestCase } public void testUpdateCascadeRefresh() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); XmlOneToOne oneToOne = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); Cascade cascade = ormOneToOneMapping.getCascade(); @@ -257,8 +266,9 @@ public class OrmCascadeTests extends ContextModelTestCase } public void testModifyCascadeRefresh() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); XmlOneToOne oneToOne = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmColumnTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmColumnTests.java index 2db4c1b957..a903d3793f 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmColumnTests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmColumnTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Oracle. All rights reserved. + * Copyright (c) 2007, 2012 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -16,6 +16,7 @@ import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; import org.eclipse.jpt.jpa.core.MappingKeys; import org.eclipse.jpt.jpa.core.context.BasicMapping; import org.eclipse.jpt.jpa.core.context.Column; +import org.eclipse.jpt.jpa.core.context.ReadOnlyColumn; import org.eclipse.jpt.jpa.core.context.java.JavaBasicMapping; import org.eclipse.jpt.jpa.core.context.java.JavaColumn; import org.eclipse.jpt.jpa.core.context.orm.OrmBasicMapping; @@ -66,8 +67,9 @@ public class OrmColumnTests extends ContextModelTestCase } public void testUpdateSpecifiedName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); OrmColumn ormColumn = ormBasicMapping.getColumn(); @@ -98,8 +100,9 @@ public class OrmColumnTests extends ContextModelTestCase } public void testModifySpecifiedName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); OrmColumn ormColumn = ormBasicMapping.getColumn(); @@ -121,8 +124,9 @@ public class OrmColumnTests extends ContextModelTestCase } public void testUpdateColumnDefinition() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); OrmColumn ormColumn = ormBasicMapping.getColumn(); @@ -153,8 +157,9 @@ public class OrmColumnTests extends ContextModelTestCase } public void testModifyColumnDefinition() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); OrmColumn ormColumn = ormBasicMapping.getColumn(); @@ -176,8 +181,9 @@ public class OrmColumnTests extends ContextModelTestCase } public void testUpdateSpecifiedTable() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); OrmColumn ormColumn = ormBasicMapping.getColumn(); @@ -208,8 +214,9 @@ public class OrmColumnTests extends ContextModelTestCase } public void testModifySpecifiedTable() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); OrmColumn ormColumn = ormBasicMapping.getColumn(); @@ -231,8 +238,9 @@ public class OrmColumnTests extends ContextModelTestCase } public void testUpdateSpecifiedNullable() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); OrmColumn ormColumn = ormBasicMapping.getColumn(); @@ -263,8 +271,9 @@ public class OrmColumnTests extends ContextModelTestCase } public void testModifySpecifiedNullable() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); OrmColumn ormColumn = ormBasicMapping.getColumn(); @@ -286,8 +295,9 @@ public class OrmColumnTests extends ContextModelTestCase } public void testUpdateSpecifiedUpdatable() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); OrmColumn ormColumn = ormBasicMapping.getColumn(); @@ -318,8 +328,9 @@ public class OrmColumnTests extends ContextModelTestCase } public void testModifySpecifiedUpdatable() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); OrmColumn ormColumn = ormBasicMapping.getColumn(); @@ -341,8 +352,9 @@ public class OrmColumnTests extends ContextModelTestCase } public void testUpdateSpecifiedInsertable() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); OrmColumn ormColumn = ormBasicMapping.getColumn(); @@ -373,8 +385,9 @@ public class OrmColumnTests extends ContextModelTestCase } public void testModifySpecifiedInsertable() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); OrmColumn ormColumn = ormBasicMapping.getColumn(); @@ -396,8 +409,9 @@ public class OrmColumnTests extends ContextModelTestCase } public void testUpdateSpecifiedUnique() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); OrmColumn ormColumn = ormBasicMapping.getColumn(); @@ -428,8 +442,9 @@ public class OrmColumnTests extends ContextModelTestCase } public void testModifySpecifiedUnique() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); OrmColumn ormColumn = ormBasicMapping.getColumn(); @@ -451,8 +466,9 @@ public class OrmColumnTests extends ContextModelTestCase } public void testUpdateSpecifiedLength() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); OrmColumn ormColumn = ormBasicMapping.getColumn(); @@ -483,8 +499,9 @@ public class OrmColumnTests extends ContextModelTestCase } public void testModifySpecifiedLength() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); OrmColumn ormColumn = ormBasicMapping.getColumn(); @@ -506,8 +523,9 @@ public class OrmColumnTests extends ContextModelTestCase } public void testUpdateSpecifiedPrecision() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); OrmColumn ormColumn = ormBasicMapping.getColumn(); @@ -538,8 +556,9 @@ public class OrmColumnTests extends ContextModelTestCase } public void testModifySpecifiedPrecision() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); OrmColumn ormColumn = ormBasicMapping.getColumn(); @@ -561,8 +580,9 @@ public class OrmColumnTests extends ContextModelTestCase } public void testUpdateSpecifiedScale() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); OrmColumn ormColumn = ormBasicMapping.getColumn(); @@ -593,8 +613,9 @@ public class OrmColumnTests extends ContextModelTestCase } public void testModifySpecifiedScale() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping(); OrmColumn ormColumn = ormBasicMapping.getColumn(); @@ -619,7 +640,7 @@ public class OrmColumnTests extends ContextModelTestCase createTestEntity(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - Iterator<OrmReadOnlyPersistentAttribute> attributes = ormPersistentType.getVirtualAttributes().iterator(); + Iterator<OrmReadOnlyPersistentAttribute> attributes = ormPersistentType.getDefaultAttributes().iterator(); attributes.next(); //virtual attribute in orm.xml, java attribute has no Column annotation @@ -633,9 +654,9 @@ public class OrmColumnTests extends ContextModelTestCase assertTrue(virtualColumn.isUpdatable()); assertTrue(virtualColumn.isNullable()); assertFalse(virtualColumn.isUnique()); - assertEquals(Column.DEFAULT_LENGTH, virtualColumn.getLength()); - assertEquals(Column.DEFAULT_PRECISION, virtualColumn.getPrecision()); - assertEquals(Column.DEFAULT_SCALE, virtualColumn.getScale()); + assertEquals(ReadOnlyColumn.DEFAULT_LENGTH, virtualColumn.getLength()); + assertEquals(ReadOnlyColumn.DEFAULT_PRECISION, virtualColumn.getPrecision()); + assertEquals(ReadOnlyColumn.DEFAULT_SCALE, virtualColumn.getScale()); //set Column annotation in Java JavaBasicMapping javaBasicMapping = (JavaBasicMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("name").getMapping(); @@ -678,9 +699,9 @@ public class OrmColumnTests extends ContextModelTestCase assertTrue(virtualColumn.isUpdatable()); assertTrue(virtualColumn.isNullable()); assertFalse(virtualColumn.isUnique()); - assertEquals(Column.DEFAULT_LENGTH, virtualColumn.getLength()); - assertEquals(Column.DEFAULT_PRECISION, virtualColumn.getPrecision()); - assertEquals(Column.DEFAULT_SCALE, virtualColumn.getScale()); + assertEquals(ReadOnlyColumn.DEFAULT_LENGTH, virtualColumn.getLength()); + assertEquals(ReadOnlyColumn.DEFAULT_PRECISION, virtualColumn.getPrecision()); + assertEquals(ReadOnlyColumn.DEFAULT_SCALE, virtualColumn.getScale()); getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true); ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.FALSE); @@ -693,9 +714,9 @@ public class OrmColumnTests extends ContextModelTestCase assertTrue(virtualColumn.isUpdatable()); assertTrue(virtualColumn.isNullable()); assertFalse(virtualColumn.isUnique()); - assertEquals(Column.DEFAULT_LENGTH, virtualColumn.getLength()); - assertEquals(Column.DEFAULT_PRECISION, virtualColumn.getPrecision()); - assertEquals(Column.DEFAULT_SCALE, virtualColumn.getScale()); + assertEquals(ReadOnlyColumn.DEFAULT_LENGTH, virtualColumn.getLength()); + assertEquals(ReadOnlyColumn.DEFAULT_PRECISION, virtualColumn.getPrecision()); + assertEquals(ReadOnlyColumn.DEFAULT_SCALE, virtualColumn.getScale()); ormPersistentType.getMapping().setSpecifiedMetadataComplete(null); nameVirtualMapping = (BasicMapping) namePersistentAttribute.getMapping(); @@ -707,9 +728,9 @@ public class OrmColumnTests extends ContextModelTestCase assertTrue(virtualColumn.isUpdatable()); assertTrue(virtualColumn.isNullable()); assertFalse(virtualColumn.isUnique()); - assertEquals(Column.DEFAULT_LENGTH, virtualColumn.getLength()); - assertEquals(Column.DEFAULT_PRECISION, virtualColumn.getPrecision()); - assertEquals(Column.DEFAULT_SCALE, virtualColumn.getScale()); + assertEquals(ReadOnlyColumn.DEFAULT_LENGTH, virtualColumn.getLength()); + assertEquals(ReadOnlyColumn.DEFAULT_PRECISION, virtualColumn.getPrecision()); + assertEquals(ReadOnlyColumn.DEFAULT_SCALE, virtualColumn.getScale()); //set metadata-complete false, orm.xml virtual column gets setting from java annotation getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false); @@ -731,7 +752,7 @@ public class OrmColumnTests extends ContextModelTestCase createTestEntity(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute namePersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "name"); + OrmPersistentAttribute namePersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("name"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); OrmBasicMapping nameVirtualMapping = (OrmBasicMapping) namePersistentAttribute.getMapping(); OrmColumn ormColumn = nameVirtualMapping.getColumn(); @@ -757,9 +778,9 @@ public class OrmColumnTests extends ContextModelTestCase assertEquals(true, ormColumn.isDefaultUpdatable()); assertEquals(true, ormColumn.isDefaultNullable()); assertEquals(false, ormColumn.isDefaultUnique()); - assertEquals(Column.DEFAULT_LENGTH, ormColumn.getDefaultLength()); - assertEquals(Column.DEFAULT_PRECISION, ormColumn.getDefaultPrecision()); - assertEquals(Column.DEFAULT_SCALE, ormColumn.getDefaultScale()); + assertEquals(ReadOnlyColumn.DEFAULT_LENGTH, ormColumn.getDefaultLength()); + assertEquals(ReadOnlyColumn.DEFAULT_PRECISION, ormColumn.getDefaultPrecision()); + assertEquals(ReadOnlyColumn.DEFAULT_SCALE, ormColumn.getDefaultScale()); assertNull(ormColumn.getSpecifiedName()); assertNull(ormColumn.getSpecifiedTable()); assertNull(ormColumn.getColumnDefinition()); @@ -794,8 +815,8 @@ public class OrmColumnTests extends ContextModelTestCase virtualColumn = nameVirtualMapping.getColumn(); assertEquals("JAVA_TABLE", virtualColumn.getTable()); - //make name persistent attribute not virtual - nameOrmAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "name"); + //make name persistent attribute not default + nameOrmAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("name"), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); BasicMapping nameSpecifiedMapping = (OrmBasicMapping) nameOrmAttribute.getMapping(); Column specifiedColumn = nameSpecifiedMapping.getColumn(); assertNull(specifiedColumn.getSpecifiedTable()); diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmEmbeddedIdMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmEmbeddedIdMappingTests.java index 1b2238fc02..7ed015db80 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmEmbeddedIdMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmEmbeddedIdMappingTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Oracle. All rights reserved. + * Copyright (c) 2007, 2012 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -323,7 +323,7 @@ public class OrmEmbeddedIdMappingTests extends ContextModelTestCase public void testEmbeddedIdMorphToIdMapping() throws Exception { createTestEntityEmbeddedIdMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "embeddedId"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY); EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) ormPersistentAttribute.getMapping(); assertFalse(embeddedIdMapping.isDefault()); @@ -338,13 +338,13 @@ public class OrmEmbeddedIdMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof IdMapping); - assertEquals("embeddedId", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testEmbeddedIdMorphToVersionMapping() throws Exception { createTestEntityEmbeddedIdMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "embeddedId"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY); EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) ormPersistentAttribute.getMapping(); assertFalse(embeddedIdMapping.isDefault()); @@ -359,13 +359,13 @@ public class OrmEmbeddedIdMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof VersionMapping); - assertEquals("embeddedId", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testEmbeddedIdMorphToTransientMapping() throws Exception { createTestEntityEmbeddedIdMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "embeddedId"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY); EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) ormPersistentAttribute.getMapping(); assertFalse(embeddedIdMapping.isDefault()); @@ -380,13 +380,13 @@ public class OrmEmbeddedIdMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof TransientMapping); - assertEquals("embeddedId", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testEmbeddedIdMorphToBasicMapping() throws Exception { createTestEntityEmbeddedIdMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "embeddedId"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY); EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) ormPersistentAttribute.getMapping(); assertFalse(embeddedIdMapping.isDefault()); @@ -401,13 +401,13 @@ public class OrmEmbeddedIdMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof BasicMapping); - assertEquals("embeddedId", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testEmbeddedIdMorphToEmbeddedMapping() throws Exception { createTestEntityEmbeddedIdMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "embeddedId"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY); EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) ormPersistentAttribute.getMapping(); assertFalse(embeddedIdMapping.isDefault()); @@ -422,7 +422,7 @@ public class OrmEmbeddedIdMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedMapping); - assertEquals("embeddedId", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); attributeOverride = ((EmbeddedMapping) ormPersistentAttribute.getMapping()).getAttributeOverrideContainer().getSpecifiedOverrides().iterator().next(); assertEquals("override", attributeOverride.getName()); assertEquals("OVERRIDE_COLUMN", attributeOverride.getColumn().getSpecifiedName()); @@ -431,7 +431,7 @@ public class OrmEmbeddedIdMappingTests extends ContextModelTestCase public void testEmbeddedIdMorphToOneToOneMapping() throws Exception { createTestEntityEmbeddedIdMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "embeddedId"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY); EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) ormPersistentAttribute.getMapping(); assertFalse(embeddedIdMapping.isDefault()); @@ -446,13 +446,13 @@ public class OrmEmbeddedIdMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof OneToOneMapping); - assertEquals("embeddedId", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testEmbeddedIdMorphToOneToManyMapping() throws Exception { createTestEntityEmbeddedIdMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "embeddedId"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY); EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) ormPersistentAttribute.getMapping(); assertFalse(embeddedIdMapping.isDefault()); @@ -467,13 +467,13 @@ public class OrmEmbeddedIdMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof OneToManyMapping); - assertEquals("embeddedId", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testEmbeddedIdMorphToManyToOneMapping() throws Exception { createTestEntityEmbeddedIdMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "embeddedId"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY); EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) ormPersistentAttribute.getMapping(); assertFalse(embeddedIdMapping.isDefault()); @@ -486,13 +486,13 @@ public class OrmEmbeddedIdMappingTests extends ContextModelTestCase ormPersistentAttribute.setMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY); assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToOneMapping); - assertEquals("embeddedId", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testEmbeddedIdMorphToManyToManyMapping() throws Exception { createTestEntityEmbeddedIdMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "embeddedId"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY); EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) ormPersistentAttribute.getMapping(); assertFalse(embeddedIdMapping.isDefault()); @@ -507,17 +507,18 @@ public class OrmEmbeddedIdMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToManyMapping); - assertEquals("embeddedId", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testUpdateName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "embeddedMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY); OrmEmbeddedIdMapping ormEmbeddedMapping = (OrmEmbeddedIdMapping) ormPersistentAttribute.getMapping(); XmlEmbeddedId embeddedResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getEmbeddedIds().get(0); - assertEquals("embeddedMapping", ormEmbeddedMapping.getName()); - assertEquals("embeddedMapping", embeddedResource.getName()); + assertEquals("id", ormEmbeddedMapping.getName()); + assertEquals("id", embeddedResource.getName()); //set name in the resource model, verify context model updated embeddedResource.setName("newName"); @@ -531,13 +532,14 @@ public class OrmEmbeddedIdMappingTests extends ContextModelTestCase } public void testModifyName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "embeddedMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY); OrmEmbeddedIdMapping ormEmbeddedMapping = (OrmEmbeddedIdMapping) ormPersistentAttribute.getMapping(); XmlEmbeddedId embeddedResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getEmbeddedIds().get(0); - assertEquals("embeddedMapping", ormEmbeddedMapping.getName()); - assertEquals("embeddedMapping", embeddedResource.getName()); + assertEquals("id", ormEmbeddedMapping.getName()); + assertEquals("id", embeddedResource.getName()); //set name in the context model, verify resource model updated ormEmbeddedMapping.setName("newName"); @@ -551,8 +553,9 @@ public class OrmEmbeddedIdMappingTests extends ContextModelTestCase } public void testMoveSpecifiedAttributeOverride() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "embeddedMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY); OrmEmbeddedIdMapping ormEmbeddedIdMapping = (OrmEmbeddedIdMapping) ormPersistentAttribute.getMapping(); OrmAttributeOverrideContainer attributeOverrideContainer = ormEmbeddedIdMapping.getAttributeOverrideContainer(); XmlEmbeddedId embeddedIdResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getEmbeddedIds().get(0); @@ -590,8 +593,9 @@ public class OrmEmbeddedIdMappingTests extends ContextModelTestCase } public void testUpdateAttributeOverrides() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "embeddedMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY); OrmEmbeddedIdMapping ormEmbeddedIdMapping = (OrmEmbeddedIdMapping) ormPersistentAttribute.getMapping(); OrmAttributeOverrideContainer attributeOverrideContainer = ormEmbeddedIdMapping.getAttributeOverrideContainer(); XmlEmbeddedId embeddedIdResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getEmbeddedIds().get(0); @@ -646,11 +650,12 @@ public class OrmEmbeddedIdMappingTests extends ContextModelTestCase OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); - ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "foo"); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("address"), MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); OrmEmbeddedIdMapping ormEmbeddedIdMapping = (OrmEmbeddedIdMapping) ormPersistentAttribute.getMapping(); + ormEmbeddedIdMapping.setName("foo"); OrmAttributeOverrideContainer attributeOverrideContainer = ormEmbeddedIdMapping.getAttributeOverrideContainer(); assertEquals("foo", ormEmbeddedIdMapping.getName()); @@ -731,7 +736,7 @@ public class OrmEmbeddedIdMappingTests extends ContextModelTestCase //embedded mapping is specified, virtual attribute overrides should exist - persistentType.getAttributeNamed("address").convertToSpecified(); + persistentType.getAttributeNamed("address").addToXml(); OrmEmbeddedIdMapping ormMapping = (OrmEmbeddedIdMapping) persistentType.getAttributeNamed("address").getMapping(); OrmAttributeOverrideContainer ormOverrideContainer = ormMapping.getAttributeOverrideContainer(); assertEquals(4, ormOverrideContainer.getOverridesSize()); @@ -781,8 +786,8 @@ public class OrmEmbeddedIdMappingTests extends ContextModelTestCase OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME_ + "Address"); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); - OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + assertEquals(3, ormPersistentType.getDefaultAttributesSize()); + OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); JavaEmbeddedIdMapping embeddedIdMapping = (JavaEmbeddedIdMapping) ormPersistentAttribute.getMapping(); JavaAttributeOverrideContainer attributeOverrideContainer = embeddedIdMapping.getAttributeOverrideContainer(); @@ -827,7 +832,7 @@ public class OrmEmbeddedIdMappingTests extends ContextModelTestCase OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); + assertEquals(3, ormPersistentType.getDefaultAttributesSize()); OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getAttributeNamed("address"); assertTrue(ormPersistentAttribute.isVirtual()); @@ -877,8 +882,8 @@ public class OrmEmbeddedIdMappingTests extends ContextModelTestCase OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); - ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "address"); - assertEquals(2, ormPersistentType.getVirtualAttributesSize()); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("address"), MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); OrmEmbeddedIdMapping ormEmbeddedIdMapping = (OrmEmbeddedIdMapping) ormPersistentAttribute.getMapping(); diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmEmbeddedMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmEmbeddedMappingTests.java index f5bcd81c2f..21809cb787 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmEmbeddedMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmEmbeddedMappingTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Oracle. All rights reserved. + * Copyright (c) 2007, 2012 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -220,13 +220,14 @@ public class OrmEmbeddedMappingTests extends ContextModelTestCase } public void testUpdateName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embeddedMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); OrmEmbeddedMapping ormEmbeddedMapping = (OrmEmbeddedMapping) ormPersistentAttribute.getMapping(); XmlEmbedded embeddedResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getEmbeddeds().get(0); - assertEquals("embeddedMapping", ormEmbeddedMapping.getName()); - assertEquals("embeddedMapping", embeddedResource.getName()); + assertEquals("id", ormEmbeddedMapping.getName()); + assertEquals("id", embeddedResource.getName()); //set name in the resource model, verify context model updated embeddedResource.setName("newName"); @@ -240,13 +241,14 @@ public class OrmEmbeddedMappingTests extends ContextModelTestCase } public void testModifyName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embeddedMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); OrmEmbeddedMapping ormEmbeddedMapping = (OrmEmbeddedMapping) ormPersistentAttribute.getMapping(); XmlEmbedded embeddedResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getEmbeddeds().get(0); - assertEquals("embeddedMapping", ormEmbeddedMapping.getName()); - assertEquals("embeddedMapping", embeddedResource.getName()); + assertEquals("id", ormEmbeddedMapping.getName()); + assertEquals("id", embeddedResource.getName()); //set name in the context model, verify resource model updated ormEmbeddedMapping.setName("newName"); @@ -320,8 +322,9 @@ public class OrmEmbeddedMappingTests extends ContextModelTestCase // } public void testMoveSpecifiedAttributeOverride() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embeddedMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); OrmEmbeddedMapping ormEmbeddedMapping = (OrmEmbeddedMapping) ormPersistentAttribute.getMapping(); OrmAttributeOverrideContainer attributeOverrideContainer = ormEmbeddedMapping.getAttributeOverrideContainer(); XmlEmbedded embeddedResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getEmbeddeds().get(0); @@ -359,8 +362,9 @@ public class OrmEmbeddedMappingTests extends ContextModelTestCase } public void testUpdateAttributeOverrides() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embeddedMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); OrmEmbeddedMapping ormEmbeddedMapping = (OrmEmbeddedMapping) ormPersistentAttribute.getMapping(); OrmAttributeOverrideContainer attributeOverrideContainer = ormEmbeddedMapping.getAttributeOverrideContainer(); XmlEmbedded embeddedResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getEmbeddeds().get(0); @@ -415,11 +419,12 @@ public class OrmEmbeddedMappingTests extends ContextModelTestCase OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); - ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "foo"); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("address"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); OrmEmbeddedMapping ormEmbeddedMapping = (OrmEmbeddedMapping) ormPersistentAttribute.getMapping(); + ormEmbeddedMapping.setName("foo"); OrmAttributeOverrideContainer attributeOverrideContainer = ormEmbeddedMapping.getAttributeOverrideContainer(); assertEquals("foo", ormEmbeddedMapping.getName()); @@ -499,7 +504,7 @@ public class OrmEmbeddedMappingTests extends ContextModelTestCase //embedded mapping is specified, virtual attribute overrides should exist - persistentType.getAttributeNamed("address").convertToSpecified(); + persistentType.getAttributeNamed("address").addToXml(); OrmEmbeddedMapping ormMapping = (OrmEmbeddedMapping) persistentType.getAttributeNamed("address").getMapping(); OrmAttributeOverrideContainer ormOverrideContainer = ormMapping.getAttributeOverrideContainer(); assertEquals(4, ormOverrideContainer.getOverridesSize()); @@ -550,8 +555,8 @@ public class OrmEmbeddedMappingTests extends ContextModelTestCase OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); - OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + assertEquals(3, ormPersistentType.getDefaultAttributesSize()); + OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); JavaEmbeddedMapping embeddedMapping = (JavaEmbeddedMapping) ormPersistentAttribute.getMapping(); JavaAttributeOverrideContainer attributeOverrideContainer = embeddedMapping.getAttributeOverrideContainer(); @@ -593,8 +598,8 @@ public class OrmEmbeddedMappingTests extends ContextModelTestCase OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); - OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + assertEquals(3, ormPersistentType.getDefaultAttributesSize()); + OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); EmbeddedMapping embeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping(); assertEquals("address", embeddedMapping.getName()); @@ -641,8 +646,8 @@ public class OrmEmbeddedMappingTests extends ContextModelTestCase OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); - ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "address"); - assertEquals(2, ormPersistentType.getVirtualAttributesSize()); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("address"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); OrmEmbeddedMapping ormEmbeddedMapping = (OrmEmbeddedMapping) ormPersistentAttribute.getMapping(); @@ -688,7 +693,7 @@ public class OrmEmbeddedMappingTests extends ContextModelTestCase public void testEmbeddedMorphToIdMapping() throws Exception { createTestEntityEmbeddedMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); EmbeddedMapping embeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping(); assertFalse(embeddedMapping.isDefault()); @@ -703,13 +708,13 @@ public class OrmEmbeddedMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof IdMapping); - assertEquals("embedded", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testEmbeddedMorphToVersionMapping() throws Exception { createTestEntityEmbeddedMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); EmbeddedMapping embeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping(); assertFalse(embeddedMapping.isDefault()); @@ -724,13 +729,13 @@ public class OrmEmbeddedMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof VersionMapping); - assertEquals("embedded", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testEmbeddedMorphToTransientMapping() throws Exception { createTestEntityEmbeddedMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); EmbeddedMapping embeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping(); assertFalse(embeddedMapping.isDefault()); @@ -745,13 +750,13 @@ public class OrmEmbeddedMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof TransientMapping); - assertEquals("embedded", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testEmbeddedMorphToBasicMapping() throws Exception { createTestEntityEmbeddedMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); EmbeddedMapping embeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping(); assertFalse(embeddedMapping.isDefault()); @@ -766,13 +771,13 @@ public class OrmEmbeddedMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof BasicMapping); - assertEquals("embedded", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testEmbeddedMorphToEmbeddedIdMapping() throws Exception { createTestEntityEmbeddedMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); EmbeddedMapping embeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping(); assertFalse(embeddedMapping.isDefault()); @@ -787,7 +792,7 @@ public class OrmEmbeddedMappingTests extends ContextModelTestCase assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedIdMapping); assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); - assertEquals("embedded", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); attributeOverride = ((EmbeddedIdMapping) ormPersistentAttribute.getMapping()).getAttributeOverrideContainer().getSpecifiedOverrides().iterator().next(); assertEquals("override", attributeOverride.getName()); assertEquals("OVERRIDE_COLUMN", attributeOverride.getColumn().getSpecifiedName()); @@ -796,7 +801,7 @@ public class OrmEmbeddedMappingTests extends ContextModelTestCase public void testEmbeddedMorphToOneToOneMapping() throws Exception { createTestEntityEmbeddedMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); EmbeddedMapping embeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping(); assertFalse(embeddedMapping.isDefault()); @@ -811,13 +816,13 @@ public class OrmEmbeddedMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof OneToOneMapping); - assertEquals("embedded", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testEmbeddedMorphToOneToManyMapping() throws Exception { createTestEntityEmbeddedMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); EmbeddedMapping embeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping(); assertFalse(embeddedMapping.isDefault()); @@ -832,13 +837,13 @@ public class OrmEmbeddedMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof OneToManyMapping); - assertEquals("embedded", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testEmbeddedMorphToManyToOneMapping() throws Exception { createTestEntityEmbeddedMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); EmbeddedMapping embeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping(); assertFalse(embeddedMapping.isDefault()); @@ -853,13 +858,13 @@ public class OrmEmbeddedMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToOneMapping); - assertEquals("embedded", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testEmbeddedMorphToManyToManyMapping() throws Exception { createTestEntityEmbeddedMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); EmbeddedMapping embeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping(); assertFalse(embeddedMapping.isDefault()); @@ -872,7 +877,7 @@ public class OrmEmbeddedMappingTests extends ContextModelTestCase ormPersistentAttribute.setMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToManyMapping); - assertEquals("embedded", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } //1.0 projects do not support dot-notation, this tests to make sure that support does not exist @@ -885,7 +890,7 @@ public class OrmEmbeddedMappingTests extends ContextModelTestCase OrmPersistentType addressPersistentType = getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); OrmPersistentType zipCodePersistentType = getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".ZipCode"); - customerPersistentType.getAttributeNamed("address").convertToSpecified(); + customerPersistentType.getAttributeNamed("address").addToXml(); OrmEmbeddedMapping embeddedMapping = (OrmEmbeddedMapping) customerPersistentType.getAttributeNamed("address").getMapping(); OrmAttributeOverrideContainer attributeOverrideContainer = embeddedMapping.getAttributeOverrideContainer(); @@ -899,7 +904,7 @@ public class OrmEmbeddedMappingTests extends ContextModelTestCase assertEquals("state", virtualAttributeOverride.getName()); assertEquals(false, virtualAttributeOverrides.hasNext()); - addressPersistentType.getAttributeNamed("zipCode").convertToSpecified(); + addressPersistentType.getAttributeNamed("zipCode").addToXml(); OrmEmbeddedMapping nestedEmbeddedMapping = (OrmEmbeddedMapping) addressPersistentType.getAttributeNamed("zipCode").getMapping(); OrmAttributeOverrideContainer nestedAttributeOverrideContainer = nestedEmbeddedMapping.getAttributeOverrideContainer(); assertEquals(2, nestedAttributeOverrideContainer.getVirtualOverridesSize()); @@ -909,7 +914,7 @@ public class OrmEmbeddedMappingTests extends ContextModelTestCase virtualAttributeOverride = virtualAttributeOverrides.next(); assertEquals("plusfour", virtualAttributeOverride.getName()); - zipCodePersistentType.getAttributeNamed("plusfour").convertToSpecified(); + zipCodePersistentType.getAttributeNamed("plusfour").addToXml(); BasicMapping plusFourMapping = (BasicMapping) zipCodePersistentType.getAttributeNamed("plusfour").getMapping(); plusFourMapping.getColumn().setSpecifiedName("BLAH"); plusFourMapping.getColumn().setSpecifiedTable("BLAH_TABLE"); 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 b6145ce3e5..dc697f1239 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 @@ -1483,7 +1483,7 @@ public class OrmEntityTests extends ContextModelTestCase OrmPersistentType childPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_CHILD_TYPE_NAME); childPersistentType.getJavaPersistentType().setMappingKey(MappingKeys.NULL_TYPE_MAPPING_KEY); - persistentType.getAttributeNamed("id").convertToSpecified(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); + persistentType.getAttributeNamed("id").addToXml(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); ((OrmEntity) persistentType.getMapping()).setSpecifiedInheritanceStrategy(InheritanceType.JOINED); @@ -1763,7 +1763,7 @@ public class OrmEntityTests extends ContextModelTestCase virtualOverride = virtualAttributeOverrides.next(); assertEquals("name", virtualOverride.getName()); - persistentType2.getAttributeNamed("basic").convertToSpecified(); + persistentType2.getAttributeNamed("basic").addToXml(); OrmBasicMapping basicMapping = (OrmBasicMapping) persistentType2.getAttributeNamed("basic").getMapping(); basicMapping.getColumn().setSpecifiedName("MY_NAME"); basicMapping.getColumn().setSpecifiedTable("BAR"); @@ -1875,7 +1875,7 @@ public class OrmEntityTests extends ContextModelTestCase OrmEntity childEntity = (OrmEntity) childType.getMapping(); OrmAttributeOverrideContainer childOverrideContainer = childEntity.getAttributeOverrideContainer(); OrmReadOnlyAttributeOverride attributeOverride = childOverrideContainer.getVirtualOverrides().iterator().next(); - ((OrmReadOnlyPersistentAttribute) childType.getSuperPersistentType().getAttributeNamed("id")).convertToSpecified(); + ((OrmReadOnlyPersistentAttribute) childType.getSuperPersistentType().getAttributeNamed("id")).addToXml(); BasicMapping basicMapping = (BasicMapping) ((OrmReadOnlyPersistentAttribute) childType.getSuperPersistentType().getAttributeNamed("id")).getMapping(); basicMapping.getColumn().setSpecifiedName("MY_COLUMN"); basicMapping.getColumn().setSpecifiedTable("BAR"); @@ -1977,7 +1977,7 @@ public class OrmEntityTests extends ContextModelTestCase assertEquals(CHILD_TYPE_NAME, virtualAttributeOverride.getColumn().getTable()); - abstractPersistentType.getAttributeNamed("id").convertToSpecified(); + abstractPersistentType.getAttributeNamed("id").addToXml(); BasicMapping idMapping = (OrmBasicMapping) abstractPersistentType.getAttributeNamed("id").getMapping(); idMapping.getColumn().setSpecifiedName("FOO"); idMapping.getColumn().setSpecifiedTable("BAR"); @@ -2172,7 +2172,7 @@ public class OrmEntityTests extends ContextModelTestCase assertEquals("manyToOne", virtualOverride.getName()); assertEquals(null, joiningStrategy.getJoinColumns().iterator().next().getSpecifiedName()); - persistentType2.getAttributeNamed("manyToOne").convertToSpecified(); + persistentType2.getAttributeNamed("manyToOne").addToXml(); OrmManyToOneMapping manyToOneMapping = (OrmManyToOneMapping) persistentType2.getAttributeNamed("manyToOne").getMapping(); OrmJoinColumn joinColumn = manyToOneMapping.getRelationship().getJoinColumnStrategy().addSpecifiedJoinColumn(0); joinColumn.setSpecifiedName("MY_NAME"); @@ -2709,7 +2709,7 @@ public class OrmEntityTests extends ContextModelTestCase OrmPersistentType subPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".AnnotationTestTypeChild"); OrmEntity childXmlEntity = (OrmEntity) subPersistentType.getMapping(); - superPersistentType.getAttributeNamed("id").convertToSpecified(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); + superPersistentType.getAttributeNamed("id").addToXml(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); assertEquals("id", childXmlEntity.getPrimaryKeyColumnName()); ((OrmIdMapping) superPersistentType.getAttributeNamed("id").getMapping()).getColumn().setSpecifiedName("MY_ID"); diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmGeneratedValueTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmGeneratedValueTests.java index 02baa501ef..aab3848225 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmGeneratedValueTests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmGeneratedValueTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Oracle. All rights reserved. + * Copyright (c) 2007, 2012 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -63,8 +63,9 @@ import org.eclipse.jpt.jpa.core.tests.internal.context.ContextModelTestCase; } public void testUpdateSpecifiedName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping(); OrmGeneratedValue ormGeneratedValue = ormIdMapping.addGeneratedValue(); XmlId idResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getIds().get(0); @@ -82,8 +83,9 @@ import org.eclipse.jpt.jpa.core.tests.internal.context.ContextModelTestCase; } public void testModifySpecifiedName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping(); OrmGeneratedValue ormGeneratedValue = ormIdMapping.addGeneratedValue(); XmlId idResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getIds().get(0); @@ -104,7 +106,7 @@ import org.eclipse.jpt.jpa.core.tests.internal.context.ContextModelTestCase; createTestEntity(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmReadOnlyPersistentAttribute ormIdAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + OrmReadOnlyPersistentAttribute ormIdAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); IdMapping ormIdMapping = (IdMapping) ormIdAttribute.getMapping(); assertEquals(null, ormIdMapping.getGeneratedValue()); @@ -118,14 +120,14 @@ import org.eclipse.jpt.jpa.core.tests.internal.context.ContextModelTestCase; assertEquals("Foo", javaGeneratedValue.getSpecifiedGenerator()); assertEquals(GenerationType.SEQUENCE, javaGeneratedValue.getSpecifiedStrategy()); - ormIdAttribute.convertToSpecified(); + ormIdAttribute.addToXml(); ormIdAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); ormIdMapping = (IdMapping) ormIdAttribute.getMapping(); assertEquals(null, ormIdMapping.getGeneratedValue()); assertEquals("Foo", javaGeneratedValue.getSpecifiedGenerator()); assertEquals(GenerationType.SEQUENCE, javaGeneratedValue.getSpecifiedStrategy()); - ((OrmPersistentAttribute) ormIdAttribute).convertToVirtual(); + ((OrmPersistentAttribute) ormIdAttribute).removeFromXml(); ormIdAttribute = ormPersistentType.getAttributeNamed("id"); ormIdMapping = (IdMapping) ormIdAttribute.getMapping(); assertEquals("Foo", ormIdMapping.getGeneratedValue().getSpecifiedGenerator()); diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmIdMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmIdMappingTests.java index b8c9fa1f03..f9f9da2d48 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmIdMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmIdMappingTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Oracle. All rights reserved. + * Copyright (c) 2007, 2012 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -89,13 +89,14 @@ public class OrmIdMappingTests extends ContextModelTestCase } public void testUpdateName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping(); XmlId idResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getIds().get(0); - assertEquals("idMapping", ormIdMapping.getName()); - assertEquals("idMapping", idResource.getName()); + assertEquals("id", ormIdMapping.getName()); + assertEquals("id", idResource.getName()); //set name in the resource model, verify context model updated idResource.setName("newName"); @@ -109,13 +110,14 @@ public class OrmIdMappingTests extends ContextModelTestCase } public void testModifyName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping(); XmlId idResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getIds().get(0); - assertEquals("idMapping", ormIdMapping.getName()); - assertEquals("idMapping", idResource.getName()); + assertEquals("id", ormIdMapping.getName()); + assertEquals("id", idResource.getName()); //set name in the context model, verify resource model updated ormIdMapping.setName("newName"); @@ -129,8 +131,9 @@ public class OrmIdMappingTests extends ContextModelTestCase } public void testUpdateTemporal() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping(); XmlId idResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getIds().get(0); @@ -157,8 +160,9 @@ public class OrmIdMappingTests extends ContextModelTestCase } public void testModifyTemporal() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping(); XmlId idResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getIds().get(0); @@ -190,8 +194,9 @@ public class OrmIdMappingTests extends ContextModelTestCase public void testAddSequenceGenerator() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping(); XmlId idResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getIds().get(0); @@ -213,8 +218,9 @@ public class OrmIdMappingTests extends ContextModelTestCase } public void testRemoveSequenceGenerator() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping(); XmlId idResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getIds().get(0); @@ -240,8 +246,9 @@ public class OrmIdMappingTests extends ContextModelTestCase } public void testUpdateSequenceGenerator() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping(); XmlId idResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getIds().get(0); @@ -264,8 +271,9 @@ public class OrmIdMappingTests extends ContextModelTestCase } public void testAddTableGenerator() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping(); XmlId idResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getIds().get(0); @@ -287,8 +295,9 @@ public class OrmIdMappingTests extends ContextModelTestCase } public void testRemoveTableGenerator() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping(); XmlId idResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getIds().get(0); @@ -314,8 +323,9 @@ public class OrmIdMappingTests extends ContextModelTestCase } public void testUpdateTableGenerator() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping(); XmlId idResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getIds().get(0); @@ -338,8 +348,9 @@ public class OrmIdMappingTests extends ContextModelTestCase } public void testAddGeneratedValue() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping(); XmlId idResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getIds().get(0); @@ -361,8 +372,9 @@ public class OrmIdMappingTests extends ContextModelTestCase } public void testRemoveGeneratedValue() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping(); XmlId idResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getIds().get(0); @@ -388,8 +400,9 @@ public class OrmIdMappingTests extends ContextModelTestCase } public void testUpdateGeneratedValue() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "idMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping(); XmlId idResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getIds().get(0); @@ -411,11 +424,12 @@ public class OrmIdMappingTests extends ContextModelTestCase createTestEntityIdMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "foo"); - assertEquals(2, ormPersistentType.getVirtualAttributesSize()); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); + assertEquals(1, ormPersistentType.getDefaultAttributesSize()); OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping(); + ormIdMapping.setName("foo"); assertEquals("foo", ormIdMapping.getName()); assertNull(ormIdMapping.getConverter().getType()); @@ -458,8 +472,8 @@ public class OrmIdMappingTests extends ContextModelTestCase public void testVirtualMappingMetadataCompleteFalse() throws Exception { createTestEntityIdMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - assertEquals(2, ormPersistentType.getVirtualAttributesSize()); - OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); + OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); IdMapping idMapping = (IdMapping) ormPersistentAttribute.getMapping(); assertEquals("id", idMapping.getName()); @@ -508,12 +522,12 @@ public class OrmIdMappingTests extends ContextModelTestCase createTestEntityIdMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE); - assertEquals(2, ormPersistentType.getVirtualAttributesSize()); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getAttributeNamed("id"); assertEquals(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMappingKey()); - ormPersistentAttribute.convertToSpecified(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); + ormPersistentAttribute.addToXml(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); ormPersistentAttribute = ormPersistentType.getAttributeNamed("id"); OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping(); @@ -541,8 +555,8 @@ public class OrmIdMappingTests extends ContextModelTestCase createTestEntityIdMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "id"); - assertEquals(1, ormPersistentType.getVirtualAttributesSize()); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); + assertEquals(1, ormPersistentType.getDefaultAttributesSize()); OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping(); @@ -585,7 +599,7 @@ public class OrmIdMappingTests extends ContextModelTestCase public void testIdMorphToBasicMapping() throws Exception { createTestEntityIdMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "id"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); IdMapping idMapping = (IdMapping) ormPersistentAttribute.getMapping(); assertFalse(idMapping.isDefault()); @@ -605,8 +619,8 @@ public class OrmIdMappingTests extends ContextModelTestCase public void testIdMorphToVersionMapping() throws Exception { createTestEntityIdMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "id"); - + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); + IdMapping idMapping = (IdMapping) ormPersistentAttribute.getMapping(); assertFalse(idMapping.isDefault()); idMapping.getColumn().setSpecifiedName("FOO"); @@ -625,7 +639,7 @@ public class OrmIdMappingTests extends ContextModelTestCase public void testIdMorphToTransientMapping() throws Exception { createTestEntityIdMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "id"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); IdMapping idMapping = (IdMapping) ormPersistentAttribute.getMapping(); assertFalse(idMapping.isDefault()); @@ -642,7 +656,7 @@ public class OrmIdMappingTests extends ContextModelTestCase public void testIdMorphToEmbeddedMapping() throws Exception { createTestEntityIdMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "id"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); IdMapping idMapping = (IdMapping) ormPersistentAttribute.getMapping(); assertFalse(idMapping.isDefault()); @@ -661,7 +675,7 @@ public class OrmIdMappingTests extends ContextModelTestCase public void testIdMorphToEmbeddedIdMapping() throws Exception { createTestEntityIdMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "id"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); IdMapping idMapping = (IdMapping) ormPersistentAttribute.getMapping(); assertFalse(idMapping.isDefault()); @@ -678,7 +692,7 @@ public class OrmIdMappingTests extends ContextModelTestCase public void testIdMorphToOneToOneMapping() throws Exception { createTestEntityIdMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "id"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); IdMapping idMapping = (IdMapping) ormPersistentAttribute.getMapping(); assertFalse(idMapping.isDefault()); @@ -697,7 +711,7 @@ public class OrmIdMappingTests extends ContextModelTestCase public void testIdMorphToOneToManyMapping() throws Exception { createTestEntityIdMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "id"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); IdMapping idMapping = (IdMapping) ormPersistentAttribute.getMapping(); assertFalse(idMapping.isDefault()); @@ -716,7 +730,7 @@ public class OrmIdMappingTests extends ContextModelTestCase public void testIdMorphToManyToOneMapping() throws Exception { createTestEntityIdMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "id"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); IdMapping idMapping = (IdMapping) ormPersistentAttribute.getMapping(); assertFalse(idMapping.isDefault()); @@ -735,7 +749,7 @@ public class OrmIdMappingTests extends ContextModelTestCase public void testIdMorphToManyToManyMapping() throws Exception { createTestEntityIdMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "id"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); IdMapping idMapping = (IdMapping) ormPersistentAttribute.getMapping(); assertFalse(idMapping.isDefault()); diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmJoinColumnTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmJoinColumnTests.java index 81466a3691..10a3c111c4 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmJoinColumnTests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmJoinColumnTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Oracle. All rights reserved. + * Copyright (c) 2007, 2012 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -40,8 +40,9 @@ public class OrmJoinColumnTests extends ContextModelTestCase } public void testUpdateSpecifiedName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -73,8 +74,9 @@ public class OrmJoinColumnTests extends ContextModelTestCase } public void testModifySpecifiedName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -98,8 +100,9 @@ public class OrmJoinColumnTests extends ContextModelTestCase } public void testUpdateSpecifiedReferencedColumnName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -131,8 +134,9 @@ public class OrmJoinColumnTests extends ContextModelTestCase } public void testModifySpecifiedReferencedColumnName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -156,8 +160,9 @@ public class OrmJoinColumnTests extends ContextModelTestCase } public void testUpdateSpecifiedColumnDefinition() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -189,8 +194,9 @@ public class OrmJoinColumnTests extends ContextModelTestCase } public void testModifySpecifiedColumnDefinition() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -214,8 +220,9 @@ public class OrmJoinColumnTests extends ContextModelTestCase } public void testUpdateSpecifiedTable() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -247,8 +254,9 @@ public class OrmJoinColumnTests extends ContextModelTestCase } public void testModifySpecifiedTable() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -272,8 +280,9 @@ public class OrmJoinColumnTests extends ContextModelTestCase } public void testUpdateSpecifiedNullable() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -305,8 +314,9 @@ public class OrmJoinColumnTests extends ContextModelTestCase } public void testModifySpecifiedNullable() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -330,8 +340,9 @@ public class OrmJoinColumnTests extends ContextModelTestCase } public void testUpdateSpecifiedUpdatable() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -363,8 +374,9 @@ public class OrmJoinColumnTests extends ContextModelTestCase } public void testModifySpecifiedUpdatable() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -388,8 +400,9 @@ public class OrmJoinColumnTests extends ContextModelTestCase } public void testUpdateSpecifiedInsertable() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -421,8 +434,9 @@ public class OrmJoinColumnTests extends ContextModelTestCase } public void testModifySpecifiedInsertable() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -446,8 +460,9 @@ public class OrmJoinColumnTests extends ContextModelTestCase } public void testUpdateSpecifiedUnique() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -479,8 +494,9 @@ public class OrmJoinColumnTests extends ContextModelTestCase } public void testModifySpecifiedUnique() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmJoinTableTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmJoinTableTests.java index 4c1fd47226..b689dc22b6 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmJoinTableTests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmJoinTableTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Oracle. All rights reserved. + * Copyright (c) 2007, 2012 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -138,8 +138,9 @@ public class OrmJoinTableTests extends ContextModelTestCase } public void testUpdateSpecifiedName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -170,8 +171,9 @@ public class OrmJoinTableTests extends ContextModelTestCase } public void testModifySpecifiedName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -212,7 +214,7 @@ public class OrmJoinTableTests extends ContextModelTestCase assertEquals(0, virtualJoinTable.getSpecifiedJoinColumnsSize()); assertEquals(0, virtualJoinTable.getSpecifiedInverseJoinColumnsSize()); JoinColumn ormJoinColumn = virtualJoinTable.getDefaultJoinColumn(); -//TODO need to test joinColumn defaults here as well as in java and all the relatioship mapping types +//TODO need to test joinColumn defaults here as well as in java and all the relationship mapping types // assertEquals("id_project_id", ormJoinColumn.getDefaultName()); // assertEquals("id_project_id", ormJoinColumn.getDefaultReferencedColumnName()); JoinColumn inverseOrmJoinColumn = virtualJoinTable.getDefaultInverseJoinColumn(); @@ -250,7 +252,7 @@ public class OrmJoinTableTests extends ContextModelTestCase OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "projects"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("projects"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); OrmJoinTable ormJoinTable = ormManyToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable(); @@ -282,7 +284,7 @@ public class OrmJoinTableTests extends ContextModelTestCase getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false); //remove m-m mapping from the orm.xml file - ormPersistentAttribute.convertToVirtual(); + ormPersistentAttribute.removeFromXml(); //ormPersistentType.getMapping().setSpecifiedMetadataComplete(null); OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("projects"); ManyToManyMapping virtualManyToManyMapping = (ManyToManyMapping) ormPersistentAttribute2.getMapping(); @@ -303,8 +305,9 @@ public class OrmJoinTableTests extends ContextModelTestCase } public void testUpdateSpecifiedSchema() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -421,8 +424,9 @@ public class OrmJoinTableTests extends ContextModelTestCase // } public void testModifySpecifiedSchema() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -443,8 +447,9 @@ public class OrmJoinTableTests extends ContextModelTestCase } public void testUpdateSpecifiedCatalog() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -474,8 +479,9 @@ public class OrmJoinTableTests extends ContextModelTestCase } public void testModifySpecifiedCatalog() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -606,8 +612,9 @@ public class OrmJoinTableTests extends ContextModelTestCase public void testAddSpecifiedJoinColumn() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -644,8 +651,9 @@ public class OrmJoinTableTests extends ContextModelTestCase } public void testRemoveSpecifiedJoinColumn() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -672,8 +680,9 @@ public class OrmJoinTableTests extends ContextModelTestCase } public void testMoveSpecifiedJoinColumn() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -710,8 +719,9 @@ public class OrmJoinTableTests extends ContextModelTestCase } public void testUpdateInverseJoinColumns() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -763,8 +773,9 @@ public class OrmJoinTableTests extends ContextModelTestCase } public void testAddSpecifiedInverseJoinColumn() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -801,8 +812,9 @@ public class OrmJoinTableTests extends ContextModelTestCase } public void testRemoveSpecifiedInverseJoinColumn() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -829,8 +841,9 @@ public class OrmJoinTableTests extends ContextModelTestCase } public void testMoveSpecifiedInverseJoinColumn() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -867,8 +880,9 @@ public class OrmJoinTableTests extends ContextModelTestCase } public void testUpdateJoinColumns() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -921,8 +935,9 @@ public class OrmJoinTableTests extends ContextModelTestCase public void testUniqueConstraints() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -949,8 +964,9 @@ public class OrmJoinTableTests extends ContextModelTestCase } public void testUniqueConstraintsSize() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -972,8 +988,9 @@ public class OrmJoinTableTests extends ContextModelTestCase } public void testAddUniqueConstraint() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -994,8 +1011,9 @@ public class OrmJoinTableTests extends ContextModelTestCase } public void testAddUniqueConstraint2() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -1016,8 +1034,9 @@ public class OrmJoinTableTests extends ContextModelTestCase } public void testRemoveUniqueConstraint() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -1062,8 +1081,9 @@ public class OrmJoinTableTests extends ContextModelTestCase } public void testMoveUniqueConstraint() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -1103,8 +1123,9 @@ public class OrmJoinTableTests extends ContextModelTestCase } public void testUpdateUniqueConstraints() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -1189,7 +1210,7 @@ public class OrmJoinTableTests extends ContextModelTestCase assertEquals("BAZ", uniqueConstraints.next().getColumnNames().iterator().next()); assertFalse(uniqueConstraints.hasNext()); - OrmManyToManyMapping specifiedManyToManyMapping = (OrmManyToManyMapping) ((VirtualOrmPersistentAttribute) virtualAttribute).convertToSpecified().getMapping(); + OrmManyToManyMapping specifiedManyToManyMapping = (OrmManyToManyMapping) ((VirtualOrmPersistentAttribute) virtualAttribute).addToXml().getMapping(); assertEquals(0, specifiedManyToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable().getUniqueConstraintsSize()); } @@ -1197,7 +1218,7 @@ public class OrmJoinTableTests extends ContextModelTestCase createTestEntityWithValidManyToMany(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - ormPersistentType.getAttributeNamed("projects").convertToSpecified(); + ormPersistentType.getAttributeNamed("projects").addToXml(); OrmManyToManyMapping manyToManyMapping = (OrmManyToManyMapping) ormPersistentType.getAttributeNamed("projects").getMapping(); JoinTable joinTable = manyToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable(); @@ -1238,7 +1259,7 @@ public class OrmJoinTableTests extends ContextModelTestCase createTestEntityWithValidManyToMany(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - ormPersistentType.getAttributeNamed("projects").convertToSpecified(); + ormPersistentType.getAttributeNamed("projects").addToXml(); OrmManyToManyMapping manyToManyMapping = (OrmManyToManyMapping) ormPersistentType.getAttributeNamed("projects").getMapping(); JoinTable joinTable = manyToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable(); JoinColumn joinColumn = joinTable.getJoinColumns().iterator().next(); @@ -1302,7 +1323,7 @@ public class OrmJoinTableTests extends ContextModelTestCase createTestEntityWithValidManyToMany(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - ormPersistentType.getAttributeNamed("projects").convertToSpecified(); + ormPersistentType.getAttributeNamed("projects").addToXml(); OrmManyToManyMapping manyToManyMapping = (OrmManyToManyMapping) ormPersistentType.getAttributeNamed("projects").getMapping(); JoinTable joinTable = manyToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable(); JoinColumn joinColumn = joinTable.getJoinColumns().iterator().next(); diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmManyToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmManyToManyMappingTests.java index ac7a850c1d..883ca5cd2e 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmManyToManyMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmManyToManyMappingTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Oracle. All rights reserved. + * Copyright (c) 2007, 2012 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -92,7 +92,7 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase }); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); for (OrmReadOnlyPersistentAttribute each : ormPersistentType.getAttributes()) { - each.convertToSpecified(); + each.addToXml(); } } @@ -257,13 +257,14 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase } public void testUpdateName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); - assertEquals("manyToManyMapping", ormManyToManyMapping.getName()); - assertEquals("manyToManyMapping", manyToMany.getName()); + assertEquals("id", ormManyToManyMapping.getName()); + assertEquals("id", manyToMany.getName()); //set name in the resource model, verify context model updated manyToMany.setName("newName"); @@ -277,13 +278,14 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase } public void testModifyName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); - assertEquals("manyToManyMapping", ormManyToManyMapping.getName()); - assertEquals("manyToManyMapping", manyToMany.getName()); + assertEquals("id", ormManyToManyMapping.getName()); + assertEquals("id", manyToMany.getName()); //set name in the context model, verify resource model updated ormManyToManyMapping.setName("newName"); @@ -297,8 +299,9 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase } public void testUpdateTargetEntity() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -317,8 +320,9 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase } public void testModifyTargetEntity() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -337,8 +341,9 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase } public void testUpdateSpecifiedFetch() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToManyResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -361,8 +366,9 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase } public void testModifySpecifiedFetch() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToManyResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -385,8 +391,9 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase } public void testUpdateMappedBy() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); OrmMappedByRelationshipStrategy strategy = ormManyToManyMapping.getRelationship().getMappedByStrategy(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -406,8 +413,9 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase } public void testModifyMappedBy() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); OrmMappedByRelationshipStrategy strategy = ormManyToManyMapping.getRelationship().getMappedByStrategy(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -497,8 +505,9 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase } public void testUpdateMapKey() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -527,8 +536,9 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase } public void testModifyMapKey() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -582,8 +592,9 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase } public void testUpdateOrderBy() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -602,8 +613,9 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase } public void testModifyOrderBy() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -622,8 +634,9 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase } public void testIsNoOrdering() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); assertTrue(ormManyToManyMapping.getOrderable().isNoOrdering()); @@ -636,8 +649,9 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase } public void testSetNoOrdering() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); assertTrue(ormManyToManyMapping.getOrderable().isNoOrdering()); @@ -659,8 +673,9 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase // } public void testIsCustomOrdering() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); assertFalse(ormManyToManyMapping.getOrderable().isCustomOrdering()); @@ -673,8 +688,9 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase } public void testManyToManyMorphToIdMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToMany"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); ManyToManyMapping manyToManyMapping = (ManyToManyMapping) ormPersistentAttribute.getMapping(); assertFalse(manyToManyMapping.isDefault()); @@ -688,12 +704,13 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof IdMapping); - assertEquals("manyToMany", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testManyToManyMorphToVersionMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToMany"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); ManyToManyMapping manyToManyMapping = (ManyToManyMapping) ormPersistentAttribute.getMapping(); assertFalse(manyToManyMapping.isDefault()); @@ -707,12 +724,13 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof VersionMapping); - assertEquals("manyToMany", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testManyToManyMorphToTransientMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToMany"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); ManyToManyMapping manyToManyMapping = (ManyToManyMapping) ormPersistentAttribute.getMapping(); assertFalse(manyToManyMapping.isDefault()); @@ -726,12 +744,13 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof TransientMapping); - assertEquals("manyToMany", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testManyToManyMorphToEmbeddedMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToMany"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); ManyToManyMapping manyToManyMapping = (ManyToManyMapping) ormPersistentAttribute.getMapping(); assertFalse(manyToManyMapping.isDefault()); @@ -745,12 +764,13 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedMapping); - assertEquals("manyToMany", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testManyToManyMorphToEmbeddedIdMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToMany"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); ManyToManyMapping manyToManyMapping = (ManyToManyMapping) ormPersistentAttribute.getMapping(); assertFalse(manyToManyMapping.isDefault()); @@ -764,12 +784,13 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedIdMapping); - assertEquals("manyToMany", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testManyToManyMorphToOneToOneMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToMany"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); ManyToManyMapping manyToManyMapping = (ManyToManyMapping) ormPersistentAttribute.getMapping(); assertFalse(manyToManyMapping.isDefault()); @@ -789,7 +810,7 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof OneToOneMapping); - assertEquals("manyToMany", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); assertEquals(FetchType.EAGER, ((OneToOneMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch()); assertEquals("TargetEntity", ((OneToOneMapping) ormPersistentAttribute.getMapping()).getSpecifiedTargetEntity()); assertEquals("mappedBy", ((OneToOneMapping) ormPersistentAttribute.getMapping()).getRelationship().getMappedByStrategy().getMappedByAttribute()); @@ -801,8 +822,9 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase } public void testManyToManyMorphToOneToManyMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToMany"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); ManyToManyMapping manyToManyMapping = (ManyToManyMapping) ormPersistentAttribute.getMapping(); assertFalse(manyToManyMapping.isDefault()); @@ -828,7 +850,7 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof OneToManyMapping); - assertEquals("manyToMany", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); assertEquals(FetchType.EAGER, ((OneToManyMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch()); assertEquals("TargetEntity", ((OneToManyMapping) ormPersistentAttribute.getMapping()).getSpecifiedTargetEntity()); assertTrue(((OneToManyMapping) ormPersistentAttribute.getMapping()).getCascade().isAll()); @@ -845,8 +867,9 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase } public void testManyToManyMorphToManyToOneMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToMany"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); ManyToManyMapping manyToManyMapping = (ManyToManyMapping) ormPersistentAttribute.getMapping(); assertFalse(manyToManyMapping.isDefault()); @@ -865,7 +888,7 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToOneMapping); - assertEquals("manyToMany", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); assertEquals(FetchType.EAGER, ((ManyToOneMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch()); assertEquals("TargetEntity", ((ManyToOneMapping) ormPersistentAttribute.getMapping()).getSpecifiedTargetEntity()); assertTrue(((ManyToOneMapping) ormPersistentAttribute.getMapping()).getCascade().isAll()); @@ -876,8 +899,9 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase } public void testManyToManyMorphToBasicMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToMany"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); ManyToManyMapping manyToManyMapping = (ManyToManyMapping) ormPersistentAttribute.getMapping(); assertFalse(manyToManyMapping.isDefault()); @@ -896,7 +920,7 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof BasicMapping); - assertEquals("manyToMany", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); //TODO assertEquals(FetchType.EAGER, ((IBasicMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch()); } @@ -907,7 +931,7 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State"); - ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "addresses"); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("addresses"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); addXmlClassRef(PACKAGE_NAME + ".Address"); @@ -984,7 +1008,7 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase assertEquals("zip", mapKeyNames.next()); assertFalse(mapKeyNames.hasNext()); - ormPersistentType.getAttributeNamed("addresses").convertToSpecified(); + ormPersistentType.getAttributeNamed("addresses").addToXml(); OrmManyToManyMapping specifiedManyToManyMapping = (OrmManyToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping(); mapKeyNames = specifiedManyToManyMapping.getCandidateMapKeyNames().iterator(); assertEquals(false, mapKeyNames.hasNext()); @@ -1008,8 +1032,8 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); - OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + assertEquals(3, ormPersistentType.getDefaultAttributesSize()); + OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); ManyToManyMapping virtualManyToManyMapping = (ManyToManyMapping) virtualPersistentAttribute.getMapping(); assertEquals("address", virtualManyToManyMapping.getName()); @@ -1036,13 +1060,13 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); + assertEquals(3, ormPersistentType.getDefaultAttributesSize()); OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.getAttributeNamed("address"); assertEquals(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY, virtualPersistentAttribute.getMappingKey()); assertTrue(virtualPersistentAttribute.isVirtual()); - virtualPersistentAttribute.convertToSpecified(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); + virtualPersistentAttribute.addToXml(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmPersistentAttribute ormPersistentAttribute= ormPersistentType.getSpecifiedAttributes().iterator().next(); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmManyToOneMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmManyToOneMappingTests.java index 473d2ca0b0..45c19e442b 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmManyToOneMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmManyToOneMappingTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Oracle. All rights reserved. + * Copyright (c) 2007, 2012 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -94,7 +94,7 @@ public class OrmManyToOneMappingTests extends ContextModelTestCase }); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); for (OrmReadOnlyPersistentAttribute each : ormPersistentType.getAttributes()) { - each.convertToSpecified(); + each.addToXml(); } } @@ -132,13 +132,14 @@ public class OrmManyToOneMappingTests extends ContextModelTestCase } public void testUpdateName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "manyToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping(); XmlManyToOne manyToOne = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToOnes().get(0); - assertEquals("manyToOneMapping", ormManyToOneMapping.getName()); - assertEquals("manyToOneMapping", manyToOne.getName()); + assertEquals("id", ormManyToOneMapping.getName()); + assertEquals("id", manyToOne.getName()); //set name in the resource model, verify context model updated manyToOne.setName("newName"); @@ -152,13 +153,14 @@ public class OrmManyToOneMappingTests extends ContextModelTestCase } public void testModifyName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "manyToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping(); XmlManyToOne manyToOne = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToOnes().get(0); - assertEquals("manyToOneMapping", ormManyToOneMapping.getName()); - assertEquals("manyToOneMapping", manyToOne.getName()); + assertEquals("id", ormManyToOneMapping.getName()); + assertEquals("id", manyToOne.getName()); //set name in the context model, verify resource model updated ormManyToOneMapping.setName("newName"); @@ -172,8 +174,9 @@ public class OrmManyToOneMappingTests extends ContextModelTestCase } public void testUpdateTargetEntity() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "manyToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping(); XmlManyToOne manyToOne = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToOnes().get(0); @@ -192,8 +195,9 @@ public class OrmManyToOneMappingTests extends ContextModelTestCase } public void testModifyTargetEntity() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "manyToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping(); XmlManyToOne manyToOne = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToOnes().get(0); @@ -212,8 +216,9 @@ public class OrmManyToOneMappingTests extends ContextModelTestCase } public void testUpdateSpecifiedFetch() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "manyToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping(); XmlManyToOne manyToOneResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToOnes().get(0); @@ -236,8 +241,9 @@ public class OrmManyToOneMappingTests extends ContextModelTestCase } public void testModifySpecifiedFetch() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "manyToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping(); XmlManyToOne manyToOneResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToOnes().get(0); @@ -260,8 +266,9 @@ public class OrmManyToOneMappingTests extends ContextModelTestCase } public void testUpdateSpecifiedOptional() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "manyToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping(); XmlManyToOne manyToOneResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToOnes().get(0); @@ -284,8 +291,9 @@ public class OrmManyToOneMappingTests extends ContextModelTestCase } public void testModifySpecifiedOptional() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "manyToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping(); XmlManyToOne manyToOneResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToOnes().get(0); @@ -308,8 +316,9 @@ public class OrmManyToOneMappingTests extends ContextModelTestCase } public void testAddSpecifiedJoinColumn() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "manyToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping(); OrmJoinColumnRelationshipStrategy strategy = ormManyToOneMapping.getRelationship().getJoinColumnStrategy(); XmlManyToOne manyToOneResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToOnes().get(0); @@ -344,8 +353,9 @@ public class OrmManyToOneMappingTests extends ContextModelTestCase } public void testRemoveSpecifiedJoinColumn() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "manyToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping(); OrmJoinColumnRelationshipStrategy strategy = ormManyToOneMapping.getRelationship().getJoinColumnStrategy(); XmlManyToOne manyToOneResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToOnes().get(0); @@ -410,8 +420,9 @@ public class OrmManyToOneMappingTests extends ContextModelTestCase } public void testMoveSpecifiedJoinColumn() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "manyToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping(); OrmJoinColumnRelationshipStrategy strategy = ormManyToOneMapping.getRelationship().getJoinColumnStrategy(); XmlManyToOne manyToOneResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToOnes().get(0); @@ -452,11 +463,12 @@ public class OrmManyToOneMappingTests extends ContextModelTestCase OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); - ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "foo"); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("address"), MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping(); + ormManyToOneMapping.setName("foo"); OrmJoinColumnRelationshipStrategy strategy = ormManyToOneMapping.getRelationship().getJoinColumnStrategy(); assertEquals("foo", ormManyToOneMapping.getName()); @@ -488,8 +500,8 @@ public class OrmManyToOneMappingTests extends ContextModelTestCase OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); - OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + assertEquals(3, ormPersistentType.getDefaultAttributesSize()); + OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); ManyToOneMapping manyToOneMapping = (ManyToOneMapping) ormPersistentAttribute.getMapping(); assertEquals("address", manyToOneMapping.getName()); @@ -522,13 +534,13 @@ public class OrmManyToOneMappingTests extends ContextModelTestCase OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); + assertEquals(3, ormPersistentType.getDefaultAttributesSize()); OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getAttributeNamed("address"); assertEquals(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMappingKey()); assertTrue(ormPersistentAttribute.isVirtual()); - ormPersistentAttribute.convertToSpecified(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY); + ormPersistentAttribute.addToXml(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY); ormPersistentAttribute= ormPersistentType.getSpecifiedAttributes().iterator().next(); OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping(); @@ -565,8 +577,8 @@ public class OrmManyToOneMappingTests extends ContextModelTestCase OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); - ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "address"); - assertEquals(2, ormPersistentType.getVirtualAttributesSize()); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("address"), MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping(); diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmOneToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmOneToManyMappingTests.java index 4d9ddf18e6..251000ad4c 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmOneToManyMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmOneToManyMappingTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Oracle. All rights reserved. + * Copyright (c) 2007, 2012 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -104,7 +104,7 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase }); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); for (OrmReadOnlyPersistentAttribute each :ormPersistentType.getAttributes()) { - each.convertToSpecified(); + each.addToXml(); } } @@ -232,13 +232,14 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase } public void testUpdateName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping(); XmlOneToMany oneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0); - assertEquals("oneToManyMapping", ormOneToManyMapping.getName()); - assertEquals("oneToManyMapping", oneToMany.getName()); + assertEquals("id", ormOneToManyMapping.getName()); + assertEquals("id", oneToMany.getName()); //set name in the resource model, verify context model updated oneToMany.setName("newName"); @@ -252,13 +253,14 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase } public void testModifyName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping(); XmlOneToMany oneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0); - assertEquals("oneToManyMapping", ormOneToManyMapping.getName()); - assertEquals("oneToManyMapping", oneToMany.getName()); + assertEquals("id", ormOneToManyMapping.getName()); + assertEquals("id", oneToMany.getName()); //set name in the context model, verify resource model updated ormOneToManyMapping.setName("newName"); @@ -272,8 +274,9 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase } public void testUpdateTargetEntity() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping(); XmlOneToMany oneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0); @@ -292,8 +295,9 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase } public void testModifyTargetEntity() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping(); XmlOneToMany oneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0); @@ -312,8 +316,9 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase } public void testUpdateSpecifiedFetch() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping(); XmlOneToMany oneToManyResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0); @@ -336,8 +341,9 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase } public void testModifySpecifiedFetch() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping(); XmlOneToMany oneToManyResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0); @@ -360,8 +366,9 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase } public void testUpdateMappedBy() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping(); OrmMappedByRelationshipStrategy strategy = ormOneToManyMapping.getRelationship().getMappedByStrategy(); XmlOneToMany oneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0); @@ -381,8 +388,9 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase } public void testModifyMappedBy() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping(); OrmMappedByRelationshipStrategy strategy = ormOneToManyMapping.getRelationship().getMappedByStrategy(); XmlOneToMany oneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0); @@ -472,8 +480,9 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase } public void testUpdateMapKey() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping(); XmlOneToMany oneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0); @@ -537,8 +546,9 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase } public void testModifyMapKey() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping(); XmlOneToMany oneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0); @@ -557,8 +567,9 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase } public void testUpdateOrderBy() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping(); XmlOneToMany oneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0); @@ -577,8 +588,9 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase } public void testModifyOrderBy() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping(); XmlOneToMany oneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0); @@ -597,8 +609,9 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase } public void testIsNoOrdering() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping(); assertTrue(ormOneToManyMapping.getOrderable().isNoOrdering()); @@ -611,8 +624,9 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase } public void testSetNoOrdering() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping(); assertTrue(ormOneToManyMapping.getOrderable().isNoOrdering()); @@ -634,8 +648,9 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase // } public void testIsCustomOrdering() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping(); assertFalse(ormOneToManyMapping.getOrderable().isCustomOrdering()); @@ -648,8 +663,9 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase } public void testOneToManyMorphToIdMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToMany"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OneToManyMapping oneToManyMapping = (OneToManyMapping) ormPersistentAttribute.getMapping(); assertFalse(oneToManyMapping.isDefault()); @@ -664,12 +680,13 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof IdMapping); - assertEquals("oneToMany", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testOneToManyMorphToVersionMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToMany"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OneToManyMapping oneToManyMapping = (OneToManyMapping) ormPersistentAttribute.getMapping(); assertFalse(oneToManyMapping.isDefault()); @@ -690,12 +707,13 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof VersionMapping); - assertEquals("oneToMany", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testOneToManyMorphToTransientMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToMany"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OneToManyMapping oneToManyMapping = (OneToManyMapping) ormPersistentAttribute.getMapping(); assertFalse(oneToManyMapping.isDefault()); @@ -710,12 +728,13 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof TransientMapping); - assertEquals("oneToMany", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testOneToManyMorphToEmbeddedMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToMany"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OneToManyMapping oneToManyMapping = (OneToManyMapping) ormPersistentAttribute.getMapping(); assertFalse(oneToManyMapping.isDefault()); @@ -736,12 +755,13 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedMapping); - assertEquals("oneToMany", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testOneToManyMorphToEmbeddedIdMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToMany"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OneToManyMapping oneToManyMapping = (OneToManyMapping) ormPersistentAttribute.getMapping(); assertFalse(oneToManyMapping.isDefault()); @@ -756,12 +776,13 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedIdMapping); - assertEquals("oneToMany", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testOneToManyMorphToOneToOneMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToMany"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OneToManyMapping oneToManyMapping = (OneToManyMapping) ormPersistentAttribute.getMapping(); assertFalse(oneToManyMapping.isDefault()); @@ -781,7 +802,7 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof OneToOneMapping); - assertEquals("oneToMany", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); assertEquals(FetchType.EAGER, ((OneToOneMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch()); assertEquals("TargetEntity", ((OneToOneMapping) ormPersistentAttribute.getMapping()).getSpecifiedTargetEntity()); assertEquals("mappedBy", ((OneToOneMapping) ormPersistentAttribute.getMapping()).getRelationship().getMappedByStrategy().getMappedByAttribute()); @@ -793,8 +814,9 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase } public void testOneToManyMorphToManyToManyMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToMany"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OneToManyMapping oneToManyMapping = (OneToManyMapping) ormPersistentAttribute.getMapping(); assertFalse(oneToManyMapping.isDefault()); @@ -820,7 +842,7 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToManyMapping); - assertEquals("oneToMany", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); assertEquals(FetchType.EAGER, ((ManyToManyMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch()); assertEquals("TargetEntity", ((ManyToManyMapping) ormPersistentAttribute.getMapping()).getSpecifiedTargetEntity()); assertTrue(((ManyToManyMapping) ormPersistentAttribute.getMapping()).getCascade().isAll()); @@ -837,8 +859,9 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase } public void testOneToManyMorphToManyToOneMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToMany"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OneToManyMapping oneToManyMapping = (OneToManyMapping) ormPersistentAttribute.getMapping(); assertFalse(oneToManyMapping.isDefault()); @@ -858,7 +881,7 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToOneMapping); - assertEquals("oneToMany", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); assertEquals(FetchType.EAGER, ((ManyToOneMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch()); assertEquals("TargetEntity", ((ManyToOneMapping) ormPersistentAttribute.getMapping()).getSpecifiedTargetEntity()); assertTrue(((ManyToOneMapping) ormPersistentAttribute.getMapping()).getCascade().isAll()); @@ -869,8 +892,9 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase } public void testOneToManyMorphToBasicMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToMany"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OneToManyMapping oneToManyMapping = (OneToManyMapping) ormPersistentAttribute.getMapping(); assertFalse(oneToManyMapping.isDefault()); @@ -890,7 +914,6 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof BasicMapping); - assertEquals("oneToMany", ormPersistentAttribute.getMapping().getName()); //TODO assertEquals(FetchType.EAGER, ((IBasicMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch()); } @@ -901,7 +924,7 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State"); - ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "addresses"); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("addresses"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); addXmlClassRef(PACKAGE_NAME + ".Address"); @@ -979,7 +1002,7 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase assertEquals("zip", mapKeyNames.next()); assertFalse(mapKeyNames.hasNext()); - OrmOneToManyMapping specifiedOneToManyMapping = (OrmOneToManyMapping) virtualAttribute.convertToSpecified().getMapping(); + OrmOneToManyMapping specifiedOneToManyMapping = (OrmOneToManyMapping) virtualAttribute.addToXml().getMapping(); mapKeyNames = specifiedOneToManyMapping.getCandidateMapKeyNames().iterator(); assertEquals(false, mapKeyNames.hasNext()); @@ -1002,8 +1025,8 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); - OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + assertEquals(3, ormPersistentType.getDefaultAttributesSize()); + OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); OneToManyMapping virtualOneToManyMapping = (OneToManyMapping) virtualPersistentAttribute.getMapping(); assertEquals("address", virtualOneToManyMapping.getName()); @@ -1030,13 +1053,13 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); + assertEquals(3, ormPersistentType.getDefaultAttributesSize()); OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.getAttributeNamed("address"); assertEquals(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY, virtualPersistentAttribute.getMappingKey()); assertTrue(virtualPersistentAttribute.isVirtual()); - OrmReadOnlyPersistentAttribute ormPersistentAttribute = virtualPersistentAttribute.convertToSpecified(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); + OrmReadOnlyPersistentAttribute ormPersistentAttribute = virtualPersistentAttribute.addToXml(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping(); assertEquals("address", ormOneToManyMapping.getName()); diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmOneToOneMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmOneToOneMappingTests.java index b0dfe76a21..39b5f335ed 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmOneToOneMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmOneToOneMappingTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Oracle. All rights reserved. + * Copyright (c) 2007, 2012 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -108,7 +108,7 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase }); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); for (OrmReadOnlyPersistentAttribute each : ormPersistentType.getAttributes()) { - each.convertToSpecified(); + each.addToXml(); } } @@ -191,13 +191,14 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase } public void testUpdateName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); XmlOneToOne oneToOne = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); - assertEquals("oneToOneMapping", ormOneToOneMapping.getName()); - assertEquals("oneToOneMapping", oneToOne.getName()); + assertEquals("id", ormOneToOneMapping.getName()); + assertEquals("id", oneToOne.getName()); //set name in the resource model, verify context model updated oneToOne.setName("newName"); @@ -211,13 +212,14 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase } public void testModifyName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); XmlOneToOne oneToOne = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); - assertEquals("oneToOneMapping", ormOneToOneMapping.getName()); - assertEquals("oneToOneMapping", oneToOne.getName()); + assertEquals("id", ormOneToOneMapping.getName()); + assertEquals("id", oneToOne.getName()); //set name in the context model, verify resource model updated ormOneToOneMapping.setName("newName"); @@ -231,8 +233,9 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase } public void testUpdateSpecifiedTargetEntity() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); XmlOneToOne oneToOne = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); @@ -251,8 +254,9 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase } public void testModifySpecifiedTargetEntity() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); XmlOneToOne oneToOne = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); @@ -271,8 +275,9 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase } public void testUpdateSpecifiedFetch() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); XmlOneToOne oneToOneResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); @@ -295,8 +300,9 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase } public void testModifySpecifiedFetch() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); XmlOneToOne oneToOneResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); @@ -319,8 +325,9 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase } public void testUpdateMappedBy() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); MappedByRelationshipStrategy strategy = ormOneToOneMapping.getRelationship().getMappedByStrategy(); XmlOneToOne oneToOne = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); @@ -340,8 +347,9 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase } public void testModifyMappedBy() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); MappedByRelationshipStrategy strategy = ormOneToOneMapping.getRelationship().getMappedByStrategy(); XmlOneToOne oneToOne = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); @@ -473,8 +481,9 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase } public void testUpdateSpecifiedOptional() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); XmlOneToOne oneToOneResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); @@ -497,8 +506,9 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase } public void testModifySpecifiedOptional() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); XmlOneToOne oneToOneResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); @@ -521,8 +531,9 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase } public void testAddSpecifiedJoinColumn() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); OrmJoinColumnRelationshipStrategy strategy = ormOneToOneMapping.getRelationship().getJoinColumnStrategy(); XmlOneToOne oneToOneResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); @@ -557,8 +568,9 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase } public void testRemoveSpecifiedJoinColumn() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); OrmJoinColumnRelationshipStrategy strategy = ormOneToOneMapping.getRelationship().getJoinColumnStrategy(); XmlOneToOne oneToOneResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); @@ -583,8 +595,9 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase } public void testMoveSpecifiedJoinColumn() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); OrmJoinColumnRelationshipStrategy strategy = ormOneToOneMapping.getRelationship().getJoinColumnStrategy(); XmlOneToOne oneToOneResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); @@ -624,12 +637,12 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); - ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "foo"); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("address"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); - + ormOneToOneMapping.setName("foo"); assertEquals("foo", ormOneToOneMapping.getName()); assertNull(ormOneToOneMapping.getSpecifiedFetch()); @@ -660,8 +673,8 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); - OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + assertEquals(3, ormPersistentType.getDefaultAttributesSize()); + OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); OneToOneMapping oneToOneMapping = (OneToOneMapping) ormPersistentAttribute.getMapping(); assertEquals("address", oneToOneMapping.getName()); @@ -697,13 +710,13 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); + assertEquals(3, ormPersistentType.getDefaultAttributesSize()); OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getAttributeNamed("address"); assertEquals(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMappingKey()); assertTrue(ormPersistentAttribute.isVirtual()); - ormPersistentAttribute.convertToSpecified(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); + ormPersistentAttribute.addToXml(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); ormPersistentAttribute= ormPersistentType.getSpecifiedAttributes().iterator().next(); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); @@ -740,8 +753,8 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); - ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "address"); - assertEquals(2, ormPersistentType.getVirtualAttributesSize()); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("address"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); @@ -788,8 +801,9 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase public void testOneToOneMorphToIdMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOne"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OneToOneMapping oneToOneMapping = (OneToOneMapping) ormPersistentAttribute.getMapping(); assertFalse(oneToOneMapping.isDefault()); @@ -810,12 +824,13 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof IdMapping); - assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testOneToOneMorphToVersionMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOne"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OneToOneMapping oneToOneMapping = (OneToOneMapping) ormPersistentAttribute.getMapping(); assertFalse(oneToOneMapping.isDefault()); @@ -836,12 +851,13 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof VersionMapping); - assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testOneToOneMorphToTransientMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOne"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OneToOneMapping oneToOneMapping = (OneToOneMapping) ormPersistentAttribute.getMapping(); assertFalse(oneToOneMapping.isDefault()); @@ -862,12 +878,13 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof TransientMapping); - assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testOneToOneMorphToEmbeddedMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOne"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OneToOneMapping oneToOneMapping = (OneToOneMapping) ormPersistentAttribute.getMapping(); assertFalse(oneToOneMapping.isDefault()); @@ -888,12 +905,13 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedMapping); - assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testOneToOneMorphToEmbeddedIdMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOne"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OneToOneMapping oneToOneMapping = (OneToOneMapping) ormPersistentAttribute.getMapping(); assertFalse(oneToOneMapping.isDefault()); @@ -914,12 +932,13 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedIdMapping); - assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testOneToOneMorphToManyToManyMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOne"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OneToOneMapping oneToOneMapping = (OneToOneMapping) ormPersistentAttribute.getMapping(); assertFalse(oneToOneMapping.isDefault()); @@ -940,7 +959,7 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToManyMapping); - assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); assertEquals(FetchType.EAGER, ((ManyToManyMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch()); assertEquals("TargetEntity", ((ManyToManyMapping) ormPersistentAttribute.getMapping()).getSpecifiedTargetEntity()); assertEquals("mappedBy", ((ManyToManyMapping) ormPersistentAttribute.getMapping()).getRelationship().getMappedByStrategy().getMappedByAttribute()); @@ -952,8 +971,9 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase } public void testOneToOneMorphToOneToManyMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOne"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OneToOneMapping oneToOneMapping = (OneToOneMapping) ormPersistentAttribute.getMapping(); assertFalse(oneToOneMapping.isDefault()); @@ -974,7 +994,7 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof OneToManyMapping); - assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); assertEquals(FetchType.EAGER, ((OneToManyMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch()); assertEquals("TargetEntity", ((OneToManyMapping) ormPersistentAttribute.getMapping()).getSpecifiedTargetEntity()); assertEquals("mappedBy", ((OneToManyMapping) ormPersistentAttribute.getMapping()).getRelationship().getMappedByStrategy().getMappedByAttribute()); @@ -986,8 +1006,9 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase } public void testOneToOneMorphToManyToOneMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOne"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OneToOneMapping oneToOneMapping = (OneToOneMapping) ormPersistentAttribute.getMapping(); assertFalse(oneToOneMapping.isDefault()); @@ -1008,7 +1029,7 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToOneMapping); - assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); assertEquals(FetchType.EAGER, ((ManyToOneMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch()); assertEquals("TargetEntity", ((ManyToOneMapping) ormPersistentAttribute.getMapping()).getSpecifiedTargetEntity()); assertTrue(((ManyToOneMapping) ormPersistentAttribute.getMapping()).getCascade().isAll()); @@ -1023,8 +1044,9 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase } public void testOneToOneMorphToBasicMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOne"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OneToOneMapping oneToOneMapping = (OneToOneMapping) ormPersistentAttribute.getMapping(); assertFalse(oneToOneMapping.isDefault()); @@ -1045,7 +1067,7 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof BasicMapping); - assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); //TODO assertEquals(FetchType.EAGER, ((IBasicMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch()); } @@ -1054,8 +1076,9 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase public void testAddPrimaryKeyJoinColumn() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); OrmPrimaryKeyJoinColumnRelationshipStrategy strategy = ormOneToOneMapping.getRelationship().getPrimaryKeyJoinColumnStrategy(); XmlOneToOne oneToOneResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); @@ -1090,8 +1113,9 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase } public void testRemovePrimaryKeyJoinColumn() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); OrmPrimaryKeyJoinColumnRelationshipStrategy strategy = ormOneToOneMapping.getRelationship().getPrimaryKeyJoinColumnStrategy(); XmlOneToOne oneToOneResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); @@ -1116,8 +1140,9 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase } public void testMovePrimaryKeyJoinColumn() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); OrmPrimaryKeyJoinColumnRelationshipStrategy strategy = ormOneToOneMapping.getRelationship().getPrimaryKeyJoinColumnStrategy(); XmlOneToOne oneToOneResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); @@ -1158,7 +1183,7 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State"); - ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "address"); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("address"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); addXmlClassRef(PACKAGE_NAME + ".Address"); diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmTableGeneratorTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmTableGeneratorTests.java index d0783f6dc9..d063949658 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmTableGeneratorTests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmTableGeneratorTests.java @@ -599,7 +599,7 @@ public class OrmTableGeneratorTests extends ContextModelTestCase // assertEquals("BAZ", uniqueConstraints.next().getColumnNames().iterator().next()); // assertFalse(uniqueConstraints.hasNext()); - OrmIdMapping ormIdMapping = (OrmIdMapping) virtualAttribute.convertToSpecified().getMapping(); + OrmIdMapping ormIdMapping = (OrmIdMapping) virtualAttribute.addToXml().getMapping(); OrmTableGenerator ormTableGenerator2 = ormIdMapping.getGeneratorContainer().addTableGenerator(); ormTableGenerator2.setName("TABLE_GENERATOR"); diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmTransientMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmTransientMappingTests.java index 8086ff8db0..3e894c7236 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmTransientMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmTransientMappingTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Oracle. All rights reserved. + * Copyright (c) 2007, 2012 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -66,34 +66,37 @@ public class OrmTransientMappingTests extends ContextModelTestCase } }); } + public void testUpdateName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "transientMapping"); - OrmTransientMapping xmlTransientnMapping = (OrmTransientMapping) ormPersistentAttribute.getMapping(); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY); + OrmTransientMapping xmlTransientMapping = (OrmTransientMapping) ormPersistentAttribute.getMapping(); XmlTransient transientResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getTransients().get(0); - assertEquals("transientMapping", xmlTransientnMapping.getName()); - assertEquals("transientMapping", transientResource.getName()); + assertEquals("id", xmlTransientMapping.getName()); + assertEquals("id", transientResource.getName()); //set name in the resource model, verify context model updated transientResource.setName("newName"); - assertEquals("newName", xmlTransientnMapping.getName()); + assertEquals("newName", xmlTransientMapping.getName()); assertEquals("newName", transientResource.getName()); //set name to null in the resource model transientResource.setName(null); - assertNull(xmlTransientnMapping.getName()); + assertNull(xmlTransientMapping.getName()); assertNull(transientResource.getName()); } public void testModifyName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "transientMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY); OrmTransientMapping xmlTransientnMapping = (OrmTransientMapping) ormPersistentAttribute.getMapping(); XmlTransient transientResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getTransients().get(0); - assertEquals("transientMapping", xmlTransientnMapping.getName()); - assertEquals("transientMapping", transientResource.getName()); + assertEquals("id", xmlTransientnMapping.getName()); + assertEquals("id", transientResource.getName()); //set name in the context model, verify resource model updated xmlTransientnMapping.setName("newName"); @@ -111,12 +114,13 @@ public class OrmTransientMappingTests extends ContextModelTestCase createTestEntityTransientMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - ormPersistentType.addSpecifiedAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "foo"); - assertEquals(2, ormPersistentType.getVirtualAttributesSize()); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY); + + assertEquals(1, ormPersistentType.getDefaultAttributesSize()); OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); OrmTransientMapping ormTransientMapping = (OrmTransientMapping) ormPersistentAttribute.getMapping(); - + ormTransientMapping.setName("foo"); assertEquals("foo", ormTransientMapping.getName()); } @@ -130,8 +134,8 @@ public class OrmTransientMappingTests extends ContextModelTestCase public void testVirtualMappingMetadataCompleteFalse() throws Exception { createTestEntityTransientMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - assertEquals(2, ormPersistentType.getVirtualAttributesSize()); - OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); + OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); TransientMapping transientMapping = (TransientMapping) ormPersistentAttribute.getMapping(); assertEquals("id", transientMapping.getName()); @@ -141,13 +145,13 @@ public class OrmTransientMappingTests extends ContextModelTestCase createTestEntityTransientMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE); - assertEquals(2, ormPersistentType.getVirtualAttributesSize()); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getAttributeNamed("id"); assertEquals(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMappingKey()); assertTrue(ormPersistentAttribute.isVirtual()); - ormPersistentAttribute.convertToSpecified(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY); + ormPersistentAttribute.addToXml(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY); ormPersistentAttribute = ormPersistentType.getAttributeNamed("id"); OrmTransientMapping ormTransientMapping = (OrmTransientMapping) ormPersistentAttribute.getMapping(); @@ -159,8 +163,8 @@ public class OrmTransientMappingTests extends ContextModelTestCase createTestEntityTransientMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - ormPersistentType.addSpecifiedAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "id"); - assertEquals(1, ormPersistentType.getVirtualAttributesSize()); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY); + assertEquals(1, ormPersistentType.getDefaultAttributesSize()); OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); OrmTransientMapping ormTransientMapping = (OrmTransientMapping) ormPersistentAttribute.getMapping(); @@ -171,7 +175,7 @@ public class OrmTransientMappingTests extends ContextModelTestCase public void testTransientMorphToIdMapping() throws Exception { createTestEntityTransientMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "transient"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY); TransientMapping transientMapping = (TransientMapping) ormPersistentAttribute.getMapping(); assertFalse(transientMapping.isDefault()); @@ -180,13 +184,13 @@ public class OrmTransientMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof IdMapping); - assertEquals("transient", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testTransientMorphToVersionMapping() throws Exception { createTestEntityTransientMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "transient"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY); TransientMapping transientMapping = (TransientMapping) ormPersistentAttribute.getMapping(); assertFalse(transientMapping.isDefault()); @@ -195,13 +199,13 @@ public class OrmTransientMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof VersionMapping); - assertEquals("transient", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testTransientMorphToTransientMapping() throws Exception { createTestEntityTransientMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "transient"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY); TransientMapping transientMapping = (TransientMapping) ormPersistentAttribute.getMapping(); assertFalse(transientMapping.isDefault()); @@ -210,13 +214,13 @@ public class OrmTransientMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof TransientMapping); - assertEquals("transient", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testTransientMorphToEmbeddedMapping() throws Exception { createTestEntityTransientMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "transient"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY); TransientMapping transientMapping = (TransientMapping) ormPersistentAttribute.getMapping(); assertFalse(transientMapping.isDefault()); @@ -225,13 +229,13 @@ public class OrmTransientMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedMapping); - assertEquals("transient", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testTransientMorphToEmbeddedIdMapping() throws Exception { createTestEntityTransientMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "transient"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY); TransientMapping transientMapping = (TransientMapping) ormPersistentAttribute.getMapping(); assertFalse(transientMapping.isDefault()); @@ -240,13 +244,13 @@ public class OrmTransientMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedIdMapping); - assertEquals("transient", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testTransientMorphToOneToOneMapping() throws Exception { createTestEntityTransientMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "transient"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY); TransientMapping transientMapping = (TransientMapping) ormPersistentAttribute.getMapping(); assertFalse(transientMapping.isDefault()); @@ -255,13 +259,13 @@ public class OrmTransientMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof OneToOneMapping); - assertEquals("transient", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testTransientMorphToOneToManyMapping() throws Exception { createTestEntityTransientMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "transient"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY); TransientMapping transientMapping = (TransientMapping) ormPersistentAttribute.getMapping(); assertFalse(transientMapping.isDefault()); @@ -270,13 +274,13 @@ public class OrmTransientMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof OneToManyMapping); - assertEquals("transient", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testTransientMorphToManyToOneMapping() throws Exception { createTestEntityTransientMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "transient"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY); TransientMapping transientMapping = (TransientMapping) ormPersistentAttribute.getMapping(); assertFalse(transientMapping.isDefault()); @@ -285,13 +289,13 @@ public class OrmTransientMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToOneMapping); - assertEquals("transient", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testTransientMorphToManyToManyMapping() throws Exception { createTestEntityTransientMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "transient"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY); TransientMapping transientMapping = (TransientMapping) ormPersistentAttribute.getMapping(); assertFalse(transientMapping.isDefault()); @@ -300,6 +304,6 @@ public class OrmTransientMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToManyMapping); - assertEquals("transient", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } }
\ No newline at end of file diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmVersionMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmVersionMappingTests.java index da7a2d2abf..f2c0a0a69e 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmVersionMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmVersionMappingTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Oracle. All rights reserved. + * Copyright (c) 2007, 2012 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -77,13 +77,14 @@ public class OrmVersionMappingTests extends ContextModelTestCase } public void testUpdateName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "versionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY); OrmVersionMapping ormVersionMapping = (OrmVersionMapping) ormPersistentAttribute.getMapping(); XmlVersion versionResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getVersions().get(0); - assertEquals("versionMapping", ormVersionMapping.getName()); - assertEquals("versionMapping", versionResource.getName()); + assertEquals("id", ormVersionMapping.getName()); + assertEquals("id", versionResource.getName()); //set name in the resource model, verify context model updated versionResource.setName("newName"); @@ -97,13 +98,14 @@ public class OrmVersionMappingTests extends ContextModelTestCase } public void testModifyName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "versionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY); OrmVersionMapping ormVersionMapping = (OrmVersionMapping) ormPersistentAttribute.getMapping(); XmlVersion versionResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getVersions().get(0); - assertEquals("versionMapping", ormVersionMapping.getName()); - assertEquals("versionMapping", versionResource.getName()); + assertEquals("id", ormVersionMapping.getName()); + assertEquals("id", versionResource.getName()); //set name in the context model, verify resource model updated ormVersionMapping.setName("newName"); @@ -117,8 +119,9 @@ public class OrmVersionMappingTests extends ContextModelTestCase } public void testUpdateTemporal() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "versionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY); OrmVersionMapping ormVersionMapping = (OrmVersionMapping) ormPersistentAttribute.getMapping(); XmlVersion versionResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getVersions().get(0); @@ -145,8 +148,9 @@ public class OrmVersionMappingTests extends ContextModelTestCase } public void testModifyTemporal() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "versionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY); OrmVersionMapping ormVersionMapping = (OrmVersionMapping) ormPersistentAttribute.getMapping(); XmlVersion versionResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getVersions().get(0); @@ -180,12 +184,12 @@ public class OrmVersionMappingTests extends ContextModelTestCase createTestEntityVersionMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - ormPersistentType.addSpecifiedAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "foo"); - assertEquals(2, ormPersistentType.getVirtualAttributesSize()); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY); + assertEquals(1, ormPersistentType.getDefaultAttributesSize()); OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); OrmVersionMapping ormVersionMapping = (OrmVersionMapping) ormPersistentAttribute.getMapping(); - + ormVersionMapping.setName("foo"); assertEquals("foo", ormVersionMapping.getName()); assertNull(ormVersionMapping.getConverter().getType()); @@ -224,8 +228,8 @@ public class OrmVersionMappingTests extends ContextModelTestCase public void testVirtualMappingMetadataCompleteFalse() throws Exception { createTestEntityVersionMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - assertEquals(2, ormPersistentType.getVirtualAttributesSize()); - OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); + OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); VersionMapping versionMapping = (VersionMapping) ormPersistentAttribute.getMapping(); assertEquals("id", versionMapping.getName()); @@ -249,13 +253,13 @@ public class OrmVersionMappingTests extends ContextModelTestCase createTestEntityVersionMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE); - assertEquals(2, ormPersistentType.getVirtualAttributesSize()); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getAttributeNamed("id"); assertEquals(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMappingKey()); assertTrue(ormPersistentAttribute.isVirtual()); - ormPersistentAttribute.convertToSpecified(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY); + ormPersistentAttribute.addToXml(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY); ormPersistentAttribute= ormPersistentType.getAttributeNamed("id"); OrmVersionMapping ormVersionMapping = (OrmVersionMapping) ormPersistentAttribute.getMapping(); @@ -280,8 +284,8 @@ public class OrmVersionMappingTests extends ContextModelTestCase createTestEntityVersionMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - ormPersistentType.addSpecifiedAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "id"); - assertEquals(1, ormPersistentType.getVirtualAttributesSize()); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY); + assertEquals(1, ormPersistentType.getDefaultAttributesSize()); OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); OrmVersionMapping ormVersionMapping = (OrmVersionMapping) ormPersistentAttribute.getMapping(); @@ -316,7 +320,7 @@ public class OrmVersionMappingTests extends ContextModelTestCase public void testVersionMorphToIdMapping() throws Exception { createTestEntityVersionMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "version"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY); VersionMapping versionMapping = (VersionMapping) ormPersistentAttribute.getMapping(); assertFalse(versionMapping.isDefault()); @@ -329,14 +333,14 @@ public class OrmVersionMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof IdMapping); - assertEquals("version", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); assertEquals("FOO", ((IdMapping) ormPersistentAttribute.getMapping()).getColumn().getSpecifiedName()); } public void testVersionMorphToBasicMapping() throws Exception { createTestEntityVersionMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "version"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY); VersionMapping versionMapping = (VersionMapping) ormPersistentAttribute.getMapping(); assertFalse(versionMapping.isDefault()); @@ -349,14 +353,14 @@ public class OrmVersionMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof BasicMapping); - assertEquals("version", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); assertEquals("FOO", ((BasicMapping) ormPersistentAttribute.getMapping()).getColumn().getSpecifiedName()); } public void testVersionMorphToTransientMapping() throws Exception { createTestEntityVersionMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "version"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY); VersionMapping versionMapping = (VersionMapping) ormPersistentAttribute.getMapping(); assertFalse(versionMapping.isDefault()); @@ -369,13 +373,13 @@ public class OrmVersionMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof TransientMapping); - assertEquals("version", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testVersionMorphToEmbeddedMapping() throws Exception { createTestEntityVersionMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "version"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY); VersionMapping versionMapping = (VersionMapping) ormPersistentAttribute.getMapping(); assertFalse(versionMapping.isDefault()); @@ -388,13 +392,13 @@ public class OrmVersionMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedMapping); - assertEquals("version", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testVersionMorphToEmbeddedIdMapping() throws Exception { createTestEntityVersionMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "version"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY); VersionMapping versionMapping = (VersionMapping) ormPersistentAttribute.getMapping(); assertFalse(versionMapping.isDefault()); @@ -407,13 +411,13 @@ public class OrmVersionMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedIdMapping); - assertEquals("version", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testVersionMorphToOneToOneMapping() throws Exception { createTestEntityVersionMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "version"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY); VersionMapping versionMapping = (VersionMapping) ormPersistentAttribute.getMapping(); assertFalse(versionMapping.isDefault()); @@ -426,13 +430,13 @@ public class OrmVersionMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof OneToOneMapping); - assertEquals("version", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testVersionMorphToOneToManyMapping() throws Exception { createTestEntityVersionMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "version"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY); VersionMapping versionMapping = (VersionMapping) ormPersistentAttribute.getMapping(); assertFalse(versionMapping.isDefault()); @@ -445,13 +449,13 @@ public class OrmVersionMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof OneToManyMapping); - assertEquals("version", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testVersionMorphToManyToOneMapping() throws Exception { createTestEntityVersionMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "version"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY); VersionMapping versionMapping = (VersionMapping) ormPersistentAttribute.getMapping(); assertFalse(versionMapping.isDefault()); @@ -464,13 +468,13 @@ public class OrmVersionMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToOneMapping); - assertEquals("version", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testVersionMorphToManyToManyMapping() throws Exception { createTestEntityVersionMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "version"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY); VersionMapping versionMapping = (VersionMapping) ormPersistentAttribute.getMapping(); assertFalse(versionMapping.isDefault()); @@ -483,7 +487,7 @@ public class OrmVersionMappingTests extends ContextModelTestCase assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToManyMapping); - assertEquals("version", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } }
\ No newline at end of file diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmAssociationOverride2_0Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmAssociationOverride2_0Tests.java index 3f9f71532c..03fa3afff6 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmAssociationOverride2_0Tests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmAssociationOverride2_0Tests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2011 Oracle. All rights reserved. + * Copyright (c) 2009, 2012 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -526,7 +526,7 @@ public class GenericOrmAssociationOverride2_0Tests extends Generic2_0ContextMode assertEquals("FOO_FOO", joinTable.getName()); PersistentType mappedSuperclass = ormPersistentType.getSuperPersistentType(); - ((OrmReadOnlyPersistentAttribute) mappedSuperclass.getAttributeNamed("address")).convertToSpecified(); + ((OrmReadOnlyPersistentAttribute) mappedSuperclass.getAttributeNamed("address")).addToXml(); ManyToManyMapping manyToManyMapping = (ManyToManyMapping) mappedSuperclass.getAttributeNamed("address").getMapping(); manyToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable().setSpecifiedName("BAR"); assertEquals("BAR", manyToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable().getName()); diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmCascade2_0Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmCascade2_0Tests.java index ccec4fbb81..0d3a2482d4 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmCascade2_0Tests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmCascade2_0Tests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Oracle. + * Copyright (c) 2010, 2012 Oracle. * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which * accompanies this distribution, and is available at @@ -40,8 +40,9 @@ public class GenericOrmCascade2_0Tests extends Generic2_0ContextModelTestCase } public void testUpdateCascadeDetach() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); XmlOneToOne oneToOne = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); Cascade2_0 cascade = (Cascade2_0) ormOneToOneMapping.getCascade(); @@ -66,8 +67,9 @@ public class GenericOrmCascade2_0Tests extends Generic2_0ContextModelTestCase } public void testModifyCascadeDetach() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping ormOneToOneMapping = (OrmOneToOneMapping) ormPersistentAttribute.getMapping(); XmlOneToOne oneToOne = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmCollectionTable2_0Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmCollectionTable2_0Tests.java index f80cb1439a..c720e0a1f7 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmCollectionTable2_0Tests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmCollectionTable2_0Tests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2011 Oracle. All rights reserved. + * Copyright (c) 2009, 2012 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -79,8 +79,9 @@ public class GenericOrmCollectionTable2_0Tests extends Generic2_0ContextModelTes } public void testUpdateSpecifiedName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 elementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -111,8 +112,9 @@ public class GenericOrmCollectionTable2_0Tests extends Generic2_0ContextModelTes } public void testModifySpecifiedName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 elementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -174,7 +176,7 @@ public class GenericOrmCollectionTable2_0Tests extends Generic2_0ContextModelTes OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "projects"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("projects"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); OrmCollectionTable2_0 ormCollectionTable = ormElementCollectionMapping.getCollectionTable(); @@ -199,7 +201,7 @@ public class GenericOrmCollectionTable2_0Tests extends Generic2_0ContextModelTes getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false); //remove element collection mapping from the orm.xml file - ormPersistentAttribute.convertToVirtual(); + ormPersistentAttribute.removeFromXml(); //ormPersistentType.getMapping().setSpecifiedMetadataComplete(null); OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("projects"); ElementCollectionMapping2_0 virtualElementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute2.getMapping(); @@ -213,8 +215,9 @@ public class GenericOrmCollectionTable2_0Tests extends Generic2_0ContextModelTes } public void testUpdateSpecifiedSchema() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -244,8 +247,9 @@ public class GenericOrmCollectionTable2_0Tests extends Generic2_0ContextModelTes } public void testModifySpecifiedSchema() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -266,8 +270,9 @@ public class GenericOrmCollectionTable2_0Tests extends Generic2_0ContextModelTes } public void testUpdateSpecifiedCatalog() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -297,8 +302,9 @@ public class GenericOrmCollectionTable2_0Tests extends Generic2_0ContextModelTes } public void testModifySpecifiedCatalog() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -319,8 +325,9 @@ public class GenericOrmCollectionTable2_0Tests extends Generic2_0ContextModelTes } public void testAddSpecifiedJoinColumn() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -357,8 +364,9 @@ public class GenericOrmCollectionTable2_0Tests extends Generic2_0ContextModelTes } public void testRemoveSpecifiedJoinColumn() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -385,8 +393,9 @@ public class GenericOrmCollectionTable2_0Tests extends Generic2_0ContextModelTes } public void testMoveSpecifiedJoinColumn() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -424,8 +433,9 @@ public class GenericOrmCollectionTable2_0Tests extends Generic2_0ContextModelTes public void testUpdateJoinColumns() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -477,8 +487,9 @@ public class GenericOrmCollectionTable2_0Tests extends Generic2_0ContextModelTes } public void testUniqueConstraints() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -505,8 +516,9 @@ public class GenericOrmCollectionTable2_0Tests extends Generic2_0ContextModelTes } public void testUniqueConstraintsSize() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -528,8 +540,9 @@ public class GenericOrmCollectionTable2_0Tests extends Generic2_0ContextModelTes } public void testAddUniqueConstraint() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -550,8 +563,9 @@ public class GenericOrmCollectionTable2_0Tests extends Generic2_0ContextModelTes } public void testAddUniqueConstraint2() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -572,8 +586,9 @@ public class GenericOrmCollectionTable2_0Tests extends Generic2_0ContextModelTes } public void testRemoveUniqueConstraint() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -618,8 +633,9 @@ public class GenericOrmCollectionTable2_0Tests extends Generic2_0ContextModelTes } public void testMoveUniqueConstraint() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -659,8 +675,9 @@ public class GenericOrmCollectionTable2_0Tests extends Generic2_0ContextModelTes } public void testUpdateUniqueConstraints() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -744,7 +761,7 @@ public class GenericOrmCollectionTable2_0Tests extends Generic2_0ContextModelTes assertEquals("BAZ", uniqueConstraints.next().getColumnNames().iterator().next()); assertFalse(uniqueConstraints.hasNext()); - virtualAttribute.convertToSpecified(); + virtualAttribute.addToXml(); virtualElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentType.getAttributes().iterator().next().getMapping(); assertEquals(0, virtualElementCollectionMapping.getCollectionTable().getUniqueConstraintsSize()); diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmElementCollectionMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmElementCollectionMapping2_0Tests.java index afb0daa0cc..88665cdb67 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmElementCollectionMapping2_0Tests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmElementCollectionMapping2_0Tests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2011 Oracle. All rights reserved. + * Copyright (c) 2009, 2012 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -41,7 +41,6 @@ import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeOverride; import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeOverrideContainer; import org.eclipse.jpt.jpa.core.context.orm.OrmColumn; import org.eclipse.jpt.jpa.core.context.orm.OrmEntity; -import org.eclipse.jpt.jpa.core.context.orm.OrmOneToManyMapping; import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute; import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType; import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute; @@ -55,7 +54,6 @@ import org.eclipse.jpt.jpa.core.jpa2.resource.java.JPA2_0; import org.eclipse.jpt.jpa.core.resource.java.JPA; import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory; import org.eclipse.jpt.jpa.core.resource.orm.XmlElementCollection; -import org.eclipse.jpt.jpa.core.resource.orm.XmlOneToMany; import org.eclipse.jpt.jpa.core.resource.orm.v2_0.XmlElementCollection_2_0; import org.eclipse.jpt.jpa.core.resource.persistence.PersistenceFactory; import org.eclipse.jpt.jpa.core.resource.persistence.XmlMappingFileRef; @@ -294,13 +292,14 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex } 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"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection elementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); - assertEquals("oneToOneMapping", ormElementCollectionMapping.getName()); - assertEquals("oneToOneMapping", elementCollection.getName()); + assertEquals("id", ormElementCollectionMapping.getName()); + assertEquals("id", elementCollection.getName()); //set name in the resource model, verify context model updated elementCollection.setName("newName"); @@ -314,13 +313,14 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex } public void testModifyName() 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"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection elementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); - assertEquals("oneToOneMapping", ormElementCollectionMapping.getName()); - assertEquals("oneToOneMapping", elementCollection.getName()); + assertEquals("id", ormElementCollectionMapping.getName()); + assertEquals("id", elementCollection.getName()); //set name in the context model, verify resource model updated ormElementCollectionMapping.setName("newName"); @@ -339,12 +339,12 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); - ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "foo"); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("address"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); - + ormElementCollectionMapping.setName("foo"); assertEquals("foo", ormElementCollectionMapping.getName()); assertNull(ormElementCollectionMapping.getSpecifiedFetch()); @@ -358,15 +358,15 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); - OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + assertEquals(3, ormPersistentType.getDefaultAttributesSize()); + OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); ElementCollectionMapping2_0 virtualElementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); assertEquals("address", virtualElementCollectionMapping.getName()); assertEquals(FetchType.EAGER, virtualElementCollectionMapping.getSpecifiedFetch()); assertEquals("String", virtualElementCollectionMapping.getSpecifiedTargetClass()); - ormPersistentAttribute = ormPersistentAttribute.convertToSpecified(); + ormPersistentAttribute = ormPersistentAttribute.addToXml(); OrmElementCollectionMapping2_0 specifiedElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); assertEquals("address", specifiedElementCollectionMapping.getName()); assertEquals(null, specifiedElementCollectionMapping.getSpecifiedFetch()); @@ -382,12 +382,12 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); + assertEquals(3, ormPersistentType.getDefaultAttributesSize()); OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getAttributeNamed("address"); assertEquals(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMappingKey()); - ormPersistentAttribute.convertToSpecified(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); + ormPersistentAttribute.addToXml(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); ormPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); @@ -402,8 +402,8 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); - ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "address"); - assertEquals(2, ormPersistentType.getVirtualAttributesSize()); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("address"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); @@ -415,8 +415,9 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex public void testMorphToIdMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOne"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); assertFalse(elementCollectionMapping.isDefault()); @@ -427,12 +428,13 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof IdMapping); - assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testMorphToVersionMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOne"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); assertFalse(elementCollectionMapping.isDefault()); @@ -443,12 +445,13 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof VersionMapping); - assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testMorphToTransientMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOne"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); assertFalse(elementCollectionMapping.isDefault()); @@ -459,12 +462,13 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof TransientMapping); - assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testMorphToEmbeddedMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOne"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); assertFalse(elementCollectionMapping.isDefault()); @@ -475,12 +479,13 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedMapping); - assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testMorphToEmbeddedIdMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOne"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); assertFalse(elementCollectionMapping.isDefault()); @@ -491,12 +496,13 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedIdMapping); - assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testMorphToManyToManyMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOne"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); assertFalse(elementCollectionMapping.isDefault()); @@ -507,13 +513,14 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToManyMapping); - assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); // assertEquals(FetchType.EAGER, ((ManyToManyMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch()); } public void testMorphToOneToManyMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOne"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); assertFalse(elementCollectionMapping.isDefault()); @@ -524,13 +531,14 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof OneToManyMapping); - assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); // assertEquals(FetchType.EAGER, ((OneToManyMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch()); } public void testMorphToManyToOneMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOne"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); assertFalse(elementCollectionMapping.isDefault()); @@ -541,13 +549,14 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToOneMapping); - assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); // assertEquals(FetchType.EAGER, ((ManyToOneMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch()); } public void testMorphToBasicMapping() throws Exception { + createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOne"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); assertFalse(elementCollectionMapping.isDefault()); @@ -558,13 +567,14 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof BasicMapping); - assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); //TODO assertEquals(FetchType.EAGER, ((IBasicMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch()); } public void testUpdateSpecifiedFetch() 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"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection elementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -587,8 +597,9 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex } public void testModifySpecifiedFetch() 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"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection elementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -611,8 +622,9 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex } public void testUpdateSpecifiedTargetClass() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection_2_0 elementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -631,8 +643,9 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex } public void testModifySpecifiedTargetClass() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection_2_0 elementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -657,7 +670,7 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, "test.Address"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "addresses"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("addresses"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); assertEquals(ElementCollectionMapping2_0.Type.EMBEDDABLE_TYPE, elementCollectionMapping.getValueType()); @@ -669,7 +682,7 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.Address"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "addresses"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("addresses"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); assertEquals(ElementCollectionMapping2_0.Type.BASIC_TYPE, elementCollectionMapping.getValueType()); @@ -681,7 +694,7 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, "test.Address"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "addresses"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("addresses"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); assertEquals(ElementCollectionMapping2_0.Type.NO_TYPE, elementCollectionMapping.getValueType()); @@ -696,7 +709,7 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.Address"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "addresses"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("addresses"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); assertEquals(ElementCollectionMapping2_0.Type.BASIC_TYPE, elementCollectionMapping.getValueType()); @@ -704,33 +717,34 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex public void testUpdateMapKey() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); - OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping(); - XmlOneToMany oneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); + ElementCollectionMapping2_0 ormElementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); + XmlElementCollection_2_0 elementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); - assertNull(ormOneToManyMapping.getSpecifiedMapKey()); - assertNull(oneToMany.getMapKey()); + assertNull(ormElementCollectionMapping.getSpecifiedMapKey()); + assertNull(elementCollection.getMapKey()); //set mapKey in the resource model, verify context model does not change - oneToMany.setMapKey(OrmFactory.eINSTANCE.createMapKey()); - assertNull(ormOneToManyMapping.getSpecifiedMapKey()); - assertNotNull(oneToMany.getMapKey()); + elementCollection.setMapKey(OrmFactory.eINSTANCE.createMapKey()); + assertNull(ormElementCollectionMapping.getSpecifiedMapKey()); + assertNotNull(elementCollection.getMapKey()); //set mapKey name in the resource model, verify context model updated - oneToMany.getMapKey().setName("myMapKey"); - assertEquals("myMapKey", ormOneToManyMapping.getSpecifiedMapKey()); - assertEquals("myMapKey", oneToMany.getMapKey().getName()); + elementCollection.getMapKey().setName("myMapKey"); + assertEquals("myMapKey", ormElementCollectionMapping.getSpecifiedMapKey()); + assertEquals("myMapKey", elementCollection.getMapKey().getName()); //set mapKey name to null in the resource model - oneToMany.getMapKey().setName(null); - assertNull(ormOneToManyMapping.getSpecifiedMapKey()); - assertNull(oneToMany.getMapKey().getName()); - - oneToMany.getMapKey().setName("myMapKey"); - oneToMany.setMapKey(null); - assertNull(ormOneToManyMapping.getSpecifiedMapKey()); - assertNull(oneToMany.getMapKey()); + elementCollection.getMapKey().setName(null); + assertNull(ormElementCollectionMapping.getSpecifiedMapKey()); + assertNull(elementCollection.getMapKey().getName()); + + elementCollection.getMapKey().setName("myMapKey"); + elementCollection.setMapKey(null); + assertNull(ormElementCollectionMapping.getSpecifiedMapKey()); + assertNull(elementCollection.getMapKey()); } public void testUpdateVirtualMapKey() throws Exception { @@ -769,23 +783,24 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex } public void testModifyMapKey() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); - OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping(); - XmlOneToMany xmlOneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); + ElementCollectionMapping2_0 ormElementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); + XmlElementCollection_2_0 xmlElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); - assertNull(ormOneToManyMapping.getSpecifiedMapKey()); - assertNull(xmlOneToMany.getMapKey()); + assertNull(ormElementCollectionMapping.getSpecifiedMapKey()); + assertNull(xmlElementCollection.getMapKey()); //set mapKey in the context model, verify resource model updated - ormOneToManyMapping.setSpecifiedMapKey("myMapKey"); - assertEquals("myMapKey", ormOneToManyMapping.getSpecifiedMapKey()); - assertEquals("myMapKey", xmlOneToMany.getMapKey().getName()); + ormElementCollectionMapping.setSpecifiedMapKey("myMapKey"); + assertEquals("myMapKey", ormElementCollectionMapping.getSpecifiedMapKey()); + assertEquals("myMapKey", xmlElementCollection.getMapKey().getName()); //set mapKey to null in the context model - ormOneToManyMapping.setSpecifiedMapKey(null); - assertNull(ormOneToManyMapping.getSpecifiedMapKey()); - assertTrue(ormOneToManyMapping.isPkMapKey()); + ormElementCollectionMapping.setSpecifiedMapKey(null); + assertNull(ormElementCollectionMapping.getSpecifiedMapKey()); + assertTrue(ormElementCollectionMapping.isPkMapKey()); } public void testCandidateMapKeyNames() throws Exception { @@ -832,7 +847,7 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex assertEquals("zip", mapKeyNames.next()); assertFalse(mapKeyNames.hasNext()); - ormPersistentType.getAttributeNamed("addresses").convertToSpecified(); + ormPersistentType.getAttributeNamed("addresses").addToXml(); virtualElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentType.getAttributeNamed("addresses").getMapping(); mapKeyNames = virtualElementCollectionMapping.getCandidateMapKeyNames().iterator(); assertEquals(false, mapKeyNames.hasNext()); @@ -852,8 +867,9 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex } public void testUpdateMapKeyClass() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection elementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -904,8 +920,9 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex } public void testModifyMapKeyClass() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection elementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -926,7 +943,7 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex public void testOrderColumnDefaults() throws Exception { createTestEntityWithGenericBasicElementCollectionMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "addresses"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("addresses"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 elementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); Orderable2_0 orderable = (Orderable2_0) elementCollectionMapping.getOrderable(); @@ -949,7 +966,7 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex public void testVirtualOrderColumn() throws Exception { createTestEntityWithGenericBasicElementCollectionMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "addresses"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("addresses"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 elementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); Orderable2_0 orderable = (Orderable2_0) elementCollectionMapping.getOrderable(); @@ -962,7 +979,7 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex assertEquals(false, orderable.isOrderColumnOrdering()); assertEquals(true, orderable.isNoOrdering()); - ormPersistentAttribute.convertToVirtual(); + ormPersistentAttribute.removeFromXml(); OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("addresses"); ElementCollectionMapping2_0 virtualCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute2.getMapping(); orderable = (Orderable2_0) virtualCollectionMapping.getOrderable(); @@ -1032,7 +1049,7 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex createTestEntityWithGenericBasicElementCollectionMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute addressesPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "addresses"); + OrmPersistentAttribute addressesPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("addresses"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 addressesVirtualMapping = (OrmElementCollectionMapping2_0) addressesPersistentAttribute.getMapping(); OrmColumn ormColumn = addressesVirtualMapping.getValueColumn(); @@ -1078,7 +1095,7 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); //virtual attribute in orm.xml, java attribute has no Column annotation - OrmReadOnlyPersistentAttribute addressesPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + OrmReadOnlyPersistentAttribute addressesPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); ElementCollectionMapping2_0 addressesVirtualMapping = (ElementCollectionMapping2_0) addressesPersistentAttribute.getMapping(); Column virtualColumn = addressesVirtualMapping.getValueColumn(); @@ -1095,8 +1112,8 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex javaElementCollectionMapping.getValueColumn().setSpecifiedTable("JAVA_TABLE"); assertEquals("JAVA_TABLE", virtualColumn.getTable()); - //make name persistent attribute not virtual - addressesPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "addresses"); + //make name persistent attribute not default + addressesPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("addresses"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); addressesVirtualMapping = (OrmElementCollectionMapping2_0) addressesPersistentAttribute.getMapping(); virtualColumn = addressesVirtualMapping.getValueColumn(); assertNull(virtualColumn.getSpecifiedTable()); @@ -1104,8 +1121,9 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex } public void testMoveSpecifiedAttributeOverride() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); OrmAttributeOverrideContainer attributeOverrideContainer = ormElementCollectionMapping.getValueAttributeOverrideContainer(); XmlElementCollection_2_0 elementCollectionResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -1143,8 +1161,9 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex } public void testUpdateAttributeOverrides() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); OrmAttributeOverrideContainer attributeOverrideContainer = ormElementCollectionMapping.getValueAttributeOverrideContainer(); XmlElementCollection_2_0 elementCollectionResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -1198,16 +1217,19 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); - ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "foo"); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("addresses"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); + ormElementCollectionMapping.setName("foo"); OrmAttributeOverrideContainer attributeOverrideContainer = ormElementCollectionMapping.getValueAttributeOverrideContainer(); assertEquals("foo", ormElementCollectionMapping.getName()); + assertNull(ormElementCollectionMapping.getSpecifiedFetch()); + assertEquals(FetchType.LAZY, ormElementCollectionMapping.getFetch()); assertFalse(attributeOverrideContainer.getSpecifiedOverrides().iterator().hasNext()); assertFalse(attributeOverrideContainer.getVirtualOverrides().iterator().hasNext()); } @@ -1284,7 +1306,7 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex //embedded mapping is specified, virtual attribute overrides should exist - persistentType.getAttributeNamed("addresses").convertToSpecified(); + persistentType.getAttributeNamed("addresses").addToXml(); elementCollectionMapping = (OrmElementCollectionMapping2_0) persistentType.getAttributeNamed("addresses").getMapping(); attributeOverrideContainer = elementCollectionMapping.getValueAttributeOverrideContainer(); assertEquals(4, attributeOverrideContainer.getOverridesSize()); @@ -1383,7 +1405,7 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex createTestEntityWithValidMapElementCollectionMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute addressesPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "addresses"); + OrmPersistentAttribute addressesPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("addresses"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 addressesVirtualMapping = (OrmElementCollectionMapping2_0) addressesPersistentAttribute.getMapping(); Column ormColumn = addressesVirtualMapping.getMapKeyColumn(); @@ -1429,7 +1451,7 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); //virtual attribute in orm.xml, java attribute has no Column annotation - OrmReadOnlyPersistentAttribute addressesPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + OrmReadOnlyPersistentAttribute addressesPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); ElementCollectionMapping2_0 addressesVirtualMapping = (ElementCollectionMapping2_0) addressesPersistentAttribute.getMapping(); Column virtualColumn = addressesVirtualMapping.getMapKeyColumn(); @@ -1446,8 +1468,8 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex javaElementCollectionMapping.getMapKeyColumn().setSpecifiedTable("JAVA_TABLE"); assertEquals("JAVA_TABLE", virtualColumn.getTable()); - //make name persistent attribute not virtual - addressesPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "addresses"); + //make name persistent attribute not default + addressesPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("addresses"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); addressesVirtualMapping = (OrmElementCollectionMapping2_0) addressesPersistentAttribute.getMapping(); virtualColumn = addressesVirtualMapping.getMapKeyColumn(); assertNull(virtualColumn.getSpecifiedTable()); @@ -1463,8 +1485,9 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex } public void testUpdateSpecifiedEnumerated() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection_2_0 elementCollectionResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -1487,8 +1510,9 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex } public void testModifySpecifiedEnumerated() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection_2_0 elementCollectionResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -1512,8 +1536,9 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex } public void testUpdateSpecifiedTemporal() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection_2_0 elementCollectionResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -1540,8 +1565,9 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex } public void testModifySpecifiedTemporal() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection_2_0 elementCollectionResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -1565,8 +1591,9 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex } public void testAddSpecifiedMapKeyJoinColumn() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); ElementCollectionMapping2_0 ormElementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection_2_0 elementCollectionResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -1600,8 +1627,9 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex } public void testRemoveSpecifiedMapKeyJoinColumn() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); ElementCollectionMapping2_0 ormElementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection_2_0 elementCollectionResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -1625,8 +1653,9 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex } public void testMoveSpecifiedMapKeyJoinColumn() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); ElementCollectionMapping2_0 ormElementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection_2_0 elementCollectionResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); @@ -1660,8 +1689,9 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex } public void testUpdateMapKeyJoinColumns() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); ElementCollectionMapping2_0 ormElementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping(); XmlElementCollection_2_0 elementCollectionResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0); diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmEmbeddedMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmEmbeddedMapping2_0Tests.java index 0a82a030a7..8730f200ed 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmEmbeddedMapping2_0Tests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmEmbeddedMapping2_0Tests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2011 Oracle. All rights reserved. + * Copyright (c) 2009, 2012 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -352,13 +352,14 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes } public void testUpdateName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embeddedMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); OrmEmbeddedMapping ormEmbeddedMapping = (OrmEmbeddedMapping) ormPersistentAttribute.getMapping(); XmlEmbedded embeddedResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getEmbeddeds().get(0); - assertEquals("embeddedMapping", ormEmbeddedMapping.getName()); - assertEquals("embeddedMapping", embeddedResource.getName()); + assertEquals("id", ormEmbeddedMapping.getName()); + assertEquals("id", embeddedResource.getName()); //set name in the resource model, verify context model updated embeddedResource.setName("newName"); @@ -372,13 +373,14 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes } public void testModifyName() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embeddedMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); OrmEmbeddedMapping ormEmbeddedMapping = (OrmEmbeddedMapping) ormPersistentAttribute.getMapping(); XmlEmbedded embeddedResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getEmbeddeds().get(0); - assertEquals("embeddedMapping", ormEmbeddedMapping.getName()); - assertEquals("embeddedMapping", embeddedResource.getName()); + assertEquals("id", ormEmbeddedMapping.getName()); + assertEquals("id", embeddedResource.getName()); //set name in the context model, verify resource model updated ormEmbeddedMapping.setName("newName"); @@ -452,8 +454,9 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes // } public void testMoveSpecifiedAttributeOverride() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embeddedMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); OrmEmbeddedMapping ormEmbeddedMapping = (OrmEmbeddedMapping) ormPersistentAttribute.getMapping(); OrmAttributeOverrideContainer attributeOverrideContainer = ormEmbeddedMapping.getAttributeOverrideContainer(); XmlEmbedded embeddedResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getEmbeddeds().get(0); @@ -491,8 +494,9 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes } public void testUpdateAttributeOverrides() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embeddedMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); OrmEmbeddedMapping ormEmbeddedMapping = (OrmEmbeddedMapping) ormPersistentAttribute.getMapping(); OrmAttributeOverrideContainer attributeOverrideContainer = ormEmbeddedMapping.getAttributeOverrideContainer(); XmlEmbedded embeddedResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getEmbeddeds().get(0); @@ -547,11 +551,12 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); - ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "foo"); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("address"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); OrmEmbeddedMapping ormEmbeddedMapping = (OrmEmbeddedMapping) ormPersistentAttribute.getMapping(); + ormEmbeddedMapping.setName("foo"); OrmAttributeOverrideContainer attributeOverrideContainer = ormEmbeddedMapping.getAttributeOverrideContainer(); assertEquals("foo", ormEmbeddedMapping.getName()); @@ -630,7 +635,7 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes //embedded mapping is specified, virtual attribute overrides should exist - persistentType.getAttributeNamed("address").convertToSpecified(); + persistentType.getAttributeNamed("address").addToXml(); embeddedMapping = (OrmEmbeddedMapping) persistentType.getAttributeNamed("address").getMapping(); attributeOverrideContainer = embeddedMapping.getAttributeOverrideContainer(); assertEquals(4, attributeOverrideContainer.getOverridesSize()); @@ -681,8 +686,8 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); - OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + assertEquals(3, ormPersistentType.getDefaultAttributesSize()); + OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); EmbeddedMapping virtualEmbeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping(); AttributeOverrideContainer attributeOverrideContainer = virtualEmbeddedMapping.getAttributeOverrideContainer(); @@ -722,8 +727,8 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); - OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + assertEquals(3, ormPersistentType.getDefaultAttributesSize()); + OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); EmbeddedMapping virtualEmbeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping(); assertEquals("address", virtualEmbeddedMapping.getName()); @@ -770,8 +775,8 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); - ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "address"); - assertEquals(2, ormPersistentType.getVirtualAttributesSize()); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("address"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); OrmEmbeddedMapping ormEmbeddedMapping = (OrmEmbeddedMapping) ormPersistentAttribute.getMapping(); @@ -817,7 +822,7 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes public void testEmbeddedMorphToIdMapping() throws Exception { createTestEntityEmbeddedMappingAttributeOverrides(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); EmbeddedMapping embeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping(); assertFalse(embeddedMapping.isDefault()); @@ -832,13 +837,13 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof IdMapping); - assertEquals("embedded", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testEmbeddedMorphToVersionMapping() throws Exception { createTestEntityEmbeddedMappingAttributeOverrides(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); EmbeddedMapping embeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping(); assertFalse(embeddedMapping.isDefault()); @@ -853,13 +858,13 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof VersionMapping); - assertEquals("embedded", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testEmbeddedMorphToTransientMapping() throws Exception { createTestEntityEmbeddedMappingAttributeOverrides(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); EmbeddedMapping embeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping(); assertFalse(embeddedMapping.isDefault()); @@ -874,13 +879,13 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof TransientMapping); - assertEquals("embedded", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testEmbeddedMorphToBasicMapping() throws Exception { createTestEntityEmbeddedMappingAttributeOverrides(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); EmbeddedMapping embeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping(); assertFalse(embeddedMapping.isDefault()); @@ -895,13 +900,13 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof BasicMapping); - assertEquals("embedded", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testEmbeddedMorphToEmbeddedIdMapping() throws Exception { createTestEntityEmbeddedMappingAttributeOverrides(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); EmbeddedMapping embeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping(); assertFalse(embeddedMapping.isDefault()); @@ -916,7 +921,7 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedIdMapping); assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); - assertEquals("embedded", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); attributeOverride = ((EmbeddedIdMapping) ormPersistentAttribute.getMapping()).getAttributeOverrideContainer().getSpecifiedOverrides().iterator().next(); assertEquals("override", attributeOverride.getName()); assertEquals("OVERRIDE_COLUMN", attributeOverride.getColumn().getSpecifiedName()); @@ -925,7 +930,7 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes public void testEmbeddedMorphToOneToOneMapping() throws Exception { createTestEntityEmbeddedMappingAttributeOverrides(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); EmbeddedMapping embeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping(); assertFalse(embeddedMapping.isDefault()); @@ -940,13 +945,13 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof OneToOneMapping); - assertEquals("embedded", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testEmbeddedMorphToOneToManyMapping() throws Exception { createTestEntityEmbeddedMappingAttributeOverrides(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); EmbeddedMapping embeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping(); assertFalse(embeddedMapping.isDefault()); @@ -961,13 +966,13 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof OneToManyMapping); - assertEquals("embedded", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testEmbeddedMorphToManyToOneMapping() throws Exception { createTestEntityEmbeddedMappingAttributeOverrides(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); EmbeddedMapping embeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping(); assertFalse(embeddedMapping.isDefault()); @@ -982,13 +987,13 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); assertEquals(ormPersistentAttribute, ormPersistentType.getSpecifiedAttributes().iterator().next()); assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToOneMapping); - assertEquals("embedded", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } public void testEmbeddedMorphToManyToManyMapping() throws Exception { createTestEntityEmbeddedMappingAttributeOverrides(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "embedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); EmbeddedMapping embeddedMapping = (EmbeddedMapping) ormPersistentAttribute.getMapping(); assertFalse(embeddedMapping.isDefault()); @@ -1001,7 +1006,7 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes ormPersistentAttribute.setMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToManyMapping); - assertEquals("embedded", ormPersistentAttribute.getMapping().getName()); + assertEquals("id", ormPersistentAttribute.getMapping().getName()); } @@ -1013,7 +1018,7 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes addXmlClassRef(PACKAGE_NAME + ".Address"); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "myEmbedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("myEmbedded"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); OrmEmbeddedMapping2_0 embeddedMapping = (OrmEmbeddedMapping2_0) ormPersistentAttribute.getMapping(); OrmAssociationOverrideContainer overrideContainer = embeddedMapping.getAssociationOverrideContainer(); @@ -1082,7 +1087,7 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes addXmlClassRef(PACKAGE_NAME + ".Address"); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "myEmbedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("myEmbedded"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); OrmEmbeddedMapping2_0 embeddedMapping = (OrmEmbeddedMapping2_0) ormPersistentAttribute.getMapping(); AssociationOverrideContainer overrideContainer = embeddedMapping.getAssociationOverrideContainer(); @@ -1147,7 +1152,7 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME); addXmlClassRef(PACKAGE_NAME + ".Address"); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "myEmbedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("myEmbedded"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); OrmEmbeddedMapping2_0 embeddedMapping = (OrmEmbeddedMapping2_0) ormPersistentAttribute.getMapping(); AssociationOverrideContainer overrideContainer = embeddedMapping.getAssociationOverrideContainer(); @@ -1173,7 +1178,7 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME); addXmlClassRef(PACKAGE_NAME + ".Address"); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "myEmbedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("myEmbedded"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); OrmEmbeddedMapping2_0 embeddedMapping = (OrmEmbeddedMapping2_0) ormPersistentAttribute.getMapping(); AssociationOverrideContainer overrideContainer = embeddedMapping.getAssociationOverrideContainer(); @@ -1193,7 +1198,7 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME); addXmlClassRef(PACKAGE_NAME + ".Address"); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "myEmbedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("myEmbedded"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); OrmEmbeddedMapping2_0 embeddedMapping = (OrmEmbeddedMapping2_0) ormPersistentAttribute.getMapping(); AssociationOverrideContainer overrideContainer = embeddedMapping.getAssociationOverrideContainer(); @@ -1221,7 +1226,7 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME); addXmlClassRef(PACKAGE_NAME + ".Address"); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "myEmbedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("myEmbedded"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); OrmEmbeddedMapping2_0 embeddedMapping = (OrmEmbeddedMapping2_0) ormPersistentAttribute.getMapping(); AssociationOverrideContainer overrideContainer = embeddedMapping.getAssociationOverrideContainer(); @@ -1242,7 +1247,7 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME); addXmlClassRef(PACKAGE_NAME + ".Address"); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "myEmbedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("myEmbedded"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); OrmEmbeddedMapping2_0 embeddedMapping = (OrmEmbeddedMapping2_0) ormPersistentAttribute.getMapping(); OrmAssociationOverrideContainer overrideContainer = embeddedMapping.getAssociationOverrideContainer(); @@ -1265,7 +1270,7 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME); addXmlClassRef(PACKAGE_NAME + ".Address"); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "myEmbedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("myEmbedded"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); OrmEmbeddedMapping2_0 embeddedMapping = (OrmEmbeddedMapping2_0) ormPersistentAttribute.getMapping(); OrmAssociationOverrideContainer overrideContainer = embeddedMapping.getAssociationOverrideContainer(); @@ -1299,7 +1304,7 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME); addXmlClassRef(PACKAGE_NAME + ".Address"); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "myEmbedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("myEmbedded"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); OrmEmbeddedMapping2_0 embeddedMapping = (OrmEmbeddedMapping2_0) ormPersistentAttribute.getMapping(); AssociationOverrideContainer overrideContainer = embeddedMapping.getAssociationOverrideContainer(); @@ -1336,7 +1341,7 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME); addXmlClassRef(PACKAGE_NAME + ".Address"); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "myEmbedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("myEmbedded"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); OrmEmbeddedMapping2_0 embeddedMapping = (OrmEmbeddedMapping2_0) ormPersistentAttribute.getMapping(); AssociationOverrideContainer overrideContainer = embeddedMapping.getAssociationOverrideContainer(); @@ -1395,7 +1400,7 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME); addXmlClassRef(PACKAGE_NAME + ".Address"); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "myEmbedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("myEmbedded"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); OrmEmbeddedMapping2_0 embeddedMapping = (OrmEmbeddedMapping2_0) ormPersistentAttribute.getMapping(); OrmAssociationOverrideContainer overrideContainer = embeddedMapping.getAssociationOverrideContainer(); @@ -1428,7 +1433,7 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME); addXmlClassRef(PACKAGE_NAME_ + "Address"); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, "myEmbedded"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("myEmbedded"), MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); OrmEmbeddedMapping2_0 embeddedMapping = (OrmEmbeddedMapping2_0) ormPersistentAttribute.getMapping(); AssociationOverrideContainer overrideContainer = embeddedMapping.getAssociationOverrideContainer(); @@ -1566,7 +1571,7 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes assertEquals(1, overrideContainer.getVirtualOverridesSize()); - ormPersistentAttribute.convertToVirtual(); + ormPersistentAttribute.removeFromXml(); EmbeddedMapping2_0 virtualEmbeddedMapping = (EmbeddedMapping2_0) ormPersistentType.getAttributeNamed("myEmbedded").getMapping(); overrideContainer = virtualEmbeddedMapping.getAssociationOverrideContainer(); AssociationOverride associationOverride = overrideContainer.getSpecifiedOverrides().iterator().next(); @@ -1606,7 +1611,7 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes OrmPersistentType addressPersistentType = getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); OrmPersistentType zipCodePersistentType = getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".ZipCode"); - customerPersistentType.getAttributeNamed("address").convertToSpecified(); + customerPersistentType.getAttributeNamed("address").addToXml(); EmbeddedMapping embeddedMapping = (EmbeddedMapping) customerPersistentType.getAttributeNamed("address").getMapping(); AttributeOverrideContainer attributeOverrideContainer = embeddedMapping.getAttributeOverrideContainer(); @@ -1636,7 +1641,7 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes assertEquals(0, virtualAttributeOverride.getColumn().getScale()); - addressPersistentType.getAttributeNamed("zipCode").convertToSpecified(); + addressPersistentType.getAttributeNamed("zipCode").addToXml(); EmbeddedMapping nestedEmbeddedMapping = (EmbeddedMapping) addressPersistentType.getAttributeNamed("zipCode").getMapping(); AttributeOverrideContainer nestedAttributeOverrideContainer = nestedEmbeddedMapping.getAttributeOverrideContainer(); assertEquals(2, nestedAttributeOverrideContainer.getVirtualOverridesSize()); @@ -1646,7 +1651,7 @@ public class GenericOrmEmbeddedMapping2_0Tests extends Generic2_0ContextModelTes virtualAttributeOverride = virtualAttributeOverrides.next(); assertEquals("plusfour", virtualAttributeOverride.getName()); - zipCodePersistentType.getAttributeNamed("plusfour").convertToSpecified(); + zipCodePersistentType.getAttributeNamed("plusfour").addToXml(); BasicMapping plusFourMapping = (BasicMapping) zipCodePersistentType.getAttributeNamed("plusfour").getMapping(); plusFourMapping.getColumn().setSpecifiedName("BLAH"); plusFourMapping.getColumn().setSpecifiedTable("BLAH_TABLE"); diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmManyToManyMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmManyToManyMapping2_0Tests.java index 43ac4cf2c0..65d572259c 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmManyToManyMapping2_0Tests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmManyToManyMapping2_0Tests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2011 Oracle. + * Copyright (c) 2009, 2012 Oracle. * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which * accompanies this distribution, and is available at @@ -249,7 +249,7 @@ public class GenericOrmManyToManyMapping2_0Tests OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State"); - ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "addresses"); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("addresses"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); addXmlClassRef(PACKAGE_NAME + ".Address"); @@ -295,7 +295,7 @@ public class GenericOrmManyToManyMapping2_0Tests OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State"); - ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "addresses"); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("addresses"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); addXmlClassRef(PACKAGE_NAME + ".Address"); @@ -335,8 +335,9 @@ public class GenericOrmManyToManyMapping2_0Tests } public void testUpdateMapKey() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -400,8 +401,9 @@ public class GenericOrmManyToManyMapping2_0Tests } public void testModifyMapKey() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping(); XmlManyToMany xmlManyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -466,7 +468,7 @@ public class GenericOrmManyToManyMapping2_0Tests assertEquals("zip", mapKeyNames.next()); assertFalse(mapKeyNames.hasNext()); - ormPersistentType.getAttributeNamed("addresses").convertToSpecified(); + ormPersistentType.getAttributeNamed("addresses").addToXml(); virtualManyToManyMapping = (OrmManyToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping(); mapKeyNames = virtualManyToManyMapping.getCandidateMapKeyNames().iterator(); assertEquals(false, mapKeyNames.hasNext()); @@ -487,8 +489,9 @@ public class GenericOrmManyToManyMapping2_0Tests } public void testUpdateMapKeyClass() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping2_0 ormManyToManyMapping = (OrmManyToManyMapping2_0) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -539,8 +542,9 @@ public class GenericOrmManyToManyMapping2_0Tests } public void testModifyMapKeyClass() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping2_0 ormManyToManyMapping = (OrmManyToManyMapping2_0) ormPersistentAttribute.getMapping(); XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -563,13 +567,13 @@ public class GenericOrmManyToManyMapping2_0Tests createTestEntityPrintJob(); OrmPersistentType printQueuePersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".PrintQueue"); - OrmPersistentAttribute jobsPersistentAttribute = printQueuePersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "jobs"); + OrmPersistentAttribute jobsPersistentAttribute = printQueuePersistentType.addAttributeToXml(printQueuePersistentType.getAttributeNamed("jobs"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping jobsMapping = (OrmManyToManyMapping) jobsPersistentAttribute.getMapping(); jobsMapping.getRelationship().setStrategyToMappedBy(); jobsMapping.getRelationship().getMappedByStrategy().setMappedByAttribute("queues"); OrmPersistentType printJobPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".PrintJob"); - OrmPersistentAttribute queuesPersistentAttribute = printJobPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "queues"); + OrmPersistentAttribute queuesPersistentAttribute = printJobPersistentType.addAttributeToXml(printJobPersistentType.getAttributeNamed("queues"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping queuesMapping = (OrmManyToManyMapping) queuesPersistentAttribute.getMapping(); Orderable2_0 jobsOrderable = ((Orderable2_0) jobsMapping.getOrderable()); @@ -623,11 +627,11 @@ public class GenericOrmManyToManyMapping2_0Tests createTestEntityPrintJob(); OrmPersistentType printQueuePersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".PrintQueue"); - OrmPersistentAttribute jobsPersistentAttribute = printQueuePersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "jobs"); + OrmPersistentAttribute jobsPersistentAttribute = printQueuePersistentType.addAttributeToXml(printQueuePersistentType.getAttributeNamed("jobs"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping jobsMapping = (OrmManyToManyMapping) jobsPersistentAttribute.getMapping(); OrmPersistentType printJobPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".PrintJob"); - OrmPersistentAttribute queuesPersistentAttribute = printJobPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "queues"); + OrmPersistentAttribute queuesPersistentAttribute = printJobPersistentType.addAttributeToXml(printJobPersistentType.getAttributeNamed("queues"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping queuesMapping = (OrmManyToManyMapping) queuesPersistentAttribute.getMapping(); Orderable2_0 jobsOrderable = ((Orderable2_0) jobsMapping.getOrderable()); @@ -645,7 +649,7 @@ public class GenericOrmManyToManyMapping2_0Tests assertEquals(false, queuesOrderable.isOrderColumnOrdering()); assertEquals(true, queuesOrderable.isNoOrdering()); - jobsPersistentAttribute.convertToVirtual(); + jobsPersistentAttribute.removeFromXml(); OrmReadOnlyPersistentAttribute jobsPersistentAttribute2 = printQueuePersistentType.getAttributeNamed("jobs"); ManyToManyMapping virtualJobsMapping = (ManyToManyMapping) jobsPersistentAttribute2.getMapping(); jobsOrderable = ((Orderable2_0) virtualJobsMapping.getOrderable()); @@ -653,7 +657,7 @@ public class GenericOrmManyToManyMapping2_0Tests assertEquals(false, jobsOrderable.isNoOrdering()); assertEquals("PrintJob_PrintQueue", jobsOrderable.getOrderColumn().getTable()); assertEquals("jobs_ORDER", jobsOrderable.getOrderColumn().getName()); - queuesPersistentAttribute.convertToVirtual(); + queuesPersistentAttribute.removeFromXml(); OrmReadOnlyPersistentAttribute queuesPersistentAttribute2 = printJobPersistentType.getAttributeNamed("queues"); ManyToManyMapping virtualQueuesMapping = (ManyToManyMapping) queuesPersistentAttribute2.getMapping(); queuesOrderable = ((Orderable2_0) virtualQueuesMapping.getOrderable()); @@ -812,7 +816,7 @@ public class GenericOrmManyToManyMapping2_0Tests OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); - OrmPersistentAttribute addressesPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "addresses"); + OrmPersistentAttribute addressesPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("addresses"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping2_0 addressesVirtualMapping = (OrmManyToManyMapping2_0) addressesPersistentAttribute.getMapping(); Column ormColumn = addressesVirtualMapping.getMapKeyColumn(); @@ -860,7 +864,7 @@ public class GenericOrmManyToManyMapping2_0Tests getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); //virtual attribute in orm.xml, java attribute has no Column annotation - OrmReadOnlyPersistentAttribute addressesPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + OrmReadOnlyPersistentAttribute addressesPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); ManyToManyMapping2_0 addressesVirtualMapping = (ManyToManyMapping2_0) addressesPersistentAttribute.getMapping(); Column column = addressesVirtualMapping.getMapKeyColumn(); @@ -877,8 +881,8 @@ public class GenericOrmManyToManyMapping2_0Tests javaManyToManyMapping.getMapKeyColumn().setSpecifiedTable("JAVA_TABLE"); assertEquals("JAVA_TABLE", column.getTable()); - //make name persistent attribute not virtual - addressesPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "addresses"); + //make name persistent attribute not default + addressesPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("addresses"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); addressesVirtualMapping = (OrmManyToManyMapping2_0) addressesPersistentAttribute.getMapping(); column = addressesVirtualMapping.getMapKeyColumn(); assertNull(column.getSpecifiedTable()); @@ -891,8 +895,8 @@ public class GenericOrmManyToManyMapping2_0Tests OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); - OrmReadOnlyPersistentAttribute virtualAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + assertEquals(3, ormPersistentType.getDefaultAttributesSize()); + OrmReadOnlyPersistentAttribute virtualAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); ManyToManyMapping2_0 virtualManyToManyMapping = (ManyToManyMapping2_0) virtualAttribute.getMapping(); assertEquals("address", virtualManyToManyMapping.getName()); @@ -919,14 +923,14 @@ public class GenericOrmManyToManyMapping2_0Tests OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); + assertEquals(3, ormPersistentType.getDefaultAttributesSize()); OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.getAttributeNamed("address"); ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE); virtualPersistentAttribute = ormPersistentType.getAttributeNamed("address"); assertEquals(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY, virtualPersistentAttribute.getMappingKey()); assertTrue(virtualPersistentAttribute.isVirtual()); - virtualPersistentAttribute.convertToSpecified(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); + virtualPersistentAttribute.addToXml(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmReadOnlyPersistentAttribute ormPersistentAttribute= ormPersistentType.getSpecifiedAttributes().iterator().next(); ManyToManyMapping2_0 ormManyToManyMapping = (ManyToManyMapping2_0) ormPersistentAttribute.getMapping(); @@ -949,8 +953,9 @@ public class GenericOrmManyToManyMapping2_0Tests } public void testUpdateSpecifiedEnumerated() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping2_0 ormManyToManyMapping = (OrmManyToManyMapping2_0) ormPersistentAttribute.getMapping(); XmlManyToMany_2_0 manyToManyResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -973,8 +978,9 @@ public class GenericOrmManyToManyMapping2_0Tests } public void testModifySpecifiedEnumerated() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "ManyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping2_0 ormManyToManyMapping = (OrmManyToManyMapping2_0) ormPersistentAttribute.getMapping(); XmlManyToMany_2_0 manyToManyResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -998,8 +1004,9 @@ public class GenericOrmManyToManyMapping2_0Tests } public void testUpdateSpecifiedTemporal() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "ManyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping2_0 ormManyToManyMapping = (OrmManyToManyMapping2_0) ormPersistentAttribute.getMapping(); XmlManyToMany_2_0 manyToManyResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -1026,8 +1033,9 @@ public class GenericOrmManyToManyMapping2_0Tests } public void testModifySpecifiedTemporal() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "ManyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmManyToManyMapping2_0 ormManyToManyMapping = (OrmManyToManyMapping2_0) ormPersistentAttribute.getMapping(); XmlManyToMany_2_0 manyToManyResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -1051,8 +1059,9 @@ public class GenericOrmManyToManyMapping2_0Tests } public void testAddSpecifiedMapKeyJoinColumn() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); ManyToManyMapping2_0 ormManyToManyMapping = (ManyToManyMapping2_0) ormPersistentAttribute.getMapping(); XmlManyToMany_2_0 manyToManyResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -1086,8 +1095,9 @@ public class GenericOrmManyToManyMapping2_0Tests } public void testRemoveSpecifiedMapKeyJoinColumn() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); ManyToManyMapping2_0 ormManyToManyMapping = (ManyToManyMapping2_0) ormPersistentAttribute.getMapping(); XmlManyToMany_2_0 manyToManyResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -1111,8 +1121,9 @@ public class GenericOrmManyToManyMapping2_0Tests } public void testMoveSpecifiedMapKeyJoinColumn() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); ManyToManyMapping2_0 ormManyToManyMapping = (ManyToManyMapping2_0) ormPersistentAttribute.getMapping(); XmlManyToMany_2_0 manyToManyResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); @@ -1146,8 +1157,9 @@ public class GenericOrmManyToManyMapping2_0Tests } public void testUpdateMapKeyJoinColumns() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); ManyToManyMapping2_0 ormManyToManyMapping = (ManyToManyMapping2_0) ormPersistentAttribute.getMapping(); XmlManyToMany_2_0 manyToManyResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0); diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmManyToOneMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmManyToOneMapping2_0Tests.java index d178847a00..43afdfdfaf 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmManyToOneMapping2_0Tests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmManyToOneMapping2_0Tests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2011 Oracle. All rights reserved. + * Copyright (c) 2009, 2012 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -76,7 +76,7 @@ public class GenericOrmManyToOneMapping2_0Tests }); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); for (OrmReadOnlyPersistentAttribute each : ormPersistentType.getAttributes()) { - each.convertToSpecified(); + each.addToXml(); } } @@ -101,7 +101,7 @@ public class GenericOrmManyToOneMapping2_0Tests }); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); for (OrmReadOnlyPersistentAttribute each : ormPersistentType.getAttributes()) { - each.convertToSpecified(); + each.addToXml(); } } @@ -145,7 +145,7 @@ public class GenericOrmManyToOneMapping2_0Tests }); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); for (OrmReadOnlyPersistentAttribute each : ormPersistentType.getAttributes()) { - each.convertToSpecified(); + each.addToXml(); } } @@ -482,7 +482,7 @@ public class GenericOrmManyToOneMapping2_0Tests OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "address"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("address"), MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmManyToOneMapping2_0 ormManyToOneMapping = (OrmManyToOneMapping2_0) ormPersistentAttribute.getMapping(); ((ManyToOneRelationship2_0) ormManyToOneMapping.getRelationship()).setStrategyToJoinTable(); OrmJoinTable ormJoinTable = ((OrmManyToOneRelationship2_0) ormManyToOneMapping.getRelationship()).getJoinTableStrategy().getJoinTable(); @@ -514,7 +514,7 @@ public class GenericOrmManyToOneMapping2_0Tests getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false); //remove m-m mapping from the orm.xml file - ormPersistentAttribute.convertToVirtual(); + ormPersistentAttribute.removeFromXml(); //ormPersistentType.getMapping().setSpecifiedMetadataComplete(null); OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.getAttributeNamed("address"); ManyToOneMapping2_0 virtualManyToOneMapping = (ManyToOneMapping2_0) virtualPersistentAttribute.getMapping(); @@ -612,8 +612,8 @@ public class GenericOrmManyToOneMapping2_0Tests OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); - OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + assertEquals(3, ormPersistentType.getDefaultAttributesSize()); + OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); ManyToOneMapping virtualManyToOneMapping = (ManyToOneMapping) virtualPersistentAttribute.getMapping(); assertEquals("address", virtualManyToOneMapping.getName()); @@ -647,13 +647,13 @@ public class GenericOrmManyToOneMapping2_0Tests OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); + assertEquals(3, ormPersistentType.getDefaultAttributesSize()); OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.getAttributeNamed("address"); assertEquals(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY, virtualPersistentAttribute.getMappingKey()); assertTrue(virtualPersistentAttribute.isVirtual()); - virtualPersistentAttribute.convertToSpecified(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY); + virtualPersistentAttribute.addToXml(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmPersistentAttribute ormPersistentAttribute= ormPersistentType.getSpecifiedAttributes().iterator().next(); OrmManyToOneMapping ormManyToOneMapping = (OrmManyToOneMapping) ormPersistentAttribute.getMapping(); diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmOneToManyMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmOneToManyMapping2_0Tests.java index ff0785e334..9db51ae92b 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmOneToManyMapping2_0Tests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmOneToManyMapping2_0Tests.java @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2009, 2011 Oracle. All rights reserved. +* Copyright (c) 2009, 2012 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -159,7 +159,7 @@ public class GenericOrmOneToManyMapping2_0Tests }); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); for (OrmReadOnlyPersistentAttribute each : ormPersistentType.getAttributes()) { - each.convertToSpecified(); + each.addToXml(); } } @@ -284,7 +284,7 @@ public class GenericOrmOneToManyMapping2_0Tests OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State"); - ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "addresses"); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("addresses"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); addXmlClassRef(PACKAGE_NAME + ".Address"); @@ -330,7 +330,7 @@ public class GenericOrmOneToManyMapping2_0Tests OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State"); - ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "addresses"); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("addresses"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); addXmlClassRef(PACKAGE_NAME + ".Address"); @@ -373,8 +373,9 @@ public class GenericOrmOneToManyMapping2_0Tests } public void testUpdateSpecifiedOrphanRemoval() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmOneToManyMapping2_0 ormOneToManyMapping = (OrmOneToManyMapping2_0) ormPersistentAttribute.getMapping(); OrmOrphanRemovable2_0 mappingsOrphanRemoval = this.getOrphanRemovalOf(ormOneToManyMapping); XmlOneToMany oneToManyResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0); @@ -393,8 +394,9 @@ public class GenericOrmOneToManyMapping2_0Tests } public void testModifySpecifiedOrphanRemoval() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmOneToManyMapping2_0 ormOneToManyMapping = (OrmOneToManyMapping2_0) ormPersistentAttribute.getMapping(); OrmOrphanRemovable2_0 mappingsOrphanRemoval = this.getOrphanRemovalOf(ormOneToManyMapping); XmlOneToMany oneToManyResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0); @@ -413,8 +415,9 @@ public class GenericOrmOneToManyMapping2_0Tests } public void testUpdateMapKey() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping(); XmlOneToMany oneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0); @@ -478,8 +481,9 @@ public class GenericOrmOneToManyMapping2_0Tests } public void testModifyMapKey() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping(); XmlOneToMany oneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0); @@ -543,7 +547,7 @@ public class GenericOrmOneToManyMapping2_0Tests assertEquals("zip", mapKeyNames.next()); assertFalse(mapKeyNames.hasNext()); - ormPersistentType.getAttributeNamed("addresses").convertToSpecified(); + ormPersistentType.getAttributeNamed("addresses").addToXml(); oneToManyMapping = (OneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping(); mapKeyNames = oneToManyMapping.getCandidateMapKeyNames().iterator(); assertEquals(false, mapKeyNames.hasNext()); @@ -564,8 +568,9 @@ public class GenericOrmOneToManyMapping2_0Tests } public void testUpdateMapKeyClass() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmOneToManyMapping2_0 ormOneToManyMapping = (OrmOneToManyMapping2_0) ormPersistentAttribute.getMapping(); XmlOneToMany oneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0); @@ -616,8 +621,9 @@ public class GenericOrmOneToManyMapping2_0Tests } public void testModifyMapKeyClass() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmOneToManyMapping2_0 ormOneToManyMapping = (OrmOneToManyMapping2_0) ormPersistentAttribute.getMapping(); XmlOneToMany oneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0); @@ -641,7 +647,7 @@ public class GenericOrmOneToManyMapping2_0Tests OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".PrintQueue"); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".PrintJob"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "jobs"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("jobs"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmOneToManyMapping oneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping(); oneToManyMapping.getRelationship().setStrategyToMappedBy(); oneToManyMapping.getRelationship().getMappedByStrategy().setMappedByAttribute("queue"); @@ -674,7 +680,7 @@ public class GenericOrmOneToManyMapping2_0Tests OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".PrintQueue"); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".PrintJob"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "jobs"); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("jobs"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OneToManyMapping oneToManyMapping = (OneToManyMapping) ormPersistentAttribute.getMapping(); Orderable2_0 orderable = ((Orderable2_0) oneToManyMapping.getOrderable()); @@ -687,7 +693,7 @@ public class GenericOrmOneToManyMapping2_0Tests assertEquals(false, orderable.isOrderColumnOrdering()); assertEquals(true, orderable.isNoOrdering()); - ormPersistentAttribute.convertToVirtual(); + ormPersistentAttribute.removeFromXml(); OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("jobs"); oneToManyMapping = (OneToManyMapping) ormPersistentAttribute2.getMapping(); orderable = ((Orderable2_0) oneToManyMapping.getOrderable()); @@ -834,7 +840,7 @@ public class GenericOrmOneToManyMapping2_0Tests OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); - OrmPersistentAttribute addressesPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "addresses"); + OrmPersistentAttribute addressesPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("addresses"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmOneToManyMapping2_0 addressesVirtualMapping = (OrmOneToManyMapping2_0) addressesPersistentAttribute.getMapping(); Column ormColumn = addressesVirtualMapping.getMapKeyColumn(); @@ -882,7 +888,7 @@ public class GenericOrmOneToManyMapping2_0Tests getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); //virtual attribute in orm.xml, java attribute has no Column annotation - OrmReadOnlyPersistentAttribute addressesPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + OrmReadOnlyPersistentAttribute addressesPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); OneToManyMapping2_0 virtualAddressesMapping = (OneToManyMapping2_0) addressesPersistentAttribute.getMapping(); Column virtualColumn = virtualAddressesMapping.getMapKeyColumn(); @@ -900,8 +906,8 @@ public class GenericOrmOneToManyMapping2_0Tests javaOneToManyMapping.getMapKeyColumn().setSpecifiedTable("JAVA_TABLE"); assertEquals("JAVA_TABLE", virtualColumn.getTable()); - //make name persistent attribute not virtual - addressesPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "addresses"); + //make name persistent attribute not default + addressesPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("addresses"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OneToManyMapping2_0 specifiedAddressesMapping = (OneToManyMapping2_0) addressesPersistentAttribute.getMapping(); Column specifiedColumn = specifiedAddressesMapping.getMapKeyColumn(); assertNull(specifiedColumn.getSpecifiedTable()); @@ -1043,7 +1049,7 @@ public class GenericOrmOneToManyMapping2_0Tests assertEquals("ADDRESS_PRIMARY_TABLE", joinColumn.getDefaultTable()); //override the mapping in orm.xml - persistentAttribute.convertToSpecified(); + persistentAttribute.addToXml(); persistentAttribute = ormPersistentType.getAttributeNamed("addresses"); oneToManyMapping = (OrmOneToManyMapping2_0) persistentAttribute.getMapping(); assertFalse(persistentAttribute.isVirtual()); @@ -1101,7 +1107,7 @@ public class GenericOrmOneToManyMapping2_0Tests assertEquals("ADDRESS_PRIMARY_TABLE", oneToManyMapping.getMapKeyColumn().getDefaultTable()); //override the mapping in orm.xml - persistentAttribute.convertToSpecified(); + persistentAttribute.addToXml(); persistentAttribute = ormPersistentType.getAttributeNamed("addresses"); oneToManyMapping = (OrmOneToManyMapping2_0) persistentAttribute.getMapping(); assertFalse(persistentAttribute.isVirtual()); @@ -1148,7 +1154,7 @@ public class GenericOrmOneToManyMapping2_0Tests assertEquals("ADDRESS_PRIMARY_TABLE", orderColumn.getTable()); //override the mapping in orm.xml - persistentAttribute.convertToSpecified(); + persistentAttribute.addToXml(); persistentAttribute = ormPersistentType.getAttributeNamed("addresses"); oneToManyMapping = (OrmOneToManyMapping2_0) persistentAttribute.getMapping(); assertFalse(persistentAttribute.isVirtual()); @@ -1176,8 +1182,8 @@ public class GenericOrmOneToManyMapping2_0Tests OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); - OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + assertEquals(3, ormPersistentType.getDefaultAttributesSize()); + OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); OneToManyMapping2_0 virtualOneToManyMapping = (OneToManyMapping2_0) virtualPersistentAttribute.getMapping(); assertEquals("address", virtualOneToManyMapping.getName()); @@ -1208,13 +1214,13 @@ public class GenericOrmOneToManyMapping2_0Tests OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); + assertEquals(3, ormPersistentType.getDefaultAttributesSize()); OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.getAttributeNamed("address"); assertEquals(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY, virtualPersistentAttribute.getMappingKey()); assertTrue(virtualPersistentAttribute.isVirtual()); - virtualPersistentAttribute.convertToSpecified(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); + virtualPersistentAttribute.addToXml(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); OrmOneToManyMapping2_0 ormOneToManyMapping = (OrmOneToManyMapping2_0) ormPersistentAttribute.getMapping(); @@ -1239,8 +1245,9 @@ public class GenericOrmOneToManyMapping2_0Tests } public void testUpdateSpecifiedEnumerated() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmOneToManyMapping2_0 ormOneToManyMapping = (OrmOneToManyMapping2_0) ormPersistentAttribute.getMapping(); XmlOneToMany_2_0 oneToManyResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0); @@ -1263,8 +1270,9 @@ public class GenericOrmOneToManyMapping2_0Tests } public void testModifySpecifiedEnumerated() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmOneToManyMapping2_0 ormOneToManyMapping = (OrmOneToManyMapping2_0) ormPersistentAttribute.getMapping(); XmlOneToMany_2_0 oneToManyResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0); @@ -1288,8 +1296,9 @@ public class GenericOrmOneToManyMapping2_0Tests } public void testUpdateSpecifiedTemporal() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmOneToManyMapping2_0 ormOneToManyMapping = (OrmOneToManyMapping2_0) ormPersistentAttribute.getMapping(); XmlOneToMany_2_0 oneToManyResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0); @@ -1316,8 +1325,9 @@ public class GenericOrmOneToManyMapping2_0Tests } public void testModifySpecifiedTemporal() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OrmOneToManyMapping2_0 ormOneToManyMapping = (OrmOneToManyMapping2_0) ormPersistentAttribute.getMapping(); XmlOneToMany_2_0 oneToManyResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0); @@ -1341,8 +1351,9 @@ public class GenericOrmOneToManyMapping2_0Tests } public void testAddSpecifiedMapKeyJoinColumn() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OneToManyMapping2_0 ormOneToManyMapping = (OneToManyMapping2_0) ormPersistentAttribute.getMapping(); XmlOneToMany_2_0 oneToManyResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0); @@ -1376,8 +1387,9 @@ public class GenericOrmOneToManyMapping2_0Tests } public void testRemoveSpecifiedMapKeyJoinColumn() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OneToManyMapping2_0 ormOneToManyMapping = (OneToManyMapping2_0) ormPersistentAttribute.getMapping(); XmlOneToMany_2_0 oneToManyResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0); @@ -1401,8 +1413,9 @@ public class GenericOrmOneToManyMapping2_0Tests } public void testMoveSpecifiedMapKeyJoinColumn() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OneToManyMapping2_0 ormOneToManyMapping = (OneToManyMapping2_0) ormPersistentAttribute.getMapping(); XmlOneToMany_2_0 oneToManyResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0); @@ -1436,8 +1449,9 @@ public class GenericOrmOneToManyMapping2_0Tests } public void testUpdateMapKeyJoinColumns() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); OneToManyMapping2_0 ormOneToManyMapping = (OneToManyMapping2_0) ormPersistentAttribute.getMapping(); XmlOneToMany_2_0 oneToManyResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0); diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmOneToOneMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmOneToOneMapping2_0Tests.java index d90195fd20..a4e2ade0a5 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmOneToOneMapping2_0Tests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmOneToOneMapping2_0Tests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2011 Oracle. All rights reserved. + * Copyright (c) 2009, 2012 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -80,7 +80,7 @@ public class GenericOrmOneToOneMapping2_0Tests }); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); for (OrmReadOnlyPersistentAttribute each : ormPersistentType.getAttributes()) { - each.convertToSpecified(); + each.addToXml(); } } @@ -105,7 +105,7 @@ public class GenericOrmOneToOneMapping2_0Tests }); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); for (OrmReadOnlyPersistentAttribute each : ormPersistentType.getAttributes()) { - each.convertToSpecified(); + each.addToXml(); } } @@ -241,7 +241,7 @@ public class GenericOrmOneToOneMapping2_0Tests }); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); for (OrmReadOnlyPersistentAttribute each : ormPersistentType.getAttributes()) { - each.convertToSpecified(); + each.addToXml(); } } @@ -493,7 +493,7 @@ public class GenericOrmOneToOneMapping2_0Tests OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State"); - ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "address"); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("address"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); addXmlClassRef(PACKAGE_NAME + ".Address"); @@ -539,7 +539,7 @@ public class GenericOrmOneToOneMapping2_0Tests OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State"); - ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "address"); + ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("address"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); addXmlClassRef(PACKAGE_NAME + ".Address"); @@ -581,8 +581,9 @@ public class GenericOrmOneToOneMapping2_0Tests } public void testUpdateSpecifiedOrphanRemoval() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping2_0 ormOneToOneMapping = (OrmOneToOneMapping2_0) ormPersistentAttribute.getMapping(); OrmOrphanRemovable2_0 mappingsOrphanRemoval = this.getOrphanRemovalOf(ormOneToOneMapping); XmlOneToOne oneToOneResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); @@ -601,8 +602,9 @@ public class GenericOrmOneToOneMapping2_0Tests } public void testModifySpecifiedOrphanRemoval() throws Exception { - OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo"); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping"); + createTestType(); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("id"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmOneToOneMapping2_0 ormOneToOneMapping = (OrmOneToOneMapping2_0) ormPersistentAttribute.getMapping(); OrmOrphanRemovable2_0 mappingsOrphanRemoval = this.getOrphanRemovalOf(ormOneToOneMapping); XmlOneToOne oneToOneResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0); @@ -680,8 +682,8 @@ public class GenericOrmOneToOneMapping2_0Tests createTestEntityWithValidOneToOneMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed("address"), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); - OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "address"); OrmOneToOneMapping2_0 ormOneToOneMapping = (OrmOneToOneMapping2_0) ormPersistentAttribute.getMapping(); ((OneToOneRelationship2_0) ormOneToOneMapping.getRelationship()).setStrategyToJoinTable(); OrmJoinTable ormJoinTable = ((OrmOneToOneRelationship2_0) ormOneToOneMapping.getRelationship()).getJoinTableStrategy().getJoinTable(); @@ -713,7 +715,7 @@ public class GenericOrmOneToOneMapping2_0Tests getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false); //remove m-m mapping from the orm.xml file - ormPersistentAttribute.convertToVirtual(); + ormPersistentAttribute.removeFromXml(); //ormPersistentType.getMapping().setSpecifiedMetadataComplete(null); OrmReadOnlyPersistentAttribute virtualAttribute = ormPersistentType.getAttributeNamed("address"); OneToOneMapping2_0 virtualOneToOneMapping = (OneToOneMapping2_0) virtualAttribute.getMapping(); @@ -909,8 +911,8 @@ public class GenericOrmOneToOneMapping2_0Tests OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); - OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + assertEquals(3, ormPersistentType.getDefaultAttributesSize()); + OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); OneToOneMapping2_0 virtualOneToOneMapping = (OneToOneMapping2_0) virtualPersistentAttribute.getMapping(); assertEquals("address", virtualOneToOneMapping.getName()); @@ -949,13 +951,13 @@ public class GenericOrmOneToOneMapping2_0Tests OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address"); ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); + assertEquals(3, ormPersistentType.getDefaultAttributesSize()); OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.getAttributeNamed("address"); assertEquals(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY, virtualPersistentAttribute.getMappingKey()); assertTrue(virtualPersistentAttribute.isVirtual()); - virtualPersistentAttribute.convertToSpecified(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); + virtualPersistentAttribute.addToXml(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); OneToOneMapping2_0 ormOneToOneMapping = (OneToOneMapping2_0) ormPersistentAttribute.getMapping(); diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmPersistentAttribute2_0Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmPersistentAttribute2_0Tests.java index d0bf3e8f57..28786fb284 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmPersistentAttribute2_0Tests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmPersistentAttribute2_0Tests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2011 Oracle. All rights reserved. + * Copyright (c) 2009, 2012 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -137,23 +137,23 @@ public class GenericOrmPersistentAttribute2_0Tests createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - assertEquals(2, ormPersistentType.getVirtualAttributesSize()); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); - OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); assertEquals("id", ormPersistentAttribute.getName()); assertTrue(ormPersistentAttribute.isVirtual()); - ormPersistentAttribute.convertToSpecified(); + ormPersistentAttribute.addToXml(); - assertEquals(1, ormPersistentType.getVirtualAttributesSize()); + assertEquals(1, ormPersistentType.getDefaultAttributesSize()); assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); OrmPersistentAttribute specifiedOrmPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); assertEquals("id", specifiedOrmPersistentAttribute.getName()); assertFalse(specifiedOrmPersistentAttribute.isVirtual()); - ormPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); - ormPersistentAttribute.convertToSpecified(); + ormPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); + ormPersistentAttribute.addToXml(); - assertEquals(0, ormPersistentType.getVirtualAttributesSize()); + assertEquals(0, ormPersistentType.getDefaultAttributesSize()); assertEquals(2, ormPersistentType.getSpecifiedAttributesSize()); Iterator<OrmPersistentAttribute> specifiedAttributes = ormPersistentType.getSpecifiedAttributes().iterator(); specifiedOrmPersistentAttribute = specifiedAttributes.next(); @@ -169,16 +169,16 @@ public class GenericOrmPersistentAttribute2_0Tests createTestEntityAnnotatedFieldPropertySpecified(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - assertEquals(2, ormPersistentType.getVirtualAttributesSize()); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); - OrmReadOnlyPersistentAttribute ormPersistentAttribute = CollectionTools.get(ormPersistentType.getVirtualAttributes(), 1); + OrmReadOnlyPersistentAttribute ormPersistentAttribute = CollectionTools.get(ormPersistentType.getDefaultAttributes(), 1); assertEquals("id", ormPersistentAttribute.getName()); assertTrue(ormPersistentAttribute.isVirtual()); assertEquals(AccessType.PROPERTY, ormPersistentAttribute.getAccess()); assertEquals(null, ormPersistentAttribute.getJavaPersistentAttribute().getSpecifiedAccess()); - ormPersistentAttribute.convertToSpecified(); + ormPersistentAttribute.addToXml(); - assertEquals(1, ormPersistentType.getVirtualAttributesSize()); + assertEquals(1, ormPersistentType.getDefaultAttributesSize()); assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); OrmPersistentAttribute specifiedOrmPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); assertEquals("id", specifiedOrmPersistentAttribute.getName()); @@ -186,13 +186,13 @@ public class GenericOrmPersistentAttribute2_0Tests assertEquals(AccessType.PROPERTY, specifiedOrmPersistentAttribute.getAccess()); assertFalse(specifiedOrmPersistentAttribute.isVirtual()); - ormPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); + ormPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); assertEquals("name", ormPersistentAttribute.getName()); assertTrue(ormPersistentAttribute.isVirtual()); assertEquals(AccessType.FIELD, ormPersistentAttribute.getAccess()); - ormPersistentAttribute.convertToSpecified(); + ormPersistentAttribute.addToXml(); - assertEquals(0, ormPersistentType.getVirtualAttributesSize()); + assertEquals(0, ormPersistentType.getDefaultAttributesSize()); assertEquals(2, ormPersistentType.getSpecifiedAttributesSize()); Iterator<OrmPersistentAttribute> specifiedAttributes = ormPersistentType.getSpecifiedAttributes().iterator(); specifiedOrmPersistentAttribute = specifiedAttributes.next(); @@ -211,16 +211,16 @@ public class GenericOrmPersistentAttribute2_0Tests createTestTypeNullAttributeMapping(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - assertEquals(3, ormPersistentType.getVirtualAttributesSize()); + assertEquals(3, ormPersistentType.getDefaultAttributesSize()); //take a virtual mapping with a mapping type and make it specified OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getAttributeNamed("address"); assertEquals("address", ormPersistentAttribute.getName()); assertTrue(ormPersistentAttribute.isVirtual()); assertTrue(ormPersistentAttribute.getMapping() instanceof GenericJavaNullAttributeMapping); - ormPersistentAttribute.convertToSpecified(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); + ormPersistentAttribute.addToXml(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); - assertEquals(2, ormPersistentType.getVirtualAttributesSize()); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); OrmPersistentAttribute specifiedOrmPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); assertEquals("address", specifiedOrmPersistentAttribute.getName()); @@ -228,10 +228,10 @@ public class GenericOrmPersistentAttribute2_0Tests assertTrue(specifiedOrmPersistentAttribute.getMapping() instanceof OrmOneToOneMapping); - ormPersistentAttribute = ormPersistentType.getVirtualAttributes().iterator().next(); - ormPersistentAttribute.convertToSpecified(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); + ormPersistentAttribute = ormPersistentType.getDefaultAttributes().iterator().next(); + ormPersistentAttribute.addToXml(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); - assertEquals(1, ormPersistentType.getVirtualAttributesSize()); + assertEquals(1, ormPersistentType.getDefaultAttributesSize()); assertEquals(2, ormPersistentType.getSpecifiedAttributesSize()); Iterator<OrmPersistentAttribute> specifiedAttributes = ormPersistentType.getSpecifiedAttributes().iterator(); @@ -249,27 +249,27 @@ public class GenericOrmPersistentAttribute2_0Tests createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - assertEquals(2, ormPersistentType.getVirtualAttributesSize()); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); - ormPersistentType.getVirtualAttributes().iterator().next().convertToSpecified(); - ormPersistentType.getVirtualAttributes().iterator().next().convertToSpecified(); + ormPersistentType.getDefaultAttributes().iterator().next().addToXml(); + ormPersistentType.getDefaultAttributes().iterator().next().addToXml(); - assertEquals(0, ormPersistentType.getVirtualAttributesSize()); + assertEquals(0, ormPersistentType.getDefaultAttributesSize()); assertEquals(2, ormPersistentType.getSpecifiedAttributesSize()); OrmPersistentAttribute specifiedOrmPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); assertEquals("id", specifiedOrmPersistentAttribute.getName()); assertFalse(specifiedOrmPersistentAttribute.isVirtual()); - specifiedOrmPersistentAttribute.convertToVirtual(); - assertEquals(1, ormPersistentType.getVirtualAttributesSize()); + specifiedOrmPersistentAttribute.removeFromXml(); + assertEquals(1, ormPersistentType.getDefaultAttributesSize()); assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); specifiedOrmPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); - specifiedOrmPersistentAttribute.convertToVirtual(); - assertEquals(2, ormPersistentType.getVirtualAttributesSize()); + specifiedOrmPersistentAttribute.removeFromXml(); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); assertEquals(0, ormPersistentType.getSpecifiedAttributesSize()); - Iterator<OrmReadOnlyPersistentAttribute> virtualAttributes = ormPersistentType.getVirtualAttributes().iterator(); + Iterator<OrmReadOnlyPersistentAttribute> virtualAttributes = ormPersistentType.getDefaultAttributes().iterator(); OrmReadOnlyPersistentAttribute virtualAttribute = virtualAttributes.next(); assertEquals("id", virtualAttribute.getName()); virtualAttribute = virtualAttributes.next(); @@ -280,23 +280,23 @@ public class GenericOrmPersistentAttribute2_0Tests createTestType(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - assertEquals(2, ormPersistentType.getVirtualAttributesSize()); + assertEquals(2, ormPersistentType.getDefaultAttributesSize()); - ormPersistentType.getVirtualAttributes().iterator().next().convertToSpecified(); - ormPersistentType.getVirtualAttributes().iterator().next().convertToSpecified(); + ormPersistentType.getDefaultAttributes().iterator().next().addToXml(); + ormPersistentType.getDefaultAttributes().iterator().next().addToXml(); ormPersistentType.getSpecifiedAttributes().iterator().next().getMapping().setName("noJavaAttribute"); - assertEquals(1, ormPersistentType.getVirtualAttributesSize()); + assertEquals(1, ormPersistentType.getDefaultAttributesSize()); assertEquals(2, ormPersistentType.getSpecifiedAttributesSize()); OrmPersistentAttribute specifiedOrmPersistentAttribute = ormPersistentType.getSpecifiedAttributes().iterator().next(); - specifiedOrmPersistentAttribute.convertToVirtual(); - assertEquals(1, ormPersistentType.getVirtualAttributesSize()); + specifiedOrmPersistentAttribute.removeFromXml(); + assertEquals(1, ormPersistentType.getDefaultAttributesSize()); assertEquals(1, ormPersistentType.getSpecifiedAttributesSize()); - assertEquals("id", ormPersistentType.getVirtualAttributes().iterator().next().getName()); + assertEquals("id", ormPersistentType.getDefaultAttributes().iterator().next().getName()); assertEquals("name", ormPersistentType.getSpecifiedAttributes().iterator().next().getName()); } @@ -353,7 +353,7 @@ public class GenericOrmPersistentAttribute2_0Tests //specified orm attribute, access type matches java : FIELD, name matches java //javaPersistentAttribute should be == to java context model object - ormPersistentAttribute.convertToSpecified(); + ormPersistentAttribute.addToXml(); ormPersistentAttribute = ormPersistentType.getAttributeNamed("id"); assertFalse(ormPersistentAttribute.isVirtual()); assertEquals(javaPersistentAttribute, ormPersistentAttribute.getJavaPersistentAttribute()); @@ -362,7 +362,7 @@ public class GenericOrmPersistentAttribute2_0Tests //virtual orm attribute, java access type FIELD, orm access type PROPERTY, name matches java //verify both the property java resource attribute and the field java resource attribute are used in orm //because the field is annotated and property is specified - ((OrmPersistentAttribute) ormPersistentAttribute).convertToVirtual(); + ((OrmPersistentAttribute) ormPersistentAttribute).removeFromXml(); ormPersistentAttribute = ormPersistentType.getAttributeNamed("id"); ormPersistentType.setSpecifiedAccess(AccessType.PROPERTY); ListIterator<OrmReadOnlyPersistentAttribute> attributes = ormPersistentType.getAttributes().iterator(); @@ -382,7 +382,7 @@ public class GenericOrmPersistentAttribute2_0Tests ormPersistentType.setSpecifiedAccess(null);//default access will be field ormPersistentAttribute = ormPersistentType.getAttributeNamed("id"); - OrmPersistentAttribute ormPersistentAttribute2 = ormPersistentAttribute.convertToSpecified(); + OrmPersistentAttribute ormPersistentAttribute2 = ormPersistentAttribute.addToXml(); ormPersistentAttribute2.getMapping().setName("id2"); assertEquals(null, ormPersistentAttribute2.getJavaPersistentAttribute()); @@ -419,7 +419,7 @@ public class GenericOrmPersistentAttribute2_0Tests assertEquals(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, javaPersistentAttribute.getMappingKey()); - ormPropertyAttribute.convertToSpecified(); + ormPropertyAttribute.addToXml(); ormPropertyAttribute = ormPersistentType.getAttributeNamed("id"); assertFalse(ormPropertyAttribute.isVirtual()); assertEquals(AccessType.PROPERTY, ormPropertyAttribute.getAccess()); @@ -451,7 +451,7 @@ public class GenericOrmPersistentAttribute2_0Tests assertTrue(javaPersistentAttribute.getResourceAttribute().getKind() == Kind.FIELD); - ormPersistentAttribute.convertToSpecified(); + ormPersistentAttribute.addToXml(); ormPersistentAttribute = ormPersistentType.getAttributeNamed("id"); assertFalse(ormPersistentAttribute.isVirtual()); assertEquals(AccessType.FIELD, ormPersistentAttribute.getAccess()); @@ -484,7 +484,7 @@ public class GenericOrmPersistentAttribute2_0Tests assertTrue(javaPersistentAttribute.getResourceAttribute().getKind() == Kind.METHOD); - ormPersistentAttribute.convertToSpecified(); + ormPersistentAttribute.addToXml(); ormPersistentAttribute = ormPersistentType.getAttributeNamed("id"); assertFalse(ormPersistentAttribute.isVirtual()); assertEquals(AccessType.PROPERTY, ormPersistentAttribute.getAccess()); @@ -527,7 +527,7 @@ public class GenericOrmPersistentAttribute2_0Tests assertTrue(nameJavaPersistentAttribute.getResourceAttribute().getKind() == Kind.FIELD); - ormPersistentAttribute.convertToSpecified(); + ormPersistentAttribute.addToXml(); ormPersistentAttribute = ormPersistentType.getAttributeNamed("id"); assertFalse(ormPersistentAttribute.isVirtual()); assertEquals(AccessType.PROPERTY, ormPersistentAttribute.getAccess()); @@ -535,7 +535,7 @@ public class GenericOrmPersistentAttribute2_0Tests assertEquals(AccessType.PROPERTY, javaPersistentAttribute.getAccess()); assertTrue(javaPersistentAttribute.getResourceAttribute().getKind() == Kind.METHOD); - nameOrmPersistentAttribute.convertToSpecified(); + nameOrmPersistentAttribute.addToXml(); nameOrmPersistentAttribute = ormPersistentType.getAttributeNamed("name"); assertFalse(nameOrmPersistentAttribute.isVirtual()); assertEquals(AccessType.FIELD, nameOrmPersistentAttribute.getAccess()); diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmPersistentType2_0Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmPersistentType2_0Tests.java index a32aa28c65..12901a4fcf 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmPersistentType2_0Tests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/orm/GenericOrmPersistentType2_0Tests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2011 Oracle. All rights reserved. + * Copyright (c) 2009, 2012 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -120,7 +120,7 @@ public class GenericOrmPersistentType2_0Tests OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getAttributeNamed("id"); - ormPersistentAttribute.convertToSpecified(); + ormPersistentAttribute.addToXml(); assertEquals(AccessType.FIELD, ormPersistentType.getAccess()); assertEquals(AccessType.FIELD, javaPersistentType.getAccess()); assertEquals(null, javaPersistentType.getSpecifiedAccess()); @@ -141,7 +141,7 @@ public class GenericOrmPersistentType2_0Tests OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getAttributeNamed("id"); - ormPersistentAttribute.convertToSpecified(); + ormPersistentAttribute.addToXml(); assertEquals(AccessType.PROPERTY, ormPersistentType.getAccess()); assertEquals(AccessType.PROPERTY, javaPersistentType.getAccess()); assertEquals(AccessType.PROPERTY, javaPersistentType.getSpecifiedAccess()); @@ -155,7 +155,7 @@ public class GenericOrmPersistentType2_0Tests createTestEntityAnnotatedFieldPropertySpecified(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - Iterator<OrmReadOnlyPersistentAttribute> virtualAttributes = ormPersistentType.getVirtualAttributes().iterator(); + Iterator<OrmReadOnlyPersistentAttribute> virtualAttributes = ormPersistentType.getDefaultAttributes().iterator(); OrmReadOnlyPersistentAttribute ormPersistentAttribute = virtualAttributes.next(); assertEquals("name", ormPersistentAttribute.getName()); assertEquals(AccessType.FIELD, ormPersistentAttribute.getAccess()); @@ -168,7 +168,7 @@ public class GenericOrmPersistentType2_0Tests assertFalse(virtualAttributes.hasNext()); ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE); - virtualAttributes = ormPersistentType.getVirtualAttributes().iterator(); + virtualAttributes = ormPersistentType.getDefaultAttributes().iterator(); ormPersistentAttribute = virtualAttributes.next(); assertEquals("name", ormPersistentAttribute.getName()); @@ -185,7 +185,7 @@ public class GenericOrmPersistentType2_0Tests createTestEntityPropertySpecified(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - Iterator<OrmReadOnlyPersistentAttribute> virtualAttributes = ormPersistentType.getVirtualAttributes().iterator(); + Iterator<OrmReadOnlyPersistentAttribute> virtualAttributes = ormPersistentType.getDefaultAttributes().iterator(); OrmReadOnlyPersistentAttribute ormPersistentAttribute = virtualAttributes.next(); assertEquals("id", ormPersistentAttribute.getName()); assertEquals(AccessType.PROPERTY, ormPersistentAttribute.getAccess()); @@ -193,7 +193,7 @@ public class GenericOrmPersistentType2_0Tests assertFalse(virtualAttributes.hasNext()); ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE); - virtualAttributes = ormPersistentType.getVirtualAttributes().iterator(); + virtualAttributes = ormPersistentType.getDefaultAttributes().iterator(); ormPersistentAttribute = virtualAttributes.next(); assertEquals("id", ormPersistentAttribute.getName()); assertEquals(AccessType.FIELD, ormPersistentAttribute.getAccess()); @@ -206,7 +206,7 @@ public class GenericOrmPersistentType2_0Tests assertFalse(virtualAttributes.hasNext()); ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.FALSE); - virtualAttributes = ormPersistentType.getVirtualAttributes().iterator(); + virtualAttributes = ormPersistentType.getDefaultAttributes().iterator(); ormPersistentAttribute = virtualAttributes.next(); assertEquals("id", ormPersistentAttribute.getName()); assertEquals(AccessType.PROPERTY, ormPersistentAttribute.getAccess()); @@ -218,7 +218,7 @@ public class GenericOrmPersistentType2_0Tests createTestEntityFieldSpecifiedPropertyAnnotated(); OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - Iterator<OrmReadOnlyPersistentAttribute> virtualAttributes = ormPersistentType.getVirtualAttributes().iterator(); + Iterator<OrmReadOnlyPersistentAttribute> virtualAttributes = ormPersistentType.getDefaultAttributes().iterator(); OrmReadOnlyPersistentAttribute virtualAttribute = virtualAttributes.next(); assertEquals("id", virtualAttribute.getName()); assertEquals(AccessType.FIELD, virtualAttribute.getAccess()); @@ -234,9 +234,9 @@ public class GenericOrmPersistentType2_0Tests assertFalse(virtualAttributes.hasNext()); - virtualAttribute.convertToSpecified(); + virtualAttribute.addToXml(); - virtualAttributes = ormPersistentType.getVirtualAttributes().iterator(); + virtualAttributes = ormPersistentType.getDefaultAttributes().iterator(); virtualAttribute = virtualAttributes.next(); assertEquals("name", virtualAttribute.getName()); assertEquals(AccessType.FIELD, virtualAttribute.getAccess()); @@ -253,10 +253,10 @@ public class GenericOrmPersistentType2_0Tests assertEquals(AccessType.PROPERTY, specifiedAttribute.getSpecifiedAccess()); - virtualAttributes = ormPersistentType.getVirtualAttributes().iterator(); + virtualAttributes = ormPersistentType.getDefaultAttributes().iterator(); virtualAttributes.next(); - virtualAttributes.next().convertToSpecified(); - virtualAttributes = ormPersistentType.getVirtualAttributes().iterator(); + virtualAttributes.next().addToXml(); + virtualAttributes = ormPersistentType.getDefaultAttributes().iterator(); virtualAttribute = virtualAttributes.next(); assertEquals("name", virtualAttribute.getName()); assertEquals(AccessType.FIELD, virtualAttribute.getAccess()); |