Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaOneToOneMappingTests.java')
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaOneToOneMappingTests.java250
1 files changed, 123 insertions, 127 deletions
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaOneToOneMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaOneToOneMappingTests.java
index 1b7e6649a8..97a7df409a 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaOneToOneMappingTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaOneToOneMappingTests.java
@@ -11,9 +11,10 @@ package org.eclipse.jpt.jpa.eclipselink.core.tests.internal.v2_0.context.java;
import java.util.Iterator;
import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceField;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement.Kind;
import org.eclipse.jpt.common.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.common.core.tests.internal.utility.jdt.AnnotationTestCase.DefaultAnnotationWriter;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
import org.eclipse.jpt.jpa.core.MappingKeys;
@@ -35,8 +36,6 @@ import org.eclipse.jpt.jpa.core.jpa2.resource.java.JPA2_0;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapsId2_0Annotation;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.OneToOne2_0Annotation;
import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
import org.eclipse.jpt.jpa.core.resource.java.OneToOneAnnotation;
import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.v2_0.context.EclipseLink2_0ContextModelTestCase;
@@ -142,7 +141,7 @@ public class EclipseLink2_0JavaOneToOneMappingTests
}
});
OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- for (OrmReadOnlyPersistentAttribute each : CollectionTools.iterable(ormPersistentType.attributes())) {
+ for (OrmReadOnlyPersistentAttribute each : ormPersistentType.getAttributes()) {
each.convertToSpecified();
}
}
@@ -269,64 +268,61 @@ public class EclipseLink2_0JavaOneToOneMappingTests
public void testUpdateDerivedId() throws Exception {
createTestEntityWithIdDerivedIdentity();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentType resourceType =
- getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute resourceAttribute = resourceType.persistableAttributes().next();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
JavaPersistentType contextType = getJavaPersistentType();
JavaPersistentAttribute contextAttribute = contextType.getAttributeNamed("oneToOne");
JavaOneToOneMapping2_0 contextMapping = (JavaOneToOneMapping2_0) contextAttribute.getMapping();
- assertNotNull(resourceAttribute.getAnnotation(JPA.ID));
+ assertNotNull(resourceField.getAnnotation(JPA.ID));
assertTrue(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
- resourceAttribute.removeAnnotation(JPA.ID);
+ resourceField.removeAnnotation(JPA.ID);
getJpaProject().synchronizeContextModel();
- assertNull(resourceAttribute.getAnnotation(JPA.ID));
+ assertNull(resourceField.getAnnotation(JPA.ID));
assertFalse(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
- resourceAttribute.addAnnotation(JPA.ID);
+ resourceField.addAnnotation(JPA.ID);
getJpaProject().synchronizeContextModel();
- assertNotNull(resourceAttribute.getAnnotation(JPA.ID));
+ assertNotNull(resourceField.getAnnotation(JPA.ID));
assertTrue(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
}
public void testSetDerivedId() throws Exception {
createTestEntityWithIdDerivedIdentity();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentType resourceType =
- getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute resourceAttribute = resourceType.persistableAttributes().next();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
JavaPersistentType contextType = getJavaPersistentType();
JavaPersistentAttribute contextAttribute = contextType.getAttributeNamed("oneToOne");
JavaOneToOneMapping2_0 contextMapping = (JavaOneToOneMapping2_0) contextAttribute.getMapping();
- assertNotNull(resourceAttribute.getAnnotation(JPA.ID));
+ assertNotNull(resourceField.getAnnotation(JPA.ID));
assertTrue(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().setValue(false);
- assertNull(resourceAttribute.getAnnotation(JPA.ID));
+ assertNull(resourceField.getAnnotation(JPA.ID));
assertFalse(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().setValue(true);
- assertNotNull(resourceAttribute.getAnnotation(JPA.ID));
+ assertNotNull(resourceField.getAnnotation(JPA.ID));
assertTrue(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
}
public void testUpdateMapsId() throws Exception {
createTestEntityWithMapsIdDerivedIdentity();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentType resourceType =
- getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute resourceAttribute = resourceType.persistableAttributes().next();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
JavaPersistentType contextType = getJavaPersistentType();
JavaPersistentAttribute contextAttribute = contextType.getAttributeNamed("oneToOne");
JavaOneToOneMapping2_0 contextMapping = (JavaOneToOneMapping2_0) contextAttribute.getMapping();
- assertNotNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID));
+ assertNotNull(resourceField.getAnnotation(JPA2_0.MAPS_ID));
assertNull(contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedIdAttributeName());
MapsId2_0Annotation annotation =
- (MapsId2_0Annotation) resourceAttribute.getAnnotation(JPA2_0.MAPS_ID);
+ (MapsId2_0Annotation) resourceField.getAnnotation(JPA2_0.MAPS_ID);
annotation.setValue("foo");
getJpaProject().synchronizeContextModel();
assertEquals("foo", annotation.getValue());
@@ -337,28 +333,27 @@ public class EclipseLink2_0JavaOneToOneMappingTests
assertEquals("bar", annotation.getValue());
assertEquals("bar", contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedIdAttributeName());
- resourceAttribute.removeAnnotation(JPA2_0.MAPS_ID);
+ resourceField.removeAnnotation(JPA2_0.MAPS_ID);
getJpaProject().synchronizeContextModel();
- assertNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID));
+ assertNull(resourceField.getAnnotation(JPA2_0.MAPS_ID));
assertNull(contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedIdAttributeName());
}
public void testSetMapsId() throws Exception {
createTestEntity();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentType resourceType =
- getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute resourceAttribute = resourceType.persistableAttributes().next();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
JavaPersistentType contextType = getJavaPersistentType();
JavaPersistentAttribute contextAttribute = contextType.getAttributeNamed("address");
JavaOneToOneMapping2_0 contextMapping = (JavaOneToOneMapping2_0) contextAttribute.getMapping();
- assertNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID));
+ assertNull(resourceField.getAnnotation(JPA2_0.MAPS_ID));
assertNull(contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedIdAttributeName());
contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().setSpecifiedIdAttributeName("foo");
MapsId2_0Annotation annotation =
- (MapsId2_0Annotation) resourceAttribute.getAnnotation(JPA2_0.MAPS_ID);
+ (MapsId2_0Annotation) resourceField.getAnnotation(JPA2_0.MAPS_ID);
assertNotNull(annotation);
assertEquals("foo", annotation.getValue());
assertEquals("foo", contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedIdAttributeName());
@@ -368,39 +363,38 @@ public class EclipseLink2_0JavaOneToOneMappingTests
assertEquals("bar", contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedIdAttributeName());
contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().setSpecifiedIdAttributeName(null);
- assertNotNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID));
+ assertNotNull(resourceField.getAnnotation(JPA2_0.MAPS_ID));
assertNull(contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedIdAttributeName());
}
public void testMorphMapping() throws Exception {
createTestEntityWithIdDerivedIdentity();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentType resourceType =
- getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute resourceAttribute = resourceType.persistableAttributes().next();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
JavaPersistentType contextType = getJavaPersistentType();
JavaPersistentAttribute contextAttribute = contextType.getAttributeNamed("oneToOne");
- assertNotNull(resourceAttribute.getAnnotation(JPA.ID));
+ assertNotNull(resourceField.getAnnotation(JPA.ID));
assertTrue(((JavaOneToOneMapping2_0) contextAttribute.getMapping()).
getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
- assertNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID));
+ assertNull(resourceField.getAnnotation(JPA2_0.MAPS_ID));
assertNull(((JavaOneToOneMapping2_0) contextAttribute.getMapping()).
getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedIdAttributeName());
contextAttribute.setMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertNotNull(resourceAttribute.getAnnotation(JPA.ID));
+ assertNotNull(resourceField.getAnnotation(JPA.ID));
assertTrue(((JavaOneToOneMapping2_0) contextAttribute.getMapping()).
getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
- assertNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID));
+ assertNull(resourceField.getAnnotation(JPA2_0.MAPS_ID));
assertNull(((JavaOneToOneMapping2_0) contextAttribute.getMapping()).
getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedIdAttributeName());
contextAttribute.setMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertNotNull(resourceAttribute.getAnnotation(JPA.ID));
+ assertNotNull(resourceField.getAnnotation(JPA.ID));
assertTrue(((JavaManyToOneMapping2_0) contextAttribute.getMapping()).
getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
- assertNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID));
+ assertNull(resourceField.getAnnotation(JPA2_0.MAPS_ID));
assertNull(((JavaManyToOneMapping2_0) contextAttribute.getMapping()).
getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedIdAttributeName());
@@ -408,20 +402,20 @@ public class EclipseLink2_0JavaOneToOneMappingTests
// contextAttribute.setMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
// the *real* test is whether the Id annotation still results in a 1:1 mapping...
contextAttribute.setMappingKey(null); // clear any mapping annotation
- resourceAttribute.addAnnotation(JPA.ID); // add Id annotation
+ resourceField.addAnnotation(JPA.ID); // add Id annotation
this.getJpaProject().synchronizeContextModel();
- assertNotNull(resourceAttribute.getAnnotation(JPA.ID));
- assertNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID));
+ assertNotNull(resourceField.getAnnotation(JPA.ID));
+ assertNull(resourceField.getAnnotation(JPA2_0.MAPS_ID));
assertTrue(contextAttribute.getMapping() instanceof JavaOneToOneMapping2_0);
contextAttribute.setMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertNotNull(resourceAttribute.getAnnotation(JPA.ID));
- assertNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID));
+ assertNotNull(resourceField.getAnnotation(JPA.ID));
+ assertNull(resourceField.getAnnotation(JPA2_0.MAPS_ID));
assertTrue(contextAttribute.getMapping() instanceof JavaManyToOneMapping2_0);
contextAttribute.setMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
- assertNull(resourceAttribute.getAnnotation(JPA.ID));
- assertNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID));
+ assertNull(resourceField.getAnnotation(JPA.ID));
+ assertNull(resourceField.getAnnotation(JPA2_0.MAPS_ID));
assertTrue(contextAttribute.getMapping() instanceof JavaBasicMapping);
}
@@ -433,7 +427,7 @@ public class EclipseLink2_0JavaOneToOneMappingTests
addXmlClassRef(PACKAGE_NAME + ".Address");
addXmlClassRef(PACKAGE_NAME + ".State");
- PersistentAttribute persistentAttribute = (getJavaPersistentType()).attributes().next();
+ PersistentAttribute persistentAttribute = (getJavaPersistentType()).getAttributes().iterator().next();
OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
Iterator<String> attributeNames =
@@ -474,7 +468,7 @@ public class EclipseLink2_0JavaOneToOneMappingTests
addXmlClassRef(PACKAGE_NAME + ".Address");
addXmlClassRef(PACKAGE_NAME + ".State");
- PersistentAttribute persistentAttribute = (getJavaPersistentType()).attributes().next();
+ PersistentAttribute persistentAttribute = (getJavaPersistentType()).getAttributes().iterator().next();
OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
Iterator<String> attributeNames =
@@ -515,7 +509,7 @@ public class EclipseLink2_0JavaOneToOneMappingTests
this.createTestEntity();
this.addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
OneToOneMapping2_0 oneToOneMapping = (OneToOneMapping2_0) persistentAttribute.getMapping();
assertEquals(false, this.getOrphanRemovalOf(oneToOneMapping).isDefaultOrphanRemoval());
}
@@ -524,7 +518,7 @@ public class EclipseLink2_0JavaOneToOneMappingTests
this.createTestEntity();
this.addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
OneToOneMapping2_0 oneToOneMapping = (OneToOneMapping2_0) persistentAttribute.getMapping();
assertEquals(false, this.getOrphanRemovalOf(oneToOneMapping).isDefaultOrphanRemoval());
}
@@ -533,7 +527,7 @@ public class EclipseLink2_0JavaOneToOneMappingTests
this.createTestEntity();
this.addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
OneToOneMapping2_0 oneToOneMapping = (OneToOneMapping2_0) persistentAttribute.getMapping();
JavaOrphanRemovable2_0 mappingsOrphanRemoval = this.getOrphanRemovalOf(oneToOneMapping);
@@ -547,15 +541,15 @@ public class EclipseLink2_0JavaOneToOneMappingTests
this.createTestEntity();
this.addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
OneToOneMapping2_0 oneToOneMapping = (OneToOneMapping2_0) persistentAttribute.getMapping();
JavaOrphanRemovable2_0 mappingsOrphanRemoval = this.getOrphanRemovalOf(oneToOneMapping);
assertNull(mappingsOrphanRemoval.getSpecifiedOrphanRemoval());
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- OneToOne2_0Annotation oneToOne = (OneToOne2_0Annotation) attributeResource.getAnnotation(JPA.ONE_TO_ONE);
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ OneToOne2_0Annotation oneToOne = (OneToOne2_0Annotation) resourceField.getAnnotation(JPA.ONE_TO_ONE);
oneToOne.setOrphanRemoval(Boolean.FALSE);
getJpaProject().synchronizeContextModel();
@@ -566,7 +560,7 @@ public class EclipseLink2_0JavaOneToOneMappingTests
this.createTestEntityWithValidOneToOneMappingOrphanRemovalSpecified();
this.addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
OneToOneMapping2_0 oneToOneMapping = (OneToOneMapping2_0) persistentAttribute.getMapping();
assertEquals(Boolean.FALSE, this.getOrphanRemovalOf(oneToOneMapping).getSpecifiedOrphanRemoval());
@@ -576,37 +570,37 @@ public class EclipseLink2_0JavaOneToOneMappingTests
this.createTestEntity();
this.addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
OneToOneMapping2_0 oneToOneMapping = (OneToOneMapping2_0) persistentAttribute.getMapping();
JavaOrphanRemovable2_0 mappingsOrphanRemoval = this.getOrphanRemovalOf(oneToOneMapping);
assertNull(mappingsOrphanRemoval.getSpecifiedOrphanRemoval());
mappingsOrphanRemoval.setSpecifiedOrphanRemoval(Boolean.TRUE);
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- OneToOne2_0Annotation oneToOne = (OneToOne2_0Annotation) attributeResource.getAnnotation(JPA.ONE_TO_ONE);
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ OneToOne2_0Annotation oneToOne = (OneToOne2_0Annotation) resourceField.getAnnotation(JPA.ONE_TO_ONE);
assertEquals(Boolean.TRUE, oneToOne.getOrphanRemoval());
mappingsOrphanRemoval.setSpecifiedOrphanRemoval(null);
- assertNotNull(attributeResource.getAnnotation(JPA.ONE_TO_ONE)); // .getElement);
+ assertNotNull(resourceField.getAnnotation(JPA.ONE_TO_ONE)); // .getElement);
}
public void testSetSpecifiedOrphanRemoval2() throws Exception {
this.createTestEntity();
this.addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
OneToOneMapping2_0 oneToOneMapping = (OneToOneMapping2_0) persistentAttribute.getMapping();
JavaOrphanRemovable2_0 mappingsOrphanRemoval = this.getOrphanRemovalOf(oneToOneMapping);
assertNull(mappingsOrphanRemoval.getSpecifiedOrphanRemoval());
mappingsOrphanRemoval.setSpecifiedOrphanRemoval(Boolean.TRUE);
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- OneToOne2_0Annotation oneToOne = (OneToOne2_0Annotation) attributeResource.getAnnotation(JPA.ONE_TO_ONE);
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ OneToOne2_0Annotation oneToOne = (OneToOne2_0Annotation) resourceField.getAnnotation(JPA.ONE_TO_ONE);
assertEquals(Boolean.TRUE, oneToOne.getOrphanRemoval());
@@ -615,22 +609,22 @@ public class EclipseLink2_0JavaOneToOneMappingTests
assertEquals(Boolean.TRUE, mappingsOrphanRemoval.getSpecifiedOrphanRemoval());
mappingsOrphanRemoval.setSpecifiedOrphanRemoval(null);
- assertNotNull(attributeResource.getAnnotation(JPA.ONE_TO_ONE));
+ assertNotNull(resourceField.getAnnotation(JPA.ONE_TO_ONE));
}
public void testGetSpecifiedOrphanRemovalUpdatesFromResourceModelChange() throws Exception {
this.createTestEntity();
this.addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
OneToOneMapping2_0 oneToOneMapping = (OneToOneMapping2_0) persistentAttribute.getMapping();
JavaOrphanRemovable2_0 mappingsOrphanRemoval = this.getOrphanRemovalOf(oneToOneMapping);
assertNull(mappingsOrphanRemoval.getSpecifiedOrphanRemoval());
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- OneToOne2_0Annotation oneToOne = (OneToOne2_0Annotation) attributeResource.getAnnotation(JPA.ONE_TO_ONE);
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ OneToOne2_0Annotation oneToOne = (OneToOne2_0Annotation) resourceField.getAnnotation(JPA.ONE_TO_ONE);
oneToOne.setOrphanRemoval(Boolean.FALSE);
getJpaProject().synchronizeContextModel();
@@ -642,7 +636,7 @@ public class EclipseLink2_0JavaOneToOneMappingTests
assertSame(oneToOneMapping, persistentAttribute.getMapping());
oneToOne.setOrphanRemoval(Boolean.FALSE);
- attributeResource.setPrimaryAnnotation(null, EmptyIterable.<String>instance());
+ resourceField.setPrimaryAnnotation(null, EmptyIterable.<String>instance());
getJpaProject().synchronizeContextModel();
assertTrue(persistentAttribute.getMapping().isDefault());
@@ -652,56 +646,57 @@ public class EclipseLink2_0JavaOneToOneMappingTests
createTestEntityWithValidOneToOneMapping();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute resourceAttribute = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME).persistableAttributes().next();
- OneToOneAnnotation annotation = (OneToOneAnnotation) resourceAttribute.getAnnotation(JPA.ONE_TO_ONE);
- PersistentAttribute contextAttribute = getJavaPersistentType().attributes().next();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ OneToOneAnnotation annotation = (OneToOneAnnotation) resourceField.getAnnotation(JPA.ONE_TO_ONE);
+ PersistentAttribute contextAttribute = getJavaPersistentType().getAttributes().iterator().next();
OneToOneMapping2_0 mapping = (OneToOneMapping2_0) contextAttribute.getMapping();
OneToOneRelationship2_0 rel = (OneToOneRelationship2_0) mapping.getRelationship();
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN));
+ assertNull(resourceField.getAnnotation(0, JPA.JOIN_COLUMN));
+ assertNull(resourceField.getAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN));
assertNull(annotation.getMappedBy());
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
+ assertNull(resourceField.getAnnotation(JPA.JOIN_TABLE));
assertTrue(rel.strategyIsJoinColumn());
assertFalse(rel.strategyIsPrimaryKeyJoinColumn());
assertFalse(rel.strategyIsMappedBy());
assertFalse(rel.strategyIsJoinTable());
rel.setStrategyToPrimaryKeyJoinColumn();
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNotNull(resourceAttribute.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN));
+ assertNull(resourceField.getAnnotation(0, JPA.JOIN_COLUMN));
+ assertNotNull(resourceField.getAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN));
assertNull(annotation.getMappedBy());
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
+ assertNull(resourceField.getAnnotation(JPA.JOIN_TABLE));
assertFalse(rel.strategyIsJoinColumn());
assertTrue(rel.strategyIsPrimaryKeyJoinColumn());
assertFalse(rel.strategyIsMappedBy());
assertFalse(rel.strategyIsJoinTable());
rel.setStrategyToMappedBy();
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN));
+ assertNull(resourceField.getAnnotation(0, JPA.JOIN_COLUMN));
+ assertNull(resourceField.getAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN));
assertNotNull(annotation.getMappedBy());
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
+ assertNull(resourceField.getAnnotation(JPA.JOIN_TABLE));
assertFalse(rel.strategyIsJoinColumn());
assertFalse(rel.strategyIsPrimaryKeyJoinColumn());
assertTrue(rel.strategyIsMappedBy());
assertFalse(rel.strategyIsJoinTable());
rel.setStrategyToJoinTable();
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN));
+ assertNull(resourceField.getAnnotation(0, JPA.JOIN_COLUMN));
+ assertNull(resourceField.getAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN));
assertNull(annotation.getMappedBy());
- assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
+ assertNotNull(resourceField.getAnnotation(JPA.JOIN_TABLE));
assertFalse(rel.strategyIsJoinColumn());
assertFalse(rel.strategyIsPrimaryKeyJoinColumn());
assertFalse(rel.strategyIsMappedBy());
assertTrue(rel.strategyIsJoinTable());
rel.setStrategyToJoinColumn();
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN));
+ assertNull(resourceField.getAnnotation(0, JPA.JOIN_COLUMN));
+ assertNull(resourceField.getAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN));
assertNull(annotation.getMappedBy());
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
+ assertNull(resourceField.getAnnotation(JPA.JOIN_TABLE));
assertTrue(rel.strategyIsJoinColumn());
assertFalse(rel.strategyIsPrimaryKeyJoinColumn());
assertFalse(rel.strategyIsMappedBy());
@@ -712,27 +707,28 @@ public class EclipseLink2_0JavaOneToOneMappingTests
createTestEntityWithValidOneToOneMapping();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute resourceAttribute = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME).persistableAttributes().next();
- OneToOneAnnotation annotation = (OneToOneAnnotation) resourceAttribute.getAnnotation(JPA.ONE_TO_ONE);
- PersistentAttribute contextAttribute = getJavaPersistentType().attributes().next();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ OneToOneAnnotation annotation = (OneToOneAnnotation) resourceField.getAnnotation(JPA.ONE_TO_ONE);
+ PersistentAttribute contextAttribute = getJavaPersistentType().getAttributes().iterator().next();
OneToOneMapping2_0 mapping = (OneToOneMapping2_0) contextAttribute.getMapping();
OneToOneRelationship2_0 rel = (OneToOneRelationship2_0) mapping.getRelationship();
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN));
+ assertNull(resourceField.getAnnotation(0, JPA.JOIN_COLUMN));
+ assertNull(resourceField.getAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN));
assertNull(annotation.getMappedBy());
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
+ assertNull(resourceField.getAnnotation(JPA.JOIN_TABLE));
assertTrue(rel.strategyIsJoinColumn());
assertFalse(rel.strategyIsPrimaryKeyJoinColumn());
assertFalse(rel.strategyIsMappedBy());
assertFalse(rel.strategyIsJoinTable());
- resourceAttribute.addAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN);
+ resourceField.addAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN);
getJpaProject().synchronizeContextModel();
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNotNull(resourceAttribute.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN));
+ assertNull(resourceField.getAnnotation(0, JPA.JOIN_COLUMN));
+ assertNotNull(resourceField.getAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN));
assertNull(annotation.getMappedBy());
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
+ assertNull(resourceField.getAnnotation(JPA.JOIN_TABLE));
assertFalse(rel.strategyIsJoinColumn());
assertTrue(rel.strategyIsPrimaryKeyJoinColumn());
assertFalse(rel.strategyIsMappedBy());
@@ -740,43 +736,43 @@ public class EclipseLink2_0JavaOneToOneMappingTests
annotation.setMappedBy("foo");
getJpaProject().synchronizeContextModel();
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNotNull(resourceAttribute.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN));
+ assertNull(resourceField.getAnnotation(0, JPA.JOIN_COLUMN));
+ assertNotNull(resourceField.getAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN));
assertNotNull(annotation.getMappedBy());
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
+ assertNull(resourceField.getAnnotation(JPA.JOIN_TABLE));
assertFalse(rel.strategyIsJoinColumn());
assertFalse(rel.strategyIsPrimaryKeyJoinColumn());
assertTrue(rel.strategyIsMappedBy());
assertFalse(rel.strategyIsJoinTable());
- resourceAttribute.addAnnotation(JPA.JOIN_COLUMN);
+ resourceField.addAnnotation(0, JPA.JOIN_COLUMN);
getJpaProject().synchronizeContextModel();
- assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNotNull(resourceAttribute.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN));
+ assertNotNull(resourceField.getAnnotation(0, JPA.JOIN_COLUMN));
+ assertNotNull(resourceField.getAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN));
assertNotNull(annotation.getMappedBy());
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
+ assertNull(resourceField.getAnnotation(JPA.JOIN_TABLE));
assertFalse(rel.strategyIsJoinColumn());
assertFalse(rel.strategyIsPrimaryKeyJoinColumn());
assertTrue(rel.strategyIsMappedBy());
assertFalse(rel.strategyIsJoinTable());
- resourceAttribute.addAnnotation(JPA.JOIN_TABLE);
+ resourceField.addAnnotation(JPA.JOIN_TABLE);
getJpaProject().synchronizeContextModel();
- assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNotNull(resourceAttribute.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN));
+ assertNotNull(resourceField.getAnnotation(0, JPA.JOIN_COLUMN));
+ assertNotNull(resourceField.getAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN));
assertNotNull(annotation.getMappedBy());
- assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
+ assertNotNull(resourceField.getAnnotation(JPA.JOIN_TABLE));
assertFalse(rel.strategyIsJoinColumn());
assertFalse(rel.strategyIsPrimaryKeyJoinColumn());
assertTrue(rel.strategyIsMappedBy());
assertFalse(rel.strategyIsJoinTable());
- resourceAttribute.removeAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN);
+ resourceField.removeAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN);
getJpaProject().synchronizeContextModel();
- assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN));
+ assertNotNull(resourceField.getAnnotation(0, JPA.JOIN_COLUMN));
+ assertNull(resourceField.getAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN));
assertNotNull(annotation.getMappedBy());
- assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
+ assertNotNull(resourceField.getAnnotation(JPA.JOIN_TABLE));
assertFalse(rel.strategyIsJoinColumn());
assertFalse(rel.strategyIsPrimaryKeyJoinColumn());
assertTrue(rel.strategyIsMappedBy());
@@ -784,32 +780,32 @@ public class EclipseLink2_0JavaOneToOneMappingTests
annotation.setMappedBy(null);
getJpaProject().synchronizeContextModel();
- assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN));
+ assertNotNull(resourceField.getAnnotation(0, JPA.JOIN_COLUMN));
+ assertNull(resourceField.getAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN));
assertNull(annotation.getMappedBy());
- assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
+ assertNotNull(resourceField.getAnnotation(JPA.JOIN_TABLE));
assertFalse(rel.strategyIsJoinColumn());
assertFalse(rel.strategyIsPrimaryKeyJoinColumn());
assertFalse(rel.strategyIsMappedBy());
assertTrue(rel.strategyIsJoinTable());
- resourceAttribute.removeAnnotation(JPA.JOIN_COLUMN);
+ resourceField.removeAnnotation(0, JPA.JOIN_COLUMN);
getJpaProject().synchronizeContextModel();
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN));
+ assertNull(resourceField.getAnnotation(0, JPA.JOIN_COLUMN));
+ assertNull(resourceField.getAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN));
assertNull(annotation.getMappedBy());
- assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
+ assertNotNull(resourceField.getAnnotation(JPA.JOIN_TABLE));
assertFalse(rel.strategyIsJoinColumn());
assertFalse(rel.strategyIsPrimaryKeyJoinColumn());
assertFalse(rel.strategyIsMappedBy());
assertTrue(rel.strategyIsJoinTable());
- resourceAttribute.removeAnnotation(JPA.JOIN_TABLE);
+ resourceField.removeAnnotation(JPA.JOIN_TABLE);
getJpaProject().synchronizeContextModel();
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN));
+ assertNull(resourceField.getAnnotation(0, JPA.JOIN_COLUMN));
+ assertNull(resourceField.getAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN));
assertNull(annotation.getMappedBy());
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
+ assertNull(resourceField.getAnnotation(JPA.JOIN_TABLE));
assertTrue(rel.strategyIsJoinColumn());
assertFalse(rel.strategyIsPrimaryKeyJoinColumn());
assertFalse(rel.strategyIsMappedBy());

Back to the top