Skip to main content
summaryrefslogtreecommitdiffstats
path: root/jpa
diff options
context:
space:
mode:
authorkmoore2011-08-04 00:34:05 +0000
committerkmoore2011-08-04 00:34:05 +0000
commit77be67e4785ca5ec392718b531bec67f75c5762c (patch)
tree9a99ae8de9c37769fb7ea4ea3472f005e6b3eb4a /jpa
parentf5282012d8d545c3133391f0611bba8f534030ed (diff)
downloadwebtools.dali-77be67e4785ca5ec392718b531bec67f75c5762c.tar.gz
webtools.dali-77be67e4785ca5ec392718b531bec67f75c5762c.tar.xz
webtools.dali-77be67e4785ca5ec392718b531bec67f75c5762c.zip
Bug 353575 - some supported annotations removed when changing attribute/type mapping
Diffstat (limited to 'jpa')
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaTypeMappingDefinitionWrapper.java52
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/Generic2_0JpaPlatformProvider.java28
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaBasicMappingDefinition2_0.java62
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaElementCollectionMappingDefinition2_0.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaEmbeddableDefinition2_0.java62
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaEmbeddedIdMappingDefinition2_0.java62
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaEmbeddedMappingDefinition2_0.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaEntityDefinition2_0.java62
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaIdMappingDefinition2_0.java20
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaManyToManyMappingDefinition2_0.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaManyToOneMappingDefinition2_0.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaMappedSuperclassDefinition2_0.java62
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaOneToManyMappingDefinition2_0.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaOneToOneMappingDefinition2_0.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaVersionMappingDefinition2_0.java62
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLinkJpaPlatformProvider.java14
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaEmbeddableDefinition.java72
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaEntityDefinition.java79
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaMappedSuperclassDefinition.java54
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v1_1/EclipseLink1_1JpaPlatformProvider.java14
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v1_2/EclipseLink1_2JpaPlatformProvider.java14
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/AbstractEclipseLink2_0JpaPlatformProvider.java46
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaBasicCollectionMappingDefinition2_0.java63
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaBasicMapMappingDefinition2_0.java63
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaBasicMappingDefinition2_0.java63
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaEmbeddableDefinition2_0.java56
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaEntityDefinition2_0.java56
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaMappedSuperclassDefinition2_0.java55
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaTransformationMappingDefinition2_0.java63
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaVariableOneToOneMappingDefinition2_0.java63
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaVersionMappingDefinition2_0.java62
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/Generic2_0JavaContextModelTests.java6
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaBasicMapping2_0Tests.java417
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaElementCollectionMapping2_0Tests.java103
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaEmbeddedIdMapping2_0Tests.java368
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaEmbeddedMapping2_0Tests.java71
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaIdMapping2_0Tests.java423
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaManyToManyMapping2_0Tests.java287
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaManyToOneMapping2_0Tests.java277
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaOneToManyMapping2_0Tests.java259
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaOneToOneMapping2_0Tests.java275
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaVersionMapping2_0Tests.java352
42 files changed, 4078 insertions, 81 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaTypeMappingDefinitionWrapper.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaTypeMappingDefinitionWrapper.java
new file mode 100644
index 0000000000..9d40e1ede0
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaTypeMappingDefinitionWrapper.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.context.java;
+
+import org.eclipse.jpt.common.core.resource.java.Annotation;
+import org.eclipse.jpt.jpa.core.JpaFactory;
+import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.java.JavaTypeMapping;
+import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
+
+/**
+ * Simplify delegation to another definition.
+ * A subclass need only implement {@link #getDelegate()} and override the
+ * appropriate method(s).
+ */
+public abstract class JavaTypeMappingDefinitionWrapper
+ implements JavaTypeMappingDefinition
+{
+ protected JavaTypeMappingDefinitionWrapper() {
+ super();
+ }
+
+ protected abstract JavaTypeMappingDefinition getDelegate();
+
+ public String getKey() {
+ return this.getDelegate().getKey();
+ }
+
+ public String getAnnotationName() {
+ return this.getDelegate().getAnnotationName();
+ }
+
+ public Iterable<String> getSupportingAnnotationNames() {
+ return this.getDelegate().getSupportingAnnotationNames();
+ }
+
+ public JavaTypeMapping buildMapping(JavaPersistentType persistentType, Annotation annotation, JpaFactory factory) {
+ return this.getDelegate().buildMapping(persistentType, annotation, factory);
+ }
+
+ @Override
+ public String toString() {
+ return this.getClass().getSimpleName();
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/Generic2_0JpaPlatformProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/Generic2_0JpaPlatformProvider.java
index 42ae0fa973..6e3847bb5a 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/Generic2_0JpaPlatformProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/Generic2_0JpaPlatformProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2011 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.
@@ -26,22 +26,22 @@ import org.eclipse.jpt.jpa.core.internal.JarResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.JavaResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.OrmResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.PersistenceResourceModelProvider;
-import org.eclipse.jpt.jpa.core.internal.context.java.JavaBasicMappingDefinition;
-import org.eclipse.jpt.jpa.core.internal.context.java.JavaEmbeddableDefinition;
-import org.eclipse.jpt.jpa.core.internal.context.java.JavaEmbeddedIdMappingDefinition;
-import org.eclipse.jpt.jpa.core.internal.context.java.JavaEntityDefinition;
-import org.eclipse.jpt.jpa.core.internal.context.java.JavaMappedSuperclassDefinition;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaTransientMappingDefinition;
-import org.eclipse.jpt.jpa.core.internal.context.java.JavaVersionMappingDefinition;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmXmlDefinition;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericPersistenceXmlDefinition;
+import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.JavaBasicMappingDefinition2_0;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.JavaElementCollectionMappingDefinition2_0;
+import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.JavaEmbeddableDefinition2_0;
+import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.JavaEmbeddedIdMappingDefinition2_0;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.JavaEmbeddedMappingDefinition2_0;
+import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.JavaEntityDefinition2_0;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.JavaIdMappingDefinition2_0;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.JavaManyToManyMappingDefinition2_0;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.JavaManyToOneMappingDefinition2_0;
+import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.JavaMappedSuperclassDefinition2_0;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.JavaOneToManyMappingDefinition2_0;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.JavaOneToOneMappingDefinition2_0;
+import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.JavaVersionMappingDefinition2_0;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.orm.GenericOrmXml2_0Definition;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.persistence.Generic2_0PersistenceXmlDefinition;
@@ -114,9 +114,9 @@ public class Generic2_0JpaPlatformProvider
// order matches that used by the Reference Implementation (EclipseLink)
protected static final JavaTypeMappingDefinition[] JAVA_TYPE_MAPPING_DEFINITIONS = new JavaTypeMappingDefinition[] {
- JavaEntityDefinition.instance(),
- JavaEmbeddableDefinition.instance(),
- JavaMappedSuperclassDefinition.instance()
+ JavaEntityDefinition2_0.instance(),
+ JavaEmbeddableDefinition2_0.instance(),
+ JavaMappedSuperclassDefinition2_0.instance()
};
@@ -130,7 +130,7 @@ public class Generic2_0JpaPlatformProvider
// order matches that used by the Reference Implementation (EclipseLink)
protected static final DefaultJavaAttributeMappingDefinition[] DEFAULT_JAVA_ATTRIBUTE_MAPPING_DEFINITIONS = new DefaultJavaAttributeMappingDefinition[] {
JavaEmbeddedMappingDefinition2_0.instance(),
- JavaBasicMappingDefinition.instance()
+ JavaBasicMappingDefinition2_0.instance()
};
@Override
@@ -143,10 +143,10 @@ public class Generic2_0JpaPlatformProvider
JavaTransientMappingDefinition.instance(),
JavaElementCollectionMappingDefinition2_0.instance(),
JavaIdMappingDefinition2_0.instance(),
- JavaVersionMappingDefinition.instance(),
- JavaBasicMappingDefinition.instance(),
+ JavaVersionMappingDefinition2_0.instance(),
+ JavaBasicMappingDefinition2_0.instance(),
JavaEmbeddedMappingDefinition2_0.instance(),
- JavaEmbeddedIdMappingDefinition.instance(),
+ JavaEmbeddedIdMappingDefinition2_0.instance(),
JavaManyToManyMappingDefinition2_0.instance(),
JavaManyToOneMappingDefinition2_0.instance(),
JavaOneToManyMappingDefinition2_0.instance(),
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaBasicMappingDefinition2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaBasicMappingDefinition2_0.java
new file mode 100644
index 0000000000..a28fcecd2a
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaBasicMappingDefinition2_0.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.jpa2.context.java;
+
+import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
+import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
+import org.eclipse.jpt.jpa.core.context.java.DefaultJavaAttributeMappingDefinition;
+import org.eclipse.jpt.jpa.core.internal.context.java.DefaultJavaAttributeMappingDefinitionWrapper;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaBasicMappingDefinition;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.Access2_0Annotation;
+
+public class JavaBasicMappingDefinition2_0
+ extends DefaultJavaAttributeMappingDefinitionWrapper
+{
+ private static final DefaultJavaAttributeMappingDefinition DELEGATE = JavaBasicMappingDefinition.instance();
+
+ // singleton
+ private static final DefaultJavaAttributeMappingDefinition INSTANCE = new JavaBasicMappingDefinition2_0();
+
+ /**
+ * Return the singleton.
+ */
+ public static DefaultJavaAttributeMappingDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Enforce singleton usage
+ */
+ private JavaBasicMappingDefinition2_0() {
+ super();
+ }
+
+ @Override
+ protected DefaultJavaAttributeMappingDefinition getDelegate() {
+ return DELEGATE;
+ }
+
+ @Override
+ public Iterable<String> getSupportingAnnotationNames() {
+ return COMBINED_SUPPORTING_ANNOTATION_NAMES;
+ }
+
+ public static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY_2_0 = new String[] {
+ Access2_0Annotation.ANNOTATION_NAME
+ };
+ private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES_2_0 = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY_2_0);
+
+ @SuppressWarnings("unchecked")
+ private static final Iterable<String> COMBINED_SUPPORTING_ANNOTATION_NAMES = new CompositeIterable<String>(
+ DELEGATE.getSupportingAnnotationNames(),
+ SUPPORTING_ANNOTATION_NAMES_2_0
+ );
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaElementCollectionMappingDefinition2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaElementCollectionMappingDefinition2_0.java
index 44e10d41b3..6ce75a03cb 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaElementCollectionMappingDefinition2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaElementCollectionMappingDefinition2_0.java
@@ -16,6 +16,7 @@ import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.jpa.core.jpa2.JpaFactory2_0;
import org.eclipse.jpt.jpa.core.jpa2.MappingKeys2_0;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.Access2_0Annotation;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.CollectionTable2_0Annotation;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.ElementCollection2_0Annotation;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.JPA2_0;
@@ -73,6 +74,7 @@ public class JavaElementCollectionMappingDefinition2_0
}
private static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY = new String[] {
+ Access2_0Annotation.ANNOTATION_NAME,
AssociationOverrideAnnotation.ANNOTATION_NAME,
JPA.ASSOCIATION_OVERRIDES,
AttributeOverrideAnnotation.ANNOTATION_NAME,
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaEmbeddableDefinition2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaEmbeddableDefinition2_0.java
new file mode 100644
index 0000000000..4b0f18df5c
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaEmbeddableDefinition2_0.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.jpa2.context.java;
+
+import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
+import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
+import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaEmbeddableDefinition;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaTypeMappingDefinitionWrapper;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.Access2_0Annotation;
+
+public class JavaEmbeddableDefinition2_0
+ extends JavaTypeMappingDefinitionWrapper
+{
+ private static final JavaTypeMappingDefinition DELEGATE = JavaEmbeddableDefinition.instance();
+
+ // singleton
+ private static final JavaTypeMappingDefinition INSTANCE = new JavaEmbeddableDefinition2_0();
+
+ /**
+ * Return the singleton.
+ */
+ public static JavaTypeMappingDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Enforce singleton usage
+ */
+ private JavaEmbeddableDefinition2_0() {
+ super();
+ }
+
+ @Override
+ protected JavaTypeMappingDefinition getDelegate() {
+ return DELEGATE;
+ }
+
+ @Override
+ public Iterable<String> getSupportingAnnotationNames() {
+ return COMBINED_SUPPORTING_ANNOTATION_NAMES;
+ }
+
+ public static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY_2_0 = new String[] {
+ Access2_0Annotation.ANNOTATION_NAME
+ };
+ private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES_2_0 = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY_2_0);
+
+ @SuppressWarnings("unchecked")
+ private static final Iterable<String> COMBINED_SUPPORTING_ANNOTATION_NAMES = new CompositeIterable<String>(
+ DELEGATE.getSupportingAnnotationNames(),
+ SUPPORTING_ANNOTATION_NAMES_2_0
+ );
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaEmbeddedIdMappingDefinition2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaEmbeddedIdMappingDefinition2_0.java
new file mode 100644
index 0000000000..214ca6a5e7
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaEmbeddedIdMappingDefinition2_0.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.jpa2.context.java;
+
+import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
+import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
+import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaAttributeMappingDefinitionWrapper;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaEmbeddedIdMappingDefinition;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.Access2_0Annotation;
+
+public class JavaEmbeddedIdMappingDefinition2_0
+ extends JavaAttributeMappingDefinitionWrapper
+{
+ private static final JavaAttributeMappingDefinition DELEGATE = JavaEmbeddedIdMappingDefinition.instance();
+
+ // singleton
+ private static final JavaAttributeMappingDefinition INSTANCE = new JavaEmbeddedIdMappingDefinition2_0();
+
+ /**
+ * Return the singleton.
+ */
+ public static JavaAttributeMappingDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Enforce singleton usage
+ */
+ private JavaEmbeddedIdMappingDefinition2_0() {
+ super();
+ }
+
+ @Override
+ protected JavaAttributeMappingDefinition getDelegate() {
+ return DELEGATE;
+ }
+
+ @Override
+ public Iterable<String> getSupportingAnnotationNames() {
+ return COMBINED_SUPPORTING_ANNOTATION_NAMES;
+ }
+
+ public static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY_2_0 = new String[] {
+ Access2_0Annotation.ANNOTATION_NAME
+ };
+ private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES_2_0 = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY_2_0);
+
+ @SuppressWarnings("unchecked")
+ private static final Iterable<String> COMBINED_SUPPORTING_ANNOTATION_NAMES = new CompositeIterable<String>(
+ DELEGATE.getSupportingAnnotationNames(),
+ SUPPORTING_ANNOTATION_NAMES_2_0
+ );
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaEmbeddedMappingDefinition2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaEmbeddedMappingDefinition2_0.java
index 16e8e5e6e7..13b275d511 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaEmbeddedMappingDefinition2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaEmbeddedMappingDefinition2_0.java
@@ -14,6 +14,7 @@ import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
import org.eclipse.jpt.jpa.core.context.java.DefaultJavaAttributeMappingDefinition;
import org.eclipse.jpt.jpa.core.internal.context.java.DefaultJavaAttributeMappingDefinitionWrapper;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaEmbeddedMappingDefinition;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.Access2_0Annotation;
import org.eclipse.jpt.jpa.core.resource.java.AssociationOverrideAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.JPA;
@@ -51,6 +52,7 @@ public class JavaEmbeddedMappingDefinition2_0
}
private static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY_2_0 = new String[] {
+ Access2_0Annotation.ANNOTATION_NAME,
AssociationOverrideAnnotation.ANNOTATION_NAME,
JPA.ASSOCIATION_OVERRIDES,
};
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaEntityDefinition2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaEntityDefinition2_0.java
new file mode 100644
index 0000000000..826c03abd1
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaEntityDefinition2_0.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.jpa2.context.java;
+
+import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
+import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
+import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaEntityDefinition;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaTypeMappingDefinitionWrapper;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.Access2_0Annotation;
+
+public class JavaEntityDefinition2_0
+ extends JavaTypeMappingDefinitionWrapper
+{
+ private static final JavaTypeMappingDefinition DELEGATE = JavaEntityDefinition.instance();
+
+ // singleton
+ private static final JavaTypeMappingDefinition INSTANCE = new JavaEntityDefinition2_0();
+
+ /**
+ * Return the singleton.
+ */
+ public static JavaTypeMappingDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Enforce singleton usage
+ */
+ private JavaEntityDefinition2_0() {
+ super();
+ }
+
+ @Override
+ protected JavaTypeMappingDefinition getDelegate() {
+ return DELEGATE;
+ }
+
+ @Override
+ public Iterable<String> getSupportingAnnotationNames() {
+ return COMBINED_SUPPORTING_ANNOTATION_NAMES;
+ }
+
+ public static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY_2_0 = new String[] {
+ Access2_0Annotation.ANNOTATION_NAME
+ };
+ private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES_2_0 = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY_2_0);
+
+ @SuppressWarnings("unchecked")
+ private static final Iterable<String> COMBINED_SUPPORTING_ANNOTATION_NAMES = new CompositeIterable<String>(
+ DELEGATE.getSupportingAnnotationNames(),
+ SUPPORTING_ANNOTATION_NAMES_2_0
+ );
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaIdMappingDefinition2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaIdMappingDefinition2_0.java
index 1708bb6a9f..9ec4396688 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaIdMappingDefinition2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaIdMappingDefinition2_0.java
@@ -9,10 +9,13 @@
******************************************************************************/
package org.eclipse.jpt.jpa.core.internal.jpa2.context.java;
+import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
+import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaAttributeMappingDefinitionWrapper;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaIdMappingDefinition;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.Access2_0Annotation;
/**
* JPA 2.0 Id mapping
@@ -77,4 +80,21 @@ public class JavaIdMappingDefinition2_0
private boolean attributeHasOneToOneMapping(JavaPersistentAttribute persistentAttribute) {
return JavaOneToOneMappingDefinition2_0.instance().isSpecified(persistentAttribute);
}
+
+ @Override
+ public Iterable<String> getSupportingAnnotationNames() {
+ return COMBINED_SUPPORTING_ANNOTATION_NAMES;
+ }
+
+ public static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY_2_0 = new String[] {
+ Access2_0Annotation.ANNOTATION_NAME,
+ };
+ private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES_2_0 = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY_2_0);
+
+ @SuppressWarnings("unchecked")
+ private static final Iterable<String> COMBINED_SUPPORTING_ANNOTATION_NAMES = new CompositeIterable<String>(
+ DELEGATE.getSupportingAnnotationNames(),
+ SUPPORTING_ANNOTATION_NAMES_2_0
+ );
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaManyToManyMappingDefinition2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaManyToManyMappingDefinition2_0.java
index c122b0950d..6349cfa244 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaManyToManyMappingDefinition2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaManyToManyMappingDefinition2_0.java
@@ -14,6 +14,7 @@ import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaAttributeMappingDefinitionWrapper;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaManyToManyMappingDefinition;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.Access2_0Annotation;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.JPA2_0;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapKeyClass2_0Annotation;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapKeyColumn2_0Annotation;
@@ -58,6 +59,7 @@ public class JavaManyToManyMappingDefinition2_0
}
public static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY_2_0 = new String[] {
+ Access2_0Annotation.ANNOTATION_NAME,
AttributeOverrideAnnotation.ANNOTATION_NAME,
JPA.ATTRIBUTE_OVERRIDES,
MapKeyClass2_0Annotation.ANNOTATION_NAME,
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaManyToOneMappingDefinition2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaManyToOneMappingDefinition2_0.java
index 01a6e892e3..18541ac7c8 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaManyToOneMappingDefinition2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaManyToOneMappingDefinition2_0.java
@@ -14,6 +14,7 @@ import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaAttributeMappingDefinitionWrapper;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaManyToOneMappingDefinition;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.Access2_0Annotation;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapsId2_0Annotation;
import org.eclipse.jpt.jpa.core.resource.java.IdAnnotation;
@@ -51,6 +52,7 @@ public class JavaManyToOneMappingDefinition2_0
}
public static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY_2_0 = new String[] {
+ Access2_0Annotation.ANNOTATION_NAME,
IdAnnotation.ANNOTATION_NAME,
MapsId2_0Annotation.ANNOTATION_NAME
};
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaMappedSuperclassDefinition2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaMappedSuperclassDefinition2_0.java
new file mode 100644
index 0000000000..550c76293e
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaMappedSuperclassDefinition2_0.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.jpa2.context.java;
+
+import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
+import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
+import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaMappedSuperclassDefinition;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaTypeMappingDefinitionWrapper;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.Access2_0Annotation;
+
+public class JavaMappedSuperclassDefinition2_0
+ extends JavaTypeMappingDefinitionWrapper
+{
+ private static final JavaTypeMappingDefinition DELEGATE = JavaMappedSuperclassDefinition.instance();
+
+ // singleton
+ private static final JavaTypeMappingDefinition INSTANCE = new JavaMappedSuperclassDefinition2_0();
+
+ /**
+ * Return the singleton.
+ */
+ public static JavaTypeMappingDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Enforce singleton usage
+ */
+ private JavaMappedSuperclassDefinition2_0() {
+ super();
+ }
+
+ @Override
+ protected JavaTypeMappingDefinition getDelegate() {
+ return DELEGATE;
+ }
+
+ @Override
+ public Iterable<String> getSupportingAnnotationNames() {
+ return COMBINED_SUPPORTING_ANNOTATION_NAMES;
+ }
+
+ public static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY_2_0 = new String[] {
+ Access2_0Annotation.ANNOTATION_NAME
+ };
+ private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES_2_0 = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY_2_0);
+
+ @SuppressWarnings("unchecked")
+ private static final Iterable<String> COMBINED_SUPPORTING_ANNOTATION_NAMES = new CompositeIterable<String>(
+ DELEGATE.getSupportingAnnotationNames(),
+ SUPPORTING_ANNOTATION_NAMES_2_0
+ );
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaOneToManyMappingDefinition2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaOneToManyMappingDefinition2_0.java
index f933e6cce9..b7e729f7b7 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaOneToManyMappingDefinition2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaOneToManyMappingDefinition2_0.java
@@ -14,6 +14,7 @@ import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaAttributeMappingDefinitionWrapper;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaOneToManyMappingDefinition;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.Access2_0Annotation;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.JPA2_0;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapKeyClass2_0Annotation;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapKeyColumn2_0Annotation;
@@ -58,6 +59,7 @@ public class JavaOneToManyMappingDefinition2_0
}
private static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY_2_0 = new String[] {
+ Access2_0Annotation.ANNOTATION_NAME,
AttributeOverrideAnnotation.ANNOTATION_NAME,
JPA.ATTRIBUTE_OVERRIDES,
MapKeyClass2_0Annotation.ANNOTATION_NAME,
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaOneToOneMappingDefinition2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaOneToOneMappingDefinition2_0.java
index d20817934f..6db96e73bb 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaOneToOneMappingDefinition2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaOneToOneMappingDefinition2_0.java
@@ -14,6 +14,7 @@ import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaAttributeMappingDefinitionWrapper;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaOneToOneMappingDefinition;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.Access2_0Annotation;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapsId2_0Annotation;
import org.eclipse.jpt.jpa.core.resource.java.IdAnnotation;
@@ -51,6 +52,7 @@ public class JavaOneToOneMappingDefinition2_0
}
public static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY_2_0 = new String[] {
+ Access2_0Annotation.ANNOTATION_NAME,
IdAnnotation.ANNOTATION_NAME,
MapsId2_0Annotation.ANNOTATION_NAME
};
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaVersionMappingDefinition2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaVersionMappingDefinition2_0.java
new file mode 100644
index 0000000000..6a87ebd825
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/JavaVersionMappingDefinition2_0.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.jpa2.context.java;
+
+import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
+import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
+import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaAttributeMappingDefinitionWrapper;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaVersionMappingDefinition;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.Access2_0Annotation;
+
+public class JavaVersionMappingDefinition2_0
+ extends JavaAttributeMappingDefinitionWrapper
+{
+ private static final JavaAttributeMappingDefinition DELEGATE = JavaVersionMappingDefinition.instance();
+
+ // singleton
+ private static final JavaAttributeMappingDefinition INSTANCE = new JavaVersionMappingDefinition2_0();
+
+ /**
+ * Return the singleton.
+ */
+ public static JavaAttributeMappingDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Enforce singleton usage
+ */
+ private JavaVersionMappingDefinition2_0() {
+ super();
+ }
+
+ @Override
+ protected JavaAttributeMappingDefinition getDelegate() {
+ return DELEGATE;
+ }
+
+ @Override
+ public Iterable<String> getSupportingAnnotationNames() {
+ return COMBINED_SUPPORTING_ANNOTATION_NAMES;
+ }
+
+ public static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY_2_0 = new String[] {
+ Access2_0Annotation.ANNOTATION_NAME
+ };
+ private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES_2_0 = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY_2_0);
+
+ @SuppressWarnings("unchecked")
+ private static final Iterable<String> COMBINED_SUPPORTING_ANNOTATION_NAMES = new CompositeIterable<String>(
+ DELEGATE.getSupportingAnnotationNames(),
+ SUPPORTING_ANNOTATION_NAMES_2_0
+ );
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLinkJpaPlatformProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLinkJpaPlatformProvider.java
index a236601331..641e5b14a1 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLinkJpaPlatformProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLinkJpaPlatformProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2011 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.
@@ -26,20 +26,20 @@ import org.eclipse.jpt.jpa.core.internal.JarResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.JavaResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.OrmResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.PersistenceResourceModelProvider;
-import org.eclipse.jpt.jpa.core.internal.context.java.JavaEmbeddableDefinition;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaEmbeddedIdMappingDefinition;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaEmbeddedMappingDefinition;
-import org.eclipse.jpt.jpa.core.internal.context.java.JavaEntityDefinition;
-import org.eclipse.jpt.jpa.core.internal.context.java.JavaMappedSuperclassDefinition;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaTransientMappingDefinition;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmXmlDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.JptJpaEclipseLinkCorePlugin;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaBasicCollectionMappingDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaBasicMapMappingDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaBasicMappingDefinition;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaEmbeddableDefinition;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaEntityDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaIdMappingDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaManyToManyMappingDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaManyToOneMappingDefinition;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaMappedSuperclassDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaOneToManyMappingDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaOneToOneMappingDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaTransformationMappingDefinition;
@@ -122,9 +122,9 @@ public class EclipseLinkJpaPlatformProvider
// order matches that used by EclipseLink
// NB: no EclipseLink-specific mappings
protected static final JavaTypeMappingDefinition[] JAVA_TYPE_MAPPING_DEFINITIONS = new JavaTypeMappingDefinition[] {
- JavaEntityDefinition.instance(),
- JavaEmbeddableDefinition.instance(),
- JavaMappedSuperclassDefinition.instance()
+ EclipseLinkJavaEntityDefinition.instance(),
+ EclipseLinkJavaEmbeddableDefinition.instance(),
+ EclipseLinkJavaMappedSuperclassDefinition.instance()
};
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaEmbeddableDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaEmbeddableDefinition.java
new file mode 100644
index 0000000000..f84d80d3e0
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaEmbeddableDefinition.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.eclipselink.core.internal.context.java;
+
+import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
+import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
+import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaEmbeddableDefinition;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaTypeMappingDefinitionWrapper;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkChangeTrackingAnnotation;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkConverterAnnotation;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkCustomizerAnnotation;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkObjectTypeConverterAnnotation;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkStructConverterAnnotation;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkTypeConverterAnnotation;
+
+public class EclipseLinkJavaEmbeddableDefinition
+ extends JavaTypeMappingDefinitionWrapper
+{
+ private static final JavaTypeMappingDefinition DELEGATE = JavaEmbeddableDefinition.instance();
+
+ // singleton
+ private static final JavaTypeMappingDefinition INSTANCE = new EclipseLinkJavaEmbeddableDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static JavaTypeMappingDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Enforce singleton usage
+ */
+ private EclipseLinkJavaEmbeddableDefinition() {
+ super();
+ }
+
+ @Override
+ protected JavaTypeMappingDefinition getDelegate() {
+ return DELEGATE;
+ }
+
+ @Override
+ public Iterable<String> getSupportingAnnotationNames() {
+ return COMBINED_SUPPORTING_ANNOTATION_NAMES;
+ }
+
+ private static final String[] ECLIPSE_LINK_SUPPORTING_ANNOTATION_NAMES_ARRAY = new String[] {
+ EclipseLinkChangeTrackingAnnotation.ANNOTATION_NAME,
+ EclipseLinkConverterAnnotation.ANNOTATION_NAME,
+ EclipseLinkCustomizerAnnotation.ANNOTATION_NAME,
+ EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME,
+ EclipseLinkStructConverterAnnotation.ANNOTATION_NAME,
+ EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME,
+ };
+ public static final Iterable<String> ECLIPSE_LINK_SUPPORTING_ANNOTATION_NAMES = new ArrayIterable<String>(ECLIPSE_LINK_SUPPORTING_ANNOTATION_NAMES_ARRAY);
+
+ @SuppressWarnings("unchecked")
+ private static final Iterable<String> COMBINED_SUPPORTING_ANNOTATION_NAMES = new CompositeIterable<String>(
+ DELEGATE.getSupportingAnnotationNames(),
+ ECLIPSE_LINK_SUPPORTING_ANNOTATION_NAMES
+ );
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaEntityDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaEntityDefinition.java
new file mode 100644
index 0000000000..7477386ae0
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaEntityDefinition.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.eclipselink.core.internal.context.java;
+
+import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
+import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
+import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaEntityDefinition;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaTypeMappingDefinitionWrapper;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkCacheAnnotation;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkChangeTrackingAnnotation;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkConverterAnnotation;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkCustomizerAnnotation;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkExistenceCheckingAnnotation;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkObjectTypeConverterAnnotation;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkReadOnlyAnnotation;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkStructConverterAnnotation;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkTypeConverterAnnotation;
+
+public class EclipseLinkJavaEntityDefinition
+ extends JavaTypeMappingDefinitionWrapper
+{
+ private static final JavaTypeMappingDefinition DELEGATE = JavaEntityDefinition.instance();
+
+ // singleton
+ private static final JavaTypeMappingDefinition INSTANCE = new EclipseLinkJavaEntityDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static JavaTypeMappingDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Enforce singleton usage
+ */
+ private EclipseLinkJavaEntityDefinition() {
+ super();
+ }
+
+ @Override
+ protected JavaTypeMappingDefinition getDelegate() {
+ return DELEGATE;
+ }
+
+ @Override
+ public Iterable<String> getSupportingAnnotationNames() {
+ return COMBINED_SUPPORTING_ANNOTATION_NAMES;
+ }
+
+ private static final String[] ECLIPSE_LINK_SUPPORTING_ANNOTATION_NAMES_ARRAY = new String[] {
+ EclipseLinkCacheAnnotation.ANNOTATION_NAME,
+ EclipseLinkChangeTrackingAnnotation.ANNOTATION_NAME,
+ EclipseLinkConverterAnnotation.ANNOTATION_NAME,
+ EclipseLinkCustomizerAnnotation.ANNOTATION_NAME,
+ EclipseLinkExistenceCheckingAnnotation.ANNOTATION_NAME,
+ EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME,
+ EclipseLinkReadOnlyAnnotation.ANNOTATION_NAME,
+ EclipseLinkStructConverterAnnotation.ANNOTATION_NAME,
+ EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME,
+ };
+ // 'public' because EclipseLink MappedSuperclass also supports these annotations
+ public static final Iterable<String> ECLIPSE_LINK_SUPPORTING_ANNOTATION_NAMES = new ArrayIterable<String>(ECLIPSE_LINK_SUPPORTING_ANNOTATION_NAMES_ARRAY);
+
+ @SuppressWarnings("unchecked")
+ private static final Iterable<String> COMBINED_SUPPORTING_ANNOTATION_NAMES = new CompositeIterable<String>(
+ DELEGATE.getSupportingAnnotationNames(),
+ ECLIPSE_LINK_SUPPORTING_ANNOTATION_NAMES
+ );
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaMappedSuperclassDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaMappedSuperclassDefinition.java
new file mode 100644
index 0000000000..2bcb1ca038
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaMappedSuperclassDefinition.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.eclipselink.core.internal.context.java;
+
+import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
+import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaMappedSuperclassDefinition;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaTypeMappingDefinitionWrapper;
+
+public class EclipseLinkJavaMappedSuperclassDefinition
+ extends JavaTypeMappingDefinitionWrapper
+{
+ private static final JavaTypeMappingDefinition DELEGATE = JavaMappedSuperclassDefinition.instance();
+
+ // singleton
+ private static final JavaTypeMappingDefinition INSTANCE = new EclipseLinkJavaMappedSuperclassDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static JavaTypeMappingDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Enforce singleton usage
+ */
+ private EclipseLinkJavaMappedSuperclassDefinition() {
+ super();
+ }
+
+ @Override
+ protected JavaTypeMappingDefinition getDelegate() {
+ return DELEGATE;
+ }
+
+ @Override
+ public Iterable<String> getSupportingAnnotationNames() {
+ return COMBINED_SUPPORTING_ANNOTATION_NAMES;
+ }
+ @SuppressWarnings("unchecked")
+ private static final Iterable<String> COMBINED_SUPPORTING_ANNOTATION_NAMES = new CompositeIterable<String>(
+ DELEGATE.getSupportingAnnotationNames(),
+ EclipseLinkJavaEntityDefinition.ECLIPSE_LINK_SUPPORTING_ANNOTATION_NAMES
+ );
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v1_1/EclipseLink1_1JpaPlatformProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v1_1/EclipseLink1_1JpaPlatformProvider.java
index 1e0c97b840..88ecb34718 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v1_1/EclipseLink1_1JpaPlatformProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v1_1/EclipseLink1_1JpaPlatformProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2011 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.
@@ -26,11 +26,8 @@ import org.eclipse.jpt.jpa.core.internal.JarResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.JavaResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.OrmResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.PersistenceResourceModelProvider;
-import org.eclipse.jpt.jpa.core.internal.context.java.JavaEmbeddableDefinition;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaEmbeddedIdMappingDefinition;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaEmbeddedMappingDefinition;
-import org.eclipse.jpt.jpa.core.internal.context.java.JavaEntityDefinition;
-import org.eclipse.jpt.jpa.core.internal.context.java.JavaMappedSuperclassDefinition;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaTransientMappingDefinition;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmXmlDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.JptJpaEclipseLinkCorePlugin;
@@ -38,9 +35,12 @@ import org.eclipse.jpt.jpa.eclipselink.core.internal.EclipseLinkOrmResourceModel
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaBasicCollectionMappingDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaBasicMapMappingDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaBasicMappingDefinition;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaEmbeddableDefinition;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaEntityDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaIdMappingDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaManyToManyMappingDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaManyToOneMappingDefinition;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaMappedSuperclassDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaOneToManyMappingDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaOneToOneMappingDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaTransformationMappingDefinition;
@@ -124,9 +124,9 @@ public class EclipseLink1_1JpaPlatformProvider
// order matches that used by EclipseLink
// NB: no EclipseLink-specific mappings
protected static final JavaTypeMappingDefinition[] JAVA_TYPE_MAPPING_DEFINITIONS = new JavaTypeMappingDefinition[] {
- JavaEntityDefinition.instance(),
- JavaEmbeddableDefinition.instance(),
- JavaMappedSuperclassDefinition.instance()
+ EclipseLinkJavaEntityDefinition.instance(),
+ EclipseLinkJavaEmbeddableDefinition.instance(),
+ EclipseLinkJavaMappedSuperclassDefinition.instance()
};
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v1_2/EclipseLink1_2JpaPlatformProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v1_2/EclipseLink1_2JpaPlatformProvider.java
index 92c5957e09..74abe1d5a1 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v1_2/EclipseLink1_2JpaPlatformProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v1_2/EclipseLink1_2JpaPlatformProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2011 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.
@@ -27,11 +27,8 @@ import org.eclipse.jpt.jpa.core.internal.JavaResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.OrmResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.PersistenceResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaBasicMappingDefinition;
-import org.eclipse.jpt.jpa.core.internal.context.java.JavaEmbeddableDefinition;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaEmbeddedIdMappingDefinition;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaEmbeddedMappingDefinition;
-import org.eclipse.jpt.jpa.core.internal.context.java.JavaEntityDefinition;
-import org.eclipse.jpt.jpa.core.internal.context.java.JavaMappedSuperclassDefinition;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaTransientMappingDefinition;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmXmlDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.JptJpaEclipseLinkCorePlugin;
@@ -39,9 +36,12 @@ import org.eclipse.jpt.jpa.eclipselink.core.internal.EclipseLinkOrmResourceModel
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaBasicCollectionMappingDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaBasicMapMappingDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaBasicMappingDefinition;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaEmbeddableDefinition;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaEntityDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaIdMappingDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaManyToManyMappingDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaManyToOneMappingDefinition;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaMappedSuperclassDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaOneToManyMappingDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaOneToOneMappingDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaTransformationMappingDefinition;
@@ -126,9 +126,9 @@ public class EclipseLink1_2JpaPlatformProvider
// order matches that used by EclipseLink
// NB: no EclipseLink-specific mappings
protected static final JavaTypeMappingDefinition[] JAVA_TYPE_MAPPING_DEFINITIONS = new JavaTypeMappingDefinition[] {
- JavaEntityDefinition.instance(),
- JavaEmbeddableDefinition.instance(),
- JavaMappedSuperclassDefinition.instance()
+ EclipseLinkJavaEntityDefinition.instance(),
+ EclipseLinkJavaEmbeddableDefinition.instance(),
+ EclipseLinkJavaMappedSuperclassDefinition.instance()
};
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/AbstractEclipseLink2_0JpaPlatformProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/AbstractEclipseLink2_0JpaPlatformProvider.java
index 8ba5095b0d..e5695ac657 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/AbstractEclipseLink2_0JpaPlatformProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/AbstractEclipseLink2_0JpaPlatformProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2009, 2010 Oracle. All rights reserved.
+* Copyright (c) 2009, 2011 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.
@@ -25,32 +25,32 @@ import org.eclipse.jpt.jpa.core.internal.JarResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.JavaResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.OrmResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.PersistenceResourceModelProvider;
-import org.eclipse.jpt.jpa.core.internal.context.java.JavaEmbeddableDefinition;
-import org.eclipse.jpt.jpa.core.internal.context.java.JavaEmbeddedIdMappingDefinition;
-import org.eclipse.jpt.jpa.core.internal.context.java.JavaEntityDefinition;
-import org.eclipse.jpt.jpa.core.internal.context.java.JavaMappedSuperclassDefinition;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaTransientMappingDefinition;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmXmlDefinition;
+import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.JavaEmbeddedIdMappingDefinition2_0;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.JavaEmbeddedMappingDefinition2_0;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.orm.GenericOrmXml2_0Definition;
import org.eclipse.jpt.jpa.eclipselink.core.JptJpaEclipseLinkCorePlugin;
import org.eclipse.jpt.jpa.eclipselink.core.internal.EclipseLinkOrmResourceModelProvider;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaBasicCollectionMappingDefinition;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaBasicMapMappingDefinition;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaBasicMappingDefinition;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaTransformationMappingDefinition;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaVariableOneToOneMappingDefinition;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaVersionMappingDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm.EclipseLinkOrmXmlDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.persistence.EclipseLinkPersistenceXmlDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.v1_1.context.orm.EclipseLinkOrmXml1_1Definition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.v1_2.context.orm.EclipseLinkOrmXml1_2Definition;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.v2_0.context.java.EclipseLinkJavaBasicCollectionMappingDefinition2_0;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.v2_0.context.java.EclipseLinkJavaBasicMapMappingDefinition2_0;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.v2_0.context.java.EclipseLinkJavaBasicMappingDefinition2_0;
import org.eclipse.jpt.jpa.eclipselink.core.internal.v2_0.context.java.EclipseLinkJavaElementCollectionMappingDefinition2_0;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.v2_0.context.java.EclipseLinkJavaEmbeddableDefinition2_0;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.v2_0.context.java.EclipseLinkJavaEntityDefinition2_0;
import org.eclipse.jpt.jpa.eclipselink.core.internal.v2_0.context.java.EclipseLinkJavaIdMappingDefinition2_0;
import org.eclipse.jpt.jpa.eclipselink.core.internal.v2_0.context.java.EclipseLinkJavaManyToManyMappingDefinition2_0;
import org.eclipse.jpt.jpa.eclipselink.core.internal.v2_0.context.java.EclipseLinkJavaManyToOneMappingDefinition2_0;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.v2_0.context.java.EclipseLinkJavaMappedSuperclassDefinition2_0;
import org.eclipse.jpt.jpa.eclipselink.core.internal.v2_0.context.java.EclipseLinkJavaOneToManyMappingDefinition2_0;
import org.eclipse.jpt.jpa.eclipselink.core.internal.v2_0.context.java.EclipseLinkJavaOneToOneMappingDefinition2_0;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.v2_0.context.java.EclipseLinkJavaTransformationMappingDefinition2_0;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.v2_0.context.java.EclipseLinkJavaVariableOneToOneMappingDefinition2_0;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.v2_0.context.java.EclipseLinkJavaVersionMappingDefinition2_0;
import org.eclipse.jpt.jpa.eclipselink.core.internal.v2_0.context.orm.EclipseLinkOrmXml2_0Definition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.v2_0.context.persistence.EclipseLink2_0PersistenceXmlDefinition;
@@ -113,9 +113,9 @@ public abstract class AbstractEclipseLink2_0JpaPlatformProvider
// order matches that used by EclipseLink
// NB: no EclipseLink-specific mappings
protected static final JavaTypeMappingDefinition[] JAVA_TYPE_MAPPING_DEFINITIONS = new JavaTypeMappingDefinition[] {
- JavaEntityDefinition.instance(),
- JavaEmbeddableDefinition.instance(),
- JavaMappedSuperclassDefinition.instance()
+ EclipseLinkJavaEntityDefinition2_0.instance(),
+ EclipseLinkJavaEmbeddableDefinition2_0.instance(),
+ EclipseLinkJavaMappedSuperclassDefinition2_0.instance()
};
@@ -132,8 +132,8 @@ public abstract class AbstractEclipseLink2_0JpaPlatformProvider
JavaEmbeddedMappingDefinition2_0.instance(),
EclipseLinkJavaOneToManyMappingDefinition2_0.instance(),
EclipseLinkJavaOneToOneMappingDefinition2_0.instance(),
- EclipseLinkJavaVariableOneToOneMappingDefinition.instance(),
- EclipseLinkJavaBasicMappingDefinition.instance()
+ EclipseLinkJavaVariableOneToOneMappingDefinition2_0.instance(),
+ EclipseLinkJavaBasicMappingDefinition2_0.instance()
};
@Override
@@ -144,20 +144,20 @@ public abstract class AbstractEclipseLink2_0JpaPlatformProvider
// order matches that used by EclipseLink
protected static final JavaAttributeMappingDefinition[] SPECIFIED_JAVA_ATTRIBUTE_MAPPING_DEFINITIONS = new JavaAttributeMappingDefinition[] {
JavaTransientMappingDefinition.instance(),
- EclipseLinkJavaBasicCollectionMappingDefinition.instance(),
- EclipseLinkJavaBasicMapMappingDefinition.instance(),
+ EclipseLinkJavaBasicCollectionMappingDefinition2_0.instance(),
+ EclipseLinkJavaBasicMapMappingDefinition2_0.instance(),
EclipseLinkJavaElementCollectionMappingDefinition2_0.instance(),
EclipseLinkJavaIdMappingDefinition2_0.instance(),
- EclipseLinkJavaVersionMappingDefinition.instance(),
- EclipseLinkJavaBasicMappingDefinition.instance(),
+ EclipseLinkJavaVersionMappingDefinition2_0.instance(),
+ EclipseLinkJavaBasicMappingDefinition2_0.instance(),
JavaEmbeddedMappingDefinition2_0.instance(),
- JavaEmbeddedIdMappingDefinition.instance(),
- EclipseLinkJavaTransformationMappingDefinition.instance(),
+ JavaEmbeddedIdMappingDefinition2_0.instance(),
+ EclipseLinkJavaTransformationMappingDefinition2_0.instance(),
EclipseLinkJavaManyToManyMappingDefinition2_0.instance(),
EclipseLinkJavaManyToOneMappingDefinition2_0.instance(),
EclipseLinkJavaOneToManyMappingDefinition2_0.instance(),
EclipseLinkJavaOneToOneMappingDefinition2_0.instance(),
- EclipseLinkJavaVariableOneToOneMappingDefinition.instance()
+ EclipseLinkJavaVariableOneToOneMappingDefinition2_0.instance()
};
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaBasicCollectionMappingDefinition2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaBasicCollectionMappingDefinition2_0.java
new file mode 100644
index 0000000000..0e1dbbbd2d
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaBasicCollectionMappingDefinition2_0.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.eclipselink.core.internal.v2_0.context.java;
+
+import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
+import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
+import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaAttributeMappingDefinitionWrapper;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.Access2_0Annotation;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaBasicCollectionMappingDefinition;
+
+public class EclipseLinkJavaBasicCollectionMappingDefinition2_0
+ extends JavaAttributeMappingDefinitionWrapper
+{
+ private static final JavaAttributeMappingDefinition DELEGATE = EclipseLinkJavaBasicCollectionMappingDefinition.instance();
+
+ // singleton
+ private static final JavaAttributeMappingDefinition INSTANCE = new EclipseLinkJavaBasicCollectionMappingDefinition2_0();
+
+ /**
+ * Return the singleton.
+ */
+ public static JavaAttributeMappingDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Enforce singleton usage
+ */
+ private EclipseLinkJavaBasicCollectionMappingDefinition2_0() {
+ super();
+ }
+
+ @Override
+ protected JavaAttributeMappingDefinition getDelegate() {
+ return DELEGATE;
+ }
+
+ @Override
+ public Iterable<String> getSupportingAnnotationNames() {
+ return COMBINED_SUPPORTING_ANNOTATION_NAMES;
+ }
+
+ public static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY_2_0 = new String[] {
+ Access2_0Annotation.ANNOTATION_NAME,
+ };
+ private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES_2_0 = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY_2_0);
+
+ @SuppressWarnings("unchecked")
+ private static final Iterable<String> COMBINED_SUPPORTING_ANNOTATION_NAMES = new CompositeIterable<String>(
+ DELEGATE.getSupportingAnnotationNames(),
+ SUPPORTING_ANNOTATION_NAMES_2_0
+ );
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaBasicMapMappingDefinition2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaBasicMapMappingDefinition2_0.java
new file mode 100644
index 0000000000..c7c692fc8e
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaBasicMapMappingDefinition2_0.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.eclipselink.core.internal.v2_0.context.java;
+
+import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
+import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
+import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaAttributeMappingDefinitionWrapper;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.Access2_0Annotation;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaBasicMapMappingDefinition;
+
+public class EclipseLinkJavaBasicMapMappingDefinition2_0
+ extends JavaAttributeMappingDefinitionWrapper
+{
+ private static final JavaAttributeMappingDefinition DELEGATE = EclipseLinkJavaBasicMapMappingDefinition.instance();
+
+ // singleton
+ private static final JavaAttributeMappingDefinition INSTANCE = new EclipseLinkJavaBasicMapMappingDefinition2_0();
+
+ /**
+ * Return the singleton.
+ */
+ public static JavaAttributeMappingDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Enforce singleton usage
+ */
+ private EclipseLinkJavaBasicMapMappingDefinition2_0() {
+ super();
+ }
+
+ @Override
+ protected JavaAttributeMappingDefinition getDelegate() {
+ return DELEGATE;
+ }
+
+ @Override
+ public Iterable<String> getSupportingAnnotationNames() {
+ return COMBINED_SUPPORTING_ANNOTATION_NAMES;
+ }
+
+ public static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY_2_0 = new String[] {
+ Access2_0Annotation.ANNOTATION_NAME,
+ };
+ private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES_2_0 = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY_2_0);
+
+ @SuppressWarnings("unchecked")
+ private static final Iterable<String> COMBINED_SUPPORTING_ANNOTATION_NAMES = new CompositeIterable<String>(
+ DELEGATE.getSupportingAnnotationNames(),
+ SUPPORTING_ANNOTATION_NAMES_2_0
+ );
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaBasicMappingDefinition2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaBasicMappingDefinition2_0.java
new file mode 100644
index 0000000000..98c83cf5cb
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaBasicMappingDefinition2_0.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.eclipselink.core.internal.v2_0.context.java;
+
+import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
+import org.eclipse.jpt.jpa.core.context.java.DefaultJavaAttributeMappingDefinition;
+import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
+import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaAttributeMappingDefinitionWrapper;
+import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.JavaBasicMappingDefinition2_0;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaBasicMappingDefinition;
+
+public class EclipseLinkJavaBasicMappingDefinition2_0
+ extends JavaAttributeMappingDefinitionWrapper
+ implements DefaultJavaAttributeMappingDefinition
+{
+ private static final JavaAttributeMappingDefinition DELEGATE = JavaBasicMappingDefinition2_0.instance();
+
+ // singleton
+ private static final DefaultJavaAttributeMappingDefinition INSTANCE = new EclipseLinkJavaBasicMappingDefinition2_0();
+
+ /**
+ * Return the singleton.
+ */
+ public static DefaultJavaAttributeMappingDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Enforce singleton usage
+ */
+ private EclipseLinkJavaBasicMappingDefinition2_0() {
+ super();
+ }
+
+ @Override
+ protected JavaAttributeMappingDefinition getDelegate() {
+ return DELEGATE;
+ }
+
+ @Override
+ public Iterable<String> getSupportingAnnotationNames() {
+ return COMBINED_SUPPORTING_ANNOTATION_NAMES;
+ }
+
+ @SuppressWarnings("unchecked")
+ private static final Iterable<String> COMBINED_SUPPORTING_ANNOTATION_NAMES = new CompositeIterable<String>(
+ DELEGATE.getSupportingAnnotationNames(),
+ EclipseLinkJavaBasicMappingDefinition.ECLIPSE_LINK_SUPPORTING_ANNOTATION_NAMES
+ );
+
+ public boolean isDefault(JavaPersistentAttribute persistentAttribute) {
+ return EclipseLinkJavaBasicMappingDefinition.instance().isDefault(persistentAttribute);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaEmbeddableDefinition2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaEmbeddableDefinition2_0.java
new file mode 100644
index 0000000000..c80426caf4
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaEmbeddableDefinition2_0.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.eclipselink.core.internal.v2_0.context.java;
+
+import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
+import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaTypeMappingDefinitionWrapper;
+import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.JavaEmbeddableDefinition2_0;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaEmbeddableDefinition;
+
+public class EclipseLinkJavaEmbeddableDefinition2_0
+ extends JavaTypeMappingDefinitionWrapper
+{
+ private static final JavaTypeMappingDefinition DELEGATE = JavaEmbeddableDefinition2_0.instance();
+
+ // singleton
+ private static final JavaTypeMappingDefinition INSTANCE = new EclipseLinkJavaEmbeddableDefinition2_0();
+
+ /**
+ * Return the singleton.
+ */
+ public static JavaTypeMappingDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Enforce singleton usage
+ */
+ private EclipseLinkJavaEmbeddableDefinition2_0() {
+ super();
+ }
+
+ @Override
+ protected JavaTypeMappingDefinition getDelegate() {
+ return DELEGATE;
+ }
+
+ @Override
+ public Iterable<String> getSupportingAnnotationNames() {
+ return COMBINED_SUPPORTING_ANNOTATION_NAMES;
+ }
+
+ @SuppressWarnings("unchecked")
+ private static final Iterable<String> COMBINED_SUPPORTING_ANNOTATION_NAMES = new CompositeIterable<String>(
+ DELEGATE.getSupportingAnnotationNames(),
+ EclipseLinkJavaEmbeddableDefinition.ECLIPSE_LINK_SUPPORTING_ANNOTATION_NAMES
+ );
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaEntityDefinition2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaEntityDefinition2_0.java
new file mode 100644
index 0000000000..d4ee20fa1b
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaEntityDefinition2_0.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.eclipselink.core.internal.v2_0.context.java;
+
+import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
+import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaTypeMappingDefinitionWrapper;
+import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.JavaEntityDefinition2_0;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaEntityDefinition;
+
+public class EclipseLinkJavaEntityDefinition2_0
+ extends JavaTypeMappingDefinitionWrapper
+{
+ private static final JavaTypeMappingDefinition DELEGATE = JavaEntityDefinition2_0.instance();
+
+ // singleton
+ private static final JavaTypeMappingDefinition INSTANCE = new EclipseLinkJavaEntityDefinition2_0();
+
+ /**
+ * Return the singleton.
+ */
+ public static JavaTypeMappingDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Enforce singleton usage
+ */
+ private EclipseLinkJavaEntityDefinition2_0() {
+ super();
+ }
+
+ @Override
+ protected JavaTypeMappingDefinition getDelegate() {
+ return DELEGATE;
+ }
+
+ @Override
+ public Iterable<String> getSupportingAnnotationNames() {
+ return COMBINED_SUPPORTING_ANNOTATION_NAMES;
+ }
+
+ @SuppressWarnings("unchecked")
+ private static final Iterable<String> COMBINED_SUPPORTING_ANNOTATION_NAMES = new CompositeIterable<String>(
+ DELEGATE.getSupportingAnnotationNames(),
+ EclipseLinkJavaEntityDefinition.ECLIPSE_LINK_SUPPORTING_ANNOTATION_NAMES
+ );
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaMappedSuperclassDefinition2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaMappedSuperclassDefinition2_0.java
new file mode 100644
index 0000000000..ddff5293e7
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaMappedSuperclassDefinition2_0.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.eclipselink.core.internal.v2_0.context.java;
+
+import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
+import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaTypeMappingDefinitionWrapper;
+import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.JavaMappedSuperclassDefinition2_0;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaEntityDefinition;
+
+public class EclipseLinkJavaMappedSuperclassDefinition2_0
+ extends JavaTypeMappingDefinitionWrapper
+{
+ private static final JavaTypeMappingDefinition DELEGATE = JavaMappedSuperclassDefinition2_0.instance();
+
+ // singleton
+ private static final JavaTypeMappingDefinition INSTANCE = new EclipseLinkJavaMappedSuperclassDefinition2_0();
+
+ /**
+ * Return the singleton.
+ */
+ public static JavaTypeMappingDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Enforce singleton usage
+ */
+ private EclipseLinkJavaMappedSuperclassDefinition2_0() {
+ super();
+ }
+
+ @Override
+ protected JavaTypeMappingDefinition getDelegate() {
+ return DELEGATE;
+ }
+
+ @Override
+ public Iterable<String> getSupportingAnnotationNames() {
+ return COMBINED_SUPPORTING_ANNOTATION_NAMES;
+ }
+ @SuppressWarnings("unchecked")
+ private static final Iterable<String> COMBINED_SUPPORTING_ANNOTATION_NAMES = new CompositeIterable<String>(
+ DELEGATE.getSupportingAnnotationNames(),
+ EclipseLinkJavaEntityDefinition.ECLIPSE_LINK_SUPPORTING_ANNOTATION_NAMES
+ );
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaTransformationMappingDefinition2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaTransformationMappingDefinition2_0.java
new file mode 100644
index 0000000000..af6b6dab54
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaTransformationMappingDefinition2_0.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.eclipselink.core.internal.v2_0.context.java;
+
+import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
+import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
+import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaAttributeMappingDefinitionWrapper;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.Access2_0Annotation;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaTransformationMappingDefinition;
+
+public class EclipseLinkJavaTransformationMappingDefinition2_0
+ extends JavaAttributeMappingDefinitionWrapper
+{
+ private static final JavaAttributeMappingDefinition DELEGATE = EclipseLinkJavaTransformationMappingDefinition.instance();
+
+ // singleton
+ private static final JavaAttributeMappingDefinition INSTANCE = new EclipseLinkJavaTransformationMappingDefinition2_0();
+
+ /**
+ * Return the singleton.
+ */
+ public static JavaAttributeMappingDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Enforce singleton usage
+ */
+ private EclipseLinkJavaTransformationMappingDefinition2_0() {
+ super();
+ }
+
+ @Override
+ protected JavaAttributeMappingDefinition getDelegate() {
+ return DELEGATE;
+ }
+
+ @Override
+ public Iterable<String> getSupportingAnnotationNames() {
+ return COMBINED_SUPPORTING_ANNOTATION_NAMES;
+ }
+
+ public static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY_2_0 = new String[] {
+ Access2_0Annotation.ANNOTATION_NAME,
+ };
+ private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES_2_0 = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY_2_0);
+
+ @SuppressWarnings("unchecked")
+ private static final Iterable<String> COMBINED_SUPPORTING_ANNOTATION_NAMES = new CompositeIterable<String>(
+ DELEGATE.getSupportingAnnotationNames(),
+ SUPPORTING_ANNOTATION_NAMES_2_0
+ );
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaVariableOneToOneMappingDefinition2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaVariableOneToOneMappingDefinition2_0.java
new file mode 100644
index 0000000000..fb5dd82c53
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaVariableOneToOneMappingDefinition2_0.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.eclipselink.core.internal.v2_0.context.java;
+
+import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
+import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
+import org.eclipse.jpt.jpa.core.context.java.DefaultJavaAttributeMappingDefinition;
+import org.eclipse.jpt.jpa.core.internal.context.java.DefaultJavaAttributeMappingDefinitionWrapper;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.Access2_0Annotation;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaVariableOneToOneMappingDefinition;
+
+public class EclipseLinkJavaVariableOneToOneMappingDefinition2_0
+ extends DefaultJavaAttributeMappingDefinitionWrapper
+{
+ private static final DefaultJavaAttributeMappingDefinition DELEGATE = EclipseLinkJavaVariableOneToOneMappingDefinition.instance();
+
+ // singleton
+ private static final DefaultJavaAttributeMappingDefinition INSTANCE = new EclipseLinkJavaVariableOneToOneMappingDefinition2_0();
+
+ /**
+ * Return the singleton.
+ */
+ public static DefaultJavaAttributeMappingDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Enforce singleton usage
+ */
+ private EclipseLinkJavaVariableOneToOneMappingDefinition2_0() {
+ super();
+ }
+
+ @Override
+ protected DefaultJavaAttributeMappingDefinition getDelegate() {
+ return DELEGATE;
+ }
+
+ @Override
+ public Iterable<String> getSupportingAnnotationNames() {
+ return COMBINED_SUPPORTING_ANNOTATION_NAMES;
+ }
+
+ public static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY_2_0 = new String[] {
+ Access2_0Annotation.ANNOTATION_NAME,
+ };
+ private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES_2_0 = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY_2_0);
+
+ @SuppressWarnings("unchecked")
+ private static final Iterable<String> COMBINED_SUPPORTING_ANNOTATION_NAMES = new CompositeIterable<String>(
+ DELEGATE.getSupportingAnnotationNames(),
+ SUPPORTING_ANNOTATION_NAMES_2_0
+ );
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaVersionMappingDefinition2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaVersionMappingDefinition2_0.java
new file mode 100644
index 0000000000..af86a61316
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/context/java/EclipseLinkJavaVersionMappingDefinition2_0.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.eclipselink.core.internal.v2_0.context.java;
+
+import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
+import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
+import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaAttributeMappingDefinitionWrapper;
+import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.JavaVersionMappingDefinition2_0;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaBasicMappingDefinition;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaOneToOneMappingDefinition;
+
+public class EclipseLinkJavaVersionMappingDefinition2_0
+ extends JavaAttributeMappingDefinitionWrapper
+{
+ private static final JavaAttributeMappingDefinition DELEGATE = JavaVersionMappingDefinition2_0.instance();
+
+ // singleton
+ private static final JavaAttributeMappingDefinition INSTANCE = new EclipseLinkJavaVersionMappingDefinition2_0();
+
+ /**
+ * Return the singleton.
+ */
+ public static JavaAttributeMappingDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Enforce singleton usage
+ */
+ private EclipseLinkJavaVersionMappingDefinition2_0() {
+ super();
+ }
+
+ @Override
+ protected JavaAttributeMappingDefinition getDelegate() {
+ return DELEGATE;
+ }
+
+ @Override
+ public Iterable<String> getSupportingAnnotationNames() {
+ return COMBINED_SUPPORTING_ANNOTATION_NAMES;
+ }
+
+ @SuppressWarnings("unchecked")
+ private static final Iterable<String> COMBINED_SUPPORTING_ANNOTATION_NAMES = new CompositeIterable<String>(
+ DELEGATE.getSupportingAnnotationNames(),
+ EclipseLinkJavaBasicMappingDefinition.ECLIPSE_LINK_SUPPORTING_ANNOTATION_NAMES
+ );
+
+ public boolean isDefault(JavaPersistentAttribute persistentAttribute) {
+ return EclipseLinkJavaOneToOneMappingDefinition.instance().isDefault(persistentAttribute);
+ }
+}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/Generic2_0JavaContextModelTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/Generic2_0JavaContextModelTests.java
index 8903efdb92..2f80cfeb5f 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/Generic2_0JavaContextModelTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/Generic2_0JavaContextModelTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2011 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.
@@ -19,11 +19,14 @@ public class Generic2_0JavaContextModelTests
public static Test suite() {
TestSuite suite = new TestSuite(Generic2_0JavaContextModelTests.class.getPackage().getName());
suite.addTestSuite(GenericJavaAssociationOverride2_0Tests.class);
+ suite.addTestSuite(GenericJavaBasicMapping2_0Tests.class);
suite.addTestSuite(GenericJavaCascade2_0Tests.class);
suite.addTestSuite(GenericJavaCollectionTable2_0Tests.class);
suite.addTestSuite(GenericJavaElementCollectionMapping2_0Tests.class);
suite.addTestSuite(GenericJavaEntity2_0Tests.class);
suite.addTestSuite(GenericJavaEmbeddedMapping2_0Tests.class);
+ suite.addTestSuite(GenericJavaEmbeddedIdMapping2_0Tests.class);
+ suite.addTestSuite(GenericJavaIdMapping2_0Tests.class);
suite.addTestSuite(GenericJavaManyToManyMapping2_0Tests.class);
suite.addTestSuite(GenericJavaManyToOneMapping2_0Tests.class);
suite.addTestSuite(GenericJavaOneToManyMapping2_0Tests.class);
@@ -31,6 +34,7 @@ public class Generic2_0JavaContextModelTests
suite.addTestSuite(GenericJavaPersistentAttribute2_0Tests.class);
suite.addTestSuite(GenericJavaPersistentType2_0Tests.class);
suite.addTestSuite(GenericJavaSequenceGenerator2_0Tests.class);
+ suite.addTestSuite(GenericJavaVersionMapping2_0Tests.class);
return suite;
}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaBasicMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaBasicMapping2_0Tests.java
new file mode 100644
index 0000000000..f957f6b0a7
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaBasicMapping2_0Tests.java
@@ -0,0 +1,417 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.tests.internal.jpa2.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.utility.internal.iterators.ArrayIterator;
+import org.eclipse.jpt.jpa.core.MappingKeys;
+import org.eclipse.jpt.jpa.core.context.BasicMapping;
+import org.eclipse.jpt.jpa.core.context.EmbeddedIdMapping;
+import org.eclipse.jpt.jpa.core.context.EmbeddedMapping;
+import org.eclipse.jpt.jpa.core.context.EnumType;
+import org.eclipse.jpt.jpa.core.context.EnumeratedConverter;
+import org.eclipse.jpt.jpa.core.context.FetchType;
+import org.eclipse.jpt.jpa.core.context.IdMapping;
+import org.eclipse.jpt.jpa.core.context.ManyToManyMapping;
+import org.eclipse.jpt.jpa.core.context.ManyToOneMapping;
+import org.eclipse.jpt.jpa.core.context.OneToManyMapping;
+import org.eclipse.jpt.jpa.core.context.OneToOneMapping;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.TemporalConverter;
+import org.eclipse.jpt.jpa.core.context.TemporalType;
+import org.eclipse.jpt.jpa.core.context.TransientMapping;
+import org.eclipse.jpt.jpa.core.context.VersionMapping;
+import org.eclipse.jpt.jpa.core.jpa2.MappingKeys2_0;
+import org.eclipse.jpt.jpa.core.jpa2.context.ElementCollectionMapping2_0;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.Access2_0Annotation;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.ElementCollection2_0Annotation;
+import org.eclipse.jpt.jpa.core.resource.java.BasicAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.ColumnAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.EmbeddedAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.EmbeddedIdAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.EnumeratedAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.IdAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.JPA;
+import org.eclipse.jpt.jpa.core.resource.java.LobAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.ManyToManyAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.ManyToOneAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.OneToManyAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.OneToOneAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.TemporalAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.TransientAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.VersionAnnotation;
+import org.eclipse.jpt.jpa.core.tests.internal.jpa2.context.Generic2_0ContextModelTestCase;
+
+@SuppressWarnings("nls")
+public class GenericJavaBasicMapping2_0Tests extends Generic2_0ContextModelTestCase
+{
+
+ private ICompilationUnit createTestEntityWithBasicMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.BASIC);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append("@Basic").append(CR);
+ }
+ });
+ }
+
+ public GenericJavaBasicMapping2_0Tests(String name) {
+ super(name);
+ }
+
+ public void testBasicMorphToDefaultBasic() throws Exception {
+ createTestEntityWithBasicMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(basicMapping.isDefault());
+ basicMapping.getColumn().setSpecifiedName("FOO");
+ basicMapping.setConverter(EnumeratedConverter.class);
+ ((EnumeratedConverter) basicMapping.getConverter()).setSpecifiedEnumType(EnumType.STRING);
+ resourceField.addAnnotation(LobAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(TemporalAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ basicMapping.setSpecifiedFetch(FetchType.EAGER);
+ basicMapping.setSpecifiedOptional(Boolean.FALSE);
+ assertFalse(basicMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
+ assertEquals("FOO", ((BasicMapping) persistentAttribute.getMapping()).getColumn().getSpecifiedName());
+ assertEquals(EnumType.STRING, ((EnumeratedConverter) ((BasicMapping) persistentAttribute.getMapping()).getConverter()).getEnumType());
+
+ assertNull(((BasicMapping) persistentAttribute.getMapping()).getSpecifiedFetch());
+ assertNull(((BasicMapping) persistentAttribute.getMapping()).getSpecifiedOptional());
+ assertNull(resourceField.getAnnotation(BasicAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(LobAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(EnumeratedAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testBasicMorphToId() throws Exception {
+ createTestEntityWithBasicMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(basicMapping.isDefault());
+ basicMapping.getColumn().setSpecifiedName("FOO");
+ basicMapping.setConverter(TemporalConverter.class);
+ ((TemporalConverter) basicMapping.getConverter()).setTemporalType(TemporalType.TIME);
+ resourceField.addAnnotation(LobAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(EnumeratedAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ basicMapping.setSpecifiedFetch(FetchType.EAGER);
+ basicMapping.setSpecifiedOptional(Boolean.FALSE);
+ assertFalse(basicMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
+ assertEquals("FOO", ((IdMapping) persistentAttribute.getMapping()).getColumn().getSpecifiedName());
+ assertEquals(TemporalType.TIME, ((TemporalConverter) ((IdMapping) persistentAttribute.getMapping()).getConverter()).getTemporalType());
+
+ assertNull(resourceField.getAnnotation(BasicAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(IdAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(LobAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(EnumeratedAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testBasicMorphToVersion() throws Exception {
+ createTestEntityWithBasicMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(basicMapping.isDefault());
+ basicMapping.getColumn().setSpecifiedName("FOO");
+ basicMapping.setConverter(TemporalConverter.class);
+ ((TemporalConverter) basicMapping.getConverter()).setTemporalType(TemporalType.TIME);
+ resourceField.addAnnotation(LobAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(EnumeratedAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(basicMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
+ assertEquals("FOO", ((VersionMapping) persistentAttribute.getMapping()).getColumn().getSpecifiedName());
+ assertEquals(TemporalType.TIME, ((TemporalConverter) ((VersionMapping) persistentAttribute.getMapping()).getConverter()).getTemporalType());
+
+ assertNull(resourceField.getAnnotation(BasicAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(VersionAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(LobAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(EnumeratedAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testBasicMorphToEmbedded() throws Exception {
+ createTestEntityWithBasicMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(basicMapping.isDefault());
+ basicMapping.getColumn().setSpecifiedName("FOO");
+ resourceField.addAnnotation(TemporalAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(LobAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(EnumeratedAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(basicMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof EmbeddedMapping);
+
+ assertNull(resourceField.getAnnotation(BasicAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(LobAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(EnumeratedAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testBasicMorphToEmbeddedId() throws Exception {
+ createTestEntityWithBasicMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(basicMapping.isDefault());
+ basicMapping.getColumn().setSpecifiedName("FOO");
+ resourceField.addAnnotation(TemporalAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(LobAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(EnumeratedAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(basicMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof EmbeddedIdMapping);
+
+ assertNull(resourceField.getAnnotation(BasicAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(LobAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(EnumeratedAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testBasicMorphToTransient() throws Exception {
+ createTestEntityWithBasicMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(basicMapping.isDefault());
+ basicMapping.getColumn().setSpecifiedName("FOO");
+ resourceField.addAnnotation(TemporalAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(LobAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(EnumeratedAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(basicMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof TransientMapping);
+
+ assertNull(resourceField.getAnnotation(BasicAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(TransientAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(LobAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(EnumeratedAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testBasicMorphToOneToOne() throws Exception {
+ createTestEntityWithBasicMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(basicMapping.isDefault());
+ basicMapping.getColumn().setSpecifiedName("FOO");
+ resourceField.addAnnotation(TemporalAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(LobAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(EnumeratedAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ basicMapping.setSpecifiedFetch(FetchType.EAGER);
+ basicMapping.setSpecifiedOptional(Boolean.FALSE);
+ assertFalse(basicMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof OneToOneMapping);
+
+//TODO assertEquals(FetchType.EAGER, ((OneToOneMapping) persistentAttribute.getMapping()).getSpecifiedFetch());
+// assertEquals(Boolean.FALSE, ((OneToOneMapping) persistentAttribute.getMapping()).getSpecifiedOptional());
+ assertNotNull(resourceField.getAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(BasicAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(LobAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(EnumeratedAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testBasicMorphToOneToMany() throws Exception {
+ createTestEntityWithBasicMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(basicMapping.isDefault());
+ basicMapping.getColumn().setSpecifiedName("FOO");
+ resourceField.addAnnotation(TemporalAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(LobAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(EnumeratedAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ basicMapping.setSpecifiedFetch(FetchType.EAGER);
+ basicMapping.setSpecifiedOptional(Boolean.FALSE);
+ assertFalse(basicMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof OneToManyMapping);
+
+//TODO assertEquals(FetchType.EAGER, ((OneToManyMapping) persistentAttribute.getMapping()).getSpecifiedFetch());
+ assertNotNull(resourceField.getAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(BasicAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(LobAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(EnumeratedAnnotation.ANNOTATION_NAME));
+ }
+ public void testBasicMorphToManyToOne() throws Exception {
+ createTestEntityWithBasicMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(basicMapping.isDefault());
+ basicMapping.getColumn().setSpecifiedName("FOO");
+ resourceField.addAnnotation(TemporalAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(LobAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(EnumeratedAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ basicMapping.setSpecifiedFetch(FetchType.EAGER);
+ basicMapping.setSpecifiedOptional(Boolean.FALSE);
+ assertFalse(basicMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof ManyToOneMapping);
+
+//TODO assertEquals(FetchType.EAGER, ((ManyToOneMapping) persistentAttribute.getMapping()).getSpecifiedFetch());
+// assertEquals(Boolean.FALSE, ((ManyToOneMapping) persistentAttribute.getMapping()).getSpecifiedOptional());
+ assertNotNull(resourceField.getAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(BasicAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(LobAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(EnumeratedAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testBasicMorphToManyToMany() throws Exception {
+ createTestEntityWithBasicMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(basicMapping.isDefault());
+ basicMapping.getColumn().setSpecifiedName("FOO");
+ resourceField.addAnnotation(TemporalAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(LobAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(EnumeratedAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ basicMapping.setSpecifiedFetch(FetchType.EAGER);
+ basicMapping.setSpecifiedOptional(Boolean.FALSE);
+ assertFalse(basicMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof ManyToManyMapping);
+
+// assertEquals(FetchType.EAGER, ((ManyToManyMapping) persistentAttribute.getMapping()).getSpecifiedFetch());
+ assertNotNull(resourceField.getAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(BasicAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(LobAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(EnumeratedAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testBasicMorphToElementCollection() throws Exception {
+ createTestEntityWithBasicMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(basicMapping.isDefault());
+ basicMapping.getColumn().setSpecifiedName("FOO");
+ resourceField.addAnnotation(TemporalAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(LobAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(EnumeratedAnnotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ basicMapping.setSpecifiedFetch(FetchType.EAGER);
+ basicMapping.setSpecifiedOptional(Boolean.FALSE);
+ assertFalse(basicMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof ElementCollectionMapping2_0);
+
+// assertEquals(FetchType.EAGER, ((ElementCollectionMapping2_0) persistentAttribute.getMapping()).getSpecifiedFetch());
+ assertNotNull(resourceField.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(BasicAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(LobAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(EnumeratedAnnotation.ANNOTATION_NAME));
+ }
+
+}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaElementCollectionMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaElementCollectionMapping2_0Tests.java
index 2267409676..395b7d260f 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaElementCollectionMapping2_0Tests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaElementCollectionMapping2_0Tests.java
@@ -46,10 +46,12 @@ import org.eclipse.jpt.jpa.core.jpa2.context.ElementCollectionMapping2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.OrderColumn2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.Orderable2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaElementCollectionMapping2_0;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.Access2_0Annotation;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.ElementCollection2_0Annotation;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.JPA2_0;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapKeyClass2_0Annotation;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapKeyColumn2_0Annotation;
+import org.eclipse.jpt.jpa.core.resource.java.AssociationOverrideAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.AttributeOverrideAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.BasicAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.ColumnAnnotation;
@@ -346,16 +348,22 @@ public class GenericJavaElementCollectionMapping2_0Tests extends Generic2_0Conte
PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
assertFalse(elementCollectionMapping.isDefault());
persistentAttribute.setMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
assertTrue(persistentAttribute.getMapping() instanceof BasicMapping);
assertFalse(persistentAttribute.getMapping().isDefault());
- JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
- JavaResourceField resourceField = resourceType.getFields().iterator().next();
assertNull(resourceField.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
assertNotNull(resourceField.getAnnotation(BasicAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME));
}
public void testMorphToDefault() throws Exception {
@@ -364,14 +372,20 @@ public class GenericJavaElementCollectionMapping2_0Tests extends Generic2_0Conte
PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
assertFalse(elementCollectionMapping.isDefault());
persistentAttribute.setMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
assertTrue(persistentAttribute.getMapping().isDefault());
- JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
- JavaResourceField resourceField = resourceType.getFields().iterator().next();
assertNull(resourceField.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME));
}
public void testMorphToVersionMapping() throws Exception {
@@ -380,16 +394,22 @@ public class GenericJavaElementCollectionMapping2_0Tests extends Generic2_0Conte
PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
assertFalse(elementCollectionMapping.isDefault());
persistentAttribute.setMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
assertTrue(persistentAttribute.getMapping() instanceof VersionMapping);
assertFalse(persistentAttribute.getMapping().isDefault());
- JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
- JavaResourceField resourceField = resourceType.getFields().iterator().next();
assertNull(resourceField.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
assertNotNull(resourceField.getAnnotation(VersionAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME));
}
public void testMorphToIdMapping() throws Exception {
@@ -398,16 +418,22 @@ public class GenericJavaElementCollectionMapping2_0Tests extends Generic2_0Conte
PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
assertFalse(elementCollectionMapping.isDefault());
persistentAttribute.setMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
assertTrue(persistentAttribute.getMapping() instanceof IdMapping);
assertFalse(persistentAttribute.getMapping().isDefault());
- JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
- JavaResourceField resourceField = resourceType.getFields().iterator().next();
assertNull(resourceField.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
assertNotNull(resourceField.getAnnotation(IdAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME));
}
public void testMorphToEmbeddedMapping() throws Exception {
@@ -416,16 +442,22 @@ public class GenericJavaElementCollectionMapping2_0Tests extends Generic2_0Conte
PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
assertFalse(elementCollectionMapping.isDefault());
persistentAttribute.setMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
assertTrue(persistentAttribute.getMapping() instanceof EmbeddedMapping);
assertFalse(persistentAttribute.getMapping().isDefault());
- JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
- JavaResourceField resourceField = resourceType.getFields().iterator().next();
assertNull(resourceField.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
assertNotNull(resourceField.getAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME));
}
public void testMorphToEmbeddedIdMapping() throws Exception {
@@ -434,16 +466,22 @@ public class GenericJavaElementCollectionMapping2_0Tests extends Generic2_0Conte
PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
assertFalse(elementCollectionMapping.isDefault());
persistentAttribute.setMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
assertTrue(persistentAttribute.getMapping() instanceof EmbeddedIdMapping);
assertFalse(persistentAttribute.getMapping().isDefault());
- JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
- JavaResourceField resourceField = resourceType.getFields().iterator().next();
assertNull(resourceField.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
assertNotNull(resourceField.getAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME));
}
public void testMorphToTransientMapping() throws Exception {
@@ -452,16 +490,22 @@ public class GenericJavaElementCollectionMapping2_0Tests extends Generic2_0Conte
PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
assertFalse(elementCollectionMapping.isDefault());
persistentAttribute.setMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
assertTrue(persistentAttribute.getMapping() instanceof TransientMapping);
assertFalse(persistentAttribute.getMapping().isDefault());
- JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
- JavaResourceField resourceField = resourceType.getFields().iterator().next();
assertNull(resourceField.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
assertNotNull(resourceField.getAnnotation(TransientAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME));
}
public void testMorphToManyToOneMapping() throws Exception {
@@ -470,16 +514,22 @@ public class GenericJavaElementCollectionMapping2_0Tests extends Generic2_0Conte
PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
assertFalse(elementCollectionMapping.isDefault());
persistentAttribute.setMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
assertTrue(persistentAttribute.getMapping() instanceof ManyToOneMapping);
assertFalse(persistentAttribute.getMapping().isDefault());
- JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
- JavaResourceField resourceField = resourceType.getFields().iterator().next();
assertNull(resourceField.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
assertNotNull(resourceField.getAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME));
}
public void testMorphToOneToManyMapping() throws Exception {
@@ -488,16 +538,22 @@ public class GenericJavaElementCollectionMapping2_0Tests extends Generic2_0Conte
PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
assertFalse(elementCollectionMapping.isDefault());
persistentAttribute.setMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
assertTrue(persistentAttribute.getMapping() instanceof OneToManyMapping);
assertFalse(persistentAttribute.getMapping().isDefault());
- JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
- JavaResourceField resourceField = resourceType.getFields().iterator().next();
assertNull(resourceField.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
assertNotNull(resourceField.getAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME));
}
public void testMorphToManyToManyMapping() throws Exception {
@@ -506,16 +562,23 @@ public class GenericJavaElementCollectionMapping2_0Tests extends Generic2_0Conte
PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
assertFalse(elementCollectionMapping.isDefault());
persistentAttribute.setMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
assertTrue(persistentAttribute.getMapping() instanceof ManyToManyMapping);
assertFalse(persistentAttribute.getMapping().isDefault());
- JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
- JavaResourceField resourceField = resourceType.getFields().iterator().next();
assertNull(resourceField.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
assertNotNull(resourceField.getAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME));
}
public void testUpdateSpecifiedTargetEntity() throws Exception {
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaEmbeddedIdMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaEmbeddedIdMapping2_0Tests.java
new file mode 100644
index 0000000000..a8557f089f
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaEmbeddedIdMapping2_0Tests.java
@@ -0,0 +1,368 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.tests.internal.jpa2.context.java;
+
+import java.util.Iterator;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement.Kind;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceField;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.common.core.tests.internal.projects.TestJavaProject.SourceWriter;
+import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
+import org.eclipse.jpt.jpa.core.MappingKeys;
+import org.eclipse.jpt.jpa.core.context.BasicMapping;
+import org.eclipse.jpt.jpa.core.context.EmbeddedIdMapping;
+import org.eclipse.jpt.jpa.core.context.EmbeddedMapping;
+import org.eclipse.jpt.jpa.core.context.IdMapping;
+import org.eclipse.jpt.jpa.core.context.ManyToManyMapping;
+import org.eclipse.jpt.jpa.core.context.ManyToOneMapping;
+import org.eclipse.jpt.jpa.core.context.OneToManyMapping;
+import org.eclipse.jpt.jpa.core.context.OneToOneMapping;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.TransientMapping;
+import org.eclipse.jpt.jpa.core.context.VersionMapping;
+import org.eclipse.jpt.jpa.core.context.java.JavaEmbeddedMapping;
+import org.eclipse.jpt.jpa.core.internal.jpa1.context.java.GenericJavaNullAttributeMapping;
+import org.eclipse.jpt.jpa.core.jpa2.MappingKeys2_0;
+import org.eclipse.jpt.jpa.core.jpa2.context.ElementCollectionMapping2_0;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.Access2_0Annotation;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.ElementCollection2_0Annotation;
+import org.eclipse.jpt.jpa.core.resource.java.AttributeOverrideAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.BasicAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.EmbeddedAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.EmbeddedIdAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.IdAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.JPA;
+import org.eclipse.jpt.jpa.core.resource.java.ManyToManyAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.ManyToOneAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.OneToManyAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.OneToOneAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.TransientAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.VersionAnnotation;
+import org.eclipse.jpt.jpa.core.tests.internal.jpa2.context.Generic2_0ContextModelTestCase;
+
+@SuppressWarnings("nls")
+public class GenericJavaEmbeddedIdMapping2_0Tests extends Generic2_0ContextModelTestCase
+{
+
+ public static final String EMBEDDABLE_TYPE_NAME = "MyEmbeddable";
+ public static final String FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME = PACKAGE_NAME + "." + EMBEDDABLE_TYPE_NAME;
+
+ private ICompilationUnit createTestEntityWithEmbeddedIdMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.EMBEDDED_ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append("@EmbeddedId").append(CR);
+ sb.append(CR);
+ sb.append(" private " + EMBEDDABLE_TYPE_NAME +" myEmbeddedId;").append(CR);
+ sb.append(CR);
+ }
+ });
+ }
+
+ private void createEmbeddableType() throws Exception {
+ SourceWriter sourceWriter = new SourceWriter() {
+ public void appendSourceTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append("import ");
+ sb.append(JPA.EMBEDDABLE);
+ sb.append(";");
+ sb.append(CR);
+ sb.append("@Embeddable");
+ sb.append(CR);
+ sb.append("public class ").append(EMBEDDABLE_TYPE_NAME).append(" {");
+ sb.append(CR);
+ sb.append(" private String city;").append(CR);
+ sb.append(CR);
+ sb.append(" private String state;").append(CR);
+ sb.append(CR);
+ sb.append(" ");
+ sb.append("}").append(CR);
+ }
+ };
+ this.javaProject.createCompilationUnit(PACKAGE_NAME, EMBEDDABLE_TYPE_NAME + ".java", sourceWriter);
+ }
+
+
+ public GenericJavaEmbeddedIdMapping2_0Tests(String name) {
+ super(name);
+ }
+
+ public void testMorphToBasicMapping() throws Exception {
+ createTestEntityWithEmbeddedIdMapping();
+ createEmbeddableType();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(embeddedIdMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof BasicMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(BasicAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToDefault() throws Exception {
+ createTestEntityWithEmbeddedIdMapping();
+ createEmbeddableType();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(embeddedIdMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(((JavaEmbeddedMapping) persistentAttribute.getMapping()).getAttributeOverrideContainer().getOverrides().iterator().hasNext());
+ assertTrue(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testDefaultEmbeddedIdMapping() throws Exception {
+ createTestEntityWithEmbeddedIdMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) persistentAttribute.getMapping();
+ assertFalse(embeddedIdMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof GenericJavaNullAttributeMapping);
+ assertTrue(persistentAttribute.getMapping().isDefault());
+
+ createEmbeddableType();
+ addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
+ assertTrue(persistentAttribute.getMapping() instanceof EmbeddedMapping);
+ assertTrue(persistentAttribute.getMapping().isDefault());
+ }
+
+ public void testMorphToVersionMapping() throws Exception {
+ createTestEntityWithEmbeddedIdMapping();
+ createEmbeddableType();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(embeddedIdMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof VersionMapping);
+
+ assertNull(resourceField.getAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(VersionAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToTransientMapping() throws Exception {
+ createTestEntityWithEmbeddedIdMapping();
+ createEmbeddableType();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(embeddedIdMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof TransientMapping);
+
+ assertNull(resourceField.getAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(TransientAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToIdMapping() throws Exception {
+ createTestEntityWithEmbeddedIdMapping();
+ createEmbeddableType();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(embeddedIdMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof IdMapping);
+
+ assertNull(resourceField.getAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(IdAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToEmbeddedMapping() throws Exception {
+ createTestEntityWithEmbeddedIdMapping();
+ createEmbeddableType();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(embeddedIdMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof EmbeddedMapping);
+
+ assertNull(resourceField.getAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToOneToOneMapping() throws Exception {
+ createTestEntityWithEmbeddedIdMapping();
+ createEmbeddableType();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(embeddedIdMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof OneToOneMapping);
+
+ assertNull(resourceField.getAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToOneToManyMapping() throws Exception {
+ createTestEntityWithEmbeddedIdMapping();
+ createEmbeddableType();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(embeddedIdMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof OneToManyMapping);
+
+ assertNull(resourceField.getAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToManyToOneMapping() throws Exception {
+ createTestEntityWithEmbeddedIdMapping();
+ createEmbeddableType();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(embeddedIdMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof ManyToOneMapping);
+
+ assertNull(resourceField.getAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToManyToManyMapping() throws Exception {
+ createTestEntityWithEmbeddedIdMapping();
+ createEmbeddableType();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ assertFalse(embeddedIdMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof ManyToManyMapping);
+
+ assertNull(resourceField.getAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToElementCollectionMapping() throws Exception {
+ createTestEntityWithEmbeddedIdMapping();
+ createEmbeddableType();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ EmbeddedIdMapping embeddedIdMapping = (EmbeddedIdMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ assertFalse(embeddedIdMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof ElementCollectionMapping2_0);
+
+ assertNull(resourceField.getAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ }
+}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaEmbeddedMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaEmbeddedMapping2_0Tests.java
index f404e5a4a8..194856a99c 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaEmbeddedMapping2_0Tests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaEmbeddedMapping2_0Tests.java
@@ -55,8 +55,12 @@ import org.eclipse.jpt.jpa.core.context.java.JavaVirtualAssociationOverride;
import org.eclipse.jpt.jpa.core.context.java.JavaVirtualAttributeOverride;
import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.java.GenericJavaNullAttributeMapping;
+import org.eclipse.jpt.jpa.core.jpa2.MappingKeys2_0;
+import org.eclipse.jpt.jpa.core.jpa2.context.ElementCollectionMapping2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.VirtualOverrideRelationship2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaEmbeddedMapping2_0;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.Access2_0Annotation;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.ElementCollection2_0Annotation;
import org.eclipse.jpt.jpa.core.resource.java.AssociationOverrideAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.AttributeOverrideAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.BasicAnnotation;
@@ -266,17 +270,22 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe
PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributeNamed("myEmbedded");
JavaEmbeddedMapping embeddedMapping = (JavaEmbeddedMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
assertFalse(embeddedMapping.isDefault());
persistentAttribute.setMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
assertTrue(persistentAttribute.getMapping() instanceof BasicMapping);
assertFalse(persistentAttribute.getMapping().isDefault());
- JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
- JavaResourceField resourceField = resourceType.getFields().iterator().next();
assertNull(resourceField.getAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
assertNotNull(resourceField.getAnnotation(BasicAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
assertNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME));
}
public void testMorphToDefault() throws Exception {
@@ -290,6 +299,8 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe
JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
JavaResourceField resourceField = resourceType.getFields().iterator().next();
resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
assertFalse(embeddedMapping.isDefault());
persistentAttribute.setMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
@@ -297,7 +308,9 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe
assertTrue(persistentAttribute.getMapping().isDefault());
assertNull(resourceField.getAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
assertNotNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME));
}
public void testDefaultEmbeddedMapping() throws Exception {
@@ -399,6 +412,8 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe
JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
JavaResourceField resourceField = resourceType.getFields().iterator().next();
resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
assertFalse(embeddedMapping.isDefault());
persistentAttribute.setMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
@@ -406,7 +421,9 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe
assertNull(resourceField.getAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
assertNotNull(resourceField.getAnnotation(VersionAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
assertNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME));
}
public void testMorphToTransientMapping() throws Exception {
@@ -419,6 +436,7 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe
JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
JavaResourceField resourceField = resourceType.getFields().iterator().next();
resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
assertFalse(embeddedMapping.isDefault());
persistentAttribute.setMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
@@ -426,7 +444,9 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe
assertNull(resourceField.getAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
assertNotNull(resourceField.getAnnotation(TransientAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
assertNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME));
}
public void testMorphToIdMapping() throws Exception {
@@ -439,6 +459,8 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe
JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
JavaResourceField resourceField = resourceType.getFields().iterator().next();
resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
assertFalse(embeddedMapping.isDefault());
persistentAttribute.setMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
@@ -446,7 +468,9 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe
assertNull(resourceField.getAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
assertNotNull(resourceField.getAnnotation(IdAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
assertNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME));
}
public void testMorphToEmbeddedIdMapping() throws Exception {
@@ -459,6 +483,8 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe
JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
JavaResourceField resourceField = resourceType.getFields().iterator().next();
resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
assertFalse(embeddedMapping.isDefault());
persistentAttribute.setMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
@@ -466,7 +492,9 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe
assertNull(resourceField.getAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
assertNotNull(resourceField.getAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
assertNotNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME));
}
public void testMorphToOneToOneMapping() throws Exception {
@@ -479,6 +507,8 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe
JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
JavaResourceField resourceField = resourceType.getFields().iterator().next();
resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
assertFalse(embeddedMapping.isDefault());
persistentAttribute.setMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
@@ -486,7 +516,9 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe
assertNull(resourceField.getAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
assertNotNull(resourceField.getAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
assertNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME));
}
public void testMorphToOneToManyMapping() throws Exception {
@@ -499,6 +531,8 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe
JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
JavaResourceField resourceField = resourceType.getFields().iterator().next();
resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
assertFalse(embeddedMapping.isDefault());
persistentAttribute.setMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
@@ -507,6 +541,7 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe
assertNull(resourceField.getAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
assertNotNull(resourceField.getAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
assertNotNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME));
}
public void testMorphToManyToOneMapping() throws Exception {
@@ -519,6 +554,8 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe
JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
JavaResourceField resourceField = resourceType.getFields().iterator().next();
resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
assertFalse(embeddedMapping.isDefault());
persistentAttribute.setMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
@@ -526,7 +563,9 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe
assertNull(resourceField.getAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
assertNotNull(resourceField.getAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
assertNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME));
}
public void testMorphToManyToManyMapping() throws Exception {
@@ -539,6 +578,8 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe
JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
JavaResourceField resourceField = resourceType.getFields().iterator().next();
resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
assertFalse(embeddedMapping.isDefault());
persistentAttribute.setMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
@@ -546,7 +587,33 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe
assertNull(resourceField.getAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
assertNotNull(resourceField.getAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToElementCollectionMapping() throws Exception {
+ createTestEntityWithEmbeddedMapping();
+ createEmbeddableType();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributeNamed("myEmbedded");
+ JavaEmbeddedMapping embeddedMapping = (JavaEmbeddedMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ resourceField.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE);
+ resourceField.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(embeddedMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof ElementCollectionMapping2_0);
+
+ assertNull(resourceField.getAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
assertNotNull(resourceField.getAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME));
}
public void testSpecifiedAttributeOverrides() throws Exception {
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaIdMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaIdMapping2_0Tests.java
new file mode 100644
index 0000000000..263c0dde49
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaIdMapping2_0Tests.java
@@ -0,0 +1,423 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.tests.internal.jpa2.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.utility.internal.iterators.ArrayIterator;
+import org.eclipse.jpt.jpa.core.MappingKeys;
+import org.eclipse.jpt.jpa.core.context.BasicMapping;
+import org.eclipse.jpt.jpa.core.context.EmbeddedIdMapping;
+import org.eclipse.jpt.jpa.core.context.EmbeddedMapping;
+import org.eclipse.jpt.jpa.core.context.IdMapping;
+import org.eclipse.jpt.jpa.core.context.ManyToManyMapping;
+import org.eclipse.jpt.jpa.core.context.ManyToOneMapping;
+import org.eclipse.jpt.jpa.core.context.OneToManyMapping;
+import org.eclipse.jpt.jpa.core.context.OneToOneMapping;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.TemporalConverter;
+import org.eclipse.jpt.jpa.core.context.TemporalType;
+import org.eclipse.jpt.jpa.core.context.TransientMapping;
+import org.eclipse.jpt.jpa.core.context.VersionMapping;
+import org.eclipse.jpt.jpa.core.jpa2.MappingKeys2_0;
+import org.eclipse.jpt.jpa.core.jpa2.context.ElementCollectionMapping2_0;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.Access2_0Annotation;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.ElementCollection2_0Annotation;
+import org.eclipse.jpt.jpa.core.resource.java.BasicAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.ColumnAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.EmbeddedAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.EmbeddedIdAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.GeneratedValueAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.IdAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.JPA;
+import org.eclipse.jpt.jpa.core.resource.java.ManyToManyAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.ManyToOneAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.OneToManyAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.OneToOneAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.SequenceGeneratorAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.TableGeneratorAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.TemporalAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.TransientAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.VersionAnnotation;
+import org.eclipse.jpt.jpa.core.tests.internal.jpa2.context.Generic2_0ContextModelTestCase;
+
+@SuppressWarnings("nls")
+public class GenericJavaIdMapping2_0Tests extends Generic2_0ContextModelTestCase
+{
+
+ private ICompilationUnit createTestEntityWithIdMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append("@Id").append(CR);
+ }
+ });
+ }
+
+ public GenericJavaIdMapping2_0Tests(String name) {
+ super(name);
+ }
+
+ public void testMorphToBasicMapping() throws Exception {
+ createTestEntityWithIdMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ IdMapping idMapping = (IdMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(idMapping.isDefault());
+ idMapping.getColumn().setSpecifiedName("FOO");
+ idMapping.setConverter(TemporalConverter.class);
+ ((TemporalConverter) idMapping.getConverter()).setTemporalType(TemporalType.TIME);
+ idMapping.addGeneratedValue();
+ idMapping.getGeneratorContainer().addTableGenerator();
+ idMapping.getGeneratorContainer().addSequenceGenerator();
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(idMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
+ assertEquals("FOO", ((BasicMapping) persistentAttribute.getMapping()).getColumn().getSpecifiedName());
+ assertEquals(TemporalType.TIME, ((TemporalConverter) ((BasicMapping) persistentAttribute.getMapping()).getConverter()).getTemporalType());
+
+ assertNull(resourceField.getAnnotation(IdAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(BasicAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToDefault() throws Exception {
+ createTestEntityWithIdMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ IdMapping idMapping = (IdMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(idMapping.isDefault());
+ idMapping.getColumn().setSpecifiedName("FOO");
+ idMapping.setConverter(TemporalConverter.class);
+ ((TemporalConverter) idMapping.getConverter()).setTemporalType(TemporalType.TIME);
+ idMapping.addGeneratedValue();
+ idMapping.getGeneratorContainer().addTableGenerator();
+ idMapping.getGeneratorContainer().addSequenceGenerator();
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(idMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
+ assertEquals("FOO", ((BasicMapping) persistentAttribute.getMapping()).getColumn().getSpecifiedName());
+ assertEquals(TemporalType.TIME, ((TemporalConverter) ((BasicMapping) persistentAttribute.getMapping()).getConverter()).getTemporalType());
+
+ assertNull(resourceField.getAnnotation(IdAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToVersionMapping() throws Exception {
+ createTestEntityWithIdMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ IdMapping idMapping = (IdMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(idMapping.isDefault());
+ idMapping.getColumn().setSpecifiedName("FOO");
+ idMapping.setConverter(TemporalConverter.class);
+ ((TemporalConverter) idMapping.getConverter()).setTemporalType(TemporalType.TIME);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ idMapping.addGeneratedValue();
+ idMapping.getGeneratorContainer().addTableGenerator();
+ idMapping.getGeneratorContainer().addSequenceGenerator();
+ assertFalse(idMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
+ assertEquals("FOO", ((VersionMapping) persistentAttribute.getMapping()).getColumn().getSpecifiedName());
+ assertEquals(TemporalType.TIME, ((TemporalConverter) ((VersionMapping) persistentAttribute.getMapping()).getConverter()).getTemporalType());
+
+ assertNull(resourceField.getAnnotation(IdAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(VersionAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToEmbeddedMapping() throws Exception {
+ createTestEntityWithIdMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ IdMapping idMapping = (IdMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(idMapping.isDefault());
+ idMapping.getColumn().setSpecifiedName("FOO");
+ idMapping.setConverter(TemporalConverter.class);
+ ((TemporalConverter) idMapping.getConverter()).setTemporalType(TemporalType.TIME);
+ idMapping.addGeneratedValue();
+ idMapping.getGeneratorContainer().addTableGenerator();
+ idMapping.getGeneratorContainer().addSequenceGenerator();
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(idMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof EmbeddedMapping);
+
+ assertNull(resourceField.getAnnotation(IdAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToTransientMapping() throws Exception {
+ createTestEntityWithIdMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ IdMapping idMapping = (IdMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(idMapping.isDefault());
+ idMapping.getColumn().setSpecifiedName("FOO");
+ idMapping.setConverter(TemporalConverter.class);
+ ((TemporalConverter) idMapping.getConverter()).setTemporalType(TemporalType.TIME);
+ idMapping.addGeneratedValue();
+ idMapping.getGeneratorContainer().addTableGenerator();
+ idMapping.getGeneratorContainer().addSequenceGenerator();
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(idMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof TransientMapping);
+
+ assertNull(resourceField.getAnnotation(IdAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(TransientAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToEmbeddedIdMapping() throws Exception {
+ createTestEntityWithIdMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ IdMapping idMapping = (IdMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(idMapping.isDefault());
+ idMapping.getColumn().setSpecifiedName("FOO");
+ idMapping.setConverter(TemporalConverter.class);
+ ((TemporalConverter) idMapping.getConverter()).setTemporalType(TemporalType.TIME);
+ idMapping.addGeneratedValue();
+ idMapping.getGeneratorContainer().addTableGenerator();
+ idMapping.getGeneratorContainer().addSequenceGenerator();
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(idMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof EmbeddedIdMapping);
+
+ assertNull(resourceField.getAnnotation(IdAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToOneToOneMapping() throws Exception {
+ createTestEntityWithIdMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ IdMapping idMapping = (IdMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(idMapping.isDefault());
+ idMapping.getColumn().setSpecifiedName("FOO");
+ idMapping.setConverter(TemporalConverter.class);
+ ((TemporalConverter) idMapping.getConverter()).setTemporalType(TemporalType.TIME);
+ idMapping.addGeneratedValue();
+ idMapping.getGeneratorContainer().addTableGenerator();
+ idMapping.getGeneratorContainer().addSequenceGenerator();
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(idMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof OneToOneMapping);
+
+ assertNotNull(resourceField.getAnnotation(IdAnnotation.ANNOTATION_NAME));//OneToOne with Id annotation is valid in JPA 2.0
+ assertNotNull(resourceField.getAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToOneToManyMapping() throws Exception {
+ createTestEntityWithIdMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ IdMapping idMapping = (IdMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(idMapping.isDefault());
+ idMapping.getColumn().setSpecifiedName("FOO");
+ idMapping.setConverter(TemporalConverter.class);
+ ((TemporalConverter) idMapping.getConverter()).setTemporalType(TemporalType.TIME);
+ idMapping.addGeneratedValue();
+ idMapping.getGeneratorContainer().addTableGenerator();
+ idMapping.getGeneratorContainer().addSequenceGenerator();
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(idMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof OneToManyMapping);
+
+ assertNull(resourceField.getAnnotation(IdAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToManyToOneMapping() throws Exception {
+ createTestEntityWithIdMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ IdMapping idMapping = (IdMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(idMapping.isDefault());
+ idMapping.getColumn().setSpecifiedName("FOO");
+ idMapping.setConverter(TemporalConverter.class);
+ ((TemporalConverter) idMapping.getConverter()).setTemporalType(TemporalType.TIME);
+ idMapping.addGeneratedValue();
+ idMapping.getGeneratorContainer().addTableGenerator();
+ idMapping.getGeneratorContainer().addSequenceGenerator();
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(idMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof ManyToOneMapping);
+
+ assertNotNull(resourceField.getAnnotation(IdAnnotation.ANNOTATION_NAME));//ManyToOne with Id annotation is valid in JPA 2.0
+ assertNotNull(resourceField.getAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToManyToManyMapping() throws Exception {
+ createTestEntityWithIdMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ IdMapping idMapping = (IdMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(idMapping.isDefault());
+ idMapping.getColumn().setSpecifiedName("FOO");
+ idMapping.setConverter(TemporalConverter.class);
+ ((TemporalConverter) idMapping.getConverter()).setTemporalType(TemporalType.TIME);
+ idMapping.addGeneratedValue();
+ idMapping.getGeneratorContainer().addTableGenerator();
+ idMapping.getGeneratorContainer().addSequenceGenerator();
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(idMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof ManyToManyMapping);
+
+ assertNull(resourceField.getAnnotation(IdAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME));
+ }
+
+
+ public void testMorphToElementCollectionMapping() throws Exception {
+ createTestEntityWithIdMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ IdMapping idMapping = (IdMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(idMapping.isDefault());
+ idMapping.getColumn().setSpecifiedName("FOO");
+ idMapping.setConverter(TemporalConverter.class);
+ ((TemporalConverter) idMapping.getConverter()).setTemporalType(TemporalType.TIME);
+ idMapping.addGeneratedValue();
+ idMapping.getGeneratorContainer().addTableGenerator();
+ idMapping.getGeneratorContainer().addSequenceGenerator();
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(idMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof ElementCollectionMapping2_0);
+
+ assertNull(resourceField.getAnnotation(IdAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME));
+ }
+}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaManyToManyMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaManyToManyMapping2_0Tests.java
index fcdcf70534..40d500277c 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaManyToManyMapping2_0Tests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaManyToManyMapping2_0Tests.java
@@ -18,30 +18,55 @@ import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.common.core.resource.java.NestableAnnotation;
import org.eclipse.jpt.common.core.tests.internal.projects.TestJavaProject.SourceWriter;
import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
+import org.eclipse.jpt.jpa.core.MappingKeys;
import org.eclipse.jpt.jpa.core.context.AttributeMapping;
import org.eclipse.jpt.jpa.core.context.BasicMapping;
import org.eclipse.jpt.jpa.core.context.Embeddable;
+import org.eclipse.jpt.jpa.core.context.EmbeddedIdMapping;
+import org.eclipse.jpt.jpa.core.context.EmbeddedMapping;
import org.eclipse.jpt.jpa.core.context.Entity;
+import org.eclipse.jpt.jpa.core.context.IdMapping;
import org.eclipse.jpt.jpa.core.context.JoinTableRelationshipStrategy;
import org.eclipse.jpt.jpa.core.context.ManyToManyMapping;
+import org.eclipse.jpt.jpa.core.context.ManyToOneMapping;
+import org.eclipse.jpt.jpa.core.context.OneToManyMapping;
+import org.eclipse.jpt.jpa.core.context.OneToOneMapping;
import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.ReadOnlyAttributeOverride;
+import org.eclipse.jpt.jpa.core.context.TransientMapping;
+import org.eclipse.jpt.jpa.core.context.VersionMapping;
import org.eclipse.jpt.jpa.core.context.java.JavaAttributeOverride;
import org.eclipse.jpt.jpa.core.context.java.JavaAttributeOverrideContainer;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpa.core.context.java.JavaVirtualAttributeOverride;
import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
+import org.eclipse.jpt.jpa.core.jpa2.MappingKeys2_0;
+import org.eclipse.jpt.jpa.core.jpa2.context.ElementCollectionMapping2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.ManyToManyMapping2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.OrderColumn2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.Orderable2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaManyToManyMapping2_0;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.Access2_0Annotation;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.ElementCollection2_0Annotation;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.JPA2_0;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapKeyClass2_0Annotation;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapKeyColumn2_0Annotation;
import org.eclipse.jpt.jpa.core.resource.java.AttributeOverrideAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.BasicAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.EmbeddedAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.EmbeddedIdAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.IdAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.JPA;
+import org.eclipse.jpt.jpa.core.resource.java.JoinTableAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.ManyToManyAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.ManyToOneAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.MapKeyAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.OneToManyAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.OneToOneAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.OrderByAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.TransientAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.VersionAnnotation;
import org.eclipse.jpt.jpa.core.tests.internal.jpa2.context.Generic2_0ContextModelTestCase;
@SuppressWarnings("nls")
@@ -314,6 +339,268 @@ public class GenericJavaManyToManyMapping2_0Tests
this.javaProject.createCompilationUnit(PACKAGE_NAME, "PropertyInfo.java", sourceWriter);
}
+
+ public void testMorphToBasicMapping() throws Exception {
+ createTestEntityWithValidManyToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ manyToManyMapping.getOrderable().setSpecifiedOrderBy("asdf");
+ manyToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable().setSpecifiedName("FOO");
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(manyToManyMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof BasicMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(BasicAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToDefault() throws Exception {
+ createTestEntityWithValidManyToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ manyToManyMapping.getOrderable().setSpecifiedOrderBy("asdf");
+ manyToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable().setSpecifiedName("FOO");
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(manyToManyMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToVersionMapping() throws Exception {
+ createTestEntityWithValidManyToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ manyToManyMapping.getOrderable().setSpecifiedOrderBy("asdf");
+ manyToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable().setSpecifiedName("FOO");
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(manyToManyMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof VersionMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(VersionAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToIdMapping() throws Exception {
+ createTestEntityWithValidManyToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ manyToManyMapping.getOrderable().setSpecifiedOrderBy("asdf");
+ manyToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable().setSpecifiedName("FOO");
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(manyToManyMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof IdMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(IdAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToEmbeddedMapping() throws Exception {
+ createTestEntityWithValidManyToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ manyToManyMapping.getOrderable().setSpecifiedOrderBy("asdf");
+ manyToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable().setSpecifiedName("FOO");
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(manyToManyMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof EmbeddedMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToEmbeddedIdMapping() throws Exception {
+ createTestEntityWithValidManyToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ manyToManyMapping.getOrderable().setSpecifiedOrderBy("asdf");
+ manyToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable().setSpecifiedName("FOO");
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(manyToManyMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof EmbeddedIdMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToTransientMapping() throws Exception {
+ createTestEntityWithValidManyToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ manyToManyMapping.getOrderable().setSpecifiedOrderBy("asdf");
+ manyToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable().setSpecifiedName("FOO");
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(manyToManyMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof TransientMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(TransientAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToOneToOneMapping() throws Exception {
+ createTestEntityWithValidManyToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ manyToManyMapping.getOrderable().setSpecifiedOrderBy("asdf");
+ manyToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable().setSpecifiedName("FOO");
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(manyToManyMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof OneToOneMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToOneToManyMapping() throws Exception {
+ createTestEntityWithValidManyToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ manyToManyMapping.getOrderable().setSpecifiedOrderBy("asdf");
+ manyToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable().setSpecifiedName("FOO");
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(manyToManyMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof OneToManyMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToManyToOneMapping() throws Exception {
+ createTestEntityWithValidManyToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ manyToManyMapping.getOrderable().setSpecifiedOrderBy("asdf");
+ manyToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable().setSpecifiedName("FOO");
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(manyToManyMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof ManyToOneMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToElementCollectionMapping() throws Exception {
+ createTestEntityWithValidManyToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ manyToManyMapping.getOrderable().setSpecifiedOrderBy("asdf");
+ manyToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable().setSpecifiedName("FOO");
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(manyToManyMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof ElementCollectionMapping2_0);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
public void testCandidateMappedByAttributeNames() throws Exception {
createTestEntityWithValidManyToManyMapping();
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaManyToOneMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaManyToOneMapping2_0Tests.java
index 89fbbd6135..8d38365920 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaManyToOneMapping2_0Tests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaManyToOneMapping2_0Tests.java
@@ -16,21 +16,47 @@ import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement.Kind;
import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
import org.eclipse.jpt.jpa.core.MappingKeys;
+import org.eclipse.jpt.jpa.core.context.BasicMapping;
+import org.eclipse.jpt.jpa.core.context.EmbeddedIdMapping;
+import org.eclipse.jpt.jpa.core.context.EmbeddedMapping;
+import org.eclipse.jpt.jpa.core.context.IdMapping;
+import org.eclipse.jpt.jpa.core.context.JoinColumnRelationshipStrategy;
+import org.eclipse.jpt.jpa.core.context.ManyToManyMapping;
+import org.eclipse.jpt.jpa.core.context.ManyToOneMapping;
+import org.eclipse.jpt.jpa.core.context.OneToManyMapping;
+import org.eclipse.jpt.jpa.core.context.OneToOneMapping;
import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.TransientMapping;
+import org.eclipse.jpt.jpa.core.context.VersionMapping;
import org.eclipse.jpt.jpa.core.context.java.JavaBasicMapping;
import org.eclipse.jpt.jpa.core.context.java.JavaIdMapping;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute;
+import org.eclipse.jpt.jpa.core.jpa2.MappingKeys2_0;
+import org.eclipse.jpt.jpa.core.jpa2.context.ElementCollectionMapping2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.ManyToOneMapping2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.ManyToOneRelationship2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaDerivedIdentity2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaManyToOneMapping2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOneToOneMapping2_0;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.Access2_0Annotation;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.ElementCollection2_0Annotation;
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.resource.java.BasicAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.EmbeddedAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.EmbeddedIdAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.IdAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.JPA;
+import org.eclipse.jpt.jpa.core.resource.java.JoinColumnAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.ManyToManyAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.ManyToOneAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.OneToManyAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.OneToOneAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.TransientAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.VersionAnnotation;
import org.eclipse.jpt.jpa.core.tests.internal.jpa2.context.Generic2_0ContextModelTestCase;
@SuppressWarnings("nls")
@@ -106,6 +132,257 @@ public class GenericJavaManyToOneMapping2_0Tests
}
}
+ public void testMorphToBasicMapping() throws Exception {
+ createTestEntityWithManyToOneMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ JoinColumnRelationshipStrategy joinColumns = manyToOneMapping.getRelationship().getJoinColumnStrategy();
+ joinColumns.addSpecifiedJoinColumn(0);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(manyToOneMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof BasicMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(BasicAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToDefault() throws Exception {
+ createTestEntityWithManyToOneMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ JoinColumnRelationshipStrategy joinColumns = manyToOneMapping.getRelationship().getJoinColumnStrategy();
+ joinColumns.addSpecifiedJoinColumn(0);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(manyToOneMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToVersionMapping() throws Exception {
+ createTestEntityWithManyToOneMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ JoinColumnRelationshipStrategy joinColumns = manyToOneMapping.getRelationship().getJoinColumnStrategy();
+ joinColumns.addSpecifiedJoinColumn(0);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(manyToOneMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof VersionMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(VersionAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToIdMapping() throws Exception {
+ createTestEntityWithManyToOneMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ JoinColumnRelationshipStrategy joinColumns = manyToOneMapping.getRelationship().getJoinColumnStrategy();
+ joinColumns.addSpecifiedJoinColumn(0);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(manyToOneMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof IdMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(IdAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToEmbeddedMapping() throws Exception {
+ createTestEntityWithManyToOneMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ JoinColumnRelationshipStrategy joinColumns = manyToOneMapping.getRelationship().getJoinColumnStrategy();
+ joinColumns.addSpecifiedJoinColumn(0);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(manyToOneMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof EmbeddedMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToEmbeddedIdMapping() throws Exception {
+ createTestEntityWithManyToOneMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ JoinColumnRelationshipStrategy joinColumns = manyToOneMapping.getRelationship().getJoinColumnStrategy();
+ joinColumns.addSpecifiedJoinColumn(0);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(manyToOneMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof EmbeddedIdMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToTransientMapping() throws Exception {
+ createTestEntityWithManyToOneMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ JoinColumnRelationshipStrategy joinColumns = manyToOneMapping.getRelationship().getJoinColumnStrategy();
+ joinColumns.addSpecifiedJoinColumn(0);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(manyToOneMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof TransientMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(TransientAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToOneToOneMapping() throws Exception {
+ createTestEntityWithManyToOneMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ JoinColumnRelationshipStrategy joinColumns = manyToOneMapping.getRelationship().getJoinColumnStrategy();
+ joinColumns.addSpecifiedJoinColumn(0);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(manyToOneMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof OneToOneMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToOneToManyMapping() throws Exception {
+ createTestEntityWithManyToOneMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ JoinColumnRelationshipStrategy joinColumns = manyToOneMapping.getRelationship().getJoinColumnStrategy();
+ joinColumns.addSpecifiedJoinColumn(0);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(manyToOneMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof OneToManyMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToManyToManyMapping() throws Exception {
+ createTestEntityWithManyToOneMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ JoinColumnRelationshipStrategy joinColumns = manyToOneMapping.getRelationship().getJoinColumnStrategy();
+ joinColumns.addSpecifiedJoinColumn(0);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(manyToOneMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof ManyToManyMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToElementCollectionMapping() throws Exception {
+ createTestEntityWithManyToOneMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ ManyToOneMapping manyToOneMapping = (ManyToOneMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ JoinColumnRelationshipStrategy joinColumns = manyToOneMapping.getRelationship().getJoinColumnStrategy();
+ joinColumns.addSpecifiedJoinColumn(0);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(manyToOneMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof ElementCollectionMapping2_0);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
public void testUpdateId() throws Exception {
createTestEntityWithIdDerivedIdentity();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaOneToManyMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaOneToManyMapping2_0Tests.java
index 08c34867c0..498dd1085d 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaOneToManyMapping2_0Tests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaOneToManyMapping2_0Tests.java
@@ -19,15 +19,24 @@ import org.eclipse.jpt.common.core.resource.java.NestableAnnotation;
import org.eclipse.jpt.common.core.tests.internal.projects.TestJavaProject.SourceWriter;
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;
import org.eclipse.jpt.jpa.core.context.AttributeMapping;
import org.eclipse.jpt.jpa.core.context.BasicMapping;
import org.eclipse.jpt.jpa.core.context.Embeddable;
+import org.eclipse.jpt.jpa.core.context.EmbeddedIdMapping;
+import org.eclipse.jpt.jpa.core.context.EmbeddedMapping;
import org.eclipse.jpt.jpa.core.context.Entity;
+import org.eclipse.jpt.jpa.core.context.IdMapping;
import org.eclipse.jpt.jpa.core.context.JoinColumn;
import org.eclipse.jpt.jpa.core.context.JoinColumnRelationship;
+import org.eclipse.jpt.jpa.core.context.ManyToManyMapping;
+import org.eclipse.jpt.jpa.core.context.ManyToOneMapping;
import org.eclipse.jpt.jpa.core.context.OneToManyMapping;
+import org.eclipse.jpt.jpa.core.context.OneToOneMapping;
import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
import org.eclipse.jpt.jpa.core.context.ReadOnlyAttributeOverride;
+import org.eclipse.jpt.jpa.core.context.TransientMapping;
+import org.eclipse.jpt.jpa.core.context.VersionMapping;
import org.eclipse.jpt.jpa.core.context.java.JavaAttributeOverride;
import org.eclipse.jpt.jpa.core.context.java.JavaAttributeOverrideContainer;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
@@ -40,14 +49,26 @@ import org.eclipse.jpt.jpa.core.jpa2.context.Orderable2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOneToManyMapping2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOrphanRemovable2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOrphanRemovalHolder2_0;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.Access2_0Annotation;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.JPA2_0;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapKeyClass2_0Annotation;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapKeyColumn2_0Annotation;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.OneToMany2_0Annotation;
import org.eclipse.jpt.jpa.core.resource.java.AttributeOverrideAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.BasicAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.EmbeddedAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.EmbeddedIdAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.IdAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.JPA;
+import org.eclipse.jpt.jpa.core.resource.java.JoinTableAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.ManyToManyAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.ManyToOneAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.MapKeyAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.OneToManyAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.OneToOneAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.OrderByAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.TransientAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.VersionAnnotation;
import org.eclipse.jpt.jpa.core.tests.internal.jpa2.context.Generic2_0ContextModelTestCase;
@SuppressWarnings("nls")
@@ -340,6 +361,244 @@ public class GenericJavaOneToManyMapping2_0Tests
this.javaProject.createCompilationUnit(PACKAGE_NAME, "PropertyInfo.java", sourceWriter);
}
+ public void testMorphToBasicMapping() throws Exception {
+ createTestEntityWithValidOneToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ oneToManyMapping.getOrderable().setSpecifiedOrderBy("asdf");
+ oneToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable().setSpecifiedName("FOO");
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(oneToManyMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof BasicMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(BasicAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToDefault() throws Exception {
+ createTestEntityWithValidOneToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ oneToManyMapping.getOrderable().setSpecifiedOrderBy("asdf");
+ oneToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable().setSpecifiedName("FOO");
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(oneToManyMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToVersionMapping() throws Exception {
+ createTestEntityWithValidOneToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ oneToManyMapping.getOrderable().setSpecifiedOrderBy("asdf");
+ oneToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable().setSpecifiedName("FOO");
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(oneToManyMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof VersionMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(VersionAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToIdMapping() throws Exception {
+ createTestEntityWithValidOneToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ oneToManyMapping.getOrderable().setSpecifiedOrderBy("asdf");
+ oneToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable().setSpecifiedName("FOO");
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(oneToManyMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof IdMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(IdAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToEmbeddedMapping() throws Exception {
+ createTestEntityWithValidOneToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ oneToManyMapping.getOrderable().setSpecifiedOrderBy("asdf");
+ oneToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable().setSpecifiedName("FOO");
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(oneToManyMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof EmbeddedMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToEmbeddedIdMapping() throws Exception {
+ createTestEntityWithValidOneToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ oneToManyMapping.getOrderable().setSpecifiedOrderBy("asdf");
+ oneToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable().setSpecifiedName("FOO");
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(oneToManyMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof EmbeddedIdMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToTransientMapping() throws Exception {
+ createTestEntityWithValidOneToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ oneToManyMapping.getOrderable().setSpecifiedOrderBy("asdf");
+ oneToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable().setSpecifiedName("FOO");
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(oneToManyMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof TransientMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(TransientAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToOneToOneMapping() throws Exception {
+ createTestEntityWithValidOneToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ oneToManyMapping.getOrderable().setSpecifiedOrderBy("asdf");
+ oneToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable().setSpecifiedName("FOO");
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(oneToManyMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof OneToOneMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToManyToManyMapping() throws Exception {
+ createTestEntityWithValidOneToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ oneToManyMapping.getOrderable().setSpecifiedOrderBy("asdf");
+ oneToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable().setSpecifiedName("FOO");
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(oneToManyMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof ManyToManyMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToManyToOneMapping() throws Exception {
+ createTestEntityWithValidOneToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ oneToManyMapping.getOrderable().setSpecifiedOrderBy("asdf");
+ oneToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable().setSpecifiedName("FOO");
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(oneToManyMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof ManyToOneMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(OrderByAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
public void testCandidateMappedByAttributeNames() throws Exception {
createTestEntityWithValidOneToManyMapping();
createTestTargetEntityAddress();
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaOneToOneMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaOneToOneMapping2_0Tests.java
index e0549f4fdd..bd18b5f42f 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaOneToOneMapping2_0Tests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaOneToOneMapping2_0Tests.java
@@ -19,12 +19,24 @@ 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;
import org.eclipse.jpt.jpa.core.context.AttributeMapping;
+import org.eclipse.jpt.jpa.core.context.BasicMapping;
+import org.eclipse.jpt.jpa.core.context.EmbeddedIdMapping;
+import org.eclipse.jpt.jpa.core.context.EmbeddedMapping;
+import org.eclipse.jpt.jpa.core.context.IdMapping;
+import org.eclipse.jpt.jpa.core.context.JoinColumnRelationshipStrategy;
+import org.eclipse.jpt.jpa.core.context.ManyToManyMapping;
+import org.eclipse.jpt.jpa.core.context.ManyToOneMapping;
+import org.eclipse.jpt.jpa.core.context.OneToManyMapping;
import org.eclipse.jpt.jpa.core.context.OneToOneMapping;
import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.TransientMapping;
+import org.eclipse.jpt.jpa.core.context.VersionMapping;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute;
+import org.eclipse.jpt.jpa.core.jpa2.MappingKeys2_0;
+import org.eclipse.jpt.jpa.core.jpa2.context.ElementCollectionMapping2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.OneToOneMapping2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.OneToOneRelationship2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaDerivedIdentity2_0;
@@ -32,11 +44,23 @@ import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaManyToOneMapping2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOneToOneMapping2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOrphanRemovable2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOrphanRemovalHolder2_0;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.Access2_0Annotation;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.ElementCollection2_0Annotation;
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.BasicAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.EmbeddedAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.EmbeddedIdAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.IdAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.JPA;
+import org.eclipse.jpt.jpa.core.resource.java.JoinColumnAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.ManyToManyAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.ManyToOneAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.OneToManyAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.OneToOneAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.TransientAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.VersionAnnotation;
import org.eclipse.jpt.jpa.core.tests.internal.jpa2.context.Generic2_0ContextModelTestCase;
@SuppressWarnings("nls")
@@ -265,6 +289,257 @@ public class GenericJavaOneToOneMapping2_0Tests
this.javaProject.createCompilationUnit(PACKAGE_NAME, "State.java", sourceWriter);
}
+ public void testMorphToBasicMapping() throws Exception {
+ createTestEntityWithValidOneToOneMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ JoinColumnRelationshipStrategy joinColumns = oneToOneMapping.getRelationship().getJoinColumnStrategy();
+ joinColumns.addSpecifiedJoinColumn(0);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(oneToOneMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof BasicMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(BasicAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToDefault() throws Exception {
+ createTestEntityWithValidOneToOneMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ JoinColumnRelationshipStrategy joinColumns = oneToOneMapping.getRelationship().getJoinColumnStrategy();
+ joinColumns.addSpecifiedJoinColumn(0);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(oneToOneMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToVersionMapping() throws Exception {
+ createTestEntityWithValidOneToOneMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ JoinColumnRelationshipStrategy joinColumns = oneToOneMapping.getRelationship().getJoinColumnStrategy();
+ joinColumns.addSpecifiedJoinColumn(0);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(oneToOneMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof VersionMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(VersionAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToIdMapping() throws Exception {
+ createTestEntityWithValidOneToOneMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ JoinColumnRelationshipStrategy joinColumns = oneToOneMapping.getRelationship().getJoinColumnStrategy();
+ joinColumns.addSpecifiedJoinColumn(0);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(oneToOneMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof IdMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(IdAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToEmbeddedMapping() throws Exception {
+ createTestEntityWithValidOneToOneMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ JoinColumnRelationshipStrategy joinColumns = oneToOneMapping.getRelationship().getJoinColumnStrategy();
+ joinColumns.addSpecifiedJoinColumn(0);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(oneToOneMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof EmbeddedMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToEmbeddedIdMapping() throws Exception {
+ createTestEntityWithValidOneToOneMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ JoinColumnRelationshipStrategy joinColumns = oneToOneMapping.getRelationship().getJoinColumnStrategy();
+ joinColumns.addSpecifiedJoinColumn(0);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(oneToOneMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof EmbeddedIdMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToTransientMapping() throws Exception {
+ createTestEntityWithValidOneToOneMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ JoinColumnRelationshipStrategy joinColumns = oneToOneMapping.getRelationship().getJoinColumnStrategy();
+ joinColumns.addSpecifiedJoinColumn(0);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(oneToOneMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof TransientMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(TransientAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToManyToOneMapping() throws Exception {
+ createTestEntityWithValidOneToOneMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ JoinColumnRelationshipStrategy joinColumns = oneToOneMapping.getRelationship().getJoinColumnStrategy();
+ joinColumns.addSpecifiedJoinColumn(0);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(oneToOneMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof ManyToOneMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToOneToManyMapping() throws Exception {
+ createTestEntityWithValidOneToOneMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ JoinColumnRelationshipStrategy joinColumns = oneToOneMapping.getRelationship().getJoinColumnStrategy();
+ joinColumns.addSpecifiedJoinColumn(0);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(oneToOneMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof OneToManyMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToManyToManyMapping() throws Exception {
+ createTestEntityWithValidOneToOneMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ JoinColumnRelationshipStrategy joinColumns = oneToOneMapping.getRelationship().getJoinColumnStrategy();
+ joinColumns.addSpecifiedJoinColumn(0);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(oneToOneMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof ManyToManyMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToElementCollectionMapping() throws Exception {
+ createTestEntityWithValidOneToOneMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ JoinColumnRelationshipStrategy joinColumns = oneToOneMapping.getRelationship().getJoinColumnStrategy();
+ joinColumns.addSpecifiedJoinColumn(0);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(oneToOneMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof ElementCollectionMapping2_0);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ assertNull(resourceField.getAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ }
+
public void testUpdateId() throws Exception {
createTestEntityWithIdDerivedIdentity();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaVersionMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaVersionMapping2_0Tests.java
new file mode 100644
index 0000000000..5fd0a4ff32
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaVersionMapping2_0Tests.java
@@ -0,0 +1,352 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.tests.internal.jpa2.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.utility.internal.iterators.ArrayIterator;
+import org.eclipse.jpt.jpa.core.MappingKeys;
+import org.eclipse.jpt.jpa.core.context.BasicMapping;
+import org.eclipse.jpt.jpa.core.context.EmbeddedIdMapping;
+import org.eclipse.jpt.jpa.core.context.EmbeddedMapping;
+import org.eclipse.jpt.jpa.core.context.IdMapping;
+import org.eclipse.jpt.jpa.core.context.ManyToManyMapping;
+import org.eclipse.jpt.jpa.core.context.ManyToOneMapping;
+import org.eclipse.jpt.jpa.core.context.OneToManyMapping;
+import org.eclipse.jpt.jpa.core.context.OneToOneMapping;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.TemporalConverter;
+import org.eclipse.jpt.jpa.core.context.TemporalType;
+import org.eclipse.jpt.jpa.core.context.TransientMapping;
+import org.eclipse.jpt.jpa.core.context.VersionMapping;
+import org.eclipse.jpt.jpa.core.jpa2.MappingKeys2_0;
+import org.eclipse.jpt.jpa.core.jpa2.context.ElementCollectionMapping2_0;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.Access2_0Annotation;
+import org.eclipse.jpt.jpa.core.jpa2.resource.java.ElementCollection2_0Annotation;
+import org.eclipse.jpt.jpa.core.resource.java.BasicAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.ColumnAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.EmbeddedAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.EmbeddedIdAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.IdAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.JPA;
+import org.eclipse.jpt.jpa.core.resource.java.ManyToManyAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.ManyToOneAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.OneToManyAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.OneToOneAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.TemporalAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.TransientAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.VersionAnnotation;
+import org.eclipse.jpt.jpa.core.tests.internal.jpa2.context.Generic2_0ContextModelTestCase;
+
+@SuppressWarnings("nls")
+public class GenericJavaVersionMapping2_0Tests extends Generic2_0ContextModelTestCase
+{
+ private ICompilationUnit createTestEntityWithVersionMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.VERSION);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append("@Version").append(CR);
+ }
+ });
+ }
+
+ public GenericJavaVersionMapping2_0Tests(String name) {
+ super(name);
+ }
+
+ public void testMorphToBasicMapping() throws Exception {
+ createTestEntityWithVersionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ VersionMapping versionMapping = (VersionMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(versionMapping.isDefault());
+ versionMapping.getColumn().setSpecifiedName("FOO");
+ versionMapping.setConverter(TemporalConverter.class);
+ ((TemporalConverter) versionMapping.getConverter()).setTemporalType(TemporalType.TIME);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(versionMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
+ assertEquals("FOO", ((BasicMapping) persistentAttribute.getMapping()).getColumn().getSpecifiedName());
+ assertEquals(TemporalType.TIME, ((TemporalConverter) ((BasicMapping) persistentAttribute.getMapping()).getConverter()).getTemporalType());
+
+ assertNull(resourceField.getAnnotation(VersionAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(BasicAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToDefault() throws Exception {
+ createTestEntityWithVersionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ VersionMapping versionMapping = (VersionMapping) persistentAttribute.getMapping();
+ assertFalse(versionMapping.isDefault());
+ versionMapping.getColumn().setSpecifiedName("FOO");
+ versionMapping.setConverter(TemporalConverter.class);
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ ((TemporalConverter) versionMapping.getConverter()).setTemporalType(TemporalType.TIME);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(versionMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
+ assertEquals("FOO", ((BasicMapping) persistentAttribute.getMapping()).getColumn().getSpecifiedName());
+ assertEquals(TemporalType.TIME, ((TemporalConverter) ((BasicMapping) persistentAttribute.getMapping()).getConverter()).getTemporalType());
+
+ assertNull(resourceField.getAnnotation(VersionAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToIdMapping() throws Exception {
+ createTestEntityWithVersionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ VersionMapping versionMapping = (VersionMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(versionMapping.isDefault());
+ versionMapping.getColumn().setSpecifiedName("FOO");
+ versionMapping.setConverter(TemporalConverter.class);
+ ((TemporalConverter) versionMapping.getConverter()).setTemporalType(TemporalType.TIME);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(versionMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
+ assertEquals("FOO", ((IdMapping) persistentAttribute.getMapping()).getColumn().getSpecifiedName());
+ assertEquals(TemporalType.TIME, ((TemporalConverter) ((IdMapping) persistentAttribute.getMapping()).getConverter()).getTemporalType());
+
+ assertNull(resourceField.getAnnotation(VersionAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(IdAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToEmbeddedMapping() throws Exception {
+ createTestEntityWithVersionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ VersionMapping versionMapping = (VersionMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(versionMapping.isDefault());
+ versionMapping.getColumn().setSpecifiedName("FOO");
+ versionMapping.setConverter(TemporalConverter.class);
+ ((TemporalConverter) versionMapping.getConverter()).setTemporalType(TemporalType.TIME);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(versionMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof EmbeddedMapping);
+
+ assertNull(resourceField.getAnnotation(VersionAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToTransientMapping() throws Exception {
+ createTestEntityWithVersionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ VersionMapping versionMapping = (VersionMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(versionMapping.isDefault());
+ versionMapping.getColumn().setSpecifiedName("FOO");
+ versionMapping.setConverter(TemporalConverter.class);
+ ((TemporalConverter) versionMapping.getConverter()).setTemporalType(TemporalType.TIME);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(versionMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof TransientMapping);
+
+ assertNull(resourceField.getAnnotation(VersionAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(TransientAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToEmbeddedIdMapping() throws Exception {
+ createTestEntityWithVersionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ VersionMapping versionMapping = (VersionMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(versionMapping.isDefault());
+ versionMapping.getColumn().setSpecifiedName("FOO");
+ versionMapping.setConverter(TemporalConverter.class);
+ ((TemporalConverter) versionMapping.getConverter()).setTemporalType(TemporalType.TIME);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(versionMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof EmbeddedIdMapping);
+
+ assertNull(resourceField.getAnnotation(VersionAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToOneToOneMapping() throws Exception {
+ createTestEntityWithVersionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ VersionMapping versionMapping = (VersionMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(versionMapping.isDefault());
+ versionMapping.getColumn().setSpecifiedName("FOO");
+ versionMapping.setConverter(TemporalConverter.class);
+ ((TemporalConverter) versionMapping.getConverter()).setTemporalType(TemporalType.TIME);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(versionMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof OneToOneMapping);
+
+ assertNull(resourceField.getAnnotation(VersionAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(OneToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToOneToManyMapping() throws Exception {
+ createTestEntityWithVersionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ VersionMapping versionMapping = (VersionMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(versionMapping.isDefault());
+ versionMapping.getColumn().setSpecifiedName("FOO");
+ versionMapping.setConverter(TemporalConverter.class);
+ ((TemporalConverter) versionMapping.getConverter()).setTemporalType(TemporalType.TIME);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(versionMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof OneToManyMapping);
+
+ assertNull(resourceField.getAnnotation(VersionAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToManyToOneMapping() throws Exception {
+ createTestEntityWithVersionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ VersionMapping versionMapping = (VersionMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(versionMapping.isDefault());
+ versionMapping.getColumn().setSpecifiedName("FOO");
+ versionMapping.setConverter(TemporalConverter.class);
+ ((TemporalConverter) versionMapping.getConverter()).setTemporalType(TemporalType.TIME);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(versionMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof ManyToOneMapping);
+
+ assertNull(resourceField.getAnnotation(VersionAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToManyToManyMapping() throws Exception {
+ createTestEntityWithVersionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ VersionMapping versionMapping = (VersionMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(versionMapping.isDefault());
+ versionMapping.getColumn().setSpecifiedName("FOO");
+ versionMapping.setConverter(TemporalConverter.class);
+ ((TemporalConverter) versionMapping.getConverter()).setTemporalType(TemporalType.TIME);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(versionMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof ManyToManyMapping);
+
+ assertNull(resourceField.getAnnotation(VersionAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToElementCollectionMapping() throws Exception {
+ createTestEntityWithVersionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().getAttributes().iterator().next();
+ VersionMapping versionMapping = (VersionMapping) persistentAttribute.getMapping();
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ JavaResourceField resourceField = resourceType.getFields().iterator().next();
+ assertFalse(versionMapping.isDefault());
+ versionMapping.getColumn().setSpecifiedName("FOO");
+ versionMapping.setConverter(TemporalConverter.class);
+ ((TemporalConverter) versionMapping.getConverter()).setTemporalType(TemporalType.TIME);
+ resourceField.addAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ assertFalse(versionMapping.isDefault());
+
+ persistentAttribute.setMappingKey(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof ElementCollectionMapping2_0);
+
+ assertNull(resourceField.getAnnotation(VersionAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(Access2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(ColumnAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceField.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
+ }
+}

Back to the top