Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2010-01-20 19:32:23 +0000
committerkmoore2010-01-20 19:32:23 +0000
commit9f740257dc53d20a619e4b6784356586fe1e046b (patch)
treed489647d280e2badde9fd5002a1d0f54e25989c1
parent27d01d75a983a052cbd902cd705c18f294d89ff9 (diff)
downloadwebtools.dali-9f740257dc53d20a619e4b6784356586fe1e046b.tar.gz
webtools.dali-9f740257dc53d20a619e4b6784356586fe1e046b.tar.xz
webtools.dali-9f740257dc53d20a619e4b6784356586fe1e046b.zip
300091 - metamodel generation support for Maps, handle MapKey and MapKeyClass on 1-m, m-m and element collection
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/model/jpaResourceModels.genmodel26
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/model/orm.ecore29
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/CollectionMapping.java49
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/MultiRelationshipMapping.java26
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaPersistentAttribute.java64
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/MappingTools.java18
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java83
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaPersistentAttribute.java97
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java96
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmPersistentAttribute.java53
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualMapKey.java18
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlManyToMany.java16
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlOneToMany.java11
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmAttributeOverrideContainer.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaElementCollectionMapping2_0.java325
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaPersistentAttribute2_0.java26
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmElementCollectionMapping2_0.java308
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualMapKeyClass.java33
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlElementCollection2_0.java38
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlManyToMany2_0.java27
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlOneToMany2_0.java19
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/ElementCollectionMapping2_0.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/PersistentAttribute2_0.java43
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/java/JavaPersistentAttribute2_0.java25
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/orm/OrmPersistentAttribute2_0.java28
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/AbstractXmlMultiRelationshipMapping.java416
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/MapKey.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/OrmPackage.java127
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/XmlManyToMany.java539
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/XmlOneToMany.java415
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/v2_0/OrmV2_0Package.java562
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/v2_0/XmlManyToMany_2_0.java163
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/v2_0/XmlMultiRelationshipMapping_2_0.java187
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/v2_0/XmlOneToMany_2_0.java163
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkPersistentAttribute.java24
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/VirtualEclipseLinkXmlManyToMany.java5
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v1_1/context/orm/VirtualEclipseLinkXmlManyToMany1_1.java5
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/context/orm/EclipseLinkOrmXml2_0ContextNodeFactory.java10
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/context/orm/VirtualEclipseLinkXmlElementCollection2_0.java32
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/context/orm/VirtualEclipseLinkXmlManyToMany2_0.java211
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/context/orm/VirtualEclipseLinkXmlOneToMany2_0.java233
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/orm/EclipseLinkOrmPackage.java52
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToManyMappingTests.java87
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToManyMappingTests.java88
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmManyToManyMappingTests.java167
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmOneToManyMappingTests.java147
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaElementCollectionMapping2_0Tests.java261
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaManyToManyMapping2_0Tests.java269
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaOneToManyMapping2_0Tests.java281
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/orm/GenericOrmElementCollectionMapping2_0Tests.java295
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/orm/GenericOrmManyToManyMapping2_0Tests.java273
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/orm/GenericOrmOneToManyMapping2_0Tests.java286
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmOneToManyMappingTests.java208
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaElementCollectionMappingTests.java930
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaManyToManyMappingTests.java537
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaOneToManyMappingTests.java342
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/JptEclipseLink2_0JavaContextModelTests.java2
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/orm/EclipseLink2_0OrmElementCollectionMappingTests.java878
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/orm/EclipseLink2_0OrmManyToManyMappingTests.java429
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/orm/EclipseLink2_0OrmOneToManyMappingTests.java296
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/orm/JptEclipseLink2_0OrmContextModelTests.java2
61 files changed, 8436 insertions, 1957 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/model/jpaResourceModels.genmodel b/jpa/plugins/org.eclipse.jpt.core/model/jpaResourceModels.genmodel
index 185b36b684..5941aceaae 100644
--- a/jpa/plugins/org.eclipse.jpt.core/model/jpaResourceModels.genmodel
+++ b/jpa/plugins/org.eclipse.jpt.core/model/jpaResourceModels.genmodel
@@ -391,31 +391,25 @@
<genClasses image="false" ecoreClass="orm.ecore#//v2_0/XmlGenerator_2_0">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute orm.ecore#//v2_0/XmlGenerator_2_0/description"/>
</genClasses>
- <genClasses image="false" ecoreClass="orm.ecore#//v2_0/XmlManyToMany_2_0">
- <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference orm.ecore#//v2_0/XmlManyToMany_2_0/mapKeyClass"/>
- <genFeatures createChild="false" ecoreFeature="ecore:EAttribute orm.ecore#//v2_0/XmlManyToMany_2_0/mapKeyTemporal"/>
- <genFeatures createChild="false" ecoreFeature="ecore:EAttribute orm.ecore#//v2_0/XmlManyToMany_2_0/mapKeyEnumerated"/>
- <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference orm.ecore#//v2_0/XmlManyToMany_2_0/mapKeyAttributeOverrides"/>
- <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference orm.ecore#//v2_0/XmlManyToMany_2_0/mapKeyColumn"/>
- <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference orm.ecore#//v2_0/XmlManyToMany_2_0/mapKeyJoinColumns"/>
- </genClasses>
+ <genClasses image="false" ecoreClass="orm.ecore#//v2_0/XmlManyToMany_2_0"/>
<genClasses image="false" ecoreClass="orm.ecore#//v2_0/XmlMapKeyClass_2_0">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute orm.ecore#//v2_0/XmlMapKeyClass_2_0/className"/>
</genClasses>
<genClasses image="false" ecoreClass="orm.ecore#//v2_0/XmlMapsId_2_0">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute orm.ecore#//v2_0/XmlMapsId_2_0/mapsId"/>
</genClasses>
+ <genClasses image="false" ecoreClass="orm.ecore#//v2_0/XmlMultiRelationshipMapping_2_0">
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference orm.ecore#//v2_0/XmlMultiRelationshipMapping_2_0/mapKeyClass"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute orm.ecore#//v2_0/XmlMultiRelationshipMapping_2_0/mapKeyTemporal"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute orm.ecore#//v2_0/XmlMultiRelationshipMapping_2_0/mapKeyEnumerated"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference orm.ecore#//v2_0/XmlMultiRelationshipMapping_2_0/mapKeyAttributeOverrides"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference orm.ecore#//v2_0/XmlMultiRelationshipMapping_2_0/mapKeyColumn"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference orm.ecore#//v2_0/XmlMultiRelationshipMapping_2_0/mapKeyJoinColumns"/>
+ </genClasses>
<genClasses image="false" ecoreClass="orm.ecore#//v2_0/XmlNamedQuery_2_0">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute orm.ecore#//v2_0/XmlNamedQuery_2_0/lockMode"/>
</genClasses>
- <genClasses image="false" ecoreClass="orm.ecore#//v2_0/XmlOneToMany_2_0">
- <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference orm.ecore#//v2_0/XmlOneToMany_2_0/mapKeyClass"/>
- <genFeatures createChild="false" ecoreFeature="ecore:EAttribute orm.ecore#//v2_0/XmlOneToMany_2_0/mapKeyTemporal"/>
- <genFeatures createChild="false" ecoreFeature="ecore:EAttribute orm.ecore#//v2_0/XmlOneToMany_2_0/mapKeyEnumerated"/>
- <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference orm.ecore#//v2_0/XmlOneToMany_2_0/mapKeyAttributeOverrides"/>
- <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference orm.ecore#//v2_0/XmlOneToMany_2_0/mapKeyColumn"/>
- <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference orm.ecore#//v2_0/XmlOneToMany_2_0/mapKeyJoinColumns"/>
- </genClasses>
+ <genClasses image="false" ecoreClass="orm.ecore#//v2_0/XmlOneToMany_2_0"/>
<genClasses image="false" ecoreClass="orm.ecore#//v2_0/XmlOneToOne_2_0"/>
<genClasses image="false" ecoreClass="orm.ecore#//v2_0/XmlOrderColumn_2_0">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute orm.ecore#//v2_0/XmlOrderColumn_2_0/nullable"/>
diff --git a/jpa/plugins/org.eclipse.jpt.core/model/orm.ecore b/jpa/plugins/org.eclipse.jpt.core/model/orm.ecore
index cd9ad31b95..8dc7fe9698 100644
--- a/jpa/plugins/org.eclipse.jpt.core/model/orm.ecore
+++ b/jpa/plugins/org.eclipse.jpt.core/model/orm.ecore
@@ -15,7 +15,7 @@
<eClassifiers xsi:type="ecore:EClass" name="AbstractXmlEmbedded" abstract="true"
eSuperTypes="#//AbstractXmlAttributeMapping #//XmlAttributeOverrideContainer"/>
<eClassifiers xsi:type="ecore:EClass" name="AbstractXmlMultiRelationshipMapping"
- abstract="true" eSuperTypes="#//AbstractXmlRelationshipMapping #//XmlMappedByMapping #//XmlJoinTableMapping #//XmlOrderable">
+ abstract="true" eSuperTypes="#//AbstractXmlRelationshipMapping #//XmlMappedByMapping #//XmlJoinTableMapping #//XmlOrderable #//v2_0/XmlMultiRelationshipMapping_2_0">
<eStructuralFeatures xsi:type="ecore:EReference" name="mapKey" eType="#//MapKey"
containment="true" resolveProxies="false"/>
</eClassifiers>
@@ -483,18 +483,7 @@
<eStructuralFeatures xsi:type="ecore:EAttribute" name="description" eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//String"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="XmlManyToMany_2_0" abstract="true"
- interface="true" eSuperTypes="#//v2_0/XmlOrderable_2_0">
- <eStructuralFeatures xsi:type="ecore:EReference" name="mapKeyClass" eType="#//XmlMapKeyClass"
- containment="true" resolveProxies="false"/>
- <eStructuralFeatures xsi:type="ecore:EAttribute" name="mapKeyTemporal" eType="#//TemporalType"/>
- <eStructuralFeatures xsi:type="ecore:EAttribute" name="mapKeyEnumerated" eType="#//EnumType"/>
- <eStructuralFeatures xsi:type="ecore:EReference" name="mapKeyAttributeOverrides"
- upperBound="-1" eType="#//XmlAttributeOverride" containment="true" resolveProxies="false"/>
- <eStructuralFeatures xsi:type="ecore:EReference" name="mapKeyColumn" eType="#//XmlColumn"
- containment="true" resolveProxies="false"/>
- <eStructuralFeatures xsi:type="ecore:EReference" name="mapKeyJoinColumns" upperBound="-1"
- eType="#//XmlJoinColumn" containment="true" resolveProxies="false"/>
- </eClassifiers>
+ interface="true" eSuperTypes="#//v2_0/XmlMultiRelationshipMapping_2_0"/>
<eClassifiers xsi:type="ecore:EClass" name="XmlMapKeyClass_2_0" abstract="true"
interface="true">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="className" lowerBound="1"
@@ -503,12 +492,8 @@
<eClassifiers xsi:type="ecore:EClass" name="XmlMapsId_2_0" abstract="true" interface="true">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="mapsId" eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//String"/>
</eClassifiers>
- <eClassifiers xsi:type="ecore:EClass" name="XmlNamedQuery_2_0" abstract="true"
- interface="true">
- <eStructuralFeatures xsi:type="ecore:EAttribute" name="lockMode" eType="#//v2_0/LockModeType_2_0"/>
- </eClassifiers>
- <eClassifiers xsi:type="ecore:EClass" name="XmlOneToMany_2_0" abstract="true"
- interface="true" eSuperTypes="#//v2_0/XmlOrphanRemovable_2_0 #//v2_0/XmlOrderable_2_0">
+ <eClassifiers xsi:type="ecore:EClass" name="XmlMultiRelationshipMapping_2_0" abstract="true"
+ interface="true" eSuperTypes="#//v2_0/XmlOrderable_2_0">
<eStructuralFeatures xsi:type="ecore:EReference" name="mapKeyClass" eType="#//XmlMapKeyClass"
containment="true" resolveProxies="false"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="mapKeyTemporal" eType="#//TemporalType"/>
@@ -520,6 +505,12 @@
<eStructuralFeatures xsi:type="ecore:EReference" name="mapKeyJoinColumns" upperBound="-1"
eType="#//XmlJoinColumn" containment="true" resolveProxies="false"/>
</eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="XmlNamedQuery_2_0" abstract="true"
+ interface="true">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="lockMode" eType="#//v2_0/LockModeType_2_0"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="XmlOneToMany_2_0" abstract="true"
+ interface="true" eSuperTypes="#//v2_0/XmlMultiRelationshipMapping_2_0 #//v2_0/XmlOrphanRemovable_2_0"/>
<eClassifiers xsi:type="ecore:EClass" name="XmlOneToOne_2_0" abstract="true" interface="true"
eSuperTypes="#//v2_0/XmlSingleRelationshipMapping_2_0 #//v2_0/XmlOrphanRemovable_2_0"/>
<eClassifiers xsi:type="ecore:EClass" name="XmlOrderColumn_2_0" abstract="true"
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/CollectionMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/CollectionMapping.java
index 174b466561..d420ba9c5a 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/CollectionMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/CollectionMapping.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2010 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.
@@ -9,6 +9,8 @@
******************************************************************************/
package org.eclipse.jpt.core.context;
+import java.util.Iterator;
+
/**
* 1:m, m:m, element collection are all collection mappings.
* <p>
@@ -24,5 +26,50 @@ public interface CollectionMapping
FetchType DEFAULT_FETCH_TYPE = FetchType.LAZY;
Orderable getOrderable();
+
+ PersistentType getResolvedTargetType();
+
+
+ //**************** map key *****************
+
+ String getMapKey();
+
+ String getSpecifiedMapKey();
+ void setSpecifiedMapKey(String mapKey);
+ String SPECIFIED_MAP_KEY_PROPERTY = "specifiedMapKey"; //$NON-NLS-1$
+
+ boolean isNoMapKey();
+ void setNoMapKey(boolean noMapKey);
+ String NO_MAP_KEY_PROPERTY = "noMapKey"; //$NON-NLS-1$
+
+ boolean isPkMapKey();
+ void setPkMapKey(boolean pkMapKey);
+ String PK_MAP_KEY_PROPERTY = "pkMapKey"; //$NON-NLS-1$
+
+ boolean isCustomMapKey();
+ void setCustomMapKey(boolean customMapKey);
+ String CUSTOM_MAP_KEY_PROPERTY = "customMapKey"; //$NON-NLS-1$
+
+ Iterator<String> candidateMapKeyNames();
+
+ String getMetamodelFieldMapKeyTypeName();
+
+
+ // **************** map key class **************************************
+
+ String getMapKeyClass();
+
+ String getSpecifiedMapKeyClass();
+ void setSpecifiedMapKeyClass(String value);
+ String SPECIFIED_MAP_KEY_CLASS_PROPERTY = "specifiedMapKeyClass"; //$NON-NLS-1$
+
+ String getDefaultMapKeyClass();
+ String DEFAULT_MAP_KEY_CLASS_PROPERTY = "defaultMapKeyClass"; //$NON-NLS-1$
+
+ /**
+ * Return the char to be used for browsing or creating the map key class IType.
+ * @see org.eclipse.jdt.core.IType#getFullyQualifiedName(char)
+ */
+ char getMapKeyClassEnclosingTypeSeparator();
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/MultiRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/MultiRelationshipMapping.java
index ccb7c35a61..bb30f605aa 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/MultiRelationshipMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/MultiRelationshipMapping.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2006, 2010 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.
@@ -9,8 +9,6 @@
******************************************************************************/
package org.eclipse.jpt.core.context;
-import java.util.Iterator;
-
/**
* Multi-valued (1:m, m:m) relationship mapping.
* <p>
@@ -23,26 +21,4 @@ import java.util.Iterator;
public interface MultiRelationshipMapping
extends RelationshipMapping, CollectionMapping
{
-
- String getMapKey();
-
- String getSpecifiedMapKey();
- void setSpecifiedMapKey(String mapKey);
- String SPECIFIED_MAP_KEY_PROPERTY = "specifiedMapKey"; //$NON-NLS-1$
-
- boolean isNoMapKey();
- void setNoMapKey(boolean noMapKey);
- String NO_MAP_KEY_PROPERTY = "noMapKey"; //$NON-NLS-1$
-
- boolean isPkMapKey();
- void setPkMapKey(boolean pkMapKey);
- String PK_MAP_KEY_PROPERTY = "pkMapKey"; //$NON-NLS-1$
-
- boolean isCustomMapKey();
- void setCustomMapKey(boolean customMapKey);
- String CUSTOM_MAP_KEY_PROPERTY = "customMapKey"; //$NON-NLS-1$
-
- Iterator<String> candidateMapKeyNames();
-
- String getMetamodelFieldMapKeyTypeName();
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaPersistentAttribute.java
index 47e004b0c5..4e219c3bab 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaPersistentAttribute.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaPersistentAttribute.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2006, 2010 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.
@@ -10,8 +10,10 @@
package org.eclipse.jpt.core.context.java;
import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.context.CollectionMapping;
import org.eclipse.jpt.core.context.Embeddable;
import org.eclipse.jpt.core.context.PersistentAttribute;
+import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0;
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
/**
@@ -109,4 +111,64 @@ public interface JavaPersistentAttribute
*/
String getMultiReferenceTargetTypeName();
+ /**
+ * If the attribute's type is a map type,
+ * return the type parameter that can be used as a key type.
+ * Return null if the attribute is not a map or if the type
+ * parameter is not valid as a key type (i.e. it is either
+ * an array or a "container").
+ */
+ String getMultiReferenceMapKeyTypeName();
+
+ /**
+ * Return the JpaContainer that corresponds to this attribute's type.
+ * Return a null implementation if the type is not a container (map or collection)
+ */
+ JpaContainer getJpaContainer();
+
+ /**
+ * JPA container interface (and null implementation)
+ */
+ interface JpaContainer {
+ String getTypeName();
+ boolean isContainer();
+ String getMultiReferenceTargetTypeName(JavaResourcePersistentAttribute resourcePersistentAttribute);
+ String getMultiReferenceMapKeyTypeName(JavaResourcePersistentAttribute resourcePersistentAttribute);
+ String getMetamodelContainerFieldTypeName();
+ String getMetamodelContainerFieldMapKeyTypeName(CollectionMapping mapping);
+
+ final class Null implements JpaContainer {
+ public static final JpaContainer INSTANCE = new Null();
+ public static JpaContainer instance() {
+ return INSTANCE;
+ }
+ // ensure single instance
+ private Null() {
+ super();
+ }
+ public String getTypeName() {
+ return null;
+ }
+ public boolean isContainer() {
+ return false;
+ }
+ public String getMultiReferenceTargetTypeName(JavaResourcePersistentAttribute resourcePersistentAttribute) {
+ return null;
+ }
+ public String getMultiReferenceMapKeyTypeName(JavaResourcePersistentAttribute resourcePersistentAttribute) {
+ return null;
+ }
+ public String getMetamodelContainerFieldTypeName() {
+ return JPA2_0.COLLECTION_ATTRIBUTE;
+ }
+ public String getMetamodelContainerFieldMapKeyTypeName(CollectionMapping mapping) {
+ return null;
+ }
+ @Override
+ public String toString() {
+ return "JpaContainer.Null"; //$NON-NLS-1$
+ }
+ }
+ }
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/MappingTools.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/MappingTools.java
index 7a69eed780..516d678f54 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/MappingTools.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/MappingTools.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2006, 2010 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.
@@ -11,12 +11,12 @@ package org.eclipse.jpt.core.internal.context;
import java.util.Iterator;
import org.eclipse.jpt.core.context.AttributeMapping;
+import org.eclipse.jpt.core.context.CollectionMapping;
import org.eclipse.jpt.core.context.Column;
import org.eclipse.jpt.core.context.ColumnMapping;
import org.eclipse.jpt.core.context.Entity;
import org.eclipse.jpt.core.context.JoinColumn;
import org.eclipse.jpt.core.context.JoinTable;
-import org.eclipse.jpt.core.context.MultiRelationshipMapping;
import org.eclipse.jpt.core.context.PersistentAttribute;
import org.eclipse.jpt.core.context.PersistentType;
import org.eclipse.jpt.core.context.ReferenceTable;
@@ -230,16 +230,14 @@ public class MappingTools {
}
}
- public static String getMetamodelFieldMapKeyTypeName(MultiRelationshipMapping mapping) {
- Entity targetEntity = mapping.getResolvedTargetEntity();
- if (targetEntity == null) {
- return MetamodelField.DEFAULT_TYPE_NAME;
- }
+ public static String getMetamodelFieldMapKeyTypeName(CollectionMapping mapping) {
+ PersistentType targetType = mapping.getResolvedTargetType();
String mapKey = mapping.getMapKey();
- if (mapKey == null) {
- return MetamodelField.DEFAULT_TYPE_NAME;
+ if (mapKey == null || targetType == null) {
+ String mapKeyClass = mapping.getMapKeyClass();
+ return mapKeyClass != null ? mapKeyClass : MetamodelField.DEFAULT_TYPE_NAME;
}
- PersistentAttribute mapKeyAttribute = targetEntity.getPersistentType().resolveAttribute(mapKey);
+ PersistentAttribute mapKeyAttribute = targetType.resolveAttribute(mapKey);
if (mapKeyAttribute == null) {
return MetamodelField.DEFAULT_TYPE_NAME;
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java
index b63fef8748..0545a41f13 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java
@@ -16,12 +16,14 @@ import java.util.Vector;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.context.FetchType;
+import org.eclipse.jpt.core.context.PersistentType;
import org.eclipse.jpt.core.context.java.JavaMultiRelationshipMapping;
import org.eclipse.jpt.core.context.java.JavaOrderable;
import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.core.internal.context.MappingTools;
import org.eclipse.jpt.core.jpa2.context.java.JavaPersistentAttribute2_0;
import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0;
+import org.eclipse.jpt.core.jpa2.resource.java.MapKeyClass2_0Annotation;
import org.eclipse.jpt.core.resource.java.JPA;
import org.eclipse.jpt.core.resource.java.MapKeyAnnotation;
import org.eclipse.jpt.core.resource.java.RelationshipMappingAnnotation;
@@ -45,6 +47,8 @@ public abstract class AbstractJavaMultiRelationshipMapping<T extends Relationshi
protected boolean pkMapKey = false;
protected boolean customMapKey = false;
+ protected String specifiedMapKeyClass;
+ protected String defaultMapKeyClass;
protected AbstractJavaMultiRelationshipMapping(JavaPersistentAttribute parent) {
super(parent);
@@ -56,6 +60,8 @@ public abstract class AbstractJavaMultiRelationshipMapping<T extends Relationshi
super.initialize();
this.orderable.initialize();
this.initializeMapKey();
+ this.specifiedMapKeyClass = this.getResourceMapKeyClass();
+ this.defaultMapKeyClass = this.buildDefaultMapKeyClass();
}
@Override
@@ -63,6 +69,8 @@ public abstract class AbstractJavaMultiRelationshipMapping<T extends Relationshi
super.update();
this.orderable.update();
this.updateMapKey();
+ this.setSpecifiedMapKeyClass_(this.getResourceMapKeyClass());
+ this.setDefaultMapKeyClass(this.buildDefaultMapKeyClass());
}
// ********** AbstractJavaAttributeMapping implementation **********
@@ -106,6 +114,12 @@ public abstract class AbstractJavaMultiRelationshipMapping<T extends Relationshi
}
+ // ********** CollectionMapping implementation **********
+
+ public PersistentType getResolvedTargetType() {
+ return getResolvedTargetEntity() == null ? null : getResolvedTargetEntity().getPersistentType();
+ }
+
// ********** map key **********
public String getMapKey() {
@@ -281,6 +295,75 @@ public abstract class AbstractJavaMultiRelationshipMapping<T extends Relationshi
}
+ // *************** map key class *************
+
+ public String getMapKeyClass() {
+ return (this.specifiedMapKeyClass != null) ? this.specifiedMapKeyClass : this.defaultMapKeyClass;
+ }
+
+ public String getSpecifiedMapKeyClass() {
+ return this.specifiedMapKeyClass;
+ }
+
+ public void setSpecifiedMapKeyClass(String mapKeyClass) {
+ String old = this.specifiedMapKeyClass;
+ this.specifiedMapKeyClass = mapKeyClass;
+ MapKeyClass2_0Annotation mapKeyClassAnnotation = this.getMapKeyClassAnnotation();
+ if (mapKeyClass == null) {
+ if (mapKeyClassAnnotation != null) {
+ this.removeMapKeyClassAnnotation();
+ }
+ } else {
+ if (mapKeyClassAnnotation == null) {
+ mapKeyClassAnnotation = this.addMapKeyClassAnnotation();
+ }
+ mapKeyClassAnnotation.setValue(mapKeyClass);
+ }
+
+ this.firePropertyChanged(SPECIFIED_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass);
+ }
+
+ protected void setSpecifiedMapKeyClass_(String mapKeyClass) {
+ String old = this.specifiedMapKeyClass;
+ this.specifiedMapKeyClass = mapKeyClass;
+ this.firePropertyChanged(SPECIFIED_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass);
+ }
+
+ protected String getResourceMapKeyClass() {
+ MapKeyClass2_0Annotation annotation = getMapKeyClassAnnotation();
+ return annotation == null ? null : annotation.getValue();
+ }
+
+ public String getDefaultMapKeyClass() {
+ return this.defaultMapKeyClass;
+ }
+
+ protected void setDefaultMapKeyClass(String targetClass) {
+ String old = this.defaultMapKeyClass;
+ this.defaultMapKeyClass = targetClass;
+ this.firePropertyChanged(DEFAULT_MAP_KEY_CLASS_PROPERTY, old, targetClass);
+ }
+
+ protected String buildDefaultMapKeyClass() {
+ return this.getPersistentAttribute().getMultiReferenceMapKeyTypeName();
+ }
+
+ public char getMapKeyClassEnclosingTypeSeparator() {
+ return '.';
+ }
+
+ protected MapKeyClass2_0Annotation getMapKeyClassAnnotation() {
+ return (MapKeyClass2_0Annotation) this.getResourcePersistentAttribute().getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ }
+
+ protected MapKeyClass2_0Annotation addMapKeyClassAnnotation() {
+ return (MapKeyClass2_0Annotation) this.getResourcePersistentAttribute().addAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ }
+
+ protected void removeMapKeyClassAnnotation() {
+ this.getResourcePersistentAttribute().removeAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ }
+
// ********** Java completion proposals **********
@Override
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaPersistentAttribute.java
index 0f286c5582..3d6e455c50 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaPersistentAttribute.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaPersistentAttribute.java
@@ -17,16 +17,17 @@ import org.eclipse.jdt.core.dom.Modifier;
import org.eclipse.jpt.core.JpaStructureNode;
import org.eclipse.jpt.core.MappingKeys;
import org.eclipse.jpt.core.context.AccessType;
+import org.eclipse.jpt.core.context.CollectionMapping;
import org.eclipse.jpt.core.context.Embeddable;
-import org.eclipse.jpt.core.context.MultiRelationshipMapping;
import org.eclipse.jpt.core.context.PersistentType;
import org.eclipse.jpt.core.context.TypeMapping;
import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.core.context.java.JavaStructureNodes;
import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
+import org.eclipse.jpt.core.jpa2.context.MetamodelField;
+import org.eclipse.jpt.core.jpa2.context.java.JavaPersistentAttribute2_0;
import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0;
import org.eclipse.jpt.core.resource.java.Annotation;
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
@@ -46,7 +47,7 @@ import org.eclipse.wst.validation.internal.provisional.core.IReporter;
*/
public abstract class AbstractJavaPersistentAttribute
extends AbstractJavaJpaContextNode
- implements JavaPersistentAttribute
+ implements JavaPersistentAttribute2_0
{
protected String name;
@@ -307,13 +308,13 @@ public abstract class AbstractJavaPersistentAttribute
}
public String getMultiReferenceTargetTypeName() {
- // 'typeName' may include array brackets ("[]")
- // but not generic type arguments (e.g. "<java.lang.String>")
- String typeName = this.resourcePersistentAttribute.getTypeName();
- return (typeName == null) ? null :
- this.getJpaContainer(typeName).getMultiReferenceTargetTypeName(this.resourcePersistentAttribute);
+ return this.getJpaContainer().getMultiReferenceTargetTypeName(this.resourcePersistentAttribute);
}
+ public String getMultiReferenceMapKeyTypeName() {
+ return this.getJpaContainer().getMultiReferenceMapKeyTypeName(this.resourcePersistentAttribute);
+ }
+
/**
* return whether the specified type is one of the container
* types allowed by the JPA spec
@@ -571,9 +572,34 @@ public abstract class AbstractJavaPersistentAttribute
return this.getMapping().javaCompletionProposals(pos, filter, astRoot);
}
+ // ********** metamodel **********
+
+ public String getMetamodelContainerFieldTypeName() {
+ return this.getJpaContainer().getMetamodelContainerFieldTypeName();
+ }
+
+ public String getMetamodelContainerFieldMapKeyTypeName() {
+ return this.getJpaContainer().getMetamodelContainerFieldMapKeyTypeName((CollectionMapping) this.getMapping());
+ }
+
+ public String getMetamodelTypeName() {
+ String typeName = this.resourcePersistentAttribute.getTypeName();
+ if (typeName == null) {
+ return MetamodelField.DEFAULT_TYPE_NAME;
+ }
+ if (ClassName.isPrimitive(typeName)) {
+ return ClassName.getWrapperClassName(typeName); // ???
+ }
+ return typeName;
+ }
// ********** JPA containers **********
+ public JpaContainer getJpaContainer() {
+ // 'typeName' may include array brackets ("[]")
+ // but not generic type arguments (e.g. "<java.lang.String>")
+ return getJpaContainer(this.resourcePersistentAttribute.getTypeName());
+ }
/**
* Return the JPA container corresponding to the specified type;
* return a "null" JPA container if the specified type is not one of the
@@ -596,47 +622,6 @@ public abstract class AbstractJavaPersistentAttribute
new MapJpaContainer(java.util.Map.class, JPA2_0.MAP_ATTRIBUTE)
});
- /**
- * JPA container interface (and null implementation)
- */
- protected interface JpaContainer {
- String getTypeName();
- boolean isContainer();
- String getMultiReferenceTargetTypeName(JavaResourcePersistentAttribute resourcePersistentAttribute);
- String getMetamodelContainerFieldTypeName();
- String getMetamodelContainerFieldMapKeyTypeName(MultiRelationshipMapping mapping);
-
- final class Null implements JpaContainer {
- public static final JpaContainer INSTANCE = new Null();
- public static JpaContainer instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- public String getTypeName() {
- return null;
- }
- public boolean isContainer() {
- return false;
- }
- public String getMultiReferenceTargetTypeName(JavaResourcePersistentAttribute resourcePersistentAttribute) {
- return null;
- }
- public String getMetamodelContainerFieldTypeName() {
- return JPA2_0.COLLECTION_ATTRIBUTE;
- }
- public String getMetamodelContainerFieldMapKeyTypeName(MultiRelationshipMapping mapping) {
- return null;
- }
- @Override
- public String toString() {
- return "JpaContainer.Null"; //$NON-NLS-1$
- }
- }
-
- }
/**
* Abstract JPA container
@@ -686,7 +671,11 @@ public abstract class AbstractJavaPersistentAttribute
null;
}
- public String getMetamodelContainerFieldMapKeyTypeName(MultiRelationshipMapping mapping) {
+ public String getMultiReferenceMapKeyTypeName(JavaResourcePersistentAttribute resourcePersistentAttribute) {
+ return null;
+ }
+
+ public String getMetamodelContainerFieldMapKeyTypeName(CollectionMapping mapping) {
return null;
}
}
@@ -705,7 +694,13 @@ public abstract class AbstractJavaPersistentAttribute
null;
}
- public String getMetamodelContainerFieldMapKeyTypeName(MultiRelationshipMapping mapping) {
+ public String getMultiReferenceMapKeyTypeName(JavaResourcePersistentAttribute resourcePersistentAttribute) {
+ return (resourcePersistentAttribute.typeTypeArgumentNamesSize() == 2) ?
+ resourcePersistentAttribute.getTypeTypeArgumentName(0) :
+ null;
+ }
+
+ public String getMetamodelContainerFieldMapKeyTypeName(CollectionMapping mapping) {
return mapping.getMetamodelFieldMapKeyTypeName();
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java
index db620423ef..61e6d73f89 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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.
@@ -15,14 +15,16 @@ import java.util.List;
import org.eclipse.jpt.core.context.CollectionMapping;
import org.eclipse.jpt.core.context.FetchType;
import org.eclipse.jpt.core.context.Orderable;
+import org.eclipse.jpt.core.context.PersistentType;
import org.eclipse.jpt.core.context.orm.OrmMultiRelationshipMapping;
import org.eclipse.jpt.core.context.orm.OrmOrderable;
import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
import org.eclipse.jpt.core.internal.context.MappingTools;
-import org.eclipse.jpt.core.jpa2.context.java.JavaPersistentAttribute2_0;
+import org.eclipse.jpt.core.jpa2.context.orm.OrmPersistentAttribute2_0;
import org.eclipse.jpt.core.resource.orm.AbstractXmlMultiRelationshipMapping;
import org.eclipse.jpt.core.resource.orm.MapKey;
import org.eclipse.jpt.core.resource.orm.OrmFactory;
+import org.eclipse.jpt.core.resource.orm.XmlMapKeyClass;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
@@ -40,10 +42,15 @@ public abstract class AbstractOrmMultiRelationshipMapping<T extends AbstractXmlM
protected boolean pkMapKey = false;
protected boolean customMapKey = false;
+ protected String specifiedMapKeyClass;
+ protected String defaultMapKeyClass;
+
protected AbstractOrmMultiRelationshipMapping(OrmPersistentAttribute parent, T resourceMapping) {
super(parent, resourceMapping);
this.orderable = getXmlContextNodeFactory().buildOrmOrderable(this);
this.initializeMapKey();
+ this.defaultMapKeyClass = this.buildDefaultMapKeyClass();
+ this.specifiedMapKeyClass = this.getResourceMapKeyClass();
}
@Override
@@ -51,6 +58,8 @@ public abstract class AbstractOrmMultiRelationshipMapping<T extends AbstractXmlM
super.update();
this.orderable.update();
this.updateMapKey();
+ this.setDefaultMapKeyClass(this.buildDefaultMapKeyClass());
+ this.setSpecifiedMapKeyClass_(this.getResourceMapKeyClass());
}
@Override
@@ -62,6 +71,9 @@ public abstract class AbstractOrmMultiRelationshipMapping<T extends AbstractXmlM
return CollectionMapping.DEFAULT_FETCH_TYPE;
}
+ public PersistentType getResolvedTargetType() {
+ return getResolvedTargetEntity() == null ? null : getResolvedTargetEntity().getPersistentType();
+ }
// **************** order by ***********************************************
@@ -236,11 +248,87 @@ public abstract class AbstractOrmMultiRelationshipMapping<T extends AbstractXmlM
}
+ // **************** map key class ******************************************
+
+ public char getMapKeyClassEnclosingTypeSeparator() {
+ return '$';
+ }
+
+ public String getMapKeyClass() {
+ return (this.specifiedMapKeyClass != null) ? this.specifiedMapKeyClass : this.defaultMapKeyClass;
+ }
+
+ public String getSpecifiedMapKeyClass() {
+ return this.specifiedMapKeyClass;
+ }
+
+ public void setSpecifiedMapKeyClass(String mapKeyClass) {
+ String old = this.specifiedMapKeyClass;
+ this.specifiedMapKeyClass = mapKeyClass;
+ if (this.attributeValueHasChanged(old, mapKeyClass)) {
+ XmlMapKeyClass xmlMapKeyClass = this.getXmlMapKeyClass();
+ if (mapKeyClass == null) {
+ if (xmlMapKeyClass != null) {
+ this.removeXmlMapKeyClass();
+ }
+ } else {
+ if (xmlMapKeyClass == null) {
+ xmlMapKeyClass = this.addXmlMapKeyClass();
+ }
+ xmlMapKeyClass.setClassName(mapKeyClass);
+ }
+ }
+ this.firePropertyChanged(SPECIFIED_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass);
+ }
+
+ protected void setSpecifiedMapKeyClass_(String mapKeyClass) {
+ String old = this.specifiedMapKeyClass;
+ this.specifiedMapKeyClass = mapKeyClass;
+ this.firePropertyChanged(SPECIFIED_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass);
+ }
+
+ protected XmlMapKeyClass getXmlMapKeyClass() {
+ return this.resourceAttributeMapping.getMapKeyClass();
+ }
+
+ protected XmlMapKeyClass addXmlMapKeyClass() {
+ XmlMapKeyClass mapKeyClass = OrmFactory.eINSTANCE.createXmlMapKeyClass();
+ this.resourceAttributeMapping.setMapKeyClass(mapKeyClass);
+ return mapKeyClass;
+ }
+
+ protected void removeXmlMapKeyClass() {
+ this.resourceAttributeMapping.setMapKeyClass(null);
+ }
+
+ public String getDefaultMapKeyClass() {
+ return this.defaultMapKeyClass;
+ }
+
+ protected void setDefaultMapKeyClass(String mapKeyClass) {
+ String old = this.defaultMapKeyClass;
+ this.defaultMapKeyClass = mapKeyClass;
+ this.firePropertyChanged(DEFAULT_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass);
+ }
+
+ protected String getResourceMapKeyClass() {
+ XmlMapKeyClass mapKeyClass = this.resourceAttributeMapping.getMapKeyClass();
+ return mapKeyClass == null ? null : mapKeyClass.getClassName();
+ }
+
+ protected String buildDefaultMapKeyClass() {
+ if (this.getJavaPersistentAttribute() != null) {
+ return this.getJavaPersistentAttribute().getMultiReferenceMapKeyTypeName();
+ }
+ return null;
+ }
+
+
// ********** metamodel **********
@Override
protected String getMetamodelFieldTypeName() {
- return ((JavaPersistentAttribute2_0) this.getJavaPersistentAttribute()).getMetamodelContainerFieldTypeName();
+ return ((OrmPersistentAttribute2_0) getPersistentAttribute()).getMetamodelContainerFieldTypeName();
}
@Override
@@ -250,7 +338,7 @@ public abstract class AbstractOrmMultiRelationshipMapping<T extends AbstractXmlM
}
protected void addMetamodelFieldMapKeyTypeArgumentNameTo(ArrayList<String> typeArgumentNames) {
- String keyTypeName = ((JavaPersistentAttribute2_0) this.getJavaPersistentAttribute()).getMetamodelContainerFieldMapKeyTypeName();
+ String keyTypeName = ((OrmPersistentAttribute2_0) this.getPersistentAttribute()).getMetamodelContainerFieldMapKeyTypeName();
if (keyTypeName != null) {
typeArgumentNames.add(keyTypeName);
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmPersistentAttribute.java
index a44bcc569d..4784888426 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmPersistentAttribute.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmPersistentAttribute.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2006, 2010 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.
@@ -14,15 +14,18 @@ import java.util.List;
import org.eclipse.jpt.core.JpaStructureNode;
import org.eclipse.jpt.core.MappingKeys;
import org.eclipse.jpt.core.context.AccessType;
+import org.eclipse.jpt.core.context.CollectionMapping;
import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.core.context.orm.OrmAttributeMapping;
import org.eclipse.jpt.core.context.orm.OrmAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
import org.eclipse.jpt.core.context.orm.OrmPersistentType;
import org.eclipse.jpt.core.context.orm.OrmStructureNodes;
import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
+import org.eclipse.jpt.core.jpa2.context.MetamodelField;
+import org.eclipse.jpt.core.jpa2.context.java.JavaPersistentAttribute2_0;
+import org.eclipse.jpt.core.jpa2.context.orm.OrmPersistentAttribute2_0;
import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping;
import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
@@ -33,7 +36,7 @@ import org.eclipse.wst.validation.internal.provisional.core.IReporter;
*/
public abstract class AbstractOrmPersistentAttribute
extends AbstractOrmXmlContextNode
- implements OrmPersistentAttribute
+ implements OrmPersistentAttribute2_0
{
protected final Owner owner;
@@ -192,7 +195,10 @@ public abstract class AbstractOrmPersistentAttribute
protected AccessType buildDefaultAccess() {
return getPersistentType().getAccess();
}
-
+
+
+ // ********** JpaStructureNode implementation **********
+
public JpaStructureNode getStructureNode(int offset) {
return this;
}
@@ -211,6 +217,21 @@ public abstract class AbstractOrmPersistentAttribute
return this.attributeMapping.getSelectionTextRange();
}
+ public void dispose() {
+ //nothing to dispose
+ }
+
+
+ // ********** misc overrides **********
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.getName());
+ }
+
+
+ // ********** validation **********
+
@Override
public void validate(List<IMessage> messages, IReporter reporter) {
super.validate(messages, reporter);
@@ -271,13 +292,25 @@ public abstract class AbstractOrmPersistentAttribute
return this.attributeMapping.getValidationTextRange();
}
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getName());
- }
+
+ // ********** metamodel **********
- public void dispose() {
- //nothing to dispose
+ public String getMetamodelContainerFieldTypeName() {
+ return this.getJpaContainer().getMetamodelContainerFieldTypeName();
+ }
+
+ public String getMetamodelContainerFieldMapKeyTypeName() {
+ return this.getJpaContainer().getMetamodelContainerFieldMapKeyTypeName((CollectionMapping) this.getMapping());
+ }
+
+ public String getMetamodelTypeName() {
+ JavaPersistentAttribute2_0 javaAttribute = (JavaPersistentAttribute2_0) getJavaPersistentAttribute();
+ return javaAttribute == null ? MetamodelField.DEFAULT_TYPE_NAME : javaAttribute.getMetamodelTypeName();
+ }
+
+ protected JavaPersistentAttribute.JpaContainer getJpaContainer() {
+ JavaPersistentAttribute2_0 javaAttribute = (JavaPersistentAttribute2_0) getJavaPersistentAttribute();
+ return javaAttribute == null ? JavaPersistentAttribute.JpaContainer.Null.instance() : javaAttribute.getJpaContainer();
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualMapKey.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualMapKey.java
index 0ae38eddc9..0b75a5c4d3 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualMapKey.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualMapKey.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2010 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.
@@ -9,27 +9,21 @@
******************************************************************************/
package org.eclipse.jpt.core.internal.context.orm;
-import org.eclipse.jpt.core.context.java.JavaMultiRelationshipMapping;
+import org.eclipse.jpt.core.context.CollectionMapping;
import org.eclipse.jpt.core.resource.orm.MapKey;
public class VirtualMapKey extends MapKey
{
- JavaMultiRelationshipMapping javaMultiRelationshipMapping;
-
- protected boolean metadataComplete;
+ CollectionMapping javaCollectionMapping;
- public VirtualMapKey(JavaMultiRelationshipMapping javaMultiRelationshipMapping, boolean metadataComplete) {
+ public VirtualMapKey(CollectionMapping collectionMapping) {
super();
- this.javaMultiRelationshipMapping = javaMultiRelationshipMapping;
- this.metadataComplete = metadataComplete;
+ this.javaCollectionMapping = collectionMapping;
}
@Override
public String getName() {
- if (this.metadataComplete) {
- return null;
- }
- return this.javaMultiRelationshipMapping.getSpecifiedMapKey();
+ return this.javaCollectionMapping.getSpecifiedMapKey();
}
@Override
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlManyToMany.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlManyToMany.java
index 1d5ebe08a4..02a9eb5866 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlManyToMany.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlManyToMany.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2010 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.
@@ -9,14 +9,12 @@
******************************************************************************/
package org.eclipse.jpt.core.internal.context.orm;
-import org.eclipse.emf.common.util.EList;
import org.eclipse.jpt.core.context.java.JavaManyToManyMapping;
import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
import org.eclipse.jpt.core.jpa2.context.Orderable2_0;
import org.eclipse.jpt.core.resource.orm.CascadeType;
import org.eclipse.jpt.core.resource.orm.FetchType;
import org.eclipse.jpt.core.resource.orm.MapKey;
-import org.eclipse.jpt.core.resource.orm.XmlJoinColumn;
import org.eclipse.jpt.core.resource.orm.XmlJoinTable;
import org.eclipse.jpt.core.resource.orm.XmlManyToMany;
import org.eclipse.jpt.core.resource.orm.XmlOrderColumn;
@@ -48,7 +46,7 @@ public class VirtualXmlManyToMany
this.virtualXmlAttributeMapping = new VirtualXmlAttributeMapping(ormTypeMapping, javaManyToManyMapping);
this.virtualCascadeType =
new VirtualCascadeType(javaManyToManyMapping.getCascade(), this.isOrmMetadataComplete());
- this.mapKey = new VirtualMapKey(javaManyToManyMapping, this.isOrmMetadataComplete());
+ this.mapKey = new VirtualMapKey(javaManyToManyMapping);
}
protected boolean isOrmMetadataComplete() {
@@ -88,10 +86,6 @@ public class VirtualXmlManyToMany
throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
}
- public EList<XmlJoinColumn> getJoinColumns() {
- return null;
- }
-
@Override
public CascadeType getCascade() {
return this.virtualCascadeType;
@@ -147,6 +141,12 @@ public class VirtualXmlManyToMany
@Override
public MapKey getMapKey() {
+ if (this.isOrmMetadataComplete()) {
+ return null;
+ }
+ if (this.javaAttributeMapping.isNoMapKey()) {
+ return null;
+ }
return this.mapKey;
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlOneToMany.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlOneToMany.java
index 2a97d19ae5..5ef099c8fc 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlOneToMany.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlOneToMany.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2010 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -39,7 +39,6 @@ public class VirtualXmlOneToMany
protected final MapKey mapKey;
-
public VirtualXmlOneToMany(
OrmTypeMapping ormTypeMapping, JavaOneToManyMapping javaOneToManyMapping) {
super();
@@ -48,7 +47,7 @@ public class VirtualXmlOneToMany
this.virtualXmlAttributeMapping = new VirtualXmlAttributeMapping(ormTypeMapping, javaOneToManyMapping);
this.virtualCascadeType =
new VirtualCascadeType(javaOneToManyMapping.getCascade(), this.isOrmMetadataComplete());
- this.mapKey = new VirtualMapKey(javaOneToManyMapping, this.isOrmMetadataComplete());
+ this.mapKey = new VirtualMapKey(javaOneToManyMapping);
}
protected boolean isOrmMetadataComplete() {
@@ -160,6 +159,12 @@ public class VirtualXmlOneToMany
@Override
public MapKey getMapKey() {
+ if (this.isOrmMetadataComplete()) {
+ return null;
+ }
+ if (this.javaAttributeMapping.isNoMapKey()) {
+ return null;
+ }
return this.mapKey;
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmAttributeOverrideContainer.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmAttributeOverrideContainer.java
index 5eb85ecbd4..b15ab59996 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmAttributeOverrideContainer.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmAttributeOverrideContainer.java
@@ -250,12 +250,12 @@ public class GenericOrmAttributeOverrideContainer extends AbstractOrmXmlContextN
}
protected XmlAttributeOverride buildVirtualXmlAttributeOverride(String name) {
- Column column = resolveAttributeOverrideMappingColumn(name);
+ Column column = resolveOverriddenColumn(name);
XmlColumn xmlColumn = getOwner().buildVirtualXmlColumn(column, name, getOwner().getTypeMapping().isMetadataComplete());
return new VirtualXmlAttributeOverride(name, xmlColumn);
}
- private Column resolveAttributeOverrideMappingColumn(String attributeOverrideName) {
+ private Column resolveOverriddenColumn(String attributeOverrideName) {
return getOwner().resolveOverriddenColumn(attributeOverrideName);
}
@@ -338,7 +338,7 @@ public class GenericOrmAttributeOverrideContainer extends AbstractOrmXmlContextN
if (attributeName == null) {
return null;
}
- return GenericOrmAttributeOverrideContainer.this.resolveAttributeOverrideMappingColumn(attributeName);
+ return GenericOrmAttributeOverrideContainer.this.resolveOverriddenColumn(attributeName);
}
public boolean isVirtual(BaseOverride override) {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaElementCollectionMapping2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaElementCollectionMapping2_0.java
index 17b3d3547d..70eb6671a1 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaElementCollectionMapping2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaElementCollectionMapping2_0.java
@@ -16,6 +16,7 @@ import java.util.Vector;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.MappingKeys;
import org.eclipse.jpt.core.context.AssociationOverrideContainer;
+import org.eclipse.jpt.core.context.AttributeMapping;
import org.eclipse.jpt.core.context.AttributeOverrideContainer;
import org.eclipse.jpt.core.context.Column;
import org.eclipse.jpt.core.context.Converter;
@@ -46,14 +47,20 @@ import org.eclipse.jpt.core.jpa2.context.java.JavaPersistentAttribute2_0;
import org.eclipse.jpt.core.jpa2.resource.java.CollectionTable2_0Annotation;
import org.eclipse.jpt.core.jpa2.resource.java.ElementCollection2_0Annotation;
import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0;
+import org.eclipse.jpt.core.jpa2.resource.java.MapKeyClass2_0Annotation;
import org.eclipse.jpt.core.resource.java.ColumnAnnotation;
import org.eclipse.jpt.core.resource.java.EnumeratedAnnotation;
import org.eclipse.jpt.core.resource.java.JPA;
+import org.eclipse.jpt.core.resource.java.MapKeyAnnotation;
import org.eclipse.jpt.core.resource.java.TemporalAnnotation;
import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.jpt.db.Table;
import org.eclipse.jpt.utility.Filter;
+import org.eclipse.jpt.utility.internal.StringTools;
+import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
+import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
+import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
@@ -86,6 +93,16 @@ public class GenericJavaElementCollectionMapping2_0
protected final JavaAssociationOverrideContainer valueAssociationOverrideContainer;
protected Type keyType;
+
+ //MapKey is not supported by the spec, so this is only for EclipseLink
+ //In the generic case we can handle this with validation and not showing the UI widgets
+ protected String specifiedMapKey;
+ protected boolean noMapKey = false;
+ protected boolean pkMapKey = false;
+ protected boolean customMapKey = false;
+
+ protected String specifiedMapKeyClass;
+ protected String defaultMapKeyClass;
public GenericJavaElementCollectionMapping2_0(JavaPersistentAttribute parent) {
super(parent);
@@ -119,6 +136,9 @@ public class GenericJavaElementCollectionMapping2_0
this.valueAttributeOverrideContainer.initialize(getResourcePersistentAttribute());
this.valueAssociationOverrideContainer.initialize(getResourcePersistentAttribute());
this.initializeKeyType();
+ this.initializeMapKey();
+ this.defaultMapKeyClass = this.buildDefaultMapKeyClass();
+ this.specifiedMapKeyClass = this.getResourceMapKeyClass();
}
@Override
@@ -137,6 +157,9 @@ public class GenericJavaElementCollectionMapping2_0
this.valueAttributeOverrideContainer.update(getResourcePersistentAttribute());
this.valueAssociationOverrideContainer.update(getResourcePersistentAttribute());
this.updateKeyType();
+ this.updateMapKey();
+ this.setDefaultMapKeyClass(this.buildDefaultMapKeyClass());
+ this.setSpecifiedMapKeyClass_(this.getResourceMapKeyClass());
}
@Override
@@ -232,6 +255,10 @@ public class GenericJavaElementCollectionMapping2_0
this.resolvedTargetEmbeddable = embeddable;
this.firePropertyChanged(RESOLVED_TARGET_EMBEDDABLE_PROPERTY, old, embeddable);
}
+
+ public PersistentType getResolvedTargetType() {
+ return getResolvedTargetEmbeddable() == null ? null : getResolvedTargetEmbeddable().getPersistentType();
+ }
protected PersistentType buildResolvedTargetType() {
String targetTypeClassName = (this.specifiedTargetClass == null) ?
@@ -488,7 +515,251 @@ public class GenericJavaElementCollectionMapping2_0
//TODO key type
}
-
+
+ // ********** map key **********
+
+ public String getMapKey() {
+ if (this.noMapKey) {
+ return null;
+ }
+ if (this.pkMapKey) {
+ return null;//the target is either embeddable or basic, so a key will have to be specified
+ }
+ if (this.customMapKey) {
+ return this.specifiedMapKey;
+ }
+ throw new IllegalStateException("unknown map key"); //$NON-NLS-1$
+ }
+
+ public String getSpecifiedMapKey() {
+ return this.specifiedMapKey;
+ }
+
+ public void setSpecifiedMapKey(String mapKey) {
+ String old = this.specifiedMapKey;
+ this.specifiedMapKey = mapKey;
+ MapKeyAnnotation mapKeyAnnotation = this.getMapKeyAnnotation();
+ if (mapKey == null) {
+ if (mapKeyAnnotation != null) {
+ this.removeMapKeyAnnotation();
+ }
+ } else {
+ if (mapKeyAnnotation == null) {
+ mapKeyAnnotation = this.addMapKeyAnnotation();
+ }
+ mapKeyAnnotation.setName(mapKey);
+ }
+ this.firePropertyChanged(SPECIFIED_MAP_KEY_PROPERTY, old, mapKey);
+ }
+
+ protected void setSpecifiedMapKey_(String mapKey) {
+ String old = this.specifiedMapKey;
+ this.specifiedMapKey = mapKey;
+ this.firePropertyChanged(SPECIFIED_MAP_KEY_PROPERTY, old, mapKey);
+ }
+
+ protected void initializeMapKey() {
+ MapKeyAnnotation mapKeyAnnotation = this.getMapKeyAnnotation();
+ if (mapKeyAnnotation == null) {
+ this.noMapKey = true;
+ } else {
+ this.specifiedMapKey = mapKeyAnnotation.getName();
+ if (this.specifiedMapKey == null) {
+ this.pkMapKey = true;
+ } else {
+ this.customMapKey = true;
+ }
+ }
+ }
+
+ protected void updateMapKey() {
+ MapKeyAnnotation mapKeyAnnotation = this.getMapKeyAnnotation();
+ if (mapKeyAnnotation == null) {
+ this.setSpecifiedMapKey_(null);
+ this.setNoMapKey_(true);
+ this.setPkMapKey_(false);
+ this.setCustomMapKey_(false);
+ } else {
+ String mk = mapKeyAnnotation.getName();
+ this.setSpecifiedMapKey_(mk);
+ this.setNoMapKey_(false);
+ this.setPkMapKey_(mk == null);
+ this.setCustomMapKey_(mk != null);
+ }
+ }
+
+ protected MapKeyAnnotation getMapKeyAnnotation() {
+ return (MapKeyAnnotation) this.getResourcePersistentAttribute().getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ }
+
+ protected MapKeyAnnotation addMapKeyAnnotation() {
+ return (MapKeyAnnotation) this.getResourcePersistentAttribute().addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ }
+
+ protected void removeMapKeyAnnotation() {
+ this.getResourcePersistentAttribute().removeAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ }
+
+ protected boolean mapKeyNameTouches(int pos, CompilationUnit astRoot) {
+ MapKeyAnnotation mapKeyAnnotation = this.getMapKeyAnnotation();
+ return (mapKeyAnnotation != null) && mapKeyAnnotation.nameTouches(pos, astRoot);
+ }
+
+
+ // ********** no map key **********
+
+ public boolean isNoMapKey() {
+ return this.noMapKey;
+ }
+
+ public void setNoMapKey(boolean noMapKey) {
+ boolean old = this.noMapKey;
+ this.noMapKey = noMapKey;
+ if (noMapKey) {
+ if (this.getMapKeyAnnotation() != null) {
+ this.removeMapKeyAnnotation();
+ }
+ } else {
+ // the 'noMapKey' flag is cleared as a
+ // side-effect of setting the other flags,
+ // via a call to #setNoMapKey_(boolean)
+ }
+ this.firePropertyChanged(NO_MAP_KEY_PROPERTY, old, noMapKey);
+ }
+
+ protected void setNoMapKey_(boolean noMapKey) {
+ boolean old = this.noMapKey;
+ this.noMapKey = noMapKey;
+ this.firePropertyChanged(NO_MAP_KEY_PROPERTY, old, noMapKey);
+ }
+
+
+ // ********** pk map key **********
+
+ public boolean isPkMapKey() {
+ return this.pkMapKey;
+ }
+
+ public void setPkMapKey(boolean pkMapKey) {
+ boolean old = this.pkMapKey;
+ this.pkMapKey = pkMapKey;
+ MapKeyAnnotation mapKeyAnnotation = this.getMapKeyAnnotation();
+ if (pkMapKey) {
+ if (mapKeyAnnotation == null) {
+ this.addMapKeyAnnotation();
+ } else {
+ mapKeyAnnotation.setName(null);
+ }
+ } else {
+ // the 'pkMapKey' flag is cleared as a
+ // side-effect of setting the other flags,
+ // via a call to #setPkMapKey_(boolean)
+ }
+ this.firePropertyChanged(PK_MAP_KEY_PROPERTY, old, pkMapKey);
+ }
+
+ protected void setPkMapKey_(boolean pkMapKey) {
+ boolean old = this.pkMapKey;
+ this.pkMapKey = pkMapKey;
+ this.firePropertyChanged(PK_MAP_KEY_PROPERTY, old, pkMapKey);
+ }
+
+
+ // ********** custom map key **********
+
+ public boolean isCustomMapKey() {
+ return this.customMapKey;
+ }
+
+ public void setCustomMapKey(boolean customMapKey) {
+ boolean old = this.customMapKey;
+ this.customMapKey = customMapKey;
+ if (customMapKey) {
+ this.setSpecifiedMapKey(""); //$NON-NLS-1$
+ } else {
+ // the 'customMapKey' flag is cleared as a
+ // side-effect of setting the other flags,
+ // via a call to #setCustomMapKey_(boolean)
+ }
+ this.firePropertyChanged(CUSTOM_MAP_KEY_PROPERTY, old, customMapKey);
+ }
+
+ protected void setCustomMapKey_(boolean customMapKey) {
+ boolean old = this.customMapKey;
+ this.customMapKey = customMapKey;
+ this.firePropertyChanged(CUSTOM_MAP_KEY_PROPERTY, old, customMapKey);
+ }
+
+ // *************** map key class *************
+
+ public String getMapKeyClass() {
+ return (this.specifiedMapKeyClass != null) ? this.specifiedMapKeyClass : this.defaultMapKeyClass;
+ }
+
+ public String getSpecifiedMapKeyClass() {
+ return this.specifiedMapKeyClass;
+ }
+
+ public void setSpecifiedMapKeyClass(String mapKeyClass) {
+ String old = this.specifiedMapKeyClass;
+ this.specifiedMapKeyClass = mapKeyClass;
+ MapKeyClass2_0Annotation mapKeyClassAnnotation = this.getMapKeyClassAnnotation();
+ if (mapKeyClass == null) {
+ if (mapKeyClassAnnotation != null) {
+ this.removeMapKeyClassAnnotation();
+ }
+ } else {
+ if (mapKeyClassAnnotation == null) {
+ mapKeyClassAnnotation = this.addMapKeyClassAnnotation();
+ }
+ mapKeyClassAnnotation.setValue(mapKeyClass);
+ }
+
+ this.firePropertyChanged(SPECIFIED_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass);
+ }
+
+ protected void setSpecifiedMapKeyClass_(String mapKeyClass) {
+ String old = this.specifiedMapKeyClass;
+ this.specifiedMapKeyClass = mapKeyClass;
+ this.firePropertyChanged(SPECIFIED_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass);
+ }
+
+ protected String getResourceMapKeyClass() {
+ MapKeyClass2_0Annotation annotation = getMapKeyClassAnnotation();
+ return annotation == null ? null : annotation.getValue();
+ }
+
+ public String getDefaultMapKeyClass() {
+ return this.defaultMapKeyClass;
+ }
+
+ protected void setDefaultMapKeyClass(String mapKeyClass) {
+ String old = this.defaultMapKeyClass;
+ this.defaultMapKeyClass = mapKeyClass;
+ this.firePropertyChanged(DEFAULT_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass);
+ }
+
+ protected String buildDefaultMapKeyClass() {
+ return this.getPersistentAttribute().getMultiReferenceMapKeyTypeName();
+ }
+
+ public char getMapKeyClassEnclosingTypeSeparator() {
+ return '.';
+ }
+
+ protected MapKeyClass2_0Annotation getMapKeyClassAnnotation() {
+ return (MapKeyClass2_0Annotation) this.getResourcePersistentAttribute().getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ }
+
+ protected MapKeyClass2_0Annotation addMapKeyClassAnnotation() {
+ return (MapKeyClass2_0Annotation) this.getResourcePersistentAttribute().addAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ }
+
+ protected void removeMapKeyClassAnnotation() {
+ this.getResourcePersistentAttribute().removeAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ }
+
+
// ********** Java completion proposals **********
@Override
@@ -522,14 +793,42 @@ public class GenericJavaElementCollectionMapping2_0
return result;
}
-// if (this.mapKeyNameTouches(pos, astRoot)) {
-// return this.javaCandidateMapKeyNames(filter);
-// }
+ if (this.mapKeyNameTouches(pos, astRoot)) {
+ return this.javaCandidateMapKeyNames(filter);
+ }
return null;
}
-
+
+ protected Iterator<String> javaCandidateMapKeyNames(Filter<String> filter) {
+ return StringTools.convertToJavaStringLiterals(this.candidateMapKeyNames(filter));
+ }
+
+ protected Iterator<String> candidateMapKeyNames(Filter<String> filter) {
+ return new FilteringIterator<String>(this.candidateMapKeyNames(), filter);
+ }
+
+ public Iterator<String> candidateMapKeyNames() {
+ return this.allTargetEmbeddableAttributeNames();
+ }
+
+ public Iterator<String> allTargetEmbeddableAttributeNames() {
+ return new CompositeIterator<String>(
+ new TransformationIterator<AttributeMapping, Iterator<String>>(this.allTargetEmbeddableAttributeMappings()) {
+ @Override
+ protected Iterator<String> transform(AttributeMapping mapping) {
+ return mapping.allMappingNames();
+ }
+ });
+ }
+
+ protected Iterator<AttributeMapping> allTargetEmbeddableAttributeMappings() {
+ return (this.resolvedTargetEmbeddable != null) ?
+ this.resolvedTargetEmbeddable.allAttributeMappings() :
+ EmptyIterator.<AttributeMapping> instance();
+ }
+
+
// ********** metamodel **********
- //TODO map metamodel
@Override
protected String getMetamodelFieldTypeName() {
return ((JavaPersistentAttribute2_0) this.getPersistentAttribute()).getMetamodelContainerFieldTypeName();
@@ -548,15 +847,15 @@ public class GenericJavaElementCollectionMapping2_0
}
protected void addMetamodelFieldMapKeyTypeArgumentNameTo(ArrayList<String> typeArgumentNames) {
-// String keyTypeName = ((JavaPersistentAttribute2_0) this.getPersistentAttribute()).getMetamodelContainerFieldMapKeyTypeName();
-// if (keyTypeName != null) {
-// typeArgumentNames.add(keyTypeName);
-// }
+ String keyTypeName = ((JavaPersistentAttribute2_0) this.getPersistentAttribute()).getMetamodelContainerFieldMapKeyTypeName();
+ if (keyTypeName != null) {
+ typeArgumentNames.add(keyTypeName);
+ }
}
-// public String getMetamodelFieldMapKeyTypeName() {
-// return MappingTools.getMetamodelFieldMapKeyTypeName(this);
-// }
+ public String getMetamodelFieldMapKeyTypeName() {
+ return MappingTools.getMetamodelFieldMapKeyTypeName(this);
+ }
// ********** validation **********
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaPersistentAttribute2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaPersistentAttribute2_0.java
index a24916a3e7..9b979f879f 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaPersistentAttribute2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaPersistentAttribute2_0.java
@@ -10,14 +10,11 @@
package org.eclipse.jpt.core.internal.jpa2.context.java;
import org.eclipse.jpt.core.context.AccessType;
-import org.eclipse.jpt.core.context.MultiRelationshipMapping;
import org.eclipse.jpt.core.context.PersistentType;
import org.eclipse.jpt.core.internal.context.java.AbstractJavaPersistentAttribute;
-import org.eclipse.jpt.core.jpa2.context.MetamodelField;
import org.eclipse.jpt.core.jpa2.context.java.JavaPersistentAttribute2_0;
import org.eclipse.jpt.core.jpa2.resource.java.Access2_0Annotation;
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.utility.internal.ClassName;
/**
* JPA 2.0 Java persistent attribute
@@ -68,27 +65,4 @@ public class GenericJavaPersistentAttribute2_0
super.update();
this.setSpecifiedAccess_(this.buildSpecifiedAccess());
}
-
-
- // ********** metamodel **********
-
- public String getMetamodelContainerFieldTypeName() {
- return this.getJpaContainer(this.resourcePersistentAttribute.getTypeName()).getMetamodelContainerFieldTypeName();
- }
-
- public String getMetamodelContainerFieldMapKeyTypeName() {
- return this.getJpaContainer(this.resourcePersistentAttribute.getTypeName()).getMetamodelContainerFieldMapKeyTypeName((MultiRelationshipMapping) this.getMapping());
- }
-
- public String getMetamodelTypeName() {
- String typeName = this.resourcePersistentAttribute.getTypeName();
- if (typeName == null) {
- return MetamodelField.DEFAULT_TYPE_NAME;
- }
- if (ClassName.isPrimitive(typeName)) {
- return ClassName.getWrapperClassName(typeName); // ???
- }
- return typeName;
- }
-
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmElementCollectionMapping2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmElementCollectionMapping2_0.java
index a0a9f2be15..373701419d 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmElementCollectionMapping2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmElementCollectionMapping2_0.java
@@ -10,6 +10,7 @@
package org.eclipse.jpt.core.internal.jpa2.context.orm;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import org.eclipse.jpt.core.MappingKeys;
import org.eclipse.jpt.core.context.AttributeMapping;
@@ -39,19 +40,23 @@ import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.core.jpa2.MappingKeys2_0;
import org.eclipse.jpt.core.jpa2.context.MetamodelField;
+import org.eclipse.jpt.core.jpa2.context.PersistentAttribute2_0;
import org.eclipse.jpt.core.jpa2.context.java.JavaElementCollectionMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaPersistentAttribute2_0;
import org.eclipse.jpt.core.jpa2.context.orm.OrmCollectionTable2_0;
import org.eclipse.jpt.core.jpa2.context.orm.OrmElementCollectionMapping2_0;
import org.eclipse.jpt.core.jpa2.context.orm.OrmXml2_0ContextNodeFactory;
import org.eclipse.jpt.core.resource.orm.Attributes;
+import org.eclipse.jpt.core.resource.orm.MapKey;
import org.eclipse.jpt.core.resource.orm.OrmFactory;
import org.eclipse.jpt.core.resource.orm.XmlCollectionTable;
import org.eclipse.jpt.core.resource.orm.XmlColumn;
import org.eclipse.jpt.core.resource.orm.XmlElementCollection;
+import org.eclipse.jpt.core.resource.orm.XmlMapKeyClass;
import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.jpt.db.Table;
+import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
+import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
@@ -86,6 +91,14 @@ public class GenericOrmElementCollectionMapping2_0
protected Type keyType;
+ protected String specifiedMapKey;
+ protected boolean noMapKey = false;
+ protected boolean pkMapKey = false;
+ protected boolean customMapKey = false;
+
+ protected String specifiedMapKeyClass;
+ protected String defaultMapKeyClass;
+
public GenericOrmElementCollectionMapping2_0(OrmPersistentAttribute parent, XmlElementCollection resourceMapping) {
super(parent, resourceMapping);
this.specifiedFetch = this.getResourceFetch();
@@ -101,6 +114,9 @@ public class GenericOrmElementCollectionMapping2_0
this.valueConverter = this.buildConverter(this.getResourceConverterType());
this.valueAssociationOverrideContainer = buildValueAssociationOverrideContainer();
this.valueAttributeOverrideContainer = buildValueAttributeOverrideContainer();
+ this.initializeMapKey();
+ this.defaultMapKeyClass = this.buildDefaultMapKeyClass();
+ this.specifiedMapKeyClass = this.getResourceMapKeyClass();
}
@Override
@@ -119,6 +135,9 @@ public class GenericOrmElementCollectionMapping2_0
this.valueAssociationOverrideContainer.update();
this.updateValueConverter();
this.setKeyType(buildKeyType());
+ this.updateMapKey();
+ this.setDefaultMapKeyClass(this.buildDefaultMapKeyClass());
+ this.setSpecifiedMapKeyClass_(this.getResourceMapKeyClass());
}
@Override
@@ -207,22 +226,22 @@ public class GenericOrmElementCollectionMapping2_0
this.resolvedTargetEmbeddable = targetEmbeddable;
this.firePropertyChanged(RESOLVED_TARGET_EMBEDDABLE_PROPERTY, old, targetEmbeddable);
}
-
+
+ public PersistentType getResolvedTargetType() {
+ return getResolvedTargetEmbeddable() == null ? null : getResolvedTargetEmbeddable().getPersistentType();
+ }
+
protected String getResourceTargetClass() {
return this.resourceAttributeMapping.getTargetClass();
}
protected String buildDefaultTargetClass() {
if (this.getJavaPersistentAttribute() != null) {
- return getResourceDefaultTargetClass();
+ return this.getJavaPersistentAttribute().getMultiReferenceTargetTypeName();
}
return null;
}
- protected String getResourceDefaultTargetClass() {
- return this.getJavaPersistentAttribute().getMultiReferenceTargetTypeName();
- }
-
protected PersistentType buildResolvedTargetType() {
String targetClassName = this.getTargetClass();
if (targetClassName == null) {
@@ -458,7 +477,7 @@ public class GenericOrmElementCollectionMapping2_0
}
return null;
}
-
+
protected JavaElementCollectionMapping2_0 getJavaElementCollectionMapping() {
if (this.getJavaPersistentAttribute() == null) {
return null;
@@ -470,13 +489,267 @@ public class GenericOrmElementCollectionMapping2_0
return null;
}
+ // **************** map key ************************************************
+
+ public String getMapKey() {
+ if (this.noMapKey) {
+ return null;
+ }
+ if (this.pkMapKey) {
+ return null;//the target is either embeddable or basic, so a key will have to be specified
+ }
+ if (this.customMapKey) {
+ return this.specifiedMapKey;
+ }
+ throw new IllegalStateException("unknown map key"); //$NON-NLS-1$
+ }
+
+ public String getSpecifiedMapKey() {
+ return this.specifiedMapKey;
+ }
+ public void setSpecifiedMapKey(String mapKey) {
+ String old = this.specifiedMapKey;
+ this.specifiedMapKey = mapKey;
+ if (this.attributeValueHasChanged(old, mapKey)) {
+ MapKey xmlMapKey = this.getXmlMapKey();
+ if (mapKey == null) {
+ if (xmlMapKey != null) {
+ this.removeXmlMapKey();
+ }
+ } else {
+ if (xmlMapKey == null) {
+ xmlMapKey = this.addXmlMapKey();
+ }
+ xmlMapKey.setName(mapKey);
+ }
+ }
+ this.firePropertyChanged(SPECIFIED_MAP_KEY_PROPERTY, old, mapKey);
+ }
+
+ protected void setSpecifiedMapKey_(String mapKey) {
+ String old = this.specifiedMapKey;
+ this.specifiedMapKey = mapKey;
+ this.firePropertyChanged(SPECIFIED_MAP_KEY_PROPERTY, old, mapKey);
+ }
+
+ protected void initializeMapKey() {
+ MapKey xmlMapKey = this.getXmlMapKey();
+ if (xmlMapKey == null) {
+ this.noMapKey = true;
+ } else {
+ this.specifiedMapKey = xmlMapKey.getName();
+ if (this.specifiedMapKey == null) {
+ this.pkMapKey = true;
+ } else {
+ this.customMapKey = true;
+ }
+ }
+ }
+
+ protected void updateMapKey() {
+ MapKey xmlMapKey = this.getXmlMapKey();
+ if (xmlMapKey == null) {
+ this.setSpecifiedMapKey_(null);
+ this.setNoMapKey_(true);
+ this.setPkMapKey_(false);
+ this.setCustomMapKey_(false);
+ } else {
+ String mk = xmlMapKey.getName();
+ this.setSpecifiedMapKey_(mk);
+ this.setNoMapKey_(false);
+ this.setPkMapKey_(mk == null);
+ this.setCustomMapKey_(mk != null);
+ }
+ }
+
+ protected MapKey getXmlMapKey() {
+ return this.resourceAttributeMapping.getMapKey();
+ }
+
+ protected MapKey addXmlMapKey() {
+ MapKey mapKey = OrmFactory.eINSTANCE.createMapKey();
+ this.resourceAttributeMapping.setMapKey(mapKey);
+ return mapKey;
+ }
+
+ protected void removeXmlMapKey() {
+ this.resourceAttributeMapping.setMapKey(null);
+ }
+
+ public Iterator<String> candidateMapKeyNames() {
+ return this.allTargetEmbeddableAttributeNames();
+ }
+
+ public Iterator<String> allTargetEmbeddableAttributeNames() {
+ return new CompositeIterator<String>(
+ new TransformationIterator<AttributeMapping, Iterator<String>>(this.allTargetEmbeddableAttributeMappings()) {
+ @Override
+ protected Iterator<String> transform(AttributeMapping mapping) {
+ return mapping.allMappingNames();
+ }
+ });
+ }
+
+ protected Iterator<AttributeMapping> allTargetEmbeddableAttributeMappings() {
+ return (this.resolvedTargetEmbeddable != null) ?
+ this.resolvedTargetEmbeddable.allAttributeMappings() :
+ EmptyIterator.<AttributeMapping> instance();
+ }
+
+
+ // **************** no map key ***********************************************
+
+ public boolean isNoMapKey() {
+ return this.noMapKey;
+ }
+
+ public void setNoMapKey(boolean noMapKey) {
+ boolean old = this.noMapKey;
+ this.noMapKey = noMapKey;
+ if (noMapKey) {
+ if (this.getXmlMapKey() != null) {
+ this.removeXmlMapKey();
+ }
+ }
+ this.firePropertyChanged(NO_MAP_KEY_PROPERTY, old, noMapKey);
+ }
+
+ protected void setNoMapKey_(boolean noMapKey) {
+ boolean old = this.noMapKey;
+ this.noMapKey = noMapKey;
+ this.firePropertyChanged(NO_MAP_KEY_PROPERTY, old, noMapKey);
+ }
+
+
+ // **************** pk map key ***********************************************
+
+ public boolean isPkMapKey() {
+ return this.pkMapKey;
+ }
+
+ public void setPkMapKey(boolean pkMapKey) {
+ boolean old = this.pkMapKey;
+ this.pkMapKey = pkMapKey;
+ MapKey xmlMapKey = this.getXmlMapKey();
+ if (pkMapKey) {
+ if (xmlMapKey == null) {
+ this.addXmlMapKey();
+ } else {
+ xmlMapKey.setName(null);
+ }
+ }
+ this.firePropertyChanged(PK_MAP_KEY_PROPERTY, old, pkMapKey);
+ }
+
+ protected void setPkMapKey_(boolean pkMapKey) {
+ boolean old = this.pkMapKey;
+ this.pkMapKey = pkMapKey;
+ this.firePropertyChanged(PK_MAP_KEY_PROPERTY, old, pkMapKey);
+ }
+
+
+ // **************** custom map key ***********************************************
+
+ public boolean isCustomMapKey() {
+ return this.customMapKey;
+ }
+
+ public void setCustomMapKey(boolean customMapKey) {
+ boolean old = this.customMapKey;
+ this.customMapKey = customMapKey;
+ if (customMapKey) {
+ this.setSpecifiedMapKey(""); //$NON-NLS-1$
+ }
+ this.firePropertyChanged(CUSTOM_MAP_KEY_PROPERTY, old, customMapKey);
+ }
+
+ protected void setCustomMapKey_(boolean customMapKey) {
+ boolean old = this.customMapKey;
+ this.customMapKey = customMapKey;
+ this.firePropertyChanged(CUSTOM_MAP_KEY_PROPERTY, old, customMapKey);
+ }
+
+ // **************** map key class ******************************************
+
+ public char getMapKeyClassEnclosingTypeSeparator() {
+ return '$';
+ }
+
+ public String getMapKeyClass() {
+ return (this.specifiedMapKeyClass != null) ? this.specifiedMapKeyClass : this.defaultMapKeyClass;
+ }
+
+ public String getSpecifiedMapKeyClass() {
+ return this.specifiedMapKeyClass;
+ }
+
+ public void setSpecifiedMapKeyClass(String mapKeyClass) {
+ String old = this.specifiedMapKeyClass;
+ this.specifiedMapKeyClass = mapKeyClass;
+ if (this.attributeValueHasChanged(old, mapKeyClass)) {
+ XmlMapKeyClass xmlMapKeyClass = this.getXmlMapKeyClass();
+ if (mapKeyClass == null) {
+ if (xmlMapKeyClass != null) {
+ this.removeXmlMapKeyClass();
+ }
+ } else {
+ if (xmlMapKeyClass == null) {
+ xmlMapKeyClass = this.addXmlMapKeyClass();
+ }
+ xmlMapKeyClass.setClassName(mapKeyClass);
+ }
+ }
+ this.firePropertyChanged(SPECIFIED_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass);
+ }
+
+ protected void setSpecifiedMapKeyClass_(String mapKeyClass) {
+ String old = this.specifiedMapKeyClass;
+ this.specifiedMapKeyClass = mapKeyClass;
+ this.firePropertyChanged(SPECIFIED_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass);
+ }
+
+ protected XmlMapKeyClass getXmlMapKeyClass() {
+ return this.resourceAttributeMapping.getMapKeyClass();
+ }
+
+ protected XmlMapKeyClass addXmlMapKeyClass() {
+ XmlMapKeyClass mapKeyClass = OrmFactory.eINSTANCE.createXmlMapKeyClass();
+ this.resourceAttributeMapping.setMapKeyClass(mapKeyClass);
+ return mapKeyClass;
+ }
+
+ protected void removeXmlMapKeyClass() {
+ this.resourceAttributeMapping.setMapKeyClass(null);
+ }
+
+ public String getDefaultMapKeyClass() {
+ return this.defaultMapKeyClass;
+ }
+
+ protected void setDefaultMapKeyClass(String mapKeyClass) {
+ String old = this.defaultMapKeyClass;
+ this.defaultMapKeyClass = mapKeyClass;
+ this.firePropertyChanged(DEFAULT_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass);
+ }
+
+ protected String getResourceMapKeyClass() {
+ XmlMapKeyClass mapKeyClass = this.resourceAttributeMapping.getMapKeyClass();
+ return mapKeyClass == null ? null : mapKeyClass.getClassName();
+ }
+
+ protected String buildDefaultMapKeyClass() {
+ if (this.getJavaPersistentAttribute() != null) {
+ return this.getJavaPersistentAttribute().getMultiReferenceMapKeyTypeName();
+ }
+ return null;
+ }
+
// ********** metamodel **********
- //TODO map metamodel
@Override
protected String getMetamodelFieldTypeName() {
- return ((JavaPersistentAttribute2_0) this.getPersistentAttribute()).getMetamodelContainerFieldTypeName();
+ return ((PersistentAttribute2_0) getPersistentAttribute()).getMetamodelContainerFieldTypeName();
}
@Override
@@ -492,15 +765,15 @@ public class GenericOrmElementCollectionMapping2_0
}
protected void addMetamodelFieldMapKeyTypeArgumentNameTo(ArrayList<String> typeArgumentNames) {
-// String keyTypeName = ((JavaPersistentAttribute2_0) this.getPersistentAttribute()).getMetamodelContainerFieldMapKeyTypeName();
-// if (keyTypeName != null) {
-// typeArgumentNames.add(keyTypeName);
-// }
+ String keyTypeName = ((PersistentAttribute2_0) this.getPersistentAttribute()).getMetamodelContainerFieldMapKeyTypeName();
+ if (keyTypeName != null) {
+ typeArgumentNames.add(keyTypeName);
+ }
}
-// public String getMetamodelFieldMapKeyTypeName() {
-// return MappingTools.getMetamodelFieldMapKeyTypeName(this);
-// }
+ public String getMetamodelFieldMapKeyTypeName() {
+ return MappingTools.getMetamodelFieldMapKeyTypeName(this);
+ }
// ********** validation **********
@@ -515,7 +788,6 @@ public class GenericOrmElementCollectionMapping2_0
this.getConverter().validate(messages, reporter);
this.getValueAttributeOverrideContainer().validate(messages, reporter);
this.getValueAssociationOverrideContainer().validate(messages, reporter);
-
}
protected void validateTargetClass(List<IMessage> messages) {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualMapKeyClass.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualMapKeyClass.java
new file mode 100644
index 0000000000..a900728461
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualMapKeyClass.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.core.internal.jpa2.context.orm;
+
+import org.eclipse.jpt.core.context.CollectionMapping;
+import org.eclipse.jpt.core.resource.orm.XmlMapKeyClass;
+
+public class VirtualMapKeyClass extends XmlMapKeyClass
+{
+ CollectionMapping javaCollectionMapping;
+
+ public VirtualMapKeyClass(CollectionMapping collectionMapping) {
+ super();
+ this.javaCollectionMapping = collectionMapping;
+ }
+
+ @Override
+ public String getClassName() {
+ return this.javaCollectionMapping.getSpecifiedMapKeyClass();
+ }
+
+ @Override
+ public void setClassName(String newClassName) {
+ throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlElementCollection2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlElementCollection2_0.java
index 635eac63c9..7894839208 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlElementCollection2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlElementCollection2_0.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2010 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.
@@ -10,12 +10,15 @@
package org.eclipse.jpt.core.internal.jpa2.context.orm;
import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
+import org.eclipse.jpt.core.internal.context.orm.VirtualMapKey;
import org.eclipse.jpt.core.internal.context.orm.VirtualXmlAttributeMapping;
import org.eclipse.jpt.core.jpa2.context.java.JavaElementCollectionMapping2_0;
import org.eclipse.jpt.core.resource.orm.AccessType;
import org.eclipse.jpt.core.resource.orm.FetchType;
+import org.eclipse.jpt.core.resource.orm.MapKey;
import org.eclipse.jpt.core.resource.orm.XmlCollectionTable;
import org.eclipse.jpt.core.resource.orm.XmlElementCollection;
+import org.eclipse.jpt.core.resource.orm.XmlMapKeyClass;
import org.eclipse.jpt.core.utility.TextRange;
/**
@@ -30,13 +33,18 @@ public class VirtualXmlElementCollection2_0 extends XmlElementCollection
protected final VirtualXmlAttributeMapping virtualXmlAttributeMapping;
+ protected final MapKey mapKey;
+ protected final XmlMapKeyClass mapKeyClass;
+
public VirtualXmlElementCollection2_0(
OrmTypeMapping ormTypeMapping, JavaElementCollectionMapping2_0 javaMapping) {
super();
this.ormTypeMapping = ormTypeMapping;
this.javaAttributeMapping = javaMapping;
this.virtualXmlAttributeMapping = new VirtualXmlAttributeMapping(ormTypeMapping, javaMapping);
+ this.mapKey = new VirtualMapKey(javaMapping);
+ this.mapKeyClass = new VirtualMapKeyClass(javaMapping);
}
protected boolean isOrmMetadataComplete() {
@@ -122,4 +130,32 @@ public class VirtualXmlElementCollection2_0 extends XmlElementCollection
throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
}
+ @Override
+ public MapKey getMapKey() {
+ if (this.isOrmMetadataComplete()) {
+ return null;
+ }
+ if (this.javaAttributeMapping.isNoMapKey()) {
+ return null;
+ }
+ return this.mapKey;
+ }
+
+ @Override
+ public void setMapKey(MapKey value) {
+ throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
+ }
+
+ @Override
+ public XmlMapKeyClass getMapKeyClass() {
+ if (this.isOrmMetadataComplete()) {
+ return null;
+ }
+ return this.mapKeyClass;
+ }
+
+ @Override
+ public void setMapKeyClass(XmlMapKeyClass newMapKeyClass) {
+ throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlManyToMany2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlManyToMany2_0.java
index 8a7fcac676..87befa3968 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlManyToMany2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlManyToMany2_0.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2010 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.
@@ -9,7 +9,6 @@
******************************************************************************/
package org.eclipse.jpt.core.internal.jpa2.context.orm;
-import org.eclipse.emf.common.util.EList;
import org.eclipse.jpt.core.context.java.JavaManyToManyMapping;
import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
import org.eclipse.jpt.core.internal.context.orm.VirtualXmlManyToMany;
@@ -17,9 +16,9 @@ import org.eclipse.jpt.core.resource.orm.AccessType;
import org.eclipse.jpt.core.resource.orm.CascadeType;
import org.eclipse.jpt.core.resource.orm.FetchType;
import org.eclipse.jpt.core.resource.orm.MapKey;
-import org.eclipse.jpt.core.resource.orm.XmlJoinColumn;
import org.eclipse.jpt.core.resource.orm.XmlJoinTable;
import org.eclipse.jpt.core.resource.orm.XmlManyToMany;
+import org.eclipse.jpt.core.resource.orm.XmlMapKeyClass;
import org.eclipse.jpt.core.resource.orm.XmlOrderColumn;
import org.eclipse.jpt.core.utility.TextRange;
@@ -35,12 +34,15 @@ public class VirtualXmlManyToMany2_0 extends XmlManyToMany
protected final JavaManyToManyMapping javaAttributeMapping;
protected final VirtualXmlManyToMany virtualXmlManyToMany;
-
+
+ protected final XmlMapKeyClass mapKeyClass;
+
public VirtualXmlManyToMany2_0(OrmTypeMapping ormTypeMapping, JavaManyToManyMapping javaManyToManyMapping) {
super();
this.ormTypeMapping = ormTypeMapping;
this.javaAttributeMapping = javaManyToManyMapping;
this.virtualXmlManyToMany = new VirtualXmlManyToMany(ormTypeMapping, javaManyToManyMapping);
+ this.mapKeyClass = new VirtualMapKeyClass(javaManyToManyMapping);
}
protected boolean isOrmMetadataComplete() {
@@ -77,10 +79,6 @@ public class VirtualXmlManyToMany2_0 extends XmlManyToMany
this.virtualXmlManyToMany.setFetch(newFetch);
}
- public EList<XmlJoinColumn> getJoinColumns() {
- return this.virtualXmlManyToMany.getJoinColumns();
- }
-
@Override
public CascadeType getCascade() {
return this.virtualXmlManyToMany.getCascade();
@@ -133,6 +131,19 @@ public class VirtualXmlManyToMany2_0 extends XmlManyToMany
}
@Override
+ public XmlMapKeyClass getMapKeyClass() {
+ if (this.isOrmMetadataComplete()) {
+ return null;
+ }
+ return this.mapKeyClass;
+ }
+
+ @Override
+ public void setMapKeyClass(XmlMapKeyClass newMapKeyClass) {
+ throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
+ }
+
+ @Override
public String getOrderBy() {
return this.virtualXmlManyToMany.getOrderBy();
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlOneToMany2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlOneToMany2_0.java
index cce837f50d..9661ef694f 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlOneToMany2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlOneToMany2_0.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2010 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.
@@ -22,6 +22,7 @@ import org.eclipse.jpt.core.resource.orm.FetchType;
import org.eclipse.jpt.core.resource.orm.MapKey;
import org.eclipse.jpt.core.resource.orm.XmlJoinColumn;
import org.eclipse.jpt.core.resource.orm.XmlJoinTable;
+import org.eclipse.jpt.core.resource.orm.XmlMapKeyClass;
import org.eclipse.jpt.core.resource.orm.XmlOneToMany;
import org.eclipse.jpt.core.resource.orm.XmlOrderColumn;
import org.eclipse.jpt.core.utility.TextRange;
@@ -38,6 +39,8 @@ public class VirtualXmlOneToMany2_0 extends XmlOneToMany
protected final JavaOneToManyMapping2_0 javaAttributeMapping;
protected final VirtualXmlOneToMany virtualXmlOneToMany;
+
+ protected final XmlMapKeyClass mapKeyClass;
public VirtualXmlOneToMany2_0(
OrmTypeMapping ormTypeMapping, JavaOneToManyMapping2_0 javaOneToManyMapping) {
@@ -45,6 +48,7 @@ public class VirtualXmlOneToMany2_0 extends XmlOneToMany
this.ormTypeMapping = ormTypeMapping;
this.javaAttributeMapping = javaOneToManyMapping;
this.virtualXmlOneToMany = new VirtualXmlOneToMany(ormTypeMapping, javaOneToManyMapping);
+ this.mapKeyClass = new VirtualMapKeyClass(javaOneToManyMapping);
}
protected boolean isOrmMetadataComplete() {
@@ -151,6 +155,19 @@ public class VirtualXmlOneToMany2_0 extends XmlOneToMany
}
@Override
+ public XmlMapKeyClass getMapKeyClass() {
+ if (this.isOrmMetadataComplete()) {
+ return null;
+ }
+ return this.mapKeyClass;
+ }
+
+ @Override
+ public void setMapKeyClass(XmlMapKeyClass newMapKeyClass) {
+ throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
+ }
+
+ @Override
public String getOrderBy() {
return this.virtualXmlOneToMany.getOrderBy();
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/ElementCollectionMapping2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/ElementCollectionMapping2_0.java
index cf7de8964e..06841b71b6 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/ElementCollectionMapping2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/ElementCollectionMapping2_0.java
@@ -58,8 +58,9 @@ public interface ElementCollectionMapping2_0
String KEY_TYPE_PROPERTY = "keyType"; //$NON-NLS-1$
public enum Type {
- EMBEDDABLE_TYPE,
BASIC_TYPE,
+ EMBEDDABLE_TYPE,
+ ENTITY_TYPE,
NO_TYPE
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/PersistentAttribute2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/PersistentAttribute2_0.java
new file mode 100644
index 0000000000..c97885fb9b
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/PersistentAttribute2_0.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.core.jpa2.context;
+
+import org.eclipse.jpt.core.context.PersistentAttribute;
+
+/**
+ * JPA 2.0 persistent attribute (field or property)
+ * <p>
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ */
+public interface PersistentAttribute2_0
+ extends PersistentAttribute
+{
+ /**
+ * Return the name of the container type to be used in the metamodel field
+ * declaration corresponding to the attribute's mapping.
+ */
+ String getMetamodelContainerFieldTypeName();
+
+ /**
+ * Return the name of the container map key type to be used in the
+ * metamodel field declaration corresponding to the attribute's mapping.
+ * Return null if the attribute's type is not {@link java.util.Map}.
+ */
+ String getMetamodelContainerFieldMapKeyTypeName();
+
+ /**
+ * Return the attribute's type name for the metamodel.
+ */
+ String getMetamodelTypeName();
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/java/JavaPersistentAttribute2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/java/JavaPersistentAttribute2_0.java
index 6e50f76aeb..4267d513e3 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/java/JavaPersistentAttribute2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/java/JavaPersistentAttribute2_0.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2010 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.
@@ -10,9 +10,10 @@
package org.eclipse.jpt.core.jpa2.context.java;
import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
+import org.eclipse.jpt.core.jpa2.context.PersistentAttribute2_0;
/**
- * JPA 2.0 Java persistent attribute (field or property)
+ * JPA 2.0 context Java persistent attribute (field or property)
* <p>
* Provisional API: This interface is part of an interim API that is still
* under development and expected to change significantly before reaching
@@ -21,23 +22,7 @@ import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
* will almost certainly be broken (repeatedly) as the API evolves.
*/
public interface JavaPersistentAttribute2_0
- extends JavaPersistentAttribute
+ extends JavaPersistentAttribute, PersistentAttribute2_0
{
- /**
- * Return the name of the container type to be used in the metamodel field
- * declaration corresponding to the attribute's mapping.
- */
- String getMetamodelContainerFieldTypeName();
-
- /**
- * Return the name of the container map key type to be used in the
- * metamodel field declaration corresponding to the attribute's mapping.
- * Return null if the attribute's type is not {@link java.util.Map}.
- */
- String getMetamodelContainerFieldMapKeyTypeName();
-
- /**
- * Return the attribute's type name for the metamodel.
- */
- String getMetamodelTypeName();
+ // nothing yet...
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/orm/OrmPersistentAttribute2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/orm/OrmPersistentAttribute2_0.java
new file mode 100644
index 0000000000..e4e53dddb2
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/orm/OrmPersistentAttribute2_0.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.core.jpa2.context.orm;
+
+import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
+import org.eclipse.jpt.core.jpa2.context.PersistentAttribute2_0;
+
+/**
+ * JPA 2.0 context orm persistent attribute (field or property)
+ * <p>
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ */
+public interface OrmPersistentAttribute2_0
+ extends OrmPersistentAttribute, PersistentAttribute2_0
+{
+ // nothing yet...
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/AbstractXmlMultiRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/AbstractXmlMultiRelationshipMapping.java
index b096eb26fa..2fafb4218a 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/AbstractXmlMultiRelationshipMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/AbstractXmlMultiRelationshipMapping.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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.
@@ -9,12 +9,17 @@
******************************************************************************/
package org.eclipse.jpt.core.resource.orm;
+import java.util.Collection;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
+import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
+import org.eclipse.emf.ecore.util.EObjectContainmentEList;
+import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package;
+import org.eclipse.jpt.core.resource.orm.v2_0.XmlMultiRelationshipMapping_2_0;
import org.eclipse.jpt.core.resource.orm.v2_0.XmlOrderable_2_0;
import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.wst.common.internal.emf.resource.Translator;
@@ -42,7 +47,7 @@ import org.eclipse.wst.common.internal.emf.resource.Translator;
* @model kind="class" abstract="true"
* @generated
*/
-public abstract class AbstractXmlMultiRelationshipMapping extends AbstractXmlRelationshipMapping implements XmlMappedByMapping, XmlJoinTableMapping, XmlOrderable
+public abstract class AbstractXmlMultiRelationshipMapping extends AbstractXmlRelationshipMapping implements XmlMappedByMapping, XmlJoinTableMapping, XmlOrderable, XmlMultiRelationshipMapping_2_0
{
/**
* The default value of the '{@link #getMappedBy() <em>Mapped By</em>}' attribute.
@@ -99,6 +104,70 @@ public abstract class AbstractXmlMultiRelationshipMapping extends AbstractXmlRel
*/
protected String orderBy = ORDER_BY_EDEFAULT;
/**
+ * The cached value of the '{@link #getMapKeyClass() <em>Map Key Class</em>}' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getMapKeyClass()
+ * @generated
+ * @ordered
+ */
+ protected XmlMapKeyClass mapKeyClass;
+ /**
+ * changed this to null and removed the generated flag so emf won't generate over it
+ * we don't want a default for enums, just null if the tag does not exist
+ */
+ protected static final TemporalType MAP_KEY_TEMPORAL_EDEFAULT = null;
+ /**
+ * The cached value of the '{@link #getMapKeyTemporal() <em>Map Key Temporal</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getMapKeyTemporal()
+ * @generated
+ * @ordered
+ */
+ protected TemporalType mapKeyTemporal = MAP_KEY_TEMPORAL_EDEFAULT;
+ /**
+ * changed this to null and removed the generated flag so emf won't generate over it
+ * we don't want a default for enums, just null if the tag does not exist
+ */
+ protected static final EnumType MAP_KEY_ENUMERATED_EDEFAULT = null;
+ /**
+ * The cached value of the '{@link #getMapKeyEnumerated() <em>Map Key Enumerated</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getMapKeyEnumerated()
+ * @generated
+ * @ordered
+ */
+ protected EnumType mapKeyEnumerated = MAP_KEY_ENUMERATED_EDEFAULT;
+ /**
+ * The cached value of the '{@link #getMapKeyAttributeOverrides() <em>Map Key Attribute Overrides</em>}' containment reference list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getMapKeyAttributeOverrides()
+ * @generated
+ * @ordered
+ */
+ protected EList<XmlAttributeOverride> mapKeyAttributeOverrides;
+ /**
+ * The cached value of the '{@link #getMapKeyColumn() <em>Map Key Column</em>}' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getMapKeyColumn()
+ * @generated
+ * @ordered
+ */
+ protected XmlColumn mapKeyColumn;
+ /**
+ * The cached value of the '{@link #getMapKeyJoinColumns() <em>Map Key Join Columns</em>}' containment reference list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getMapKeyJoinColumns()
+ * @generated
+ * @ordered
+ */
+ protected EList<XmlJoinColumn> mapKeyJoinColumns;
+ /**
* The cached value of the '{@link #getMapKey() <em>Map Key</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -318,6 +387,248 @@ public abstract class AbstractXmlMultiRelationshipMapping extends AbstractXmlRel
}
/**
+ * Returns the value of the '<em><b>Map Key Class</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Map Key Class</em>' containment reference isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Map Key Class</em>' containment reference.
+ * @see #setMapKeyClass(XmlMapKeyClass)
+ * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlMultiRelationshipMapping_2_0_MapKeyClass()
+ * @model containment="true"
+ * @generated
+ */
+ public XmlMapKeyClass getMapKeyClass()
+ {
+ return mapKeyClass;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public NotificationChain basicSetMapKeyClass(XmlMapKeyClass newMapKeyClass, NotificationChain msgs)
+ {
+ XmlMapKeyClass oldMapKeyClass = mapKeyClass;
+ mapKeyClass = newMapKeyClass;
+ if (eNotificationRequired())
+ {
+ ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_CLASS, oldMapKeyClass, newMapKeyClass);
+ if (msgs == null) msgs = notification; else msgs.add(notification);
+ }
+ return msgs;
+ }
+
+ /**
+ * Sets the value of the '{@link org.eclipse.jpt.core.resource.orm.AbstractXmlMultiRelationshipMapping#getMapKeyClass <em>Map Key Class</em>}' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Map Key Class</em>' containment reference.
+ * @see #getMapKeyClass()
+ * @generated
+ */
+ public void setMapKeyClass(XmlMapKeyClass newMapKeyClass)
+ {
+ if (newMapKeyClass != mapKeyClass)
+ {
+ NotificationChain msgs = null;
+ if (mapKeyClass != null)
+ msgs = ((InternalEObject)mapKeyClass).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_CLASS, null, msgs);
+ if (newMapKeyClass != null)
+ msgs = ((InternalEObject)newMapKeyClass).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_CLASS, null, msgs);
+ msgs = basicSetMapKeyClass(newMapKeyClass, msgs);
+ if (msgs != null) msgs.dispatch();
+ }
+ else if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_CLASS, newMapKeyClass, newMapKeyClass));
+ }
+
+ /**
+ * Returns the value of the '<em><b>Map Key Temporal</b></em>' attribute.
+ * The literals are from the enumeration {@link org.eclipse.jpt.core.resource.orm.TemporalType}.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Map Key Temporal</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Map Key Temporal</em>' attribute.
+ * @see org.eclipse.jpt.core.resource.orm.TemporalType
+ * @see #setMapKeyTemporal(TemporalType)
+ * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlMultiRelationshipMapping_2_0_MapKeyTemporal()
+ * @model
+ * @generated
+ */
+ public TemporalType getMapKeyTemporal()
+ {
+ return mapKeyTemporal;
+ }
+
+ /**
+ * Sets the value of the '{@link org.eclipse.jpt.core.resource.orm.AbstractXmlMultiRelationshipMapping#getMapKeyTemporal <em>Map Key Temporal</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Map Key Temporal</em>' attribute.
+ * @see org.eclipse.jpt.core.resource.orm.TemporalType
+ * @see #getMapKeyTemporal()
+ * @generated
+ */
+ public void setMapKeyTemporal(TemporalType newMapKeyTemporal)
+ {
+ TemporalType oldMapKeyTemporal = mapKeyTemporal;
+ mapKeyTemporal = newMapKeyTemporal == null ? MAP_KEY_TEMPORAL_EDEFAULT : newMapKeyTemporal;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_TEMPORAL, oldMapKeyTemporal, mapKeyTemporal));
+ }
+
+ /**
+ * Returns the value of the '<em><b>Map Key Enumerated</b></em>' attribute.
+ * The literals are from the enumeration {@link org.eclipse.jpt.core.resource.orm.EnumType}.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Map Key Enumerated</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Map Key Enumerated</em>' attribute.
+ * @see org.eclipse.jpt.core.resource.orm.EnumType
+ * @see #setMapKeyEnumerated(EnumType)
+ * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlMultiRelationshipMapping_2_0_MapKeyEnumerated()
+ * @model
+ * @generated
+ */
+ public EnumType getMapKeyEnumerated()
+ {
+ return mapKeyEnumerated;
+ }
+
+ /**
+ * Sets the value of the '{@link org.eclipse.jpt.core.resource.orm.AbstractXmlMultiRelationshipMapping#getMapKeyEnumerated <em>Map Key Enumerated</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Map Key Enumerated</em>' attribute.
+ * @see org.eclipse.jpt.core.resource.orm.EnumType
+ * @see #getMapKeyEnumerated()
+ * @generated
+ */
+ public void setMapKeyEnumerated(EnumType newMapKeyEnumerated)
+ {
+ EnumType oldMapKeyEnumerated = mapKeyEnumerated;
+ mapKeyEnumerated = newMapKeyEnumerated == null ? MAP_KEY_ENUMERATED_EDEFAULT : newMapKeyEnumerated;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_ENUMERATED, oldMapKeyEnumerated, mapKeyEnumerated));
+ }
+
+ /**
+ * Returns the value of the '<em><b>Map Key Attribute Overrides</b></em>' containment reference list.
+ * The list contents are of type {@link org.eclipse.jpt.core.resource.orm.XmlAttributeOverride}.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Map Key Attribute Overrides</em>' containment reference list isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Map Key Attribute Overrides</em>' containment reference list.
+ * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlMultiRelationshipMapping_2_0_MapKeyAttributeOverrides()
+ * @model containment="true"
+ * @generated
+ */
+ public EList<XmlAttributeOverride> getMapKeyAttributeOverrides()
+ {
+ if (mapKeyAttributeOverrides == null)
+ {
+ mapKeyAttributeOverrides = new EObjectContainmentEList<XmlAttributeOverride>(XmlAttributeOverride.class, this, OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_ATTRIBUTE_OVERRIDES);
+ }
+ return mapKeyAttributeOverrides;
+ }
+
+ /**
+ * Returns the value of the '<em><b>Map Key Column</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Map Key Column</em>' containment reference isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Map Key Column</em>' containment reference.
+ * @see #setMapKeyColumn(XmlColumn)
+ * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlMultiRelationshipMapping_2_0_MapKeyColumn()
+ * @model containment="true"
+ * @generated
+ */
+ public XmlColumn getMapKeyColumn()
+ {
+ return mapKeyColumn;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public NotificationChain basicSetMapKeyColumn(XmlColumn newMapKeyColumn, NotificationChain msgs)
+ {
+ XmlColumn oldMapKeyColumn = mapKeyColumn;
+ mapKeyColumn = newMapKeyColumn;
+ if (eNotificationRequired())
+ {
+ ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_COLUMN, oldMapKeyColumn, newMapKeyColumn);
+ if (msgs == null) msgs = notification; else msgs.add(notification);
+ }
+ return msgs;
+ }
+
+ /**
+ * Sets the value of the '{@link org.eclipse.jpt.core.resource.orm.AbstractXmlMultiRelationshipMapping#getMapKeyColumn <em>Map Key Column</em>}' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Map Key Column</em>' containment reference.
+ * @see #getMapKeyColumn()
+ * @generated
+ */
+ public void setMapKeyColumn(XmlColumn newMapKeyColumn)
+ {
+ if (newMapKeyColumn != mapKeyColumn)
+ {
+ NotificationChain msgs = null;
+ if (mapKeyColumn != null)
+ msgs = ((InternalEObject)mapKeyColumn).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_COLUMN, null, msgs);
+ if (newMapKeyColumn != null)
+ msgs = ((InternalEObject)newMapKeyColumn).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_COLUMN, null, msgs);
+ msgs = basicSetMapKeyColumn(newMapKeyColumn, msgs);
+ if (msgs != null) msgs.dispatch();
+ }
+ else if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_COLUMN, newMapKeyColumn, newMapKeyColumn));
+ }
+
+ /**
+ * Returns the value of the '<em><b>Map Key Join Columns</b></em>' containment reference list.
+ * The list contents are of type {@link org.eclipse.jpt.core.resource.orm.XmlJoinColumn}.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Map Key Join Columns</em>' containment reference list isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Map Key Join Columns</em>' containment reference list.
+ * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlMultiRelationshipMapping_2_0_MapKeyJoinColumns()
+ * @model containment="true"
+ * @generated
+ */
+ public EList<XmlJoinColumn> getMapKeyJoinColumns()
+ {
+ if (mapKeyJoinColumns == null)
+ {
+ mapKeyJoinColumns = new EObjectContainmentEList<XmlJoinColumn>(XmlJoinColumn.class, this, OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_JOIN_COLUMNS);
+ }
+ return mapKeyJoinColumns;
+ }
+
+ /**
* Returns the value of the '<em><b>Map Key</b></em>' containment reference.
* <!-- begin-user-doc -->
* <p>
@@ -389,6 +700,14 @@ public abstract class AbstractXmlMultiRelationshipMapping extends AbstractXmlRel
return basicSetJoinTable(null, msgs);
case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__ORDER_COLUMN:
return basicSetOrderColumn(null, msgs);
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_CLASS:
+ return basicSetMapKeyClass(null, msgs);
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_ATTRIBUTE_OVERRIDES:
+ return ((InternalEList<?>)getMapKeyAttributeOverrides()).basicRemove(otherEnd, msgs);
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_COLUMN:
+ return basicSetMapKeyColumn(null, msgs);
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_JOIN_COLUMNS:
+ return ((InternalEList<?>)getMapKeyJoinColumns()).basicRemove(otherEnd, msgs);
case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY:
return basicSetMapKey(null, msgs);
}
@@ -413,6 +732,18 @@ public abstract class AbstractXmlMultiRelationshipMapping extends AbstractXmlRel
return getOrderColumn();
case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__ORDER_BY:
return getOrderBy();
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_CLASS:
+ return getMapKeyClass();
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_TEMPORAL:
+ return getMapKeyTemporal();
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_ENUMERATED:
+ return getMapKeyEnumerated();
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_ATTRIBUTE_OVERRIDES:
+ return getMapKeyAttributeOverrides();
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_COLUMN:
+ return getMapKeyColumn();
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_JOIN_COLUMNS:
+ return getMapKeyJoinColumns();
case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY:
return getMapKey();
}
@@ -424,6 +755,7 @@ public abstract class AbstractXmlMultiRelationshipMapping extends AbstractXmlRel
* <!-- end-user-doc -->
* @generated
*/
+ @SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue)
{
@@ -441,6 +773,26 @@ public abstract class AbstractXmlMultiRelationshipMapping extends AbstractXmlRel
case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__ORDER_BY:
setOrderBy((String)newValue);
return;
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_CLASS:
+ setMapKeyClass((XmlMapKeyClass)newValue);
+ return;
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_TEMPORAL:
+ setMapKeyTemporal((TemporalType)newValue);
+ return;
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_ENUMERATED:
+ setMapKeyEnumerated((EnumType)newValue);
+ return;
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_ATTRIBUTE_OVERRIDES:
+ getMapKeyAttributeOverrides().clear();
+ getMapKeyAttributeOverrides().addAll((Collection<? extends XmlAttributeOverride>)newValue);
+ return;
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_COLUMN:
+ setMapKeyColumn((XmlColumn)newValue);
+ return;
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_JOIN_COLUMNS:
+ getMapKeyJoinColumns().clear();
+ getMapKeyJoinColumns().addAll((Collection<? extends XmlJoinColumn>)newValue);
+ return;
case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY:
setMapKey((MapKey)newValue);
return;
@@ -470,6 +822,24 @@ public abstract class AbstractXmlMultiRelationshipMapping extends AbstractXmlRel
case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__ORDER_BY:
setOrderBy(ORDER_BY_EDEFAULT);
return;
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_CLASS:
+ setMapKeyClass((XmlMapKeyClass)null);
+ return;
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_TEMPORAL:
+ setMapKeyTemporal(MAP_KEY_TEMPORAL_EDEFAULT);
+ return;
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_ENUMERATED:
+ setMapKeyEnumerated(MAP_KEY_ENUMERATED_EDEFAULT);
+ return;
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_ATTRIBUTE_OVERRIDES:
+ getMapKeyAttributeOverrides().clear();
+ return;
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_COLUMN:
+ setMapKeyColumn((XmlColumn)null);
+ return;
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_JOIN_COLUMNS:
+ getMapKeyJoinColumns().clear();
+ return;
case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY:
setMapKey((MapKey)null);
return;
@@ -495,6 +865,18 @@ public abstract class AbstractXmlMultiRelationshipMapping extends AbstractXmlRel
return orderColumn != null;
case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__ORDER_BY:
return ORDER_BY_EDEFAULT == null ? orderBy != null : !ORDER_BY_EDEFAULT.equals(orderBy);
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_CLASS:
+ return mapKeyClass != null;
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_TEMPORAL:
+ return mapKeyTemporal != MAP_KEY_TEMPORAL_EDEFAULT;
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_ENUMERATED:
+ return mapKeyEnumerated != MAP_KEY_ENUMERATED_EDEFAULT;
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_ATTRIBUTE_OVERRIDES:
+ return mapKeyAttributeOverrides != null && !mapKeyAttributeOverrides.isEmpty();
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_COLUMN:
+ return mapKeyColumn != null;
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_JOIN_COLUMNS:
+ return mapKeyJoinColumns != null && !mapKeyJoinColumns.isEmpty();
case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY:
return mapKey != null;
}
@@ -541,6 +923,19 @@ public abstract class AbstractXmlMultiRelationshipMapping extends AbstractXmlRel
default: return -1;
}
}
+ if (baseClass == XmlMultiRelationshipMapping_2_0.class)
+ {
+ switch (derivedFeatureID)
+ {
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_CLASS: return OrmV2_0Package.XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_CLASS;
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_TEMPORAL: return OrmV2_0Package.XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_TEMPORAL;
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_ENUMERATED: return OrmV2_0Package.XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_ENUMERATED;
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_ATTRIBUTE_OVERRIDES: return OrmV2_0Package.XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_ATTRIBUTE_OVERRIDES;
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_COLUMN: return OrmV2_0Package.XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_COLUMN;
+ case OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_JOIN_COLUMNS: return OrmV2_0Package.XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_JOIN_COLUMNS;
+ default: return -1;
+ }
+ }
return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass);
}
@@ -584,6 +979,19 @@ public abstract class AbstractXmlMultiRelationshipMapping extends AbstractXmlRel
default: return -1;
}
}
+ if (baseClass == XmlMultiRelationshipMapping_2_0.class)
+ {
+ switch (baseFeatureID)
+ {
+ case OrmV2_0Package.XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_CLASS: return OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_CLASS;
+ case OrmV2_0Package.XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_TEMPORAL: return OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_TEMPORAL;
+ case OrmV2_0Package.XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_ENUMERATED: return OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_ENUMERATED;
+ case OrmV2_0Package.XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_ATTRIBUTE_OVERRIDES: return OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_ATTRIBUTE_OVERRIDES;
+ case OrmV2_0Package.XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_COLUMN: return OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_COLUMN;
+ case OrmV2_0Package.XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_JOIN_COLUMNS: return OrmPackage.ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_JOIN_COLUMNS;
+ default: return -1;
+ }
+ }
return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass);
}
@@ -602,6 +1010,10 @@ public abstract class AbstractXmlMultiRelationshipMapping extends AbstractXmlRel
result.append(mappedBy);
result.append(", orderBy: ");
result.append(orderBy);
+ result.append(", mapKeyTemporal: ");
+ result.append(mapKeyTemporal);
+ result.append(", mapKeyEnumerated: ");
+ result.append(mapKeyEnumerated);
result.append(')');
return result.toString();
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/MapKey.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/MapKey.java
index 0172da4768..845a5cbfe1 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/MapKey.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/MapKey.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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.
@@ -215,7 +215,7 @@ public class MapKey extends AbstractJpaEObject implements JpaEObject
}
protected static Translator buildNameTranslator() {
- return new Translator(JPA.MAP_KEY, OrmPackage.eINSTANCE.getMapKey_Name());
+ return new Translator(JPA.NAME, OrmPackage.eINSTANCE.getMapKey_Name(), Translator.DOM_ATTRIBUTE);
}
} // MapKey
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/OrmPackage.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/OrmPackage.java
index 5780e9aa8c..1cc569dc5c 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/OrmPackage.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/OrmPackage.java
@@ -496,13 +496,67 @@ public class OrmPackage extends EPackageImpl
public static final int ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__ORDER_BY = ABSTRACT_XML_RELATIONSHIP_MAPPING_FEATURE_COUNT + 3;
/**
+ * The feature id for the '<em><b>Map Key Class</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_CLASS = ABSTRACT_XML_RELATIONSHIP_MAPPING_FEATURE_COUNT + 4;
+
+ /**
+ * The feature id for the '<em><b>Map Key Temporal</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_TEMPORAL = ABSTRACT_XML_RELATIONSHIP_MAPPING_FEATURE_COUNT + 5;
+
+ /**
+ * The feature id for the '<em><b>Map Key Enumerated</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_ENUMERATED = ABSTRACT_XML_RELATIONSHIP_MAPPING_FEATURE_COUNT + 6;
+
+ /**
+ * The feature id for the '<em><b>Map Key Attribute Overrides</b></em>' containment reference list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_ATTRIBUTE_OVERRIDES = ABSTRACT_XML_RELATIONSHIP_MAPPING_FEATURE_COUNT + 7;
+
+ /**
+ * The feature id for the '<em><b>Map Key Column</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_COLUMN = ABSTRACT_XML_RELATIONSHIP_MAPPING_FEATURE_COUNT + 8;
+
+ /**
+ * The feature id for the '<em><b>Map Key Join Columns</b></em>' containment reference list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_JOIN_COLUMNS = ABSTRACT_XML_RELATIONSHIP_MAPPING_FEATURE_COUNT + 9;
+
+ /**
* The feature id for the '<em><b>Map Key</b></em>' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- public static final int ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY = ABSTRACT_XML_RELATIONSHIP_MAPPING_FEATURE_COUNT + 4;
+ public static final int ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY = ABSTRACT_XML_RELATIONSHIP_MAPPING_FEATURE_COUNT + 10;
/**
* The number of structural features of the '<em>Abstract Xml Multi Relationship Mapping</em>' class.
@@ -511,7 +565,7 @@ public class OrmPackage extends EPackageImpl
* @generated
* @ordered
*/
- public static final int ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING_FEATURE_COUNT = ABSTRACT_XML_RELATIONSHIP_MAPPING_FEATURE_COUNT + 5;
+ public static final int ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING_FEATURE_COUNT = ABSTRACT_XML_RELATIONSHIP_MAPPING_FEATURE_COUNT + 11;
/**
* The meta object id for the '{@link org.eclipse.jpt.core.resource.orm.AbstractXmlSingleRelationshipMapping <em>Abstract Xml Single Relationship Mapping</em>}' class.
@@ -3649,67 +3703,67 @@ public class OrmPackage extends EPackageImpl
public static final int XML_MANY_TO_MANY__ORDER_BY = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__ORDER_BY;
/**
- * The feature id for the '<em><b>Map Key</b></em>' containment reference.
+ * The feature id for the '<em><b>Map Key Class</b></em>' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- public static final int XML_MANY_TO_MANY__MAP_KEY = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY;
+ public static final int XML_MANY_TO_MANY__MAP_KEY_CLASS = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_CLASS;
/**
- * The feature id for the '<em><b>Map Key Class</b></em>' containment reference.
+ * The feature id for the '<em><b>Map Key Temporal</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- public static final int XML_MANY_TO_MANY__MAP_KEY_CLASS = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING_FEATURE_COUNT + 0;
+ public static final int XML_MANY_TO_MANY__MAP_KEY_TEMPORAL = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_TEMPORAL;
/**
- * The feature id for the '<em><b>Map Key Temporal</b></em>' attribute.
+ * The feature id for the '<em><b>Map Key Enumerated</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- public static final int XML_MANY_TO_MANY__MAP_KEY_TEMPORAL = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING_FEATURE_COUNT + 1;
+ public static final int XML_MANY_TO_MANY__MAP_KEY_ENUMERATED = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_ENUMERATED;
/**
- * The feature id for the '<em><b>Map Key Enumerated</b></em>' attribute.
+ * The feature id for the '<em><b>Map Key Attribute Overrides</b></em>' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- public static final int XML_MANY_TO_MANY__MAP_KEY_ENUMERATED = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING_FEATURE_COUNT + 2;
+ public static final int XML_MANY_TO_MANY__MAP_KEY_ATTRIBUTE_OVERRIDES = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_ATTRIBUTE_OVERRIDES;
/**
- * The feature id for the '<em><b>Map Key Attribute Overrides</b></em>' containment reference list.
+ * The feature id for the '<em><b>Map Key Column</b></em>' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- public static final int XML_MANY_TO_MANY__MAP_KEY_ATTRIBUTE_OVERRIDES = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING_FEATURE_COUNT + 3;
+ public static final int XML_MANY_TO_MANY__MAP_KEY_COLUMN = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_COLUMN;
/**
- * The feature id for the '<em><b>Map Key Column</b></em>' containment reference.
+ * The feature id for the '<em><b>Map Key Join Columns</b></em>' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- public static final int XML_MANY_TO_MANY__MAP_KEY_COLUMN = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING_FEATURE_COUNT + 4;
+ public static final int XML_MANY_TO_MANY__MAP_KEY_JOIN_COLUMNS = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_JOIN_COLUMNS;
/**
- * The feature id for the '<em><b>Map Key Join Columns</b></em>' containment reference list.
+ * The feature id for the '<em><b>Map Key</b></em>' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- public static final int XML_MANY_TO_MANY__MAP_KEY_JOIN_COLUMNS = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING_FEATURE_COUNT + 5;
+ public static final int XML_MANY_TO_MANY__MAP_KEY = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY;
/**
* The number of structural features of the '<em>Xml Many To Many</em>' class.
@@ -3718,7 +3772,7 @@ public class OrmPackage extends EPackageImpl
* @generated
* @ordered
*/
- public static final int XML_MANY_TO_MANY_FEATURE_COUNT = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING_FEATURE_COUNT + 6;
+ public static final int XML_MANY_TO_MANY_FEATURE_COUNT = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING_FEATURE_COUNT + 0;
/**
* The feature id for the '<em><b>Access</b></em>' attribute.
@@ -4234,85 +4288,85 @@ public class OrmPackage extends EPackageImpl
public static final int XML_ONE_TO_MANY__ORDER_BY = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__ORDER_BY;
/**
- * The feature id for the '<em><b>Map Key</b></em>' containment reference.
+ * The feature id for the '<em><b>Map Key Class</b></em>' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- public static final int XML_ONE_TO_MANY__MAP_KEY = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY;
+ public static final int XML_ONE_TO_MANY__MAP_KEY_CLASS = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_CLASS;
/**
- * The feature id for the '<em><b>Join Columns</b></em>' containment reference list.
+ * The feature id for the '<em><b>Map Key Temporal</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- public static final int XML_ONE_TO_MANY__JOIN_COLUMNS = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING_FEATURE_COUNT + 0;
+ public static final int XML_ONE_TO_MANY__MAP_KEY_TEMPORAL = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_TEMPORAL;
/**
- * The feature id for the '<em><b>Orphan Removal</b></em>' attribute.
+ * The feature id for the '<em><b>Map Key Enumerated</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- public static final int XML_ONE_TO_MANY__ORPHAN_REMOVAL = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING_FEATURE_COUNT + 1;
+ public static final int XML_ONE_TO_MANY__MAP_KEY_ENUMERATED = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_ENUMERATED;
/**
- * The feature id for the '<em><b>Map Key Class</b></em>' containment reference.
+ * The feature id for the '<em><b>Map Key Attribute Overrides</b></em>' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- public static final int XML_ONE_TO_MANY__MAP_KEY_CLASS = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING_FEATURE_COUNT + 2;
+ public static final int XML_ONE_TO_MANY__MAP_KEY_ATTRIBUTE_OVERRIDES = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_ATTRIBUTE_OVERRIDES;
/**
- * The feature id for the '<em><b>Map Key Temporal</b></em>' attribute.
+ * The feature id for the '<em><b>Map Key Column</b></em>' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- public static final int XML_ONE_TO_MANY__MAP_KEY_TEMPORAL = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING_FEATURE_COUNT + 3;
+ public static final int XML_ONE_TO_MANY__MAP_KEY_COLUMN = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_COLUMN;
/**
- * The feature id for the '<em><b>Map Key Enumerated</b></em>' attribute.
+ * The feature id for the '<em><b>Map Key Join Columns</b></em>' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- public static final int XML_ONE_TO_MANY__MAP_KEY_ENUMERATED = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING_FEATURE_COUNT + 4;
+ public static final int XML_ONE_TO_MANY__MAP_KEY_JOIN_COLUMNS = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY_JOIN_COLUMNS;
/**
- * The feature id for the '<em><b>Map Key Attribute Overrides</b></em>' containment reference list.
+ * The feature id for the '<em><b>Map Key</b></em>' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- public static final int XML_ONE_TO_MANY__MAP_KEY_ATTRIBUTE_OVERRIDES = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING_FEATURE_COUNT + 5;
+ public static final int XML_ONE_TO_MANY__MAP_KEY = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING__MAP_KEY;
/**
- * The feature id for the '<em><b>Map Key Column</b></em>' containment reference.
+ * The feature id for the '<em><b>Join Columns</b></em>' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- public static final int XML_ONE_TO_MANY__MAP_KEY_COLUMN = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING_FEATURE_COUNT + 6;
+ public static final int XML_ONE_TO_MANY__JOIN_COLUMNS = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING_FEATURE_COUNT + 0;
/**
- * The feature id for the '<em><b>Map Key Join Columns</b></em>' containment reference list.
+ * The feature id for the '<em><b>Orphan Removal</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- public static final int XML_ONE_TO_MANY__MAP_KEY_JOIN_COLUMNS = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING_FEATURE_COUNT + 7;
+ public static final int XML_ONE_TO_MANY__ORPHAN_REMOVAL = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING_FEATURE_COUNT + 1;
/**
* The number of structural features of the '<em>Xml One To Many</em>' class.
@@ -4321,7 +4375,7 @@ public class OrmPackage extends EPackageImpl
* @generated
* @ordered
*/
- public static final int XML_ONE_TO_MANY_FEATURE_COUNT = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING_FEATURE_COUNT + 8;
+ public static final int XML_ONE_TO_MANY_FEATURE_COUNT = ABSTRACT_XML_MULTI_RELATIONSHIP_MAPPING_FEATURE_COUNT + 2;
/**
* The feature id for the '<em><b>Access</b></em>' attribute.
@@ -9877,6 +9931,7 @@ public class OrmPackage extends EPackageImpl
abstractXmlMultiRelationshipMappingEClass.getESuperTypes().add(this.getXmlMappedByMapping());
abstractXmlMultiRelationshipMappingEClass.getESuperTypes().add(this.getXmlJoinTableMapping());
abstractXmlMultiRelationshipMappingEClass.getESuperTypes().add(this.getXmlOrderable());
+ abstractXmlMultiRelationshipMappingEClass.getESuperTypes().add(theOrmV2_0Package.getXmlMultiRelationshipMapping_2_0());
abstractXmlRelationshipMappingEClass.getESuperTypes().add(this.getAbstractXmlAttributeMapping());
abstractXmlSingleRelationshipMappingEClass.getESuperTypes().add(this.getAbstractXmlRelationshipMapping());
abstractXmlSingleRelationshipMappingEClass.getESuperTypes().add(this.getXmlJoinTableMapping());
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/XmlManyToMany.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/XmlManyToMany.java
index e3a38d8c8c..129a1bc214 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/XmlManyToMany.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/XmlManyToMany.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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.
@@ -9,22 +9,13 @@
******************************************************************************/
package org.eclipse.jpt.core.resource.orm;
-import java.util.Collection;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.NotificationChain;
-import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.InternalEObject;
-import org.eclipse.emf.ecore.impl.ENotificationImpl;
-import org.eclipse.emf.ecore.util.EObjectContainmentEList;
-import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.jpt.core.MappingKeys;
import org.eclipse.jpt.core.internal.utility.translators.SimpleTranslator;
import org.eclipse.jpt.core.resource.orm.v2_0.JPA2_0;
import org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package;
import org.eclipse.jpt.core.resource.orm.v2_0.XmlManyToMany_2_0;
-import org.eclipse.jpt.core.resource.orm.v2_0.XmlOrderable_2_0;
import org.eclipse.wst.common.internal.emf.resource.Translator;
/**
@@ -45,72 +36,6 @@ import org.eclipse.wst.common.internal.emf.resource.Translator;
*/
public class XmlManyToMany extends AbstractXmlMultiRelationshipMapping implements XmlManyToMany_2_0
{
-
- /**
- * The cached value of the '{@link #getMapKeyClass() <em>Map Key Class</em>}' containment reference.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getMapKeyClass()
- * @generated
- * @ordered
- */
- protected XmlMapKeyClass mapKeyClass;
- /**
- * changed this to null and removed the generated flag so emf won't generate over it
- * we don't want a default for enums, just null if the tag does not exist
- */
- protected static final TemporalType MAP_KEY_TEMPORAL_EDEFAULT = null;
- /**
- * The cached value of the '{@link #getMapKeyTemporal() <em>Map Key Temporal</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getMapKeyTemporal()
- * @generated
- * @ordered
- */
- protected TemporalType mapKeyTemporal = MAP_KEY_TEMPORAL_EDEFAULT;
- /**
- * changed this to null and removed the generated flag so emf won't generate over it
- * we don't want a default for enums, just null if the tag does not exist
- */
- protected static final EnumType MAP_KEY_ENUMERATED_EDEFAULT = null;
- /**
- * The cached value of the '{@link #getMapKeyEnumerated() <em>Map Key Enumerated</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getMapKeyEnumerated()
- * @generated
- * @ordered
- */
- protected EnumType mapKeyEnumerated = MAP_KEY_ENUMERATED_EDEFAULT;
- /**
- * The cached value of the '{@link #getMapKeyAttributeOverrides() <em>Map Key Attribute Overrides</em>}' containment reference list.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getMapKeyAttributeOverrides()
- * @generated
- * @ordered
- */
- protected EList<XmlAttributeOverride> mapKeyAttributeOverrides;
- /**
- * The cached value of the '{@link #getMapKeyColumn() <em>Map Key Column</em>}' containment reference.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getMapKeyColumn()
- * @generated
- * @ordered
- */
- protected XmlColumn mapKeyColumn;
- /**
- * The cached value of the '{@link #getMapKeyJoinColumns() <em>Map Key Join Columns</em>}' containment reference list.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getMapKeyJoinColumns()
- * @generated
- * @ordered
- */
- protected EList<XmlJoinColumn> mapKeyJoinColumns;
-
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -132,456 +57,6 @@ public class XmlManyToMany extends AbstractXmlMultiRelationshipMapping implement
return OrmPackage.Literals.XML_MANY_TO_MANY;
}
- /**
- * Returns the value of the '<em><b>Map Key Class</b></em>' containment reference.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Map Key Class</em>' containment reference isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Map Key Class</em>' containment reference.
- * @see #setMapKeyClass(XmlMapKeyClass)
- * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlManyToMany_2_0_MapKeyClass()
- * @model containment="true"
- * @generated
- */
- public XmlMapKeyClass getMapKeyClass()
- {
- return mapKeyClass;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public NotificationChain basicSetMapKeyClass(XmlMapKeyClass newMapKeyClass, NotificationChain msgs)
- {
- XmlMapKeyClass oldMapKeyClass = mapKeyClass;
- mapKeyClass = newMapKeyClass;
- if (eNotificationRequired())
- {
- ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, OrmPackage.XML_MANY_TO_MANY__MAP_KEY_CLASS, oldMapKeyClass, newMapKeyClass);
- if (msgs == null) msgs = notification; else msgs.add(notification);
- }
- return msgs;
- }
-
- /**
- * Sets the value of the '{@link org.eclipse.jpt.core.resource.orm.XmlManyToMany#getMapKeyClass <em>Map Key Class</em>}' containment reference.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Map Key Class</em>' containment reference.
- * @see #getMapKeyClass()
- * @generated
- */
- public void setMapKeyClass(XmlMapKeyClass newMapKeyClass)
- {
- if (newMapKeyClass != mapKeyClass)
- {
- NotificationChain msgs = null;
- if (mapKeyClass != null)
- msgs = ((InternalEObject)mapKeyClass).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - OrmPackage.XML_MANY_TO_MANY__MAP_KEY_CLASS, null, msgs);
- if (newMapKeyClass != null)
- msgs = ((InternalEObject)newMapKeyClass).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - OrmPackage.XML_MANY_TO_MANY__MAP_KEY_CLASS, null, msgs);
- msgs = basicSetMapKeyClass(newMapKeyClass, msgs);
- if (msgs != null) msgs.dispatch();
- }
- else if (eNotificationRequired())
- eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.XML_MANY_TO_MANY__MAP_KEY_CLASS, newMapKeyClass, newMapKeyClass));
- }
-
- /**
- * Returns the value of the '<em><b>Map Key Temporal</b></em>' attribute.
- * The literals are from the enumeration {@link org.eclipse.jpt.core.resource.orm.TemporalType}.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Map Key Temporal</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Map Key Temporal</em>' attribute.
- * @see org.eclipse.jpt.core.resource.orm.TemporalType
- * @see #setMapKeyTemporal(TemporalType)
- * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlManyToMany_2_0_MapKeyTemporal()
- * @model
- * @generated
- */
- public TemporalType getMapKeyTemporal()
- {
- return mapKeyTemporal;
- }
-
- /**
- * Sets the value of the '{@link org.eclipse.jpt.core.resource.orm.XmlManyToMany#getMapKeyTemporal <em>Map Key Temporal</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Map Key Temporal</em>' attribute.
- * @see org.eclipse.jpt.core.resource.orm.TemporalType
- * @see #getMapKeyTemporal()
- * @generated
- */
- public void setMapKeyTemporal(TemporalType newMapKeyTemporal)
- {
- TemporalType oldMapKeyTemporal = mapKeyTemporal;
- mapKeyTemporal = newMapKeyTemporal == null ? MAP_KEY_TEMPORAL_EDEFAULT : newMapKeyTemporal;
- if (eNotificationRequired())
- eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.XML_MANY_TO_MANY__MAP_KEY_TEMPORAL, oldMapKeyTemporal, mapKeyTemporal));
- }
-
- /**
- * Returns the value of the '<em><b>Map Key Enumerated</b></em>' attribute.
- * The literals are from the enumeration {@link org.eclipse.jpt.core.resource.orm.EnumType}.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Map Key Enumerated</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Map Key Enumerated</em>' attribute.
- * @see org.eclipse.jpt.core.resource.orm.EnumType
- * @see #setMapKeyEnumerated(EnumType)
- * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlManyToMany_2_0_MapKeyEnumerated()
- * @model
- * @generated
- */
- public EnumType getMapKeyEnumerated()
- {
- return mapKeyEnumerated;
- }
-
- /**
- * Sets the value of the '{@link org.eclipse.jpt.core.resource.orm.XmlManyToMany#getMapKeyEnumerated <em>Map Key Enumerated</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Map Key Enumerated</em>' attribute.
- * @see org.eclipse.jpt.core.resource.orm.EnumType
- * @see #getMapKeyEnumerated()
- * @generated
- */
- public void setMapKeyEnumerated(EnumType newMapKeyEnumerated)
- {
- EnumType oldMapKeyEnumerated = mapKeyEnumerated;
- mapKeyEnumerated = newMapKeyEnumerated == null ? MAP_KEY_ENUMERATED_EDEFAULT : newMapKeyEnumerated;
- if (eNotificationRequired())
- eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.XML_MANY_TO_MANY__MAP_KEY_ENUMERATED, oldMapKeyEnumerated, mapKeyEnumerated));
- }
-
- /**
- * Returns the value of the '<em><b>Map Key Attribute Overrides</b></em>' containment reference list.
- * The list contents are of type {@link org.eclipse.jpt.core.resource.orm.XmlAttributeOverride}.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Map Key Attribute Overrides</em>' containment reference list isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Map Key Attribute Overrides</em>' containment reference list.
- * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlManyToMany_2_0_MapKeyAttributeOverrides()
- * @model containment="true"
- * @generated
- */
- public EList<XmlAttributeOverride> getMapKeyAttributeOverrides()
- {
- if (mapKeyAttributeOverrides == null)
- {
- mapKeyAttributeOverrides = new EObjectContainmentEList<XmlAttributeOverride>(XmlAttributeOverride.class, this, OrmPackage.XML_MANY_TO_MANY__MAP_KEY_ATTRIBUTE_OVERRIDES);
- }
- return mapKeyAttributeOverrides;
- }
-
- /**
- * Returns the value of the '<em><b>Map Key Column</b></em>' containment reference.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Map Key Column</em>' containment reference isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Map Key Column</em>' containment reference.
- * @see #setMapKeyColumn(XmlColumn)
- * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlManyToMany_2_0_MapKeyColumn()
- * @model containment="true"
- * @generated
- */
- public XmlColumn getMapKeyColumn()
- {
- return mapKeyColumn;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public NotificationChain basicSetMapKeyColumn(XmlColumn newMapKeyColumn, NotificationChain msgs)
- {
- XmlColumn oldMapKeyColumn = mapKeyColumn;
- mapKeyColumn = newMapKeyColumn;
- if (eNotificationRequired())
- {
- ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, OrmPackage.XML_MANY_TO_MANY__MAP_KEY_COLUMN, oldMapKeyColumn, newMapKeyColumn);
- if (msgs == null) msgs = notification; else msgs.add(notification);
- }
- return msgs;
- }
-
- /**
- * Sets the value of the '{@link org.eclipse.jpt.core.resource.orm.XmlManyToMany#getMapKeyColumn <em>Map Key Column</em>}' containment reference.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Map Key Column</em>' containment reference.
- * @see #getMapKeyColumn()
- * @generated
- */
- public void setMapKeyColumn(XmlColumn newMapKeyColumn)
- {
- if (newMapKeyColumn != mapKeyColumn)
- {
- NotificationChain msgs = null;
- if (mapKeyColumn != null)
- msgs = ((InternalEObject)mapKeyColumn).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - OrmPackage.XML_MANY_TO_MANY__MAP_KEY_COLUMN, null, msgs);
- if (newMapKeyColumn != null)
- msgs = ((InternalEObject)newMapKeyColumn).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - OrmPackage.XML_MANY_TO_MANY__MAP_KEY_COLUMN, null, msgs);
- msgs = basicSetMapKeyColumn(newMapKeyColumn, msgs);
- if (msgs != null) msgs.dispatch();
- }
- else if (eNotificationRequired())
- eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.XML_MANY_TO_MANY__MAP_KEY_COLUMN, newMapKeyColumn, newMapKeyColumn));
- }
-
- /**
- * Returns the value of the '<em><b>Map Key Join Columns</b></em>' containment reference list.
- * The list contents are of type {@link org.eclipse.jpt.core.resource.orm.XmlJoinColumn}.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Map Key Join Columns</em>' containment reference list isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Map Key Join Columns</em>' containment reference list.
- * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlManyToMany_2_0_MapKeyJoinColumns()
- * @model containment="true"
- * @generated
- */
- public EList<XmlJoinColumn> getMapKeyJoinColumns()
- {
- if (mapKeyJoinColumns == null)
- {
- mapKeyJoinColumns = new EObjectContainmentEList<XmlJoinColumn>(XmlJoinColumn.class, this, OrmPackage.XML_MANY_TO_MANY__MAP_KEY_JOIN_COLUMNS);
- }
- return mapKeyJoinColumns;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- @Override
- public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
- {
- switch (featureID)
- {
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_CLASS:
- return basicSetMapKeyClass(null, msgs);
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_ATTRIBUTE_OVERRIDES:
- return ((InternalEList<?>)getMapKeyAttributeOverrides()).basicRemove(otherEnd, msgs);
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_COLUMN:
- return basicSetMapKeyColumn(null, msgs);
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_JOIN_COLUMNS:
- return ((InternalEList<?>)getMapKeyJoinColumns()).basicRemove(otherEnd, msgs);
- }
- return super.eInverseRemove(otherEnd, featureID, msgs);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- @Override
- public Object eGet(int featureID, boolean resolve, boolean coreType)
- {
- switch (featureID)
- {
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_CLASS:
- return getMapKeyClass();
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_TEMPORAL:
- return getMapKeyTemporal();
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_ENUMERATED:
- return getMapKeyEnumerated();
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_ATTRIBUTE_OVERRIDES:
- return getMapKeyAttributeOverrides();
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_COLUMN:
- return getMapKeyColumn();
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_JOIN_COLUMNS:
- return getMapKeyJoinColumns();
- }
- return super.eGet(featureID, resolve, coreType);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- @SuppressWarnings("unchecked")
- @Override
- public void eSet(int featureID, Object newValue)
- {
- switch (featureID)
- {
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_CLASS:
- setMapKeyClass((XmlMapKeyClass)newValue);
- return;
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_TEMPORAL:
- setMapKeyTemporal((TemporalType)newValue);
- return;
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_ENUMERATED:
- setMapKeyEnumerated((EnumType)newValue);
- return;
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_ATTRIBUTE_OVERRIDES:
- getMapKeyAttributeOverrides().clear();
- getMapKeyAttributeOverrides().addAll((Collection<? extends XmlAttributeOverride>)newValue);
- return;
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_COLUMN:
- setMapKeyColumn((XmlColumn)newValue);
- return;
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_JOIN_COLUMNS:
- getMapKeyJoinColumns().clear();
- getMapKeyJoinColumns().addAll((Collection<? extends XmlJoinColumn>)newValue);
- return;
- }
- super.eSet(featureID, newValue);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- @Override
- public void eUnset(int featureID)
- {
- switch (featureID)
- {
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_CLASS:
- setMapKeyClass((XmlMapKeyClass)null);
- return;
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_TEMPORAL:
- setMapKeyTemporal(MAP_KEY_TEMPORAL_EDEFAULT);
- return;
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_ENUMERATED:
- setMapKeyEnumerated(MAP_KEY_ENUMERATED_EDEFAULT);
- return;
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_ATTRIBUTE_OVERRIDES:
- getMapKeyAttributeOverrides().clear();
- return;
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_COLUMN:
- setMapKeyColumn((XmlColumn)null);
- return;
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_JOIN_COLUMNS:
- getMapKeyJoinColumns().clear();
- return;
- }
- super.eUnset(featureID);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- @Override
- public boolean eIsSet(int featureID)
- {
- switch (featureID)
- {
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_CLASS:
- return mapKeyClass != null;
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_TEMPORAL:
- return mapKeyTemporal != MAP_KEY_TEMPORAL_EDEFAULT;
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_ENUMERATED:
- return mapKeyEnumerated != MAP_KEY_ENUMERATED_EDEFAULT;
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_ATTRIBUTE_OVERRIDES:
- return mapKeyAttributeOverrides != null && !mapKeyAttributeOverrides.isEmpty();
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_COLUMN:
- return mapKeyColumn != null;
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_JOIN_COLUMNS:
- return mapKeyJoinColumns != null && !mapKeyJoinColumns.isEmpty();
- }
- return super.eIsSet(featureID);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- @Override
- public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass)
- {
- if (baseClass == XmlManyToMany_2_0.class)
- {
- switch (derivedFeatureID)
- {
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_CLASS: return OrmV2_0Package.XML_MANY_TO_MANY_20__MAP_KEY_CLASS;
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_TEMPORAL: return OrmV2_0Package.XML_MANY_TO_MANY_20__MAP_KEY_TEMPORAL;
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_ENUMERATED: return OrmV2_0Package.XML_MANY_TO_MANY_20__MAP_KEY_ENUMERATED;
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_ATTRIBUTE_OVERRIDES: return OrmV2_0Package.XML_MANY_TO_MANY_20__MAP_KEY_ATTRIBUTE_OVERRIDES;
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_COLUMN: return OrmV2_0Package.XML_MANY_TO_MANY_20__MAP_KEY_COLUMN;
- case OrmPackage.XML_MANY_TO_MANY__MAP_KEY_JOIN_COLUMNS: return OrmV2_0Package.XML_MANY_TO_MANY_20__MAP_KEY_JOIN_COLUMNS;
- default: return -1;
- }
- }
- return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- @Override
- public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass)
- {
- if (baseClass == XmlManyToMany_2_0.class)
- {
- switch (baseFeatureID)
- {
- case OrmV2_0Package.XML_MANY_TO_MANY_20__MAP_KEY_CLASS: return OrmPackage.XML_MANY_TO_MANY__MAP_KEY_CLASS;
- case OrmV2_0Package.XML_MANY_TO_MANY_20__MAP_KEY_TEMPORAL: return OrmPackage.XML_MANY_TO_MANY__MAP_KEY_TEMPORAL;
- case OrmV2_0Package.XML_MANY_TO_MANY_20__MAP_KEY_ENUMERATED: return OrmPackage.XML_MANY_TO_MANY__MAP_KEY_ENUMERATED;
- case OrmV2_0Package.XML_MANY_TO_MANY_20__MAP_KEY_ATTRIBUTE_OVERRIDES: return OrmPackage.XML_MANY_TO_MANY__MAP_KEY_ATTRIBUTE_OVERRIDES;
- case OrmV2_0Package.XML_MANY_TO_MANY_20__MAP_KEY_COLUMN: return OrmPackage.XML_MANY_TO_MANY__MAP_KEY_COLUMN;
- case OrmV2_0Package.XML_MANY_TO_MANY_20__MAP_KEY_JOIN_COLUMNS: return OrmPackage.XML_MANY_TO_MANY__MAP_KEY_JOIN_COLUMNS;
- default: return -1;
- }
- }
- return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- @Override
- public String toString()
- {
- if (eIsProxy()) return super.toString();
-
- StringBuffer result = new StringBuffer(super.toString());
- result.append(" (mapKeyTemporal: ");
- result.append(mapKeyTemporal);
- result.append(", mapKeyEnumerated: ");
- result.append(mapKeyEnumerated);
- result.append(')');
- return result.toString();
- }
-
public String getMappingKey() {
return MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY;
}
@@ -618,27 +93,27 @@ public class XmlManyToMany extends AbstractXmlMultiRelationshipMapping implement
}
protected static Translator buildMapKeyClassTranslator() {
- return XmlMapKeyClass.buildTranslator(JPA2_0.MAP_KEY_CLASS, OrmV2_0Package.eINSTANCE.getXmlManyToMany_2_0_MapKeyClass());
+ return XmlMapKeyClass.buildTranslator(JPA2_0.MAP_KEY_CLASS, OrmV2_0Package.eINSTANCE.getXmlMultiRelationshipMapping_2_0_MapKeyClass());
}
protected static Translator buildMapKeyTemporalTranslator() {
- return new Translator(JPA2_0.MAP_KEY_TEMPORAL, OrmV2_0Package.eINSTANCE.getXmlManyToMany_2_0_MapKeyTemporal());
+ return new Translator(JPA2_0.MAP_KEY_TEMPORAL, OrmV2_0Package.eINSTANCE.getXmlMultiRelationshipMapping_2_0_MapKeyTemporal());
}
protected static Translator buildMapKeyEnumeratedTranslator() {
- return new Translator(JPA2_0.MAP_KEY_ENUMERATED, OrmV2_0Package.eINSTANCE.getXmlManyToMany_2_0_MapKeyEnumerated());
+ return new Translator(JPA2_0.MAP_KEY_ENUMERATED, OrmV2_0Package.eINSTANCE.getXmlMultiRelationshipMapping_2_0_MapKeyEnumerated());
}
protected static Translator buildMapKeyAttributeOverrideTranslator() {
- return XmlAttributeOverride.buildTranslator(JPA2_0.MAP_KEY_ATTRIBUTE_OVERRIDE, OrmV2_0Package.eINSTANCE.getXmlManyToMany_2_0_MapKeyAttributeOverrides());
+ return XmlAttributeOverride.buildTranslator(JPA2_0.MAP_KEY_ATTRIBUTE_OVERRIDE, OrmV2_0Package.eINSTANCE.getXmlMultiRelationshipMapping_2_0_MapKeyAttributeOverrides());
}
protected static Translator buildMapKeyColumnTranslator() {
- return XmlColumn.buildTranslator(JPA2_0.MAP_KEY_COLUMN, OrmV2_0Package.eINSTANCE.getXmlManyToMany_2_0_MapKeyColumn());
+ return XmlColumn.buildTranslator(JPA2_0.MAP_KEY_COLUMN, OrmV2_0Package.eINSTANCE.getXmlMultiRelationshipMapping_2_0_MapKeyColumn());
}
protected static Translator buildMapKeyJoinColumnTranslator() {
- return XmlJoinColumn.buildTranslator(JPA2_0.MAP_KEY_JOIN_COLUMN, OrmV2_0Package.eINSTANCE.getXmlManyToMany_2_0_MapKeyJoinColumns());
+ return XmlJoinColumn.buildTranslator(JPA2_0.MAP_KEY_JOIN_COLUMN, OrmV2_0Package.eINSTANCE.getXmlMultiRelationshipMapping_2_0_MapKeyJoinColumns());
}
protected static Translator buildJoinTableTranslator() {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/XmlOneToMany.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/XmlOneToMany.java
index 17ae6b52e5..bed54d18b5 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/XmlOneToMany.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/XmlOneToMany.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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.
@@ -24,7 +24,6 @@ import org.eclipse.jpt.core.internal.utility.translators.SimpleTranslator;
import org.eclipse.jpt.core.resource.orm.v2_0.JPA2_0;
import org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package;
import org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0;
-import org.eclipse.jpt.core.resource.orm.v2_0.XmlOrderable_2_0;
import org.eclipse.jpt.core.resource.orm.v2_0.XmlOrphanRemovable_2_0;
import org.eclipse.wst.common.internal.emf.resource.Translator;
@@ -77,78 +76,6 @@ public class XmlOneToMany extends AbstractXmlMultiRelationshipMapping implements
protected Boolean orphanRemoval = ORPHAN_REMOVAL_EDEFAULT;
/**
- * The cached value of the '{@link #getMapKeyClass() <em>Map Key Class</em>}' containment reference.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getMapKeyClass()
- * @generated
- * @ordered
- */
- protected XmlMapKeyClass mapKeyClass;
-
- /**
- * changed this to null and removed the generated flag so emf won't generate over it
- * we don't want a default for enums, just null if the tag does not exist
- */
- protected static final TemporalType MAP_KEY_TEMPORAL_EDEFAULT = null;
-
- /**
- * The cached value of the '{@link #getMapKeyTemporal() <em>Map Key Temporal</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getMapKeyTemporal()
- * @generated
- * @ordered
- */
- protected TemporalType mapKeyTemporal = MAP_KEY_TEMPORAL_EDEFAULT;
-
- /**
- * changed this to null and removed the generated flag so emf won't generate over it
- * we don't want a default for enums, just null if the tag does not exist
- */
- protected static final EnumType MAP_KEY_ENUMERATED_EDEFAULT = null;
-
- /**
- * The cached value of the '{@link #getMapKeyEnumerated() <em>Map Key Enumerated</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getMapKeyEnumerated()
- * @generated
- * @ordered
- */
- protected EnumType mapKeyEnumerated = MAP_KEY_ENUMERATED_EDEFAULT;
-
- /**
- * The cached value of the '{@link #getMapKeyAttributeOverrides() <em>Map Key Attribute Overrides</em>}' containment reference list.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getMapKeyAttributeOverrides()
- * @generated
- * @ordered
- */
- protected EList<XmlAttributeOverride> mapKeyAttributeOverrides;
-
- /**
- * The cached value of the '{@link #getMapKeyColumn() <em>Map Key Column</em>}' containment reference.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getMapKeyColumn()
- * @generated
- * @ordered
- */
- protected XmlColumn mapKeyColumn;
-
- /**
- * The cached value of the '{@link #getMapKeyJoinColumns() <em>Map Key Join Columns</em>}' containment reference list.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getMapKeyJoinColumns()
- * @generated
- * @ordered
- */
- protected EList<XmlJoinColumn> mapKeyJoinColumns;
-
- /**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
@@ -193,248 +120,6 @@ public class XmlOneToMany extends AbstractXmlMultiRelationshipMapping implements
}
/**
- * Returns the value of the '<em><b>Map Key Class</b></em>' containment reference.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Map Key Class</em>' containment reference isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Map Key Class</em>' containment reference.
- * @see #setMapKeyClass(XmlMapKeyClass)
- * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlOneToMany_2_0_MapKeyClass()
- * @model containment="true"
- * @generated
- */
- public XmlMapKeyClass getMapKeyClass()
- {
- return mapKeyClass;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public NotificationChain basicSetMapKeyClass(XmlMapKeyClass newMapKeyClass, NotificationChain msgs)
- {
- XmlMapKeyClass oldMapKeyClass = mapKeyClass;
- mapKeyClass = newMapKeyClass;
- if (eNotificationRequired())
- {
- ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, OrmPackage.XML_ONE_TO_MANY__MAP_KEY_CLASS, oldMapKeyClass, newMapKeyClass);
- if (msgs == null) msgs = notification; else msgs.add(notification);
- }
- return msgs;
- }
-
- /**
- * Sets the value of the '{@link org.eclipse.jpt.core.resource.orm.XmlOneToMany#getMapKeyClass <em>Map Key Class</em>}' containment reference.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Map Key Class</em>' containment reference.
- * @see #getMapKeyClass()
- * @generated
- */
- public void setMapKeyClass(XmlMapKeyClass newMapKeyClass)
- {
- if (newMapKeyClass != mapKeyClass)
- {
- NotificationChain msgs = null;
- if (mapKeyClass != null)
- msgs = ((InternalEObject)mapKeyClass).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - OrmPackage.XML_ONE_TO_MANY__MAP_KEY_CLASS, null, msgs);
- if (newMapKeyClass != null)
- msgs = ((InternalEObject)newMapKeyClass).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - OrmPackage.XML_ONE_TO_MANY__MAP_KEY_CLASS, null, msgs);
- msgs = basicSetMapKeyClass(newMapKeyClass, msgs);
- if (msgs != null) msgs.dispatch();
- }
- else if (eNotificationRequired())
- eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.XML_ONE_TO_MANY__MAP_KEY_CLASS, newMapKeyClass, newMapKeyClass));
- }
-
- /**
- * Returns the value of the '<em><b>Map Key Temporal</b></em>' attribute.
- * The literals are from the enumeration {@link org.eclipse.jpt.core.resource.orm.TemporalType}.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Map Key Temporal</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Map Key Temporal</em>' attribute.
- * @see org.eclipse.jpt.core.resource.orm.TemporalType
- * @see #setMapKeyTemporal(TemporalType)
- * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlOneToMany_2_0_MapKeyTemporal()
- * @model
- * @generated
- */
- public TemporalType getMapKeyTemporal()
- {
- return mapKeyTemporal;
- }
-
- /**
- * Sets the value of the '{@link org.eclipse.jpt.core.resource.orm.XmlOneToMany#getMapKeyTemporal <em>Map Key Temporal</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Map Key Temporal</em>' attribute.
- * @see org.eclipse.jpt.core.resource.orm.TemporalType
- * @see #getMapKeyTemporal()
- * @generated
- */
- public void setMapKeyTemporal(TemporalType newMapKeyTemporal)
- {
- TemporalType oldMapKeyTemporal = mapKeyTemporal;
- mapKeyTemporal = newMapKeyTemporal == null ? MAP_KEY_TEMPORAL_EDEFAULT : newMapKeyTemporal;
- if (eNotificationRequired())
- eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.XML_ONE_TO_MANY__MAP_KEY_TEMPORAL, oldMapKeyTemporal, mapKeyTemporal));
- }
-
- /**
- * Returns the value of the '<em><b>Map Key Enumerated</b></em>' attribute.
- * The literals are from the enumeration {@link org.eclipse.jpt.core.resource.orm.EnumType}.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Map Key Enumerated</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Map Key Enumerated</em>' attribute.
- * @see org.eclipse.jpt.core.resource.orm.EnumType
- * @see #setMapKeyEnumerated(EnumType)
- * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlOneToMany_2_0_MapKeyEnumerated()
- * @model
- * @generated
- */
- public EnumType getMapKeyEnumerated()
- {
- return mapKeyEnumerated;
- }
-
- /**
- * Sets the value of the '{@link org.eclipse.jpt.core.resource.orm.XmlOneToMany#getMapKeyEnumerated <em>Map Key Enumerated</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Map Key Enumerated</em>' attribute.
- * @see org.eclipse.jpt.core.resource.orm.EnumType
- * @see #getMapKeyEnumerated()
- * @generated
- */
- public void setMapKeyEnumerated(EnumType newMapKeyEnumerated)
- {
- EnumType oldMapKeyEnumerated = mapKeyEnumerated;
- mapKeyEnumerated = newMapKeyEnumerated == null ? MAP_KEY_ENUMERATED_EDEFAULT : newMapKeyEnumerated;
- if (eNotificationRequired())
- eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.XML_ONE_TO_MANY__MAP_KEY_ENUMERATED, oldMapKeyEnumerated, mapKeyEnumerated));
- }
-
- /**
- * Returns the value of the '<em><b>Map Key Attribute Overrides</b></em>' containment reference list.
- * The list contents are of type {@link org.eclipse.jpt.core.resource.orm.XmlAttributeOverride}.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Map Key Attribute Overrides</em>' containment reference list isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Map Key Attribute Overrides</em>' containment reference list.
- * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlOneToMany_2_0_MapKeyAttributeOverrides()
- * @model containment="true"
- * @generated
- */
- public EList<XmlAttributeOverride> getMapKeyAttributeOverrides()
- {
- if (mapKeyAttributeOverrides == null)
- {
- mapKeyAttributeOverrides = new EObjectContainmentEList<XmlAttributeOverride>(XmlAttributeOverride.class, this, OrmPackage.XML_ONE_TO_MANY__MAP_KEY_ATTRIBUTE_OVERRIDES);
- }
- return mapKeyAttributeOverrides;
- }
-
- /**
- * Returns the value of the '<em><b>Map Key Column</b></em>' containment reference.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Map Key Column</em>' containment reference isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Map Key Column</em>' containment reference.
- * @see #setMapKeyColumn(XmlColumn)
- * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlOneToMany_2_0_MapKeyColumn()
- * @model containment="true"
- * @generated
- */
- public XmlColumn getMapKeyColumn()
- {
- return mapKeyColumn;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public NotificationChain basicSetMapKeyColumn(XmlColumn newMapKeyColumn, NotificationChain msgs)
- {
- XmlColumn oldMapKeyColumn = mapKeyColumn;
- mapKeyColumn = newMapKeyColumn;
- if (eNotificationRequired())
- {
- ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, OrmPackage.XML_ONE_TO_MANY__MAP_KEY_COLUMN, oldMapKeyColumn, newMapKeyColumn);
- if (msgs == null) msgs = notification; else msgs.add(notification);
- }
- return msgs;
- }
-
- /**
- * Sets the value of the '{@link org.eclipse.jpt.core.resource.orm.XmlOneToMany#getMapKeyColumn <em>Map Key Column</em>}' containment reference.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Map Key Column</em>' containment reference.
- * @see #getMapKeyColumn()
- * @generated
- */
- public void setMapKeyColumn(XmlColumn newMapKeyColumn)
- {
- if (newMapKeyColumn != mapKeyColumn)
- {
- NotificationChain msgs = null;
- if (mapKeyColumn != null)
- msgs = ((InternalEObject)mapKeyColumn).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - OrmPackage.XML_ONE_TO_MANY__MAP_KEY_COLUMN, null, msgs);
- if (newMapKeyColumn != null)
- msgs = ((InternalEObject)newMapKeyColumn).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - OrmPackage.XML_ONE_TO_MANY__MAP_KEY_COLUMN, null, msgs);
- msgs = basicSetMapKeyColumn(newMapKeyColumn, msgs);
- if (msgs != null) msgs.dispatch();
- }
- else if (eNotificationRequired())
- eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.XML_ONE_TO_MANY__MAP_KEY_COLUMN, newMapKeyColumn, newMapKeyColumn));
- }
-
- /**
- * Returns the value of the '<em><b>Map Key Join Columns</b></em>' containment reference list.
- * The list contents are of type {@link org.eclipse.jpt.core.resource.orm.XmlJoinColumn}.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Map Key Join Columns</em>' containment reference list isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Map Key Join Columns</em>' containment reference list.
- * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlOneToMany_2_0_MapKeyJoinColumns()
- * @model containment="true"
- * @generated
- */
- public EList<XmlJoinColumn> getMapKeyJoinColumns()
- {
- if (mapKeyJoinColumns == null)
- {
- mapKeyJoinColumns = new EObjectContainmentEList<XmlJoinColumn>(XmlJoinColumn.class, this, OrmPackage.XML_ONE_TO_MANY__MAP_KEY_JOIN_COLUMNS);
- }
- return mapKeyJoinColumns;
- }
-
- /**
* Returns the value of the '<em><b>Orphan Removal</b></em>' attribute.
* <!-- begin-user-doc -->
* <p>
@@ -481,14 +166,6 @@ public class XmlOneToMany extends AbstractXmlMultiRelationshipMapping implements
{
case OrmPackage.XML_ONE_TO_MANY__JOIN_COLUMNS:
return ((InternalEList<?>)getJoinColumns()).basicRemove(otherEnd, msgs);
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_CLASS:
- return basicSetMapKeyClass(null, msgs);
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_ATTRIBUTE_OVERRIDES:
- return ((InternalEList<?>)getMapKeyAttributeOverrides()).basicRemove(otherEnd, msgs);
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_COLUMN:
- return basicSetMapKeyColumn(null, msgs);
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_JOIN_COLUMNS:
- return ((InternalEList<?>)getMapKeyJoinColumns()).basicRemove(otherEnd, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
@@ -507,18 +184,6 @@ public class XmlOneToMany extends AbstractXmlMultiRelationshipMapping implements
return getJoinColumns();
case OrmPackage.XML_ONE_TO_MANY__ORPHAN_REMOVAL:
return getOrphanRemoval();
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_CLASS:
- return getMapKeyClass();
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_TEMPORAL:
- return getMapKeyTemporal();
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_ENUMERATED:
- return getMapKeyEnumerated();
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_ATTRIBUTE_OVERRIDES:
- return getMapKeyAttributeOverrides();
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_COLUMN:
- return getMapKeyColumn();
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_JOIN_COLUMNS:
- return getMapKeyJoinColumns();
}
return super.eGet(featureID, resolve, coreType);
}
@@ -541,26 +206,6 @@ public class XmlOneToMany extends AbstractXmlMultiRelationshipMapping implements
case OrmPackage.XML_ONE_TO_MANY__ORPHAN_REMOVAL:
setOrphanRemoval((Boolean)newValue);
return;
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_CLASS:
- setMapKeyClass((XmlMapKeyClass)newValue);
- return;
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_TEMPORAL:
- setMapKeyTemporal((TemporalType)newValue);
- return;
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_ENUMERATED:
- setMapKeyEnumerated((EnumType)newValue);
- return;
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_ATTRIBUTE_OVERRIDES:
- getMapKeyAttributeOverrides().clear();
- getMapKeyAttributeOverrides().addAll((Collection<? extends XmlAttributeOverride>)newValue);
- return;
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_COLUMN:
- setMapKeyColumn((XmlColumn)newValue);
- return;
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_JOIN_COLUMNS:
- getMapKeyJoinColumns().clear();
- getMapKeyJoinColumns().addAll((Collection<? extends XmlJoinColumn>)newValue);
- return;
}
super.eSet(featureID, newValue);
}
@@ -581,24 +226,6 @@ public class XmlOneToMany extends AbstractXmlMultiRelationshipMapping implements
case OrmPackage.XML_ONE_TO_MANY__ORPHAN_REMOVAL:
setOrphanRemoval(ORPHAN_REMOVAL_EDEFAULT);
return;
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_CLASS:
- setMapKeyClass((XmlMapKeyClass)null);
- return;
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_TEMPORAL:
- setMapKeyTemporal(MAP_KEY_TEMPORAL_EDEFAULT);
- return;
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_ENUMERATED:
- setMapKeyEnumerated(MAP_KEY_ENUMERATED_EDEFAULT);
- return;
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_ATTRIBUTE_OVERRIDES:
- getMapKeyAttributeOverrides().clear();
- return;
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_COLUMN:
- setMapKeyColumn((XmlColumn)null);
- return;
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_JOIN_COLUMNS:
- getMapKeyJoinColumns().clear();
- return;
}
super.eUnset(featureID);
}
@@ -617,18 +244,6 @@ public class XmlOneToMany extends AbstractXmlMultiRelationshipMapping implements
return joinColumns != null && !joinColumns.isEmpty();
case OrmPackage.XML_ONE_TO_MANY__ORPHAN_REMOVAL:
return ORPHAN_REMOVAL_EDEFAULT == null ? orphanRemoval != null : !ORPHAN_REMOVAL_EDEFAULT.equals(orphanRemoval);
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_CLASS:
- return mapKeyClass != null;
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_TEMPORAL:
- return mapKeyTemporal != MAP_KEY_TEMPORAL_EDEFAULT;
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_ENUMERATED:
- return mapKeyEnumerated != MAP_KEY_ENUMERATED_EDEFAULT;
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_ATTRIBUTE_OVERRIDES:
- return mapKeyAttributeOverrides != null && !mapKeyAttributeOverrides.isEmpty();
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_COLUMN:
- return mapKeyColumn != null;
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_JOIN_COLUMNS:
- return mapKeyJoinColumns != null && !mapKeyJoinColumns.isEmpty();
}
return super.eIsSet(featureID);
}
@@ -661,12 +276,6 @@ public class XmlOneToMany extends AbstractXmlMultiRelationshipMapping implements
{
switch (derivedFeatureID)
{
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_CLASS: return OrmV2_0Package.XML_ONE_TO_MANY_20__MAP_KEY_CLASS;
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_TEMPORAL: return OrmV2_0Package.XML_ONE_TO_MANY_20__MAP_KEY_TEMPORAL;
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_ENUMERATED: return OrmV2_0Package.XML_ONE_TO_MANY_20__MAP_KEY_ENUMERATED;
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_ATTRIBUTE_OVERRIDES: return OrmV2_0Package.XML_ONE_TO_MANY_20__MAP_KEY_ATTRIBUTE_OVERRIDES;
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_COLUMN: return OrmV2_0Package.XML_ONE_TO_MANY_20__MAP_KEY_COLUMN;
- case OrmPackage.XML_ONE_TO_MANY__MAP_KEY_JOIN_COLUMNS: return OrmV2_0Package.XML_ONE_TO_MANY_20__MAP_KEY_JOIN_COLUMNS;
default: return -1;
}
}
@@ -701,12 +310,6 @@ public class XmlOneToMany extends AbstractXmlMultiRelationshipMapping implements
{
switch (baseFeatureID)
{
- case OrmV2_0Package.XML_ONE_TO_MANY_20__MAP_KEY_CLASS: return OrmPackage.XML_ONE_TO_MANY__MAP_KEY_CLASS;
- case OrmV2_0Package.XML_ONE_TO_MANY_20__MAP_KEY_TEMPORAL: return OrmPackage.XML_ONE_TO_MANY__MAP_KEY_TEMPORAL;
- case OrmV2_0Package.XML_ONE_TO_MANY_20__MAP_KEY_ENUMERATED: return OrmPackage.XML_ONE_TO_MANY__MAP_KEY_ENUMERATED;
- case OrmV2_0Package.XML_ONE_TO_MANY_20__MAP_KEY_ATTRIBUTE_OVERRIDES: return OrmPackage.XML_ONE_TO_MANY__MAP_KEY_ATTRIBUTE_OVERRIDES;
- case OrmV2_0Package.XML_ONE_TO_MANY_20__MAP_KEY_COLUMN: return OrmPackage.XML_ONE_TO_MANY__MAP_KEY_COLUMN;
- case OrmV2_0Package.XML_ONE_TO_MANY_20__MAP_KEY_JOIN_COLUMNS: return OrmPackage.XML_ONE_TO_MANY__MAP_KEY_JOIN_COLUMNS;
default: return -1;
}
}
@@ -726,10 +329,6 @@ public class XmlOneToMany extends AbstractXmlMultiRelationshipMapping implements
StringBuffer result = new StringBuffer(super.toString());
result.append(" (orphanRemoval: ");
result.append(orphanRemoval);
- result.append(", mapKeyTemporal: ");
- result.append(mapKeyTemporal);
- result.append(", mapKeyEnumerated: ");
- result.append(mapKeyEnumerated);
result.append(')');
return result.toString();
}
@@ -780,27 +379,27 @@ public class XmlOneToMany extends AbstractXmlMultiRelationshipMapping implements
}
protected static Translator buildMapKeyTemporalTranslator() {
- return new Translator(JPA2_0.MAP_KEY_TEMPORAL, OrmV2_0Package.eINSTANCE.getXmlOneToMany_2_0_MapKeyTemporal());
+ return new Translator(JPA2_0.MAP_KEY_TEMPORAL, OrmV2_0Package.eINSTANCE.getXmlMultiRelationshipMapping_2_0_MapKeyTemporal());
}
protected static Translator buildMapKeyEnumeratedTranslator() {
- return new Translator(JPA2_0.MAP_KEY_ENUMERATED, OrmV2_0Package.eINSTANCE.getXmlOneToMany_2_0_MapKeyEnumerated());
+ return new Translator(JPA2_0.MAP_KEY_ENUMERATED, OrmV2_0Package.eINSTANCE.getXmlMultiRelationshipMapping_2_0_MapKeyEnumerated());
}
protected static Translator buildMapKeyClassTranslator() {
- return XmlMapKeyClass.buildTranslator(JPA2_0.MAP_KEY_CLASS, OrmV2_0Package.eINSTANCE.getXmlOneToMany_2_0_MapKeyClass());
+ return XmlMapKeyClass.buildTranslator(JPA2_0.MAP_KEY_CLASS, OrmV2_0Package.eINSTANCE.getXmlMultiRelationshipMapping_2_0_MapKeyClass());
}
protected static Translator buildMapKeyAttributeOverrideTranslator() {
- return XmlAttributeOverride.buildTranslator(JPA2_0.MAP_KEY_ATTRIBUTE_OVERRIDE, OrmV2_0Package.eINSTANCE.getXmlOneToMany_2_0_MapKeyAttributeOverrides());
+ return XmlAttributeOverride.buildTranslator(JPA2_0.MAP_KEY_ATTRIBUTE_OVERRIDE, OrmV2_0Package.eINSTANCE.getXmlMultiRelationshipMapping_2_0_MapKeyAttributeOverrides());
}
protected static Translator buildMapKeyColumnTranslator() {
- return XmlColumn.buildTranslator(JPA2_0.MAP_KEY_COLUMN, OrmV2_0Package.eINSTANCE.getXmlOneToMany_2_0_MapKeyColumn());
+ return XmlColumn.buildTranslator(JPA2_0.MAP_KEY_COLUMN, OrmV2_0Package.eINSTANCE.getXmlMultiRelationshipMapping_2_0_MapKeyColumn());
}
protected static Translator buildMapKeyJoinColumnTranslator() {
- return XmlJoinColumn.buildTranslator(JPA2_0.MAP_KEY_JOIN_COLUMN, OrmV2_0Package.eINSTANCE.getXmlOneToMany_2_0_MapKeyJoinColumns());
+ return XmlJoinColumn.buildTranslator(JPA2_0.MAP_KEY_JOIN_COLUMN, OrmV2_0Package.eINSTANCE.getXmlMultiRelationshipMapping_2_0_MapKeyJoinColumns());
}
protected static Translator buildJoinTableTranslator() {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/v2_0/OrmV2_0Package.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/v2_0/OrmV2_0Package.java
index 09dd81b321..4ce26d0b77 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/v2_0/OrmV2_0Package.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/v2_0/OrmV2_0Package.java
@@ -476,7 +476,7 @@ public class OrmV2_0Package extends EPackageImpl
* @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlCacheable_2_0()
* @generated
*/
- public static final int XML_CACHEABLE_20 = 27;
+ public static final int XML_CACHEABLE_20 = 28;
/**
* The feature id for the '<em><b>Cacheable</b></em>' attribute.
@@ -616,7 +616,7 @@ public class OrmV2_0Package extends EPackageImpl
* @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlOrderable_2_0()
* @generated
*/
- public static final int XML_ORDERABLE_20 = 29;
+ public static final int XML_ORDERABLE_20 = 30;
/**
* The feature id for the '<em><b>Order Column</b></em>' containment reference.
@@ -637,6 +637,88 @@ public class OrmV2_0Package extends EPackageImpl
public static final int XML_ORDERABLE_20_FEATURE_COUNT = 1;
/**
+ * The meta object id for the '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlMultiRelationshipMapping_2_0 <em>Xml Multi Relationship Mapping 20</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlMultiRelationshipMapping_2_0
+ * @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlMultiRelationshipMapping_2_0()
+ * @generated
+ */
+ public static final int XML_MULTI_RELATIONSHIP_MAPPING_20 = 15;
+
+ /**
+ * The feature id for the '<em><b>Order Column</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int XML_MULTI_RELATIONSHIP_MAPPING_20__ORDER_COLUMN = XML_ORDERABLE_20__ORDER_COLUMN;
+
+ /**
+ * The feature id for the '<em><b>Map Key Class</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_CLASS = XML_ORDERABLE_20_FEATURE_COUNT + 0;
+
+ /**
+ * The feature id for the '<em><b>Map Key Temporal</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_TEMPORAL = XML_ORDERABLE_20_FEATURE_COUNT + 1;
+
+ /**
+ * The feature id for the '<em><b>Map Key Enumerated</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_ENUMERATED = XML_ORDERABLE_20_FEATURE_COUNT + 2;
+
+ /**
+ * The feature id for the '<em><b>Map Key Attribute Overrides</b></em>' containment reference list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_ATTRIBUTE_OVERRIDES = XML_ORDERABLE_20_FEATURE_COUNT + 3;
+
+ /**
+ * The feature id for the '<em><b>Map Key Column</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_COLUMN = XML_ORDERABLE_20_FEATURE_COUNT + 4;
+
+ /**
+ * The feature id for the '<em><b>Map Key Join Columns</b></em>' containment reference list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_JOIN_COLUMNS = XML_ORDERABLE_20_FEATURE_COUNT + 5;
+
+ /**
+ * The number of structural features of the '<em>Xml Multi Relationship Mapping 20</em>' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int XML_MULTI_RELATIONSHIP_MAPPING_20_FEATURE_COUNT = XML_ORDERABLE_20_FEATURE_COUNT + 6;
+
+ /**
* The meta object id for the '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlManyToMany_2_0 <em>Xml Many To Many 20</em>}' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -653,7 +735,7 @@ public class OrmV2_0Package extends EPackageImpl
* @generated
* @ordered
*/
- public static final int XML_MANY_TO_MANY_20__ORDER_COLUMN = XML_ORDERABLE_20__ORDER_COLUMN;
+ public static final int XML_MANY_TO_MANY_20__ORDER_COLUMN = XML_MULTI_RELATIONSHIP_MAPPING_20__ORDER_COLUMN;
/**
* The feature id for the '<em><b>Map Key Class</b></em>' containment reference.
@@ -662,7 +744,7 @@ public class OrmV2_0Package extends EPackageImpl
* @generated
* @ordered
*/
- public static final int XML_MANY_TO_MANY_20__MAP_KEY_CLASS = XML_ORDERABLE_20_FEATURE_COUNT + 0;
+ public static final int XML_MANY_TO_MANY_20__MAP_KEY_CLASS = XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_CLASS;
/**
* The feature id for the '<em><b>Map Key Temporal</b></em>' attribute.
@@ -671,7 +753,7 @@ public class OrmV2_0Package extends EPackageImpl
* @generated
* @ordered
*/
- public static final int XML_MANY_TO_MANY_20__MAP_KEY_TEMPORAL = XML_ORDERABLE_20_FEATURE_COUNT + 1;
+ public static final int XML_MANY_TO_MANY_20__MAP_KEY_TEMPORAL = XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_TEMPORAL;
/**
* The feature id for the '<em><b>Map Key Enumerated</b></em>' attribute.
@@ -680,7 +762,7 @@ public class OrmV2_0Package extends EPackageImpl
* @generated
* @ordered
*/
- public static final int XML_MANY_TO_MANY_20__MAP_KEY_ENUMERATED = XML_ORDERABLE_20_FEATURE_COUNT + 2;
+ public static final int XML_MANY_TO_MANY_20__MAP_KEY_ENUMERATED = XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_ENUMERATED;
/**
* The feature id for the '<em><b>Map Key Attribute Overrides</b></em>' containment reference list.
@@ -689,7 +771,7 @@ public class OrmV2_0Package extends EPackageImpl
* @generated
* @ordered
*/
- public static final int XML_MANY_TO_MANY_20__MAP_KEY_ATTRIBUTE_OVERRIDES = XML_ORDERABLE_20_FEATURE_COUNT + 3;
+ public static final int XML_MANY_TO_MANY_20__MAP_KEY_ATTRIBUTE_OVERRIDES = XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_ATTRIBUTE_OVERRIDES;
/**
* The feature id for the '<em><b>Map Key Column</b></em>' containment reference.
@@ -698,7 +780,7 @@ public class OrmV2_0Package extends EPackageImpl
* @generated
* @ordered
*/
- public static final int XML_MANY_TO_MANY_20__MAP_KEY_COLUMN = XML_ORDERABLE_20_FEATURE_COUNT + 4;
+ public static final int XML_MANY_TO_MANY_20__MAP_KEY_COLUMN = XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_COLUMN;
/**
* The feature id for the '<em><b>Map Key Join Columns</b></em>' containment reference list.
@@ -707,7 +789,7 @@ public class OrmV2_0Package extends EPackageImpl
* @generated
* @ordered
*/
- public static final int XML_MANY_TO_MANY_20__MAP_KEY_JOIN_COLUMNS = XML_ORDERABLE_20_FEATURE_COUNT + 5;
+ public static final int XML_MANY_TO_MANY_20__MAP_KEY_JOIN_COLUMNS = XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_JOIN_COLUMNS;
/**
* The number of structural features of the '<em>Xml Many To Many 20</em>' class.
@@ -716,7 +798,7 @@ public class OrmV2_0Package extends EPackageImpl
* @generated
* @ordered
*/
- public static final int XML_MANY_TO_MANY_20_FEATURE_COUNT = XML_ORDERABLE_20_FEATURE_COUNT + 6;
+ public static final int XML_MANY_TO_MANY_20_FEATURE_COUNT = XML_MULTI_RELATIONSHIP_MAPPING_20_FEATURE_COUNT + 0;
/**
* The meta object id for the '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlMapKeyClass_2_0 <em>Xml Map Key Class 20</em>}' class.
@@ -782,7 +864,7 @@ public class OrmV2_0Package extends EPackageImpl
* @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlNamedQuery_2_0()
* @generated
*/
- public static final int XML_NAMED_QUERY_20 = 15;
+ public static final int XML_NAMED_QUERY_20 = 16;
/**
* The feature id for the '<em><b>Lock Mode</b></em>' attribute.
@@ -810,25 +892,7 @@ public class OrmV2_0Package extends EPackageImpl
* @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlOrphanRemovable_2_0()
* @generated
*/
- public static final int XML_ORPHAN_REMOVABLE_20 = 28;
-
- /**
- * The feature id for the '<em><b>Orphan Removal</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public static final int XML_ORPHAN_REMOVABLE_20__ORPHAN_REMOVAL = 0;
-
- /**
- * The number of structural features of the '<em>Xml Orphan Removable 20</em>' class.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public static final int XML_ORPHAN_REMOVABLE_20_FEATURE_COUNT = 1;
+ public static final int XML_ORPHAN_REMOVABLE_20 = 29;
/**
* The meta object id for the '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0 <em>Xml One To Many 20</em>}' class.
@@ -838,16 +902,7 @@ public class OrmV2_0Package extends EPackageImpl
* @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlOneToMany_2_0()
* @generated
*/
- public static final int XML_ONE_TO_MANY_20 = 16;
-
- /**
- * The feature id for the '<em><b>Orphan Removal</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public static final int XML_ONE_TO_MANY_20__ORPHAN_REMOVAL = XML_ORPHAN_REMOVABLE_20__ORPHAN_REMOVAL;
+ public static final int XML_ONE_TO_MANY_20 = 17;
/**
* The feature id for the '<em><b>Order Column</b></em>' containment reference.
@@ -856,7 +911,7 @@ public class OrmV2_0Package extends EPackageImpl
* @generated
* @ordered
*/
- public static final int XML_ONE_TO_MANY_20__ORDER_COLUMN = XML_ORPHAN_REMOVABLE_20_FEATURE_COUNT + 0;
+ public static final int XML_ONE_TO_MANY_20__ORDER_COLUMN = XML_MULTI_RELATIONSHIP_MAPPING_20__ORDER_COLUMN;
/**
* The feature id for the '<em><b>Map Key Class</b></em>' containment reference.
@@ -865,7 +920,7 @@ public class OrmV2_0Package extends EPackageImpl
* @generated
* @ordered
*/
- public static final int XML_ONE_TO_MANY_20__MAP_KEY_CLASS = XML_ORPHAN_REMOVABLE_20_FEATURE_COUNT + 1;
+ public static final int XML_ONE_TO_MANY_20__MAP_KEY_CLASS = XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_CLASS;
/**
* The feature id for the '<em><b>Map Key Temporal</b></em>' attribute.
@@ -874,7 +929,7 @@ public class OrmV2_0Package extends EPackageImpl
* @generated
* @ordered
*/
- public static final int XML_ONE_TO_MANY_20__MAP_KEY_TEMPORAL = XML_ORPHAN_REMOVABLE_20_FEATURE_COUNT + 2;
+ public static final int XML_ONE_TO_MANY_20__MAP_KEY_TEMPORAL = XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_TEMPORAL;
/**
* The feature id for the '<em><b>Map Key Enumerated</b></em>' attribute.
@@ -883,7 +938,7 @@ public class OrmV2_0Package extends EPackageImpl
* @generated
* @ordered
*/
- public static final int XML_ONE_TO_MANY_20__MAP_KEY_ENUMERATED = XML_ORPHAN_REMOVABLE_20_FEATURE_COUNT + 3;
+ public static final int XML_ONE_TO_MANY_20__MAP_KEY_ENUMERATED = XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_ENUMERATED;
/**
* The feature id for the '<em><b>Map Key Attribute Overrides</b></em>' containment reference list.
@@ -892,7 +947,7 @@ public class OrmV2_0Package extends EPackageImpl
* @generated
* @ordered
*/
- public static final int XML_ONE_TO_MANY_20__MAP_KEY_ATTRIBUTE_OVERRIDES = XML_ORPHAN_REMOVABLE_20_FEATURE_COUNT + 4;
+ public static final int XML_ONE_TO_MANY_20__MAP_KEY_ATTRIBUTE_OVERRIDES = XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_ATTRIBUTE_OVERRIDES;
/**
* The feature id for the '<em><b>Map Key Column</b></em>' containment reference.
@@ -901,7 +956,7 @@ public class OrmV2_0Package extends EPackageImpl
* @generated
* @ordered
*/
- public static final int XML_ONE_TO_MANY_20__MAP_KEY_COLUMN = XML_ORPHAN_REMOVABLE_20_FEATURE_COUNT + 5;
+ public static final int XML_ONE_TO_MANY_20__MAP_KEY_COLUMN = XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_COLUMN;
/**
* The feature id for the '<em><b>Map Key Join Columns</b></em>' containment reference list.
@@ -910,7 +965,16 @@ public class OrmV2_0Package extends EPackageImpl
* @generated
* @ordered
*/
- public static final int XML_ONE_TO_MANY_20__MAP_KEY_JOIN_COLUMNS = XML_ORPHAN_REMOVABLE_20_FEATURE_COUNT + 6;
+ public static final int XML_ONE_TO_MANY_20__MAP_KEY_JOIN_COLUMNS = XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_JOIN_COLUMNS;
+
+ /**
+ * The feature id for the '<em><b>Orphan Removal</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int XML_ONE_TO_MANY_20__ORPHAN_REMOVAL = XML_MULTI_RELATIONSHIP_MAPPING_20_FEATURE_COUNT + 0;
/**
* The number of structural features of the '<em>Xml One To Many 20</em>' class.
@@ -919,7 +983,7 @@ public class OrmV2_0Package extends EPackageImpl
* @generated
* @ordered
*/
- public static final int XML_ONE_TO_MANY_20_FEATURE_COUNT = XML_ORPHAN_REMOVABLE_20_FEATURE_COUNT + 7;
+ public static final int XML_ONE_TO_MANY_20_FEATURE_COUNT = XML_MULTI_RELATIONSHIP_MAPPING_20_FEATURE_COUNT + 1;
/**
* The meta object id for the '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlSingleRelationshipMapping_2_0 <em>Xml Single Relationship Mapping 20</em>}' class.
@@ -929,7 +993,7 @@ public class OrmV2_0Package extends EPackageImpl
* @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlSingleRelationshipMapping_2_0()
* @generated
*/
- public static final int XML_SINGLE_RELATIONSHIP_MAPPING_20 = 24;
+ public static final int XML_SINGLE_RELATIONSHIP_MAPPING_20 = 25;
/**
* The feature id for the '<em><b>Id</b></em>' attribute.
@@ -966,7 +1030,7 @@ public class OrmV2_0Package extends EPackageImpl
* @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlOneToOne_2_0()
* @generated
*/
- public static final int XML_ONE_TO_ONE_20 = 17;
+ public static final int XML_ONE_TO_ONE_20 = 18;
/**
* The feature id for the '<em><b>Id</b></em>' attribute.
@@ -1012,7 +1076,7 @@ public class OrmV2_0Package extends EPackageImpl
* @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlOrderColumn_2_0()
* @generated
*/
- public static final int XML_ORDER_COLUMN_20 = 18;
+ public static final int XML_ORDER_COLUMN_20 = 19;
/**
* The feature id for the '<em><b>Nullable</b></em>' attribute.
@@ -1058,7 +1122,7 @@ public class OrmV2_0Package extends EPackageImpl
* @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlPersistenceUnitDefaults_2_0()
* @generated
*/
- public static final int XML_PERSISTENCE_UNIT_DEFAULTS_20 = 19;
+ public static final int XML_PERSISTENCE_UNIT_DEFAULTS_20 = 20;
/**
* The feature id for the '<em><b>Description</b></em>' attribute.
@@ -1095,7 +1159,7 @@ public class OrmV2_0Package extends EPackageImpl
* @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlPersistenceUnitMetadata_2_0()
* @generated
*/
- public static final int XML_PERSISTENCE_UNIT_METADATA_20 = 20;
+ public static final int XML_PERSISTENCE_UNIT_METADATA_20 = 21;
/**
* The feature id for the '<em><b>Description</b></em>' attribute.
@@ -1123,7 +1187,7 @@ public class OrmV2_0Package extends EPackageImpl
* @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlQuery_2_0()
* @generated
*/
- public static final int XML_QUERY_20 = 21;
+ public static final int XML_QUERY_20 = 22;
/**
* The feature id for the '<em><b>Description</b></em>' attribute.
@@ -1151,7 +1215,7 @@ public class OrmV2_0Package extends EPackageImpl
* @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlQueryHint_2_0()
* @generated
*/
- public static final int XML_QUERY_HINT_20 = 22;
+ public static final int XML_QUERY_HINT_20 = 23;
/**
* The feature id for the '<em><b>Description</b></em>' attribute.
@@ -1179,7 +1243,7 @@ public class OrmV2_0Package extends EPackageImpl
* @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlSequenceGenerator_2_0()
* @generated
*/
- public static final int XML_SEQUENCE_GENERATOR_20 = 23;
+ public static final int XML_SEQUENCE_GENERATOR_20 = 24;
/**
* The feature id for the '<em><b>Catalog</b></em>' attribute.
@@ -1216,7 +1280,7 @@ public class OrmV2_0Package extends EPackageImpl
* @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlSqlResultSetMapping_2_0()
* @generated
*/
- public static final int XML_SQL_RESULT_SET_MAPPING_20 = 25;
+ public static final int XML_SQL_RESULT_SET_MAPPING_20 = 26;
/**
* The feature id for the '<em><b>Description</b></em>' attribute.
@@ -1244,7 +1308,7 @@ public class OrmV2_0Package extends EPackageImpl
* @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlUniqueConstraint_2_0()
* @generated
*/
- public static final int XML_UNIQUE_CONSTRAINT_20 = 26;
+ public static final int XML_UNIQUE_CONSTRAINT_20 = 27;
/**
* The feature id for the '<em><b>Name</b></em>' attribute.
@@ -1265,6 +1329,24 @@ public class OrmV2_0Package extends EPackageImpl
public static final int XML_UNIQUE_CONSTRAINT_20_FEATURE_COUNT = 1;
/**
+ * The feature id for the '<em><b>Orphan Removal</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int XML_ORPHAN_REMOVABLE_20__ORPHAN_REMOVAL = 0;
+
+ /**
+ * The number of structural features of the '<em>Xml Orphan Removable 20</em>' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int XML_ORPHAN_REMOVABLE_20_FEATURE_COUNT = 1;
+
+ /**
* The meta object id for the '{@link org.eclipse.jpt.core.resource.orm.v2_0.LockModeType_2_0 <em>Lock Mode Type 20</em>}' enum.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -1272,7 +1354,7 @@ public class OrmV2_0Package extends EPackageImpl
* @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getLockModeType_2_0()
* @generated
*/
- public static final int LOCK_MODE_TYPE_20 = 30;
+ public static final int LOCK_MODE_TYPE_20 = 31;
/**
* <!-- begin-user-doc -->
@@ -1384,6 +1466,13 @@ public class OrmV2_0Package extends EPackageImpl
* <!-- end-user-doc -->
* @generated
*/
+ private EClass xmlMultiRelationshipMapping_2_0EClass = null;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
private EClass xmlNamedQuery_2_0EClass = null;
/**
@@ -2056,96 +2145,6 @@ public class OrmV2_0Package extends EPackageImpl
/**
- * Returns the meta object for the containment reference '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlManyToMany_2_0#getMapKeyClass <em>Map Key Class</em>}'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return the meta object for the containment reference '<em>Map Key Class</em>'.
- * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlManyToMany_2_0#getMapKeyClass()
- * @see #getXmlManyToMany_2_0()
- * @generated
- */
- public EReference getXmlManyToMany_2_0_MapKeyClass()
- {
- return (EReference)xmlManyToMany_2_0EClass.getEStructuralFeatures().get(0);
- }
-
-
- /**
- * Returns the meta object for the attribute '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlManyToMany_2_0#getMapKeyTemporal <em>Map Key Temporal</em>}'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return the meta object for the attribute '<em>Map Key Temporal</em>'.
- * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlManyToMany_2_0#getMapKeyTemporal()
- * @see #getXmlManyToMany_2_0()
- * @generated
- */
- public EAttribute getXmlManyToMany_2_0_MapKeyTemporal()
- {
- return (EAttribute)xmlManyToMany_2_0EClass.getEStructuralFeatures().get(1);
- }
-
-
- /**
- * Returns the meta object for the attribute '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlManyToMany_2_0#getMapKeyEnumerated <em>Map Key Enumerated</em>}'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return the meta object for the attribute '<em>Map Key Enumerated</em>'.
- * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlManyToMany_2_0#getMapKeyEnumerated()
- * @see #getXmlManyToMany_2_0()
- * @generated
- */
- public EAttribute getXmlManyToMany_2_0_MapKeyEnumerated()
- {
- return (EAttribute)xmlManyToMany_2_0EClass.getEStructuralFeatures().get(2);
- }
-
-
- /**
- * Returns the meta object for the containment reference list '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlManyToMany_2_0#getMapKeyAttributeOverrides <em>Map Key Attribute Overrides</em>}'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return the meta object for the containment reference list '<em>Map Key Attribute Overrides</em>'.
- * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlManyToMany_2_0#getMapKeyAttributeOverrides()
- * @see #getXmlManyToMany_2_0()
- * @generated
- */
- public EReference getXmlManyToMany_2_0_MapKeyAttributeOverrides()
- {
- return (EReference)xmlManyToMany_2_0EClass.getEStructuralFeatures().get(3);
- }
-
-
- /**
- * Returns the meta object for the containment reference '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlManyToMany_2_0#getMapKeyColumn <em>Map Key Column</em>}'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return the meta object for the containment reference '<em>Map Key Column</em>'.
- * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlManyToMany_2_0#getMapKeyColumn()
- * @see #getXmlManyToMany_2_0()
- * @generated
- */
- public EReference getXmlManyToMany_2_0_MapKeyColumn()
- {
- return (EReference)xmlManyToMany_2_0EClass.getEStructuralFeatures().get(4);
- }
-
-
- /**
- * Returns the meta object for the containment reference list '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlManyToMany_2_0#getMapKeyJoinColumns <em>Map Key Join Columns</em>}'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return the meta object for the containment reference list '<em>Map Key Join Columns</em>'.
- * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlManyToMany_2_0#getMapKeyJoinColumns()
- * @see #getXmlManyToMany_2_0()
- * @generated
- */
- public EReference getXmlManyToMany_2_0_MapKeyJoinColumns()
- {
- return (EReference)xmlManyToMany_2_0EClass.getEStructuralFeatures().get(5);
- }
-
-
- /**
* Returns the meta object for class '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlMapKeyClass_2_0 <em>Xml Map Key Class 20</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -2204,135 +2203,149 @@ public class OrmV2_0Package extends EPackageImpl
/**
- * Returns the meta object for class '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlNamedQuery_2_0 <em>Xml Named Query 20</em>}'.
+ * Returns the meta object for class '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlMultiRelationshipMapping_2_0 <em>Xml Multi Relationship Mapping 20</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @return the meta object for class '<em>Xml Named Query 20</em>'.
- * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlNamedQuery_2_0
+ * @return the meta object for class '<em>Xml Multi Relationship Mapping 20</em>'.
+ * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlMultiRelationshipMapping_2_0
* @generated
*/
- public EClass getXmlNamedQuery_2_0()
+ public EClass getXmlMultiRelationshipMapping_2_0()
{
- return xmlNamedQuery_2_0EClass;
+ return xmlMultiRelationshipMapping_2_0EClass;
}
/**
- * Returns the meta object for the attribute '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlNamedQuery_2_0#getLockMode <em>Lock Mode</em>}'.
+ * Returns the meta object for the containment reference '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlMultiRelationshipMapping_2_0#getMapKeyClass <em>Map Key Class</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @return the meta object for the attribute '<em>Lock Mode</em>'.
- * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlNamedQuery_2_0#getLockMode()
- * @see #getXmlNamedQuery_2_0()
+ * @return the meta object for the containment reference '<em>Map Key Class</em>'.
+ * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlMultiRelationshipMapping_2_0#getMapKeyClass()
+ * @see #getXmlMultiRelationshipMapping_2_0()
* @generated
*/
- public EAttribute getXmlNamedQuery_2_0_LockMode()
+ public EReference getXmlMultiRelationshipMapping_2_0_MapKeyClass()
{
- return (EAttribute)xmlNamedQuery_2_0EClass.getEStructuralFeatures().get(0);
+ return (EReference)xmlMultiRelationshipMapping_2_0EClass.getEStructuralFeatures().get(0);
}
/**
- * Returns the meta object for class '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0 <em>Xml One To Many 20</em>}'.
+ * Returns the meta object for the attribute '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlMultiRelationshipMapping_2_0#getMapKeyTemporal <em>Map Key Temporal</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @return the meta object for class '<em>Xml One To Many 20</em>'.
- * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0
+ * @return the meta object for the attribute '<em>Map Key Temporal</em>'.
+ * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlMultiRelationshipMapping_2_0#getMapKeyTemporal()
+ * @see #getXmlMultiRelationshipMapping_2_0()
* @generated
*/
- public EClass getXmlOneToMany_2_0()
+ public EAttribute getXmlMultiRelationshipMapping_2_0_MapKeyTemporal()
{
- return xmlOneToMany_2_0EClass;
+ return (EAttribute)xmlMultiRelationshipMapping_2_0EClass.getEStructuralFeatures().get(1);
}
/**
- * Returns the meta object for the containment reference '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0#getMapKeyClass <em>Map Key Class</em>}'.
+ * Returns the meta object for the attribute '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlMultiRelationshipMapping_2_0#getMapKeyEnumerated <em>Map Key Enumerated</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @return the meta object for the containment reference '<em>Map Key Class</em>'.
- * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0#getMapKeyClass()
- * @see #getXmlOneToMany_2_0()
+ * @return the meta object for the attribute '<em>Map Key Enumerated</em>'.
+ * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlMultiRelationshipMapping_2_0#getMapKeyEnumerated()
+ * @see #getXmlMultiRelationshipMapping_2_0()
* @generated
*/
- public EReference getXmlOneToMany_2_0_MapKeyClass()
+ public EAttribute getXmlMultiRelationshipMapping_2_0_MapKeyEnumerated()
{
- return (EReference)xmlOneToMany_2_0EClass.getEStructuralFeatures().get(0);
+ return (EAttribute)xmlMultiRelationshipMapping_2_0EClass.getEStructuralFeatures().get(2);
}
/**
- * Returns the meta object for the attribute '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0#getMapKeyTemporal <em>Map Key Temporal</em>}'.
+ * Returns the meta object for the containment reference list '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlMultiRelationshipMapping_2_0#getMapKeyAttributeOverrides <em>Map Key Attribute Overrides</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @return the meta object for the attribute '<em>Map Key Temporal</em>'.
- * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0#getMapKeyTemporal()
- * @see #getXmlOneToMany_2_0()
+ * @return the meta object for the containment reference list '<em>Map Key Attribute Overrides</em>'.
+ * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlMultiRelationshipMapping_2_0#getMapKeyAttributeOverrides()
+ * @see #getXmlMultiRelationshipMapping_2_0()
* @generated
*/
- public EAttribute getXmlOneToMany_2_0_MapKeyTemporal()
+ public EReference getXmlMultiRelationshipMapping_2_0_MapKeyAttributeOverrides()
{
- return (EAttribute)xmlOneToMany_2_0EClass.getEStructuralFeatures().get(1);
+ return (EReference)xmlMultiRelationshipMapping_2_0EClass.getEStructuralFeatures().get(3);
}
/**
- * Returns the meta object for the attribute '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0#getMapKeyEnumerated <em>Map Key Enumerated</em>}'.
+ * Returns the meta object for the containment reference '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlMultiRelationshipMapping_2_0#getMapKeyColumn <em>Map Key Column</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @return the meta object for the attribute '<em>Map Key Enumerated</em>'.
- * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0#getMapKeyEnumerated()
- * @see #getXmlOneToMany_2_0()
+ * @return the meta object for the containment reference '<em>Map Key Column</em>'.
+ * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlMultiRelationshipMapping_2_0#getMapKeyColumn()
+ * @see #getXmlMultiRelationshipMapping_2_0()
* @generated
*/
- public EAttribute getXmlOneToMany_2_0_MapKeyEnumerated()
+ public EReference getXmlMultiRelationshipMapping_2_0_MapKeyColumn()
{
- return (EAttribute)xmlOneToMany_2_0EClass.getEStructuralFeatures().get(2);
+ return (EReference)xmlMultiRelationshipMapping_2_0EClass.getEStructuralFeatures().get(4);
}
/**
- * Returns the meta object for the containment reference list '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0#getMapKeyAttributeOverrides <em>Map Key Attribute Overrides</em>}'.
+ * Returns the meta object for the containment reference list '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlMultiRelationshipMapping_2_0#getMapKeyJoinColumns <em>Map Key Join Columns</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @return the meta object for the containment reference list '<em>Map Key Attribute Overrides</em>'.
- * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0#getMapKeyAttributeOverrides()
- * @see #getXmlOneToMany_2_0()
+ * @return the meta object for the containment reference list '<em>Map Key Join Columns</em>'.
+ * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlMultiRelationshipMapping_2_0#getMapKeyJoinColumns()
+ * @see #getXmlMultiRelationshipMapping_2_0()
* @generated
*/
- public EReference getXmlOneToMany_2_0_MapKeyAttributeOverrides()
+ public EReference getXmlMultiRelationshipMapping_2_0_MapKeyJoinColumns()
{
- return (EReference)xmlOneToMany_2_0EClass.getEStructuralFeatures().get(3);
+ return (EReference)xmlMultiRelationshipMapping_2_0EClass.getEStructuralFeatures().get(5);
}
/**
- * Returns the meta object for the containment reference '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0#getMapKeyColumn <em>Map Key Column</em>}'.
+ * Returns the meta object for class '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlNamedQuery_2_0 <em>Xml Named Query 20</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @return the meta object for the containment reference '<em>Map Key Column</em>'.
- * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0#getMapKeyColumn()
- * @see #getXmlOneToMany_2_0()
+ * @return the meta object for class '<em>Xml Named Query 20</em>'.
+ * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlNamedQuery_2_0
* @generated
*/
- public EReference getXmlOneToMany_2_0_MapKeyColumn()
+ public EClass getXmlNamedQuery_2_0()
{
- return (EReference)xmlOneToMany_2_0EClass.getEStructuralFeatures().get(4);
+ return xmlNamedQuery_2_0EClass;
}
/**
- * Returns the meta object for the containment reference list '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0#getMapKeyJoinColumns <em>Map Key Join Columns</em>}'.
+ * Returns the meta object for the attribute '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlNamedQuery_2_0#getLockMode <em>Lock Mode</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @return the meta object for the containment reference list '<em>Map Key Join Columns</em>'.
- * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0#getMapKeyJoinColumns()
- * @see #getXmlOneToMany_2_0()
+ * @return the meta object for the attribute '<em>Lock Mode</em>'.
+ * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlNamedQuery_2_0#getLockMode()
+ * @see #getXmlNamedQuery_2_0()
+ * @generated
+ */
+ public EAttribute getXmlNamedQuery_2_0_LockMode()
+ {
+ return (EAttribute)xmlNamedQuery_2_0EClass.getEStructuralFeatures().get(0);
+ }
+
+
+ /**
+ * Returns the meta object for class '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0 <em>Xml One To Many 20</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for class '<em>Xml One To Many 20</em>'.
+ * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0
* @generated
*/
- public EReference getXmlOneToMany_2_0_MapKeyJoinColumns()
+ public EClass getXmlOneToMany_2_0()
{
- return (EReference)xmlOneToMany_2_0EClass.getEStructuralFeatures().get(5);
+ return xmlOneToMany_2_0EClass;
}
@@ -2832,12 +2845,6 @@ public class OrmV2_0Package extends EPackageImpl
createEAttribute(xmlGenerator_2_0EClass, XML_GENERATOR_20__DESCRIPTION);
xmlManyToMany_2_0EClass = createEClass(XML_MANY_TO_MANY_20);
- createEReference(xmlManyToMany_2_0EClass, XML_MANY_TO_MANY_20__MAP_KEY_CLASS);
- createEAttribute(xmlManyToMany_2_0EClass, XML_MANY_TO_MANY_20__MAP_KEY_TEMPORAL);
- createEAttribute(xmlManyToMany_2_0EClass, XML_MANY_TO_MANY_20__MAP_KEY_ENUMERATED);
- createEReference(xmlManyToMany_2_0EClass, XML_MANY_TO_MANY_20__MAP_KEY_ATTRIBUTE_OVERRIDES);
- createEReference(xmlManyToMany_2_0EClass, XML_MANY_TO_MANY_20__MAP_KEY_COLUMN);
- createEReference(xmlManyToMany_2_0EClass, XML_MANY_TO_MANY_20__MAP_KEY_JOIN_COLUMNS);
xmlMapKeyClass_2_0EClass = createEClass(XML_MAP_KEY_CLASS_20);
createEAttribute(xmlMapKeyClass_2_0EClass, XML_MAP_KEY_CLASS_20__CLASS_NAME);
@@ -2845,16 +2852,18 @@ public class OrmV2_0Package extends EPackageImpl
xmlMapsId_2_0EClass = createEClass(XML_MAPS_ID_20);
createEAttribute(xmlMapsId_2_0EClass, XML_MAPS_ID_20__MAPS_ID);
+ xmlMultiRelationshipMapping_2_0EClass = createEClass(XML_MULTI_RELATIONSHIP_MAPPING_20);
+ createEReference(xmlMultiRelationshipMapping_2_0EClass, XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_CLASS);
+ createEAttribute(xmlMultiRelationshipMapping_2_0EClass, XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_TEMPORAL);
+ createEAttribute(xmlMultiRelationshipMapping_2_0EClass, XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_ENUMERATED);
+ createEReference(xmlMultiRelationshipMapping_2_0EClass, XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_ATTRIBUTE_OVERRIDES);
+ createEReference(xmlMultiRelationshipMapping_2_0EClass, XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_COLUMN);
+ createEReference(xmlMultiRelationshipMapping_2_0EClass, XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_JOIN_COLUMNS);
+
xmlNamedQuery_2_0EClass = createEClass(XML_NAMED_QUERY_20);
createEAttribute(xmlNamedQuery_2_0EClass, XML_NAMED_QUERY_20__LOCK_MODE);
xmlOneToMany_2_0EClass = createEClass(XML_ONE_TO_MANY_20);
- createEReference(xmlOneToMany_2_0EClass, XML_ONE_TO_MANY_20__MAP_KEY_CLASS);
- createEAttribute(xmlOneToMany_2_0EClass, XML_ONE_TO_MANY_20__MAP_KEY_TEMPORAL);
- createEAttribute(xmlOneToMany_2_0EClass, XML_ONE_TO_MANY_20__MAP_KEY_ENUMERATED);
- createEReference(xmlOneToMany_2_0EClass, XML_ONE_TO_MANY_20__MAP_KEY_ATTRIBUTE_OVERRIDES);
- createEReference(xmlOneToMany_2_0EClass, XML_ONE_TO_MANY_20__MAP_KEY_COLUMN);
- createEReference(xmlOneToMany_2_0EClass, XML_ONE_TO_MANY_20__MAP_KEY_JOIN_COLUMNS);
xmlOneToOne_2_0EClass = createEClass(XML_ONE_TO_ONE_20);
@@ -2942,9 +2951,10 @@ public class OrmV2_0Package extends EPackageImpl
xmlElementCollection_2_0EClass.getESuperTypes().add(theOrmPackage.getXmlAssociationOverrideContainer());
xmlEmbedded_2_0EClass.getESuperTypes().add(theOrmPackage.getXmlAssociationOverrideContainer());
xmlEntity_2_0EClass.getESuperTypes().add(this.getXmlCacheable_2_0());
- xmlManyToMany_2_0EClass.getESuperTypes().add(this.getXmlOrderable_2_0());
+ xmlManyToMany_2_0EClass.getESuperTypes().add(this.getXmlMultiRelationshipMapping_2_0());
+ xmlMultiRelationshipMapping_2_0EClass.getESuperTypes().add(this.getXmlOrderable_2_0());
+ xmlOneToMany_2_0EClass.getESuperTypes().add(this.getXmlMultiRelationshipMapping_2_0());
xmlOneToMany_2_0EClass.getESuperTypes().add(this.getXmlOrphanRemovable_2_0());
- xmlOneToMany_2_0EClass.getESuperTypes().add(this.getXmlOrderable_2_0());
xmlOneToOne_2_0EClass.getESuperTypes().add(this.getXmlSingleRelationshipMapping_2_0());
xmlOneToOne_2_0EClass.getESuperTypes().add(this.getXmlOrphanRemovable_2_0());
xmlSingleRelationshipMapping_2_0EClass.getESuperTypes().add(this.getXmlDerivedId_2_0());
@@ -2996,12 +3006,6 @@ public class OrmV2_0Package extends EPackageImpl
initEAttribute(getXmlGenerator_2_0_Description(), theXMLTypePackage.getString(), "description", null, 0, 1, XmlGenerator_2_0.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(xmlManyToMany_2_0EClass, XmlManyToMany_2_0.class, "XmlManyToMany_2_0", IS_ABSTRACT, IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
- initEReference(getXmlManyToMany_2_0_MapKeyClass(), theOrmPackage.getXmlMapKeyClass(), null, "mapKeyClass", null, 0, 1, XmlManyToMany_2_0.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
- initEAttribute(getXmlManyToMany_2_0_MapKeyTemporal(), theOrmPackage.getTemporalType(), "mapKeyTemporal", null, 0, 1, XmlManyToMany_2_0.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
- initEAttribute(getXmlManyToMany_2_0_MapKeyEnumerated(), theOrmPackage.getEnumType(), "mapKeyEnumerated", null, 0, 1, XmlManyToMany_2_0.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
- initEReference(getXmlManyToMany_2_0_MapKeyAttributeOverrides(), theOrmPackage.getXmlAttributeOverride(), null, "mapKeyAttributeOverrides", null, 0, -1, XmlManyToMany_2_0.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
- initEReference(getXmlManyToMany_2_0_MapKeyColumn(), theOrmPackage.getXmlColumn(), null, "mapKeyColumn", null, 0, 1, XmlManyToMany_2_0.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
- initEReference(getXmlManyToMany_2_0_MapKeyJoinColumns(), theOrmPackage.getXmlJoinColumn(), null, "mapKeyJoinColumns", null, 0, -1, XmlManyToMany_2_0.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(xmlMapKeyClass_2_0EClass, XmlMapKeyClass_2_0.class, "XmlMapKeyClass_2_0", IS_ABSTRACT, IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEAttribute(getXmlMapKeyClass_2_0_ClassName(), theXMLTypePackage.getString(), "className", null, 1, 1, XmlMapKeyClass_2_0.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
@@ -3009,16 +3013,18 @@ public class OrmV2_0Package extends EPackageImpl
initEClass(xmlMapsId_2_0EClass, XmlMapsId_2_0.class, "XmlMapsId_2_0", IS_ABSTRACT, IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEAttribute(getXmlMapsId_2_0_MapsId(), theXMLTypePackage.getString(), "mapsId", null, 0, 1, XmlMapsId_2_0.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEClass(xmlMultiRelationshipMapping_2_0EClass, XmlMultiRelationshipMapping_2_0.class, "XmlMultiRelationshipMapping_2_0", IS_ABSTRACT, IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEReference(getXmlMultiRelationshipMapping_2_0_MapKeyClass(), theOrmPackage.getXmlMapKeyClass(), null, "mapKeyClass", null, 0, 1, XmlMultiRelationshipMapping_2_0.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEAttribute(getXmlMultiRelationshipMapping_2_0_MapKeyTemporal(), theOrmPackage.getTemporalType(), "mapKeyTemporal", null, 0, 1, XmlMultiRelationshipMapping_2_0.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEAttribute(getXmlMultiRelationshipMapping_2_0_MapKeyEnumerated(), theOrmPackage.getEnumType(), "mapKeyEnumerated", null, 0, 1, XmlMultiRelationshipMapping_2_0.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference(getXmlMultiRelationshipMapping_2_0_MapKeyAttributeOverrides(), theOrmPackage.getXmlAttributeOverride(), null, "mapKeyAttributeOverrides", null, 0, -1, XmlMultiRelationshipMapping_2_0.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference(getXmlMultiRelationshipMapping_2_0_MapKeyColumn(), theOrmPackage.getXmlColumn(), null, "mapKeyColumn", null, 0, 1, XmlMultiRelationshipMapping_2_0.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference(getXmlMultiRelationshipMapping_2_0_MapKeyJoinColumns(), theOrmPackage.getXmlJoinColumn(), null, "mapKeyJoinColumns", null, 0, -1, XmlMultiRelationshipMapping_2_0.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+
initEClass(xmlNamedQuery_2_0EClass, XmlNamedQuery_2_0.class, "XmlNamedQuery_2_0", IS_ABSTRACT, IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEAttribute(getXmlNamedQuery_2_0_LockMode(), this.getLockModeType_2_0(), "lockMode", null, 0, 1, XmlNamedQuery_2_0.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(xmlOneToMany_2_0EClass, XmlOneToMany_2_0.class, "XmlOneToMany_2_0", IS_ABSTRACT, IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
- initEReference(getXmlOneToMany_2_0_MapKeyClass(), theOrmPackage.getXmlMapKeyClass(), null, "mapKeyClass", null, 0, 1, XmlOneToMany_2_0.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
- initEAttribute(getXmlOneToMany_2_0_MapKeyTemporal(), theOrmPackage.getTemporalType(), "mapKeyTemporal", null, 0, 1, XmlOneToMany_2_0.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
- initEAttribute(getXmlOneToMany_2_0_MapKeyEnumerated(), theOrmPackage.getEnumType(), "mapKeyEnumerated", null, 0, 1, XmlOneToMany_2_0.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
- initEReference(getXmlOneToMany_2_0_MapKeyAttributeOverrides(), theOrmPackage.getXmlAttributeOverride(), null, "mapKeyAttributeOverrides", null, 0, -1, XmlOneToMany_2_0.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
- initEReference(getXmlOneToMany_2_0_MapKeyColumn(), theOrmPackage.getXmlColumn(), null, "mapKeyColumn", null, 0, 1, XmlOneToMany_2_0.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
- initEReference(getXmlOneToMany_2_0_MapKeyJoinColumns(), theOrmPackage.getXmlJoinColumn(), null, "mapKeyJoinColumns", null, 0, -1, XmlOneToMany_2_0.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(xmlOneToOne_2_0EClass, XmlOneToOne_2_0.class, "XmlOneToOne_2_0", IS_ABSTRACT, IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
@@ -3378,54 +3384,6 @@ public class OrmV2_0Package extends EPackageImpl
public static final EClass XML_MANY_TO_MANY_20 = eINSTANCE.getXmlManyToMany_2_0();
/**
- * The meta object literal for the '<em><b>Map Key Class</b></em>' containment reference feature.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static final EReference XML_MANY_TO_MANY_20__MAP_KEY_CLASS = eINSTANCE.getXmlManyToMany_2_0_MapKeyClass();
-
- /**
- * The meta object literal for the '<em><b>Map Key Temporal</b></em>' attribute feature.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static final EAttribute XML_MANY_TO_MANY_20__MAP_KEY_TEMPORAL = eINSTANCE.getXmlManyToMany_2_0_MapKeyTemporal();
-
- /**
- * The meta object literal for the '<em><b>Map Key Enumerated</b></em>' attribute feature.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static final EAttribute XML_MANY_TO_MANY_20__MAP_KEY_ENUMERATED = eINSTANCE.getXmlManyToMany_2_0_MapKeyEnumerated();
-
- /**
- * The meta object literal for the '<em><b>Map Key Attribute Overrides</b></em>' containment reference list feature.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static final EReference XML_MANY_TO_MANY_20__MAP_KEY_ATTRIBUTE_OVERRIDES = eINSTANCE.getXmlManyToMany_2_0_MapKeyAttributeOverrides();
-
- /**
- * The meta object literal for the '<em><b>Map Key Column</b></em>' containment reference feature.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static final EReference XML_MANY_TO_MANY_20__MAP_KEY_COLUMN = eINSTANCE.getXmlManyToMany_2_0_MapKeyColumn();
-
- /**
- * The meta object literal for the '<em><b>Map Key Join Columns</b></em>' containment reference list feature.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static final EReference XML_MANY_TO_MANY_20__MAP_KEY_JOIN_COLUMNS = eINSTANCE.getXmlManyToMany_2_0_MapKeyJoinColumns();
-
- /**
* The meta object literal for the '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlMapKeyClass_2_0 <em>Xml Map Key Class 20</em>}' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -3462,80 +3420,90 @@ public class OrmV2_0Package extends EPackageImpl
public static final EAttribute XML_MAPS_ID_20__MAPS_ID = eINSTANCE.getXmlMapsId_2_0_MapsId();
/**
- * The meta object literal for the '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlNamedQuery_2_0 <em>Xml Named Query 20</em>}' class.
+ * The meta object literal for the '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlMultiRelationshipMapping_2_0 <em>Xml Multi Relationship Mapping 20</em>}' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlNamedQuery_2_0
- * @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlNamedQuery_2_0()
+ * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlMultiRelationshipMapping_2_0
+ * @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlMultiRelationshipMapping_2_0()
* @generated
*/
- public static final EClass XML_NAMED_QUERY_20 = eINSTANCE.getXmlNamedQuery_2_0();
+ public static final EClass XML_MULTI_RELATIONSHIP_MAPPING_20 = eINSTANCE.getXmlMultiRelationshipMapping_2_0();
/**
- * The meta object literal for the '<em><b>Lock Mode</b></em>' attribute feature.
+ * The meta object literal for the '<em><b>Map Key Class</b></em>' containment reference feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
- public static final EAttribute XML_NAMED_QUERY_20__LOCK_MODE = eINSTANCE.getXmlNamedQuery_2_0_LockMode();
+ public static final EReference XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_CLASS = eINSTANCE.getXmlMultiRelationshipMapping_2_0_MapKeyClass();
/**
- * The meta object literal for the '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0 <em>Xml One To Many 20</em>}' class.
+ * The meta object literal for the '<em><b>Map Key Temporal</b></em>' attribute feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0
- * @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlOneToMany_2_0()
* @generated
*/
- public static final EClass XML_ONE_TO_MANY_20 = eINSTANCE.getXmlOneToMany_2_0();
+ public static final EAttribute XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_TEMPORAL = eINSTANCE.getXmlMultiRelationshipMapping_2_0_MapKeyTemporal();
/**
- * The meta object literal for the '<em><b>Map Key Class</b></em>' containment reference feature.
+ * The meta object literal for the '<em><b>Map Key Enumerated</b></em>' attribute feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
- public static final EReference XML_ONE_TO_MANY_20__MAP_KEY_CLASS = eINSTANCE.getXmlOneToMany_2_0_MapKeyClass();
+ public static final EAttribute XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_ENUMERATED = eINSTANCE.getXmlMultiRelationshipMapping_2_0_MapKeyEnumerated();
/**
- * The meta object literal for the '<em><b>Map Key Temporal</b></em>' attribute feature.
+ * The meta object literal for the '<em><b>Map Key Attribute Overrides</b></em>' containment reference list feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
- public static final EAttribute XML_ONE_TO_MANY_20__MAP_KEY_TEMPORAL = eINSTANCE.getXmlOneToMany_2_0_MapKeyTemporal();
+ public static final EReference XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_ATTRIBUTE_OVERRIDES = eINSTANCE.getXmlMultiRelationshipMapping_2_0_MapKeyAttributeOverrides();
/**
- * The meta object literal for the '<em><b>Map Key Enumerated</b></em>' attribute feature.
+ * The meta object literal for the '<em><b>Map Key Column</b></em>' containment reference feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
- public static final EAttribute XML_ONE_TO_MANY_20__MAP_KEY_ENUMERATED = eINSTANCE.getXmlOneToMany_2_0_MapKeyEnumerated();
+ public static final EReference XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_COLUMN = eINSTANCE.getXmlMultiRelationshipMapping_2_0_MapKeyColumn();
/**
- * The meta object literal for the '<em><b>Map Key Attribute Overrides</b></em>' containment reference list feature.
+ * The meta object literal for the '<em><b>Map Key Join Columns</b></em>' containment reference list feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
- public static final EReference XML_ONE_TO_MANY_20__MAP_KEY_ATTRIBUTE_OVERRIDES = eINSTANCE.getXmlOneToMany_2_0_MapKeyAttributeOverrides();
+ public static final EReference XML_MULTI_RELATIONSHIP_MAPPING_20__MAP_KEY_JOIN_COLUMNS = eINSTANCE.getXmlMultiRelationshipMapping_2_0_MapKeyJoinColumns();
/**
- * The meta object literal for the '<em><b>Map Key Column</b></em>' containment reference feature.
+ * The meta object literal for the '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlNamedQuery_2_0 <em>Xml Named Query 20</em>}' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlNamedQuery_2_0
+ * @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlNamedQuery_2_0()
* @generated
*/
- public static final EReference XML_ONE_TO_MANY_20__MAP_KEY_COLUMN = eINSTANCE.getXmlOneToMany_2_0_MapKeyColumn();
+ public static final EClass XML_NAMED_QUERY_20 = eINSTANCE.getXmlNamedQuery_2_0();
/**
- * The meta object literal for the '<em><b>Map Key Join Columns</b></em>' containment reference list feature.
+ * The meta object literal for the '<em><b>Lock Mode</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final EAttribute XML_NAMED_QUERY_20__LOCK_MODE = eINSTANCE.getXmlNamedQuery_2_0_LockMode();
+
+ /**
+ * The meta object literal for the '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0 <em>Xml One To Many 20</em>}' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ * @see org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0
+ * @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlOneToMany_2_0()
* @generated
*/
- public static final EReference XML_ONE_TO_MANY_20__MAP_KEY_JOIN_COLUMNS = eINSTANCE.getXmlOneToMany_2_0_MapKeyJoinColumns();
+ public static final EClass XML_ONE_TO_MANY_20 = eINSTANCE.getXmlOneToMany_2_0();
/**
* The meta object literal for the '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToOne_2_0 <em>Xml One To One 20</em>}' class.
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/v2_0/XmlManyToMany_2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/v2_0/XmlManyToMany_2_0.java
index 438a97f9c8..fc1b205174 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/v2_0/XmlManyToMany_2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/v2_0/XmlManyToMany_2_0.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Oracle.
+ * Copyright (c) 2009, 2010 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
@@ -11,13 +11,6 @@
package org.eclipse.jpt.core.resource.orm.v2_0;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.jpt.core.resource.orm.EnumType;
-import org.eclipse.jpt.core.resource.orm.TemporalType;
-import org.eclipse.jpt.core.resource.orm.XmlAttributeOverride;
-import org.eclipse.jpt.core.resource.orm.XmlColumn;
-import org.eclipse.jpt.core.resource.orm.XmlJoinColumn;
-import org.eclipse.jpt.core.resource.orm.XmlMapKeyClass;
/**
* <!-- begin-user-doc -->
@@ -30,164 +23,12 @@ import org.eclipse.jpt.core.resource.orm.XmlMapKeyClass;
* will almost certainly be broken (repeatedly) as the API evolves.
* <!-- end-user-doc -->
*
- * <p>
- * The following features are supported:
- * <ul>
- * <li>{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlManyToMany_2_0#getMapKeyClass <em>Map Key Class</em>}</li>
- * <li>{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlManyToMany_2_0#getMapKeyTemporal <em>Map Key Temporal</em>}</li>
- * <li>{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlManyToMany_2_0#getMapKeyEnumerated <em>Map Key Enumerated</em>}</li>
- * <li>{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlManyToMany_2_0#getMapKeyAttributeOverrides <em>Map Key Attribute Overrides</em>}</li>
- * <li>{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlManyToMany_2_0#getMapKeyColumn <em>Map Key Column</em>}</li>
- * <li>{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlManyToMany_2_0#getMapKeyJoinColumns <em>Map Key Join Columns</em>}</li>
- * </ul>
- * </p>
*
* @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlManyToMany_2_0()
* @model kind="class" interface="true" abstract="true"
* @generated
*/
-public interface XmlManyToMany_2_0 extends XmlOrderable_2_0
+public interface XmlManyToMany_2_0 extends XmlMultiRelationshipMapping_2_0
{
- /**
- * Returns the value of the '<em><b>Map Key Class</b></em>' containment reference.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Map Key Class</em>' containment reference isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Map Key Class</em>' containment reference.
- * @see #setMapKeyClass(XmlMapKeyClass)
- * @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlManyToMany_2_0_MapKeyClass()
- * @model containment="true"
- * @generated
- */
- XmlMapKeyClass getMapKeyClass();
-
- /**
- * Sets the value of the '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlManyToMany_2_0#getMapKeyClass <em>Map Key Class</em>}' containment reference.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Map Key Class</em>' containment reference.
- * @see #getMapKeyClass()
- * @generated
- */
- void setMapKeyClass(XmlMapKeyClass value);
-
- /**
- * Returns the value of the '<em><b>Map Key Temporal</b></em>' attribute.
- * The literals are from the enumeration {@link org.eclipse.jpt.core.resource.orm.TemporalType}.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Map Key Temporal</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Map Key Temporal</em>' attribute.
- * @see org.eclipse.jpt.core.resource.orm.TemporalType
- * @see #setMapKeyTemporal(TemporalType)
- * @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlManyToMany_2_0_MapKeyTemporal()
- * @model
- * @generated
- */
- TemporalType getMapKeyTemporal();
-
- /**
- * Sets the value of the '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlManyToMany_2_0#getMapKeyTemporal <em>Map Key Temporal</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Map Key Temporal</em>' attribute.
- * @see org.eclipse.jpt.core.resource.orm.TemporalType
- * @see #getMapKeyTemporal()
- * @generated
- */
- void setMapKeyTemporal(TemporalType value);
-
- /**
- * Returns the value of the '<em><b>Map Key Enumerated</b></em>' attribute.
- * The literals are from the enumeration {@link org.eclipse.jpt.core.resource.orm.EnumType}.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Map Key Enumerated</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Map Key Enumerated</em>' attribute.
- * @see org.eclipse.jpt.core.resource.orm.EnumType
- * @see #setMapKeyEnumerated(EnumType)
- * @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlManyToMany_2_0_MapKeyEnumerated()
- * @model
- * @generated
- */
- EnumType getMapKeyEnumerated();
-
- /**
- * Sets the value of the '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlManyToMany_2_0#getMapKeyEnumerated <em>Map Key Enumerated</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Map Key Enumerated</em>' attribute.
- * @see org.eclipse.jpt.core.resource.orm.EnumType
- * @see #getMapKeyEnumerated()
- * @generated
- */
- void setMapKeyEnumerated(EnumType value);
-
- /**
- * Returns the value of the '<em><b>Map Key Attribute Overrides</b></em>' containment reference list.
- * The list contents are of type {@link org.eclipse.jpt.core.resource.orm.XmlAttributeOverride}.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Map Key Attribute Overrides</em>' containment reference list isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Map Key Attribute Overrides</em>' containment reference list.
- * @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlManyToMany_2_0_MapKeyAttributeOverrides()
- * @model containment="true"
- * @generated
- */
- EList<XmlAttributeOverride> getMapKeyAttributeOverrides();
-
- /**
- * Returns the value of the '<em><b>Map Key Column</b></em>' containment reference.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Map Key Column</em>' containment reference isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Map Key Column</em>' containment reference.
- * @see #setMapKeyColumn(XmlColumn)
- * @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlManyToMany_2_0_MapKeyColumn()
- * @model containment="true"
- * @generated
- */
- XmlColumn getMapKeyColumn();
-
- /**
- * Sets the value of the '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlManyToMany_2_0#getMapKeyColumn <em>Map Key Column</em>}' containment reference.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Map Key Column</em>' containment reference.
- * @see #getMapKeyColumn()
- * @generated
- */
- void setMapKeyColumn(XmlColumn value);
-
- /**
- * Returns the value of the '<em><b>Map Key Join Columns</b></em>' containment reference list.
- * The list contents are of type {@link org.eclipse.jpt.core.resource.orm.XmlJoinColumn}.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Map Key Join Columns</em>' containment reference list isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Map Key Join Columns</em>' containment reference list.
- * @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlManyToMany_2_0_MapKeyJoinColumns()
- * @model containment="true"
- * @generated
- */
- EList<XmlJoinColumn> getMapKeyJoinColumns();
} // XmlManyToMany_2_0
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/v2_0/XmlMultiRelationshipMapping_2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/v2_0/XmlMultiRelationshipMapping_2_0.java
new file mode 100644
index 0000000000..2c759d781e
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/v2_0/XmlMultiRelationshipMapping_2_0.java
@@ -0,0 +1,187 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.core.resource.orm.v2_0;
+
+import org.eclipse.emf.common.util.EList;
+
+import org.eclipse.jpt.core.resource.orm.EnumType;
+import org.eclipse.jpt.core.resource.orm.TemporalType;
+import org.eclipse.jpt.core.resource.orm.XmlAttributeOverride;
+import org.eclipse.jpt.core.resource.orm.XmlColumn;
+import org.eclipse.jpt.core.resource.orm.XmlJoinColumn;
+import org.eclipse.jpt.core.resource.orm.XmlMapKeyClass;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Xml Multi Relationship Mapping 20</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlMultiRelationshipMapping_2_0#getMapKeyClass <em>Map Key Class</em>}</li>
+ * <li>{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlMultiRelationshipMapping_2_0#getMapKeyTemporal <em>Map Key Temporal</em>}</li>
+ * <li>{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlMultiRelationshipMapping_2_0#getMapKeyEnumerated <em>Map Key Enumerated</em>}</li>
+ * <li>{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlMultiRelationshipMapping_2_0#getMapKeyAttributeOverrides <em>Map Key Attribute Overrides</em>}</li>
+ * <li>{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlMultiRelationshipMapping_2_0#getMapKeyColumn <em>Map Key Column</em>}</li>
+ * <li>{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlMultiRelationshipMapping_2_0#getMapKeyJoinColumns <em>Map Key Join Columns</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlMultiRelationshipMapping_2_0()
+ * @model kind="class" interface="true" abstract="true"
+ * @generated
+ */
+public interface XmlMultiRelationshipMapping_2_0 extends XmlOrderable_2_0
+{
+ /**
+ * Returns the value of the '<em><b>Map Key Class</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Map Key Class</em>' containment reference isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Map Key Class</em>' containment reference.
+ * @see #setMapKeyClass(XmlMapKeyClass)
+ * @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlMultiRelationshipMapping_2_0_MapKeyClass()
+ * @model containment="true"
+ * @generated
+ */
+ XmlMapKeyClass getMapKeyClass();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlMultiRelationshipMapping_2_0#getMapKeyClass <em>Map Key Class</em>}' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Map Key Class</em>' containment reference.
+ * @see #getMapKeyClass()
+ * @generated
+ */
+ void setMapKeyClass(XmlMapKeyClass value);
+
+ /**
+ * Returns the value of the '<em><b>Map Key Temporal</b></em>' attribute.
+ * The literals are from the enumeration {@link org.eclipse.jpt.core.resource.orm.TemporalType}.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Map Key Temporal</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Map Key Temporal</em>' attribute.
+ * @see org.eclipse.jpt.core.resource.orm.TemporalType
+ * @see #setMapKeyTemporal(TemporalType)
+ * @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlMultiRelationshipMapping_2_0_MapKeyTemporal()
+ * @model
+ * @generated
+ */
+ TemporalType getMapKeyTemporal();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlMultiRelationshipMapping_2_0#getMapKeyTemporal <em>Map Key Temporal</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Map Key Temporal</em>' attribute.
+ * @see org.eclipse.jpt.core.resource.orm.TemporalType
+ * @see #getMapKeyTemporal()
+ * @generated
+ */
+ void setMapKeyTemporal(TemporalType value);
+
+ /**
+ * Returns the value of the '<em><b>Map Key Enumerated</b></em>' attribute.
+ * The literals are from the enumeration {@link org.eclipse.jpt.core.resource.orm.EnumType}.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Map Key Enumerated</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Map Key Enumerated</em>' attribute.
+ * @see org.eclipse.jpt.core.resource.orm.EnumType
+ * @see #setMapKeyEnumerated(EnumType)
+ * @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlMultiRelationshipMapping_2_0_MapKeyEnumerated()
+ * @model
+ * @generated
+ */
+ EnumType getMapKeyEnumerated();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlMultiRelationshipMapping_2_0#getMapKeyEnumerated <em>Map Key Enumerated</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Map Key Enumerated</em>' attribute.
+ * @see org.eclipse.jpt.core.resource.orm.EnumType
+ * @see #getMapKeyEnumerated()
+ * @generated
+ */
+ void setMapKeyEnumerated(EnumType value);
+
+ /**
+ * Returns the value of the '<em><b>Map Key Attribute Overrides</b></em>' containment reference list.
+ * The list contents are of type {@link org.eclipse.jpt.core.resource.orm.XmlAttributeOverride}.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Map Key Attribute Overrides</em>' containment reference list isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Map Key Attribute Overrides</em>' containment reference list.
+ * @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlMultiRelationshipMapping_2_0_MapKeyAttributeOverrides()
+ * @model containment="true"
+ * @generated
+ */
+ EList<XmlAttributeOverride> getMapKeyAttributeOverrides();
+
+ /**
+ * Returns the value of the '<em><b>Map Key Column</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Map Key Column</em>' containment reference isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Map Key Column</em>' containment reference.
+ * @see #setMapKeyColumn(XmlColumn)
+ * @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlMultiRelationshipMapping_2_0_MapKeyColumn()
+ * @model containment="true"
+ * @generated
+ */
+ XmlColumn getMapKeyColumn();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlMultiRelationshipMapping_2_0#getMapKeyColumn <em>Map Key Column</em>}' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Map Key Column</em>' containment reference.
+ * @see #getMapKeyColumn()
+ * @generated
+ */
+ void setMapKeyColumn(XmlColumn value);
+
+ /**
+ * Returns the value of the '<em><b>Map Key Join Columns</b></em>' containment reference list.
+ * The list contents are of type {@link org.eclipse.jpt.core.resource.orm.XmlJoinColumn}.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Map Key Join Columns</em>' containment reference list isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Map Key Join Columns</em>' containment reference list.
+ * @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlMultiRelationshipMapping_2_0_MapKeyJoinColumns()
+ * @model containment="true"
+ * @generated
+ */
+ EList<XmlJoinColumn> getMapKeyJoinColumns();
+
+} // XmlMultiRelationshipMapping_2_0
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/v2_0/XmlOneToMany_2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/v2_0/XmlOneToMany_2_0.java
index 4e4e05c78b..bc79a92245 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/v2_0/XmlOneToMany_2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/v2_0/XmlOneToMany_2_0.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Oracle.
+ * Copyright (c) 2009, 2010 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
@@ -11,177 +11,18 @@
package org.eclipse.jpt.core.resource.orm.v2_0;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.jpt.core.resource.orm.EnumType;
-import org.eclipse.jpt.core.resource.orm.TemporalType;
-import org.eclipse.jpt.core.resource.orm.XmlAttributeOverride;
-import org.eclipse.jpt.core.resource.orm.XmlColumn;
-import org.eclipse.jpt.core.resource.orm.XmlJoinColumn;
-import org.eclipse.jpt.core.resource.orm.XmlMapKeyClass;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Xml One To Many 20</b></em>'.
* <!-- end-user-doc -->
*
- * <p>
- * The following features are supported:
- * <ul>
- * <li>{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0#getMapKeyClass <em>Map Key Class</em>}</li>
- * <li>{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0#getMapKeyTemporal <em>Map Key Temporal</em>}</li>
- * <li>{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0#getMapKeyEnumerated <em>Map Key Enumerated</em>}</li>
- * <li>{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0#getMapKeyAttributeOverrides <em>Map Key Attribute Overrides</em>}</li>
- * <li>{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0#getMapKeyColumn <em>Map Key Column</em>}</li>
- * <li>{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0#getMapKeyJoinColumns <em>Map Key Join Columns</em>}</li>
- * </ul>
- * </p>
*
* @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlOneToMany_2_0()
* @model kind="class" interface="true" abstract="true"
* @generated
*/
-public interface XmlOneToMany_2_0 extends XmlOrphanRemovable_2_0, XmlOrderable_2_0
+public interface XmlOneToMany_2_0 extends XmlMultiRelationshipMapping_2_0, XmlOrphanRemovable_2_0
{
- /**
- * Returns the value of the '<em><b>Map Key Class</b></em>' containment reference.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Map Key Class</em>' containment reference isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Map Key Class</em>' containment reference.
- * @see #setMapKeyClass(XmlMapKeyClass)
- * @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlOneToMany_2_0_MapKeyClass()
- * @model containment="true"
- * @generated
- */
- XmlMapKeyClass getMapKeyClass();
-
- /**
- * Sets the value of the '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0#getMapKeyClass <em>Map Key Class</em>}' containment reference.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Map Key Class</em>' containment reference.
- * @see #getMapKeyClass()
- * @generated
- */
- void setMapKeyClass(XmlMapKeyClass value);
-
- /**
- * Returns the value of the '<em><b>Map Key Temporal</b></em>' attribute.
- * The literals are from the enumeration {@link org.eclipse.jpt.core.resource.orm.TemporalType}.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Map Key Temporal</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Map Key Temporal</em>' attribute.
- * @see org.eclipse.jpt.core.resource.orm.TemporalType
- * @see #setMapKeyTemporal(TemporalType)
- * @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlOneToMany_2_0_MapKeyTemporal()
- * @model
- * @generated
- */
- TemporalType getMapKeyTemporal();
-
- /**
- * Sets the value of the '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0#getMapKeyTemporal <em>Map Key Temporal</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Map Key Temporal</em>' attribute.
- * @see org.eclipse.jpt.core.resource.orm.TemporalType
- * @see #getMapKeyTemporal()
- * @generated
- */
- void setMapKeyTemporal(TemporalType value);
-
- /**
- * Returns the value of the '<em><b>Map Key Enumerated</b></em>' attribute.
- * The literals are from the enumeration {@link org.eclipse.jpt.core.resource.orm.EnumType}.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Map Key Enumerated</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Map Key Enumerated</em>' attribute.
- * @see org.eclipse.jpt.core.resource.orm.EnumType
- * @see #setMapKeyEnumerated(EnumType)
- * @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlOneToMany_2_0_MapKeyEnumerated()
- * @model
- * @generated
- */
- EnumType getMapKeyEnumerated();
-
- /**
- * Sets the value of the '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0#getMapKeyEnumerated <em>Map Key Enumerated</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Map Key Enumerated</em>' attribute.
- * @see org.eclipse.jpt.core.resource.orm.EnumType
- * @see #getMapKeyEnumerated()
- * @generated
- */
- void setMapKeyEnumerated(EnumType value);
-
- /**
- * Returns the value of the '<em><b>Map Key Attribute Overrides</b></em>' containment reference list.
- * The list contents are of type {@link org.eclipse.jpt.core.resource.orm.XmlAttributeOverride}.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Map Key Attribute Overrides</em>' containment reference list isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Map Key Attribute Overrides</em>' containment reference list.
- * @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlOneToMany_2_0_MapKeyAttributeOverrides()
- * @model containment="true"
- * @generated
- */
- EList<XmlAttributeOverride> getMapKeyAttributeOverrides();
-
- /**
- * Returns the value of the '<em><b>Map Key Column</b></em>' containment reference.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Map Key Column</em>' containment reference isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Map Key Column</em>' containment reference.
- * @see #setMapKeyColumn(XmlColumn)
- * @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlOneToMany_2_0_MapKeyColumn()
- * @model containment="true"
- * @generated
- */
- XmlColumn getMapKeyColumn();
-
- /**
- * Sets the value of the '{@link org.eclipse.jpt.core.resource.orm.v2_0.XmlOneToMany_2_0#getMapKeyColumn <em>Map Key Column</em>}' containment reference.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Map Key Column</em>' containment reference.
- * @see #getMapKeyColumn()
- * @generated
- */
- void setMapKeyColumn(XmlColumn value);
-
- /**
- * Returns the value of the '<em><b>Map Key Join Columns</b></em>' containment reference list.
- * The list contents are of type {@link org.eclipse.jpt.core.resource.orm.XmlJoinColumn}.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Map Key Join Columns</em>' containment reference list isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Map Key Join Columns</em>' containment reference list.
- * @see org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package#getXmlOneToMany_2_0_MapKeyJoinColumns()
- * @model containment="true"
- * @generated
- */
- EList<XmlJoinColumn> getMapKeyJoinColumns();
} // XmlOneToMany_2_0
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkPersistentAttribute.java
index 8c9e53b6eb..c63bc0eda1 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkPersistentAttribute.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkPersistentAttribute.java
@@ -10,13 +10,10 @@
package org.eclipse.jpt.eclipselink.core.internal.context.java;
import org.eclipse.jpt.core.context.AccessType;
-import org.eclipse.jpt.core.context.MultiRelationshipMapping;
import org.eclipse.jpt.core.context.PersistentType;
import org.eclipse.jpt.core.internal.context.java.AbstractJavaPersistentAttribute;
-import org.eclipse.jpt.core.jpa2.context.MetamodelField;
import org.eclipse.jpt.core.jpa2.context.java.JavaPersistentAttribute2_0;
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.utility.internal.ClassName;
/**
* EclipseLink Java persistent attribute
@@ -70,25 +67,4 @@ public class JavaEclipseLinkPersistentAttribute
this.typeIsContainer(interfaceName) ||
interfaceName.equals("org.eclipse.persistence.indirection.ValueHolderInterface"); //$NON-NLS-1$
}
-
- // ********** metamodel **********
-
- public String getMetamodelContainerFieldTypeName() {
- return this.getJpaContainer(this.resourcePersistentAttribute.getTypeName()).getMetamodelContainerFieldTypeName();
- }
-
- public String getMetamodelContainerFieldMapKeyTypeName() {
- return this.getJpaContainer(this.resourcePersistentAttribute.getTypeName()).getMetamodelContainerFieldMapKeyTypeName((MultiRelationshipMapping) this.getMapping());
- }
-
- public String getMetamodelTypeName() {
- String typeName = this.resourcePersistentAttribute.getTypeName();
- if (typeName == null) {
- return MetamodelField.DEFAULT_TYPE_NAME;
- }
- if (ClassName.isPrimitive(typeName)) {
- return ClassName.getWrapperClassName(typeName); // ???
- }
- return typeName;
- }
}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/VirtualEclipseLinkXmlManyToMany.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/VirtualEclipseLinkXmlManyToMany.java
index cc6151f20c..08605a984c 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/VirtualEclipseLinkXmlManyToMany.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/VirtualEclipseLinkXmlManyToMany.java
@@ -16,7 +16,6 @@ import org.eclipse.jpt.core.internal.context.orm.VirtualXmlManyToMany;
import org.eclipse.jpt.core.resource.orm.CascadeType;
import org.eclipse.jpt.core.resource.orm.FetchType;
import org.eclipse.jpt.core.resource.orm.MapKey;
-import org.eclipse.jpt.core.resource.orm.XmlJoinColumn;
import org.eclipse.jpt.core.resource.orm.XmlJoinTable;
import org.eclipse.jpt.core.resource.orm.XmlOrderColumn;
import org.eclipse.jpt.core.utility.TextRange;
@@ -80,10 +79,6 @@ public class VirtualEclipseLinkXmlManyToMany extends XmlManyToMany
this.virtualXmlManyToMany.setFetch(newFetch);
}
- public EList<XmlJoinColumn> getJoinColumns() {
- return this.virtualXmlManyToMany.getJoinColumns();
- }
-
@Override
public CascadeType getCascade() {
return this.virtualXmlManyToMany.getCascade();
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v1_1/context/orm/VirtualEclipseLinkXmlManyToMany1_1.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v1_1/context/orm/VirtualEclipseLinkXmlManyToMany1_1.java
index 280224484a..555f6af671 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v1_1/context/orm/VirtualEclipseLinkXmlManyToMany1_1.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v1_1/context/orm/VirtualEclipseLinkXmlManyToMany1_1.java
@@ -16,7 +16,6 @@ import org.eclipse.jpt.core.resource.orm.AccessType;
import org.eclipse.jpt.core.resource.orm.CascadeType;
import org.eclipse.jpt.core.resource.orm.FetchType;
import org.eclipse.jpt.core.resource.orm.MapKey;
-import org.eclipse.jpt.core.resource.orm.XmlJoinColumn;
import org.eclipse.jpt.core.resource.orm.XmlJoinTable;
import org.eclipse.jpt.core.resource.orm.XmlOrderColumn;
import org.eclipse.jpt.core.utility.TextRange;
@@ -79,10 +78,6 @@ public class VirtualEclipseLinkXmlManyToMany1_1 extends XmlManyToMany
this.virtualXmlManyToMany.setFetch(newFetch);
}
- public EList<XmlJoinColumn> getJoinColumns() {
- return this.virtualXmlManyToMany.getJoinColumns();
- }
-
@Override
public CascadeType getCascade() {
return this.virtualXmlManyToMany.getCascade();
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/context/orm/EclipseLinkOrmXml2_0ContextNodeFactory.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/context/orm/EclipseLinkOrmXml2_0ContextNodeFactory.java
index 7847f50de7..284358b5f8 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/context/orm/EclipseLinkOrmXml2_0ContextNodeFactory.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/context/orm/EclipseLinkOrmXml2_0ContextNodeFactory.java
@@ -18,6 +18,7 @@ import org.eclipse.jpt.core.context.java.JavaEmbeddedMapping;
import org.eclipse.jpt.core.context.java.JavaIdMapping;
import org.eclipse.jpt.core.context.java.JavaManyToManyMapping;
import org.eclipse.jpt.core.context.java.JavaManyToOneMapping;
+import org.eclipse.jpt.core.context.java.JavaOneToManyMapping;
import org.eclipse.jpt.core.context.java.JavaTransientMapping;
import org.eclipse.jpt.core.context.java.JavaVersionMapping;
import org.eclipse.jpt.core.context.orm.OrmAssociationOverride;
@@ -60,6 +61,7 @@ import org.eclipse.jpt.core.resource.orm.v2_0.XmlOrphanRemovable_2_0;
import org.eclipse.jpt.core.resource.orm.v2_0.XmlSingleRelationshipMapping_2_0;
import org.eclipse.jpt.eclipselink.core.internal.context.java.JavaEclipseLinkBasicCollectionMapping;
import org.eclipse.jpt.eclipselink.core.internal.context.java.JavaEclipseLinkBasicMapMapping;
+import org.eclipse.jpt.eclipselink.core.internal.context.java.JavaEclipseLinkOneToManyMapping;
import org.eclipse.jpt.eclipselink.core.internal.context.java.JavaEclipseLinkTransformationMapping;
import org.eclipse.jpt.eclipselink.core.internal.context.java.JavaEclipseLinkVariableOneToOneMapping;
import org.eclipse.jpt.eclipselink.core.internal.context.orm.EclipseLinkOrmXmlContextNodeFactory;
@@ -70,7 +72,6 @@ import org.eclipse.jpt.eclipselink.core.internal.v1_1.context.orm.VirtualEclipse
import org.eclipse.jpt.eclipselink.core.internal.v1_1.context.orm.VirtualEclipseLinkXmlBasicMap1_1;
import org.eclipse.jpt.eclipselink.core.internal.v1_1.context.orm.VirtualEclipseLinkXmlEmbeddedId1_1;
import org.eclipse.jpt.eclipselink.core.internal.v1_1.context.orm.VirtualEclipseLinkXmlId1_1;
-import org.eclipse.jpt.eclipselink.core.internal.v1_1.context.orm.VirtualEclipseLinkXmlManyToMany1_1;
import org.eclipse.jpt.eclipselink.core.internal.v1_1.context.orm.VirtualEclipseLinkXmlManyToOne1_1;
import org.eclipse.jpt.eclipselink.core.internal.v1_1.context.orm.VirtualEclipseLinkXmlTransformation1_1;
import org.eclipse.jpt.eclipselink.core.internal.v1_1.context.orm.VirtualEclipseLinkXmlTransient1_1;
@@ -85,6 +86,7 @@ import org.eclipse.jpt.eclipselink.core.resource.orm.XmlEmbeddedId;
import org.eclipse.jpt.eclipselink.core.resource.orm.XmlId;
import org.eclipse.jpt.eclipselink.core.resource.orm.XmlManyToMany;
import org.eclipse.jpt.eclipselink.core.resource.orm.XmlManyToOne;
+import org.eclipse.jpt.eclipselink.core.resource.orm.XmlOneToMany;
import org.eclipse.jpt.eclipselink.core.resource.orm.XmlTransformation;
import org.eclipse.jpt.eclipselink.core.resource.orm.XmlTransient;
import org.eclipse.jpt.eclipselink.core.resource.orm.XmlVariableOneToOne;
@@ -168,7 +170,7 @@ public class EclipseLinkOrmXml2_0ContextNodeFactory extends EclipseLinkOrmXmlCon
@Override
public XmlManyToMany buildVirtualXmlManyToMany(OrmTypeMapping ormTypeMapping, JavaManyToManyMapping javaManyToManyMapping) {
- return new VirtualEclipseLinkXmlManyToMany1_1(ormTypeMapping, javaManyToManyMapping);
+ return new VirtualEclipseLinkXmlManyToMany2_0(ormTypeMapping, javaManyToManyMapping);
}
@Override
@@ -176,6 +178,10 @@ public class EclipseLinkOrmXml2_0ContextNodeFactory extends EclipseLinkOrmXmlCon
return new VirtualEclipseLinkXmlManyToOne1_1(ormTypeMapping, javaManyToOneMapping);
}
+ @Override
+ public XmlOneToMany buildVirtualXmlOneToMany(OrmTypeMapping ormTypeMapping, JavaOneToManyMapping javaOneToManyMapping) {
+ return new VirtualEclipseLinkXmlOneToMany2_0(ormTypeMapping, (JavaEclipseLinkOneToManyMapping) javaOneToManyMapping);
+ }
@Override
public XmlVersion buildVirtualXmlVersion(OrmTypeMapping ormTypeMapping, JavaVersionMapping javaVersionMapping) {
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/context/orm/VirtualEclipseLinkXmlElementCollection2_0.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/context/orm/VirtualEclipseLinkXmlElementCollection2_0.java
index 3b10ffa018..2fa58ae9db 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/context/orm/VirtualEclipseLinkXmlElementCollection2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/context/orm/VirtualEclipseLinkXmlElementCollection2_0.java
@@ -15,8 +15,11 @@ import org.eclipse.jpt.core.internal.jpa2.context.orm.VirtualXmlElementCollectio
import org.eclipse.jpt.core.jpa2.context.java.JavaElementCollectionMapping2_0;
import org.eclipse.jpt.core.resource.orm.AccessType;
import org.eclipse.jpt.core.resource.orm.EnumType;
+import org.eclipse.jpt.core.resource.orm.FetchType;
+import org.eclipse.jpt.core.resource.orm.MapKey;
import org.eclipse.jpt.core.resource.orm.TemporalType;
import org.eclipse.jpt.core.resource.orm.XmlColumn;
+import org.eclipse.jpt.core.resource.orm.XmlMapKeyClass;
import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.jpt.eclipselink.core.resource.orm.XmlAccessMethods;
import org.eclipse.jpt.eclipselink.core.resource.orm.XmlElementCollection;
@@ -64,6 +67,15 @@ public class VirtualEclipseLinkXmlElementCollection2_0 extends XmlElementCollect
public TextRange getNameTextRange() {
return this.virtualXmlElementCollection.getNameTextRange();
}
+ @Override
+ public FetchType getFetch() {
+ return this.virtualXmlElementCollection.getFetch();
+ }
+
+ @Override
+ public void setFetch(FetchType newFetch) {
+ this.virtualXmlElementCollection.setFetch(newFetch);
+ }
@Override
public XmlColumn getColumn() {
@@ -155,4 +167,24 @@ public class VirtualEclipseLinkXmlElementCollection2_0 extends XmlElementCollect
public void setTargetClass(String newTargetClass) {
this.virtualXmlElementCollection.setTargetClass(newTargetClass);
}
+
+ @Override
+ public MapKey getMapKey() {
+ return this.virtualXmlElementCollection.getMapKey();
+ }
+
+ @Override
+ public void setMapKey(MapKey newMapKey) {
+ this.virtualXmlElementCollection.setMapKey(newMapKey);
+ }
+
+ @Override
+ public XmlMapKeyClass getMapKeyClass() {
+ return this.virtualXmlElementCollection.getMapKeyClass();
+ }
+
+ @Override
+ public void setMapKeyClass(XmlMapKeyClass newMapKeyClass) {
+ this.virtualXmlElementCollection.setMapKeyClass(newMapKeyClass);
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/context/orm/VirtualEclipseLinkXmlManyToMany2_0.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/context/orm/VirtualEclipseLinkXmlManyToMany2_0.java
new file mode 100644
index 0000000000..85db2b4f50
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/context/orm/VirtualEclipseLinkXmlManyToMany2_0.java
@@ -0,0 +1,211 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.eclipselink.core.internal.v2_0.context.orm;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.jpt.core.context.java.JavaManyToManyMapping;
+import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
+import org.eclipse.jpt.core.internal.jpa2.context.orm.VirtualXmlManyToMany2_0;
+import org.eclipse.jpt.core.resource.orm.AccessType;
+import org.eclipse.jpt.core.resource.orm.CascadeType;
+import org.eclipse.jpt.core.resource.orm.FetchType;
+import org.eclipse.jpt.core.resource.orm.MapKey;
+import org.eclipse.jpt.core.resource.orm.XmlJoinTable;
+import org.eclipse.jpt.core.resource.orm.XmlMapKeyClass;
+import org.eclipse.jpt.core.resource.orm.XmlOrderColumn;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.eclipselink.core.internal.context.orm.VirtualEclipseLinkXmlManyToMany;
+import org.eclipse.jpt.eclipselink.core.resource.orm.XmlAccessMethods;
+import org.eclipse.jpt.eclipselink.core.resource.orm.XmlJoinFetchType;
+import org.eclipse.jpt.eclipselink.core.resource.orm.XmlManyToMany;
+import org.eclipse.jpt.eclipselink.core.resource.orm.XmlProperty;
+
+/**
+ * VirtualEclipseLinkXmlManyToMany2_0 is an implementation of XmlManyToMany used when there is
+ * no tag in the orm.xml and an underlying java many to many exists.
+ */
+public class VirtualEclipseLinkXmlManyToMany2_0 extends XmlManyToMany
+{
+ protected OrmTypeMapping ormTypeMapping;
+
+ protected final JavaManyToManyMapping javaAttributeMapping;
+
+ protected final VirtualEclipseLinkXmlManyToMany eclipseLinkVirtualXmlManyToMany;
+
+ protected final VirtualXmlManyToMany2_0 virtualXmlManyToMany;
+
+ public VirtualEclipseLinkXmlManyToMany2_0(OrmTypeMapping ormTypeMapping, JavaManyToManyMapping javaManyToManyMapping) {
+ super();
+ this.ormTypeMapping = ormTypeMapping;
+ this.javaAttributeMapping = javaManyToManyMapping;
+ this.eclipseLinkVirtualXmlManyToMany = new VirtualEclipseLinkXmlManyToMany(ormTypeMapping, javaManyToManyMapping);
+ this.virtualXmlManyToMany = new VirtualXmlManyToMany2_0(ormTypeMapping, javaManyToManyMapping);
+ }
+
+ protected boolean isOrmMetadataComplete() {
+ return this.ormTypeMapping.isMetadataComplete();
+ }
+
+ @Override
+ public String getMappingKey() {
+ return this.virtualXmlManyToMany.getMappingKey();
+ }
+
+ @Override
+ public String getName() {
+ return this.virtualXmlManyToMany.getName();
+ }
+
+ @Override
+ public void setName(String newName) {
+ this.virtualXmlManyToMany.setName(newName);
+ }
+
+ @Override
+ public TextRange getNameTextRange() {
+ return this.virtualXmlManyToMany.getNameTextRange();
+ }
+
+ @Override
+ public FetchType getFetch() {
+ return this.virtualXmlManyToMany.getFetch();
+ }
+
+ @Override
+ public void setFetch(FetchType newFetch) {
+ this.virtualXmlManyToMany.setFetch(newFetch);
+ }
+
+ @Override
+ public CascadeType getCascade() {
+ return this.virtualXmlManyToMany.getCascade();
+ }
+
+ @Override
+ public void setCascade(CascadeType value) {
+ this.virtualXmlManyToMany.setCascade(value);
+ }
+
+ @Override
+ public XmlJoinTable getJoinTable() {
+ return this.virtualXmlManyToMany.getJoinTable();
+ }
+
+ @Override
+ public void setJoinTable(XmlJoinTable value) {
+ this.virtualXmlManyToMany.setJoinTable(value);
+ }
+
+ @Override
+ public String getTargetEntity() {
+ return this.virtualXmlManyToMany.getTargetEntity();
+ }
+
+ @Override
+ public void setTargetEntity(String value) {
+ this.virtualXmlManyToMany.setTargetEntity(value);
+ }
+
+ @Override
+ public String getMappedBy() {
+ return this.virtualXmlManyToMany.getMappedBy();
+ }
+
+ @Override
+ public void setMappedBy(String value) {
+ this.virtualXmlManyToMany.setMappedBy(value);
+ }
+
+
+ @Override
+ public MapKey getMapKey() {
+ return this.virtualXmlManyToMany.getMapKey();
+ }
+
+ @Override
+ public void setMapKey(MapKey value) {
+ this.virtualXmlManyToMany.setMapKey(value);
+ }
+
+ @Override
+ public XmlMapKeyClass getMapKeyClass() {
+ return this.virtualXmlManyToMany.getMapKeyClass();
+ }
+
+ @Override
+ public void setMapKeyClass(XmlMapKeyClass value) {
+ this.virtualXmlManyToMany.setMapKeyClass(value);
+ }
+
+ @Override
+ public String getOrderBy() {
+ return this.virtualXmlManyToMany.getOrderBy();
+ }
+
+ @Override
+ public void setOrderBy(String value) {
+ this.virtualXmlManyToMany.setOrderBy(value);
+ }
+
+ @Override
+ public XmlOrderColumn getOrderColumn() {
+ return this.virtualXmlManyToMany.getOrderColumn();
+ }
+
+ @Override
+ public TextRange getMappedByTextRange() {
+ return this.virtualXmlManyToMany.getMappedByTextRange();
+ }
+
+ @Override
+ public TextRange getTargetEntityTextRange() {
+ return this.virtualXmlManyToMany.getTargetEntityTextRange();
+ }
+
+ @Override
+ public XmlJoinFetchType getJoinFetch() {
+ return this.eclipseLinkVirtualXmlManyToMany.getJoinFetch();
+ }
+
+ @Override
+ public void setJoinFetch(XmlJoinFetchType value) {
+ this.eclipseLinkVirtualXmlManyToMany.setJoinFetch(value);
+ }
+
+ @Override
+ public XmlAccessMethods getAccessMethods() {
+ return this.eclipseLinkVirtualXmlManyToMany.getAccessMethods();
+ }
+
+ @Override
+ public void setAccessMethods(XmlAccessMethods value) {
+ this.eclipseLinkVirtualXmlManyToMany.setAccessMethods(value);
+ }
+
+ @Override
+ public EList<XmlProperty> getProperties() {
+ return this.eclipseLinkVirtualXmlManyToMany.getProperties();
+ }
+
+ @Override
+ public TextRange getJoinFetchTextRange() {
+ return this.eclipseLinkVirtualXmlManyToMany.getJoinFetchTextRange();
+ }
+
+ @Override
+ public AccessType getAccess() {
+ return org.eclipse.jpt.core.context.AccessType.toOrmResourceModel(this.javaAttributeMapping.getPersistentAttribute().getAccess());
+ }
+
+ @Override
+ public void setAccess(AccessType value) {
+ throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/context/orm/VirtualEclipseLinkXmlOneToMany2_0.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/context/orm/VirtualEclipseLinkXmlOneToMany2_0.java
new file mode 100644
index 0000000000..36213b2ab2
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/context/orm/VirtualEclipseLinkXmlOneToMany2_0.java
@@ -0,0 +1,233 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.eclipselink.core.internal.v2_0.context.orm;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
+import org.eclipse.jpt.core.internal.jpa2.context.orm.VirtualXmlOneToMany2_0;
+import org.eclipse.jpt.core.resource.orm.AccessType;
+import org.eclipse.jpt.core.resource.orm.CascadeType;
+import org.eclipse.jpt.core.resource.orm.FetchType;
+import org.eclipse.jpt.core.resource.orm.MapKey;
+import org.eclipse.jpt.core.resource.orm.XmlJoinColumn;
+import org.eclipse.jpt.core.resource.orm.XmlJoinTable;
+import org.eclipse.jpt.core.resource.orm.XmlMapKeyClass;
+import org.eclipse.jpt.core.resource.orm.XmlOrderColumn;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.eclipselink.core.internal.context.java.JavaEclipseLinkOneToManyMapping;
+import org.eclipse.jpt.eclipselink.core.internal.v1_1.context.orm.VirtualEclipseLinkXmlOneToMany1_1;
+import org.eclipse.jpt.eclipselink.core.resource.orm.XmlAccessMethods;
+import org.eclipse.jpt.eclipselink.core.resource.orm.XmlJoinFetchType;
+import org.eclipse.jpt.eclipselink.core.resource.orm.XmlOneToMany;
+import org.eclipse.jpt.eclipselink.core.resource.orm.XmlProperty;
+
+/**
+ * VirtualEclipseLinkXmlOneToMany2_0 is an implementation of XmlOneToMany used when there is
+ * no tag in the orm.xml and an underlying javaOneToMany exists.
+ */
+public class VirtualEclipseLinkXmlOneToMany2_0 extends XmlOneToMany
+{
+ protected OrmTypeMapping ormTypeMapping;
+
+ protected final JavaEclipseLinkOneToManyMapping javaAttributeMapping;
+
+ protected final VirtualEclipseLinkXmlOneToMany1_1 eclipseLinkVirtualXmlOneToMany;
+
+ protected final VirtualXmlOneToMany2_0 virtualXmlOneToMany;
+
+ public VirtualEclipseLinkXmlOneToMany2_0(
+ OrmTypeMapping ormTypeMapping, JavaEclipseLinkOneToManyMapping javaOneToManyMapping) {
+ super();
+ this.ormTypeMapping = ormTypeMapping;
+ this.javaAttributeMapping = javaOneToManyMapping;
+ this.eclipseLinkVirtualXmlOneToMany = new VirtualEclipseLinkXmlOneToMany1_1(ormTypeMapping, javaOneToManyMapping);
+ this.virtualXmlOneToMany = new VirtualXmlOneToMany2_0(ormTypeMapping, javaOneToManyMapping);
+ }
+
+ protected boolean isOrmMetadataComplete() {
+ return this.ormTypeMapping.isMetadataComplete();
+ }
+
+ @Override
+ public String getMappingKey() {
+ return this.virtualXmlOneToMany.getMappingKey();
+ }
+
+ @Override
+ public String getName() {
+ return this.virtualXmlOneToMany.getName();
+ }
+
+ @Override
+ public void setName(String newName) {
+ this.virtualXmlOneToMany.setName(newName);
+ }
+
+ @Override
+ public TextRange getNameTextRange() {
+ return this.virtualXmlOneToMany.getNameTextRange();
+ }
+
+ @Override
+ public FetchType getFetch() {
+ return this.virtualXmlOneToMany.getFetch();
+ }
+
+ @Override
+ public void setFetch(FetchType newFetch) {
+ this.virtualXmlOneToMany.setFetch(newFetch);
+ }
+
+ @Override
+ public CascadeType getCascade() {
+ return this.virtualXmlOneToMany.getCascade();
+ }
+
+ @Override
+ public void setCascade(CascadeType value) {
+ this.virtualXmlOneToMany.setCascade(value);
+ }
+
+ @Override
+ public XmlJoinTable getJoinTable() {
+ return this.virtualXmlOneToMany.getJoinTable();
+ }
+
+ @Override
+ public void setJoinTable(XmlJoinTable value) {
+ this.virtualXmlOneToMany.setJoinTable(value);
+ }
+
+ @Override
+ public String getTargetEntity() {
+ return this.virtualXmlOneToMany.getTargetEntity();
+ }
+
+ @Override
+ public void setTargetEntity(String value) {
+ this.virtualXmlOneToMany.setTargetEntity(value);
+ }
+
+ @Override
+ public String getMappedBy() {
+ return this.virtualXmlOneToMany.getMappedBy();
+ }
+
+ @Override
+ public void setMappedBy(String value) {
+ this.virtualXmlOneToMany.setMappedBy(value);
+ }
+
+
+ @Override
+ public MapKey getMapKey() {
+ return this.virtualXmlOneToMany.getMapKey();
+ }
+
+ @Override
+ public void setMapKey(MapKey value) {
+ this.virtualXmlOneToMany.setMapKey(value);
+ }
+
+ @Override
+ public XmlMapKeyClass getMapKeyClass() {
+ return this.virtualXmlOneToMany.getMapKeyClass();
+ }
+
+ @Override
+ public void setMapKeyClass(XmlMapKeyClass value) {
+ this.virtualXmlOneToMany.setMapKeyClass(value);
+ }
+
+ @Override
+ public String getOrderBy() {
+ return this.virtualXmlOneToMany.getOrderBy();
+ }
+
+ @Override
+ public void setOrderBy(String value) {
+ this.virtualXmlOneToMany.setOrderBy(value);
+ }
+
+ @Override
+ public XmlOrderColumn getOrderColumn() {
+ return this.virtualXmlOneToMany.getOrderColumn();
+ }
+
+ @Override
+ public TextRange getMappedByTextRange() {
+ return this.virtualXmlOneToMany.getMappedByTextRange();
+ }
+
+ @Override
+ public TextRange getTargetEntityTextRange() {
+ return this.virtualXmlOneToMany.getTargetEntityTextRange();
+ }
+
+ @Override
+ public EList<XmlJoinColumn> getJoinColumns() {
+ return this.eclipseLinkVirtualXmlOneToMany.getJoinColumns();
+ }
+
+ @Override
+ public XmlJoinFetchType getJoinFetch() {
+ return this.eclipseLinkVirtualXmlOneToMany.getJoinFetch();
+ }
+
+ @Override
+ public void setJoinFetch(XmlJoinFetchType value) {
+ this.eclipseLinkVirtualXmlOneToMany.setJoinFetch(value);
+ }
+
+ @Override
+ public boolean isPrivateOwned() {
+ return this.eclipseLinkVirtualXmlOneToMany.isPrivateOwned();
+ }
+
+ @Override
+ public void setPrivateOwned(boolean value) {
+ this.eclipseLinkVirtualXmlOneToMany.setPrivateOwned(value);
+ }
+
+ @Override
+ public XmlAccessMethods getAccessMethods() {
+ return this.eclipseLinkVirtualXmlOneToMany.getAccessMethods();
+ }
+
+ @Override
+ public void setAccessMethods(XmlAccessMethods value) {
+ this.eclipseLinkVirtualXmlOneToMany.setAccessMethods(value);
+ }
+
+ @Override
+ public EList<XmlProperty> getProperties() {
+ return this.eclipseLinkVirtualXmlOneToMany.getProperties();
+ }
+
+ @Override
+ public TextRange getJoinFetchTextRange() {
+ return this.eclipseLinkVirtualXmlOneToMany.getJoinFetchTextRange();
+ }
+
+ @Override
+ public TextRange getPrivateOwnedTextRange() {
+ return this.eclipseLinkVirtualXmlOneToMany.getPrivateOwnedTextRange();
+ }
+
+ @Override
+ public AccessType getAccess() {
+ return this.eclipseLinkVirtualXmlOneToMany.getAccess();
+ }
+
+ @Override
+ public void setAccess(AccessType value) {
+ this.eclipseLinkVirtualXmlOneToMany.setAccess(value);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/orm/EclipseLinkOrmPackage.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/orm/EclipseLinkOrmPackage.java
index ead18e08ca..a08ebced0b 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/orm/EclipseLinkOrmPackage.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/orm/EclipseLinkOrmPackage.java
@@ -2573,14 +2573,6 @@ public class EclipseLinkOrmPackage extends EPackageImpl
*/
public static final int XML_MANY_TO_MANY__ORDER_BY = OrmPackage.XML_MANY_TO_MANY__ORDER_BY;
/**
- * The feature id for the '<em><b>Map Key</b></em>' containment reference.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public static final int XML_MANY_TO_MANY__MAP_KEY = OrmPackage.XML_MANY_TO_MANY__MAP_KEY;
- /**
* The feature id for the '<em><b>Map Key Class</b></em>' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -2629,6 +2621,14 @@ public class EclipseLinkOrmPackage extends EPackageImpl
*/
public static final int XML_MANY_TO_MANY__MAP_KEY_JOIN_COLUMNS = OrmPackage.XML_MANY_TO_MANY__MAP_KEY_JOIN_COLUMNS;
/**
+ * The feature id for the '<em><b>Map Key</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int XML_MANY_TO_MANY__MAP_KEY = OrmPackage.XML_MANY_TO_MANY__MAP_KEY;
+ /**
* The feature id for the '<em><b>Access Methods</b></em>' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -3267,77 +3267,77 @@ public class EclipseLinkOrmPackage extends EPackageImpl
*/
public static final int XML_ONE_TO_MANY__ORDER_BY = OrmPackage.XML_ONE_TO_MANY__ORDER_BY;
/**
- * The feature id for the '<em><b>Map Key</b></em>' containment reference.
+ * The feature id for the '<em><b>Map Key Class</b></em>' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- public static final int XML_ONE_TO_MANY__MAP_KEY = OrmPackage.XML_ONE_TO_MANY__MAP_KEY;
+ public static final int XML_ONE_TO_MANY__MAP_KEY_CLASS = OrmPackage.XML_ONE_TO_MANY__MAP_KEY_CLASS;
/**
- * The feature id for the '<em><b>Join Columns</b></em>' containment reference list.
+ * The feature id for the '<em><b>Map Key Temporal</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- public static final int XML_ONE_TO_MANY__JOIN_COLUMNS = OrmPackage.XML_ONE_TO_MANY__JOIN_COLUMNS;
+ public static final int XML_ONE_TO_MANY__MAP_KEY_TEMPORAL = OrmPackage.XML_ONE_TO_MANY__MAP_KEY_TEMPORAL;
/**
- * The feature id for the '<em><b>Orphan Removal</b></em>' attribute.
+ * The feature id for the '<em><b>Map Key Enumerated</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- public static final int XML_ONE_TO_MANY__ORPHAN_REMOVAL = OrmPackage.XML_ONE_TO_MANY__ORPHAN_REMOVAL;
+ public static final int XML_ONE_TO_MANY__MAP_KEY_ENUMERATED = OrmPackage.XML_ONE_TO_MANY__MAP_KEY_ENUMERATED;
/**
- * The feature id for the '<em><b>Map Key Class</b></em>' containment reference.
+ * The feature id for the '<em><b>Map Key Attribute Overrides</b></em>' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- public static final int XML_ONE_TO_MANY__MAP_KEY_CLASS = OrmPackage.XML_ONE_TO_MANY__MAP_KEY_CLASS;
+ public static final int XML_ONE_TO_MANY__MAP_KEY_ATTRIBUTE_OVERRIDES = OrmPackage.XML_ONE_TO_MANY__MAP_KEY_ATTRIBUTE_OVERRIDES;
/**
- * The feature id for the '<em><b>Map Key Temporal</b></em>' attribute.
+ * The feature id for the '<em><b>Map Key Column</b></em>' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- public static final int XML_ONE_TO_MANY__MAP_KEY_TEMPORAL = OrmPackage.XML_ONE_TO_MANY__MAP_KEY_TEMPORAL;
+ public static final int XML_ONE_TO_MANY__MAP_KEY_COLUMN = OrmPackage.XML_ONE_TO_MANY__MAP_KEY_COLUMN;
/**
- * The feature id for the '<em><b>Map Key Enumerated</b></em>' attribute.
+ * The feature id for the '<em><b>Map Key Join Columns</b></em>' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- public static final int XML_ONE_TO_MANY__MAP_KEY_ENUMERATED = OrmPackage.XML_ONE_TO_MANY__MAP_KEY_ENUMERATED;
+ public static final int XML_ONE_TO_MANY__MAP_KEY_JOIN_COLUMNS = OrmPackage.XML_ONE_TO_MANY__MAP_KEY_JOIN_COLUMNS;
/**
- * The feature id for the '<em><b>Map Key Attribute Overrides</b></em>' containment reference list.
+ * The feature id for the '<em><b>Map Key</b></em>' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- public static final int XML_ONE_TO_MANY__MAP_KEY_ATTRIBUTE_OVERRIDES = OrmPackage.XML_ONE_TO_MANY__MAP_KEY_ATTRIBUTE_OVERRIDES;
+ public static final int XML_ONE_TO_MANY__MAP_KEY = OrmPackage.XML_ONE_TO_MANY__MAP_KEY;
/**
- * The feature id for the '<em><b>Map Key Column</b></em>' containment reference.
+ * The feature id for the '<em><b>Join Columns</b></em>' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- public static final int XML_ONE_TO_MANY__MAP_KEY_COLUMN = OrmPackage.XML_ONE_TO_MANY__MAP_KEY_COLUMN;
+ public static final int XML_ONE_TO_MANY__JOIN_COLUMNS = OrmPackage.XML_ONE_TO_MANY__JOIN_COLUMNS;
/**
- * The feature id for the '<em><b>Map Key Join Columns</b></em>' containment reference list.
+ * The feature id for the '<em><b>Orphan Removal</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- public static final int XML_ONE_TO_MANY__MAP_KEY_JOIN_COLUMNS = OrmPackage.XML_ONE_TO_MANY__MAP_KEY_JOIN_COLUMNS;
+ public static final int XML_ONE_TO_MANY__ORPHAN_REMOVAL = OrmPackage.XML_ONE_TO_MANY__ORPHAN_REMOVAL;
/**
* The feature id for the '<em><b>Access Methods</b></em>' containment reference.
* <!-- begin-user-doc -->
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToManyMappingTests.java
index 4448cea823..dad78b3d98 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToManyMappingTests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToManyMappingTests.java
@@ -27,6 +27,7 @@ import org.eclipse.jpt.core.context.PersistentAttribute;
import org.eclipse.jpt.core.context.TransientMapping;
import org.eclipse.jpt.core.context.TypeMapping;
import org.eclipse.jpt.core.context.VersionMapping;
+import org.eclipse.jpt.core.context.java.JavaManyToManyMapping;
import org.eclipse.jpt.core.context.java.JavaPersistentType;
import org.eclipse.jpt.core.context.persistence.ClassRef;
import org.eclipse.jpt.core.resource.java.BasicAnnotation;
@@ -194,6 +195,50 @@ public class JavaManyToManyMappingTests extends ContextModelTestCase
}
});
}
+
+ private ICompilationUnit createTestEntityWithValidMapManyToManyMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @ManyToMany").append(CR);
+ sb.append(" private java.util.Map<String, Address> addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
+ private ICompilationUnit createTestEntityWithValidNonGenericMapManyToManyMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @ManyToMany").append(CR);
+ sb.append(" private java.util.Map addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
private void createTestDepartment() throws Exception {
SourceWriter sourceWriter = new SourceWriter() {
@@ -835,7 +880,49 @@ public class JavaManyToManyMappingTests extends ContextModelTestCase
assertNull(manyToManyMapping.getSpecifiedMapKey());
assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
}
+
+ public void testCandidateMapKeyNames() throws Exception {
+ createTestEntityWithValidMapManyToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ addXmlClassRef(PACKAGE_NAME + ".Address");
+ addXmlClassRef(PACKAGE_NAME + ".State");
+
+ JavaManyToManyMapping javaManyToManyMapping = (JavaManyToManyMapping) getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+
+ Iterator<String> mapKeyNames =
+ javaManyToManyMapping.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+ }
+
+ public void testCandidateMapKeyNames2() throws Exception {
+ createTestEntityWithValidNonGenericMapManyToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ addXmlClassRef(PACKAGE_NAME + ".Address");
+ addXmlClassRef(PACKAGE_NAME + ".State");
+
+ JavaManyToManyMapping javaManyToManyMapping = (JavaManyToManyMapping) getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+ Iterator<String> mapKeyNames = javaManyToManyMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+
+ javaManyToManyMapping.setSpecifiedTargetEntity("test.Address");
+ mapKeyNames = javaManyToManyMapping.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+ }
public void testUpdateOrderBy() throws Exception {
createTestEntityWithManyToManyMapping();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToManyMappingTests.java
index 71c62d35fc..597426ac6d 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToManyMappingTests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToManyMappingTests.java
@@ -27,6 +27,7 @@ import org.eclipse.jpt.core.context.PersistentAttribute;
import org.eclipse.jpt.core.context.TransientMapping;
import org.eclipse.jpt.core.context.TypeMapping;
import org.eclipse.jpt.core.context.VersionMapping;
+import org.eclipse.jpt.core.context.java.JavaOneToManyMapping;
import org.eclipse.jpt.core.context.java.JavaPersistentType;
import org.eclipse.jpt.core.context.persistence.ClassRef;
import org.eclipse.jpt.core.resource.java.BasicAnnotation;
@@ -196,6 +197,50 @@ public class JavaOneToManyMappingTests extends ContextModelTestCase
});
}
+ private ICompilationUnit createTestEntityWithValidMapOneToManyMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @OneToMany").append(CR);
+ sb.append(" private java.util.Map<String, Address> addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
+ private ICompilationUnit createTestEntityWithValidNonGenericMapOneToManyMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @OneToMany").append(CR);
+ sb.append(" private java.util.Map addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
private void createTestDepartment() throws Exception {
SourceWriter sourceWriter = new SourceWriter() {
public void appendSourceTo(StringBuilder sb) {
@@ -839,6 +884,49 @@ public class JavaOneToManyMappingTests extends ContextModelTestCase
assertNull(oneToManyMapping.getSpecifiedMapKey());
assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
}
+
+ public void testCandidateMapKeyNames() throws Exception {
+ createTestEntityWithValidMapOneToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ addXmlClassRef(PACKAGE_NAME + ".Address");
+ addXmlClassRef(PACKAGE_NAME + ".State");
+
+ JavaOneToManyMapping javaOneToManyMapping = (JavaOneToManyMapping) getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+
+ Iterator<String> mapKeyNames =
+ javaOneToManyMapping.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+ }
+
+ public void testCandidateMapKeyNames2() throws Exception {
+ createTestEntityWithValidNonGenericMapOneToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ addXmlClassRef(PACKAGE_NAME + ".Address");
+ addXmlClassRef(PACKAGE_NAME + ".State");
+
+ JavaOneToManyMapping javaOneToManyMapping = (JavaOneToManyMapping) getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+
+ Iterator<String> mapKeyNames = javaOneToManyMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+
+ javaOneToManyMapping.setSpecifiedTargetEntity("test.Address");
+ mapKeyNames = javaOneToManyMapping.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+ }
public void testUpdateOrderBy() throws Exception {
createTestEntityWithOneToManyMapping();
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmManyToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmManyToManyMappingTests.java
index c9bec4c9c6..f45e0eb9b2 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmManyToManyMappingTests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmManyToManyMappingTests.java
@@ -28,6 +28,7 @@ import org.eclipse.jpt.core.context.OneToOneMapping;
import org.eclipse.jpt.core.context.PersistentAttribute;
import org.eclipse.jpt.core.context.TransientMapping;
import org.eclipse.jpt.core.context.VersionMapping;
+import org.eclipse.jpt.core.context.java.JavaManyToManyMapping;
import org.eclipse.jpt.core.context.orm.OrmManyToManyMapping;
import org.eclipse.jpt.core.context.orm.OrmMappedByJoiningStrategy;
import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
@@ -69,6 +70,72 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase
});
}
+ private ICompilationUnit createTestEntityWithValidManyToManyMapMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @ManyToMany").append(CR);
+ sb.append(" private java.util.Map<String, Address> addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
+ private ICompilationUnit createTestEntityWithValidMapManyToManyMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @ManyToMany").append(CR);
+ sb.append(" private java.util.Map<String, Address> addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
+ private ICompilationUnit createTestEntityWithValidNonGenericMapManyToManyMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @ManyToMany").append(CR);
+ sb.append(" private java.util.Map addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
private void createTestTargetEntityAddress() throws Exception {
SourceWriter sourceWriter = new SourceWriter() {
public void appendSourceTo(StringBuilder sb) {
@@ -119,9 +186,9 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase
sb.append("public class ").append("State").append(" ");
sb.append("{").append(CR);
sb.append(CR);
- sb.append(" private String foo;").append(CR);
+ sb.append(" private String name;").append(CR);
sb.append(CR);
- sb.append(" private Address address;").append(CR);
+ sb.append(" private String abbr;").append(CR);
sb.append(CR);
sb.append("}").append(CR);
}
@@ -358,6 +425,41 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase
assertNull(ormManyToManyMapping.getSpecifiedMapKey());
assertNull(manyToMany.getMapKey());
}
+
+ public void testUpdateVirtualMapKey() throws Exception {
+ createTestEntityWithValidManyToManyMapMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ JavaManyToManyMapping javaManyToManyMapping = (JavaManyToManyMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+ assertNull(ormManyToManyMapping.getSpecifiedMapKey());
+ assertNull(ormManyToManyMapping.getMapKey());
+ assertFalse(ormManyToManyMapping.isPkMapKey());
+ assertFalse(ormManyToManyMapping.isCustomMapKey());
+ assertTrue(ormManyToManyMapping.isNoMapKey());
+
+ //set pk mapKey in the java, verify virtual orm mapping updates
+ javaManyToManyMapping.setPkMapKey(true);
+ assertEquals("id", ormManyToManyMapping.getMapKey());
+ assertTrue(ormManyToManyMapping.isPkMapKey());
+ assertFalse(ormManyToManyMapping.isCustomMapKey());
+ assertFalse(ormManyToManyMapping.isNoMapKey());
+
+
+ //set custom specified mapKey in the java, verify virtual orm mapping updates
+ javaManyToManyMapping.setCustomMapKey(true);
+ javaManyToManyMapping.setSpecifiedMapKey("city");
+ assertEquals("city", ormManyToManyMapping.getSpecifiedMapKey());
+ assertEquals("city", ormManyToManyMapping.getMapKey());
+ assertFalse(ormManyToManyMapping.isPkMapKey());
+ assertTrue(ormManyToManyMapping.isCustomMapKey());
+ assertFalse(ormManyToManyMapping.isNoMapKey());
+ }
public void testUpdateOrderBy() throws Exception {
OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
@@ -719,4 +821,65 @@ public class OrmManyToManyMappingTests extends ContextModelTestCase
AttributeMapping stateFooMapping = manyToManyMapping.getResolvedTargetEntity().resolveAttributeMapping("state.foo");
assertNull(stateFooMapping);
}
+
+ public void testCandidateMapKeyNames() throws Exception {
+ createTestEntityWithValidMapManyToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+
+ Iterator<String> mapKeyNames =
+ ormManyToManyMapping.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+ }
+
+ public void testCandidateMapKeyNames2() throws Exception {
+ createTestEntityWithValidNonGenericMapManyToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ JavaManyToManyMapping javaManyToManyMapping = (JavaManyToManyMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+
+ Iterator<String> mapKeyNames = ormManyToManyMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+
+ javaManyToManyMapping.setSpecifiedTargetEntity("test.Address");
+ mapKeyNames = ormManyToManyMapping.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+
+ ormManyToManyMapping.getPersistentAttribute().makeSpecified();
+ ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ mapKeyNames = ormManyToManyMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+
+ ormManyToManyMapping.setSpecifiedTargetEntity("test.Address");
+ mapKeyNames = ormManyToManyMapping.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+
+ ormManyToManyMapping.setSpecifiedTargetEntity("String");
+ mapKeyNames = ormManyToManyMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+ }
} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmOneToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmOneToManyMappingTests.java
index 175d992ecf..d9ac09d1cd 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmOneToManyMappingTests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmOneToManyMappingTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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.
@@ -28,6 +28,7 @@ import org.eclipse.jpt.core.context.OneToOneMapping;
import org.eclipse.jpt.core.context.PersistentAttribute;
import org.eclipse.jpt.core.context.TransientMapping;
import org.eclipse.jpt.core.context.VersionMapping;
+import org.eclipse.jpt.core.context.java.JavaOneToManyMapping;
import org.eclipse.jpt.core.context.orm.OrmMappedByJoiningStrategy;
import org.eclipse.jpt.core.context.orm.OrmOneToManyMapping;
import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
@@ -103,6 +104,50 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase
});
}
+ private ICompilationUnit createTestEntityWithValidMapOneToManyMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @OneToMany").append(CR);
+ sb.append(" private java.util.Map<String, Address> addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
+ private ICompilationUnit createTestEntityWithValidNonGenericMapOneToManyMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @OneToMany").append(CR);
+ sb.append(" private java.util.Map addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
private void createTestEmbeddableState() throws Exception {
SourceWriter sourceWriter = new SourceWriter() {
public void appendSourceTo(StringBuilder sb) {
@@ -116,9 +161,9 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase
sb.append("public class ").append("State").append(" ");
sb.append("{").append(CR);
sb.append(CR);
- sb.append(" private String foo;").append(CR);
+ sb.append(" private String name;").append(CR);
sb.append(CR);
- sb.append(" private Address address;").append(CR);
+ sb.append(" private String abbr;").append(CR);
sb.append(CR);
sb.append("}").append(CR);
}
@@ -336,6 +381,41 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase
assertNull(oneToMany.getMapKey());
}
+ public void testUpdateVirtualMapKey() throws Exception {
+ createTestEntityWithValidMapOneToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ JavaOneToManyMapping javaOneToManyMapping = (JavaOneToManyMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+ assertNull(ormOneToManyMapping.getSpecifiedMapKey());
+ assertNull(ormOneToManyMapping.getMapKey());
+ assertFalse(ormOneToManyMapping.isPkMapKey());
+ assertFalse(ormOneToManyMapping.isCustomMapKey());
+ assertTrue(ormOneToManyMapping.isNoMapKey());
+
+ //set pk mapKey in the java, verify virtual orm mapping updates
+ javaOneToManyMapping.setPkMapKey(true);
+ assertEquals("id", ormOneToManyMapping.getMapKey());
+ assertTrue(ormOneToManyMapping.isPkMapKey());
+ assertFalse(ormOneToManyMapping.isCustomMapKey());
+ assertFalse(ormOneToManyMapping.isNoMapKey());
+
+
+ //set custom specified mapKey in the java, verify virtual orm mapping updates
+ javaOneToManyMapping.setCustomMapKey(true);
+ javaOneToManyMapping.setSpecifiedMapKey("city");
+ assertEquals("city", ormOneToManyMapping.getSpecifiedMapKey());
+ assertEquals("city", ormOneToManyMapping.getMapKey());
+ assertFalse(ormOneToManyMapping.isPkMapKey());
+ assertTrue(ormOneToManyMapping.isCustomMapKey());
+ assertFalse(ormOneToManyMapping.isNoMapKey());
+ }
+
public void testModifyMapKey() throws Exception {
OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
@@ -735,4 +815,65 @@ public class OrmOneToManyMappingTests extends ContextModelTestCase
AttributeMapping stateFooMapping = oneToManyMapping.getResolvedTargetEntity().resolveAttributeMapping("state.foo");
assertNull(stateFooMapping);
}
+
+ public void testCandidateMapKeyNames() throws Exception {
+ createTestEntityWithValidMapOneToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+
+ Iterator<String> mapKeyNames =
+ ormOneToManyMapping.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+ }
+
+ public void testCandidateMapKeyNames2() throws Exception {
+ createTestEntityWithValidNonGenericMapOneToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ JavaOneToManyMapping javaOneToManyMapping = (JavaOneToManyMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+
+ Iterator<String> mapKeyNames = ormOneToManyMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+
+ javaOneToManyMapping.setSpecifiedTargetEntity("test.Address");
+ mapKeyNames = ormOneToManyMapping.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+
+ ormOneToManyMapping.getPersistentAttribute().makeSpecified();
+ ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ mapKeyNames = ormOneToManyMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+
+ ormOneToManyMapping.setSpecifiedTargetEntity("test.Address");
+ mapKeyNames = ormOneToManyMapping.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+
+ ormOneToManyMapping.setSpecifiedTargetEntity("String");
+ mapKeyNames = ormOneToManyMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+ }
} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaElementCollectionMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaElementCollectionMapping2_0Tests.java
index 14eda4dc4f..84ba7d0e75 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaElementCollectionMapping2_0Tests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaElementCollectionMapping2_0Tests.java
@@ -30,6 +30,7 @@ import org.eclipse.jpt.core.context.persistence.ClassRef;
import org.eclipse.jpt.core.jpa2.context.ElementCollectionMapping2_0;
import org.eclipse.jpt.core.jpa2.resource.java.ElementCollection2_0Annotation;
import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0;
+import org.eclipse.jpt.core.jpa2.resource.java.MapKeyClass2_0Annotation;
import org.eclipse.jpt.core.resource.java.BasicAnnotation;
import org.eclipse.jpt.core.resource.java.EmbeddedAnnotation;
import org.eclipse.jpt.core.resource.java.EmbeddedIdAnnotation;
@@ -39,6 +40,7 @@ import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
import org.eclipse.jpt.core.resource.java.ManyToManyAnnotation;
import org.eclipse.jpt.core.resource.java.ManyToOneAnnotation;
+import org.eclipse.jpt.core.resource.java.MapKeyAnnotation;
import org.eclipse.jpt.core.resource.java.OneToManyAnnotation;
import org.eclipse.jpt.core.resource.java.TransientAnnotation;
import org.eclipse.jpt.core.resource.java.VersionAnnotation;
@@ -212,26 +214,27 @@ public class GenericJavaElementCollectionMapping2_0Tests extends Generic2_0Conte
this.javaProject.createCompilationUnit(PACKAGE_NAME, "Address.java", sourceWriter);
}
- private ICompilationUnit createTestEntityWithGenericElementCollectionBasicType() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ private void createTestEmbeddableState() throws Exception {
+ SourceWriter sourceWriter = new SourceWriter() {
+ public void appendSourceTo(StringBuilder sb) {
sb.append(CR);
- sb.append(" @ElementCollection").append(CR);
- sb.append(" private java.util.Collection<String> addresses;").append(CR);
+ sb.append("import ");
+ sb.append(JPA.EMBEDDABLE);
+ sb.append(";");
+ sb.append(CR);
+ sb.append("@Embeddable");
sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
+ sb.append("public class ").append("State").append(" ");
+ sb.append("{").append(CR);
+ sb.append(CR);
+ sb.append(" private String name;").append(CR);
+ sb.append(CR);
+ sb.append(" private String abbr;").append(CR);
+ sb.append(CR);
+ sb.append("}").append(CR);
+ }
+ };
+ this.javaProject.createCompilationUnit(PACKAGE_NAME, "State.java", sourceWriter);
}
public GenericJavaElementCollectionMapping2_0Tests(String name) {
@@ -594,7 +597,7 @@ public class GenericJavaElementCollectionMapping2_0Tests extends Generic2_0Conte
}
public void testResolvedTargetEmbeddableWithBasicType() throws Exception {
- createTestEntityWithGenericElementCollectionBasicType();
+ createTestEntityWithGenericBasicElementCollectionMapping();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
@@ -700,5 +703,225 @@ public class GenericJavaElementCollectionMapping2_0Tests extends Generic2_0Conte
assertEquals(ElementCollectionMapping2_0.Type.BASIC_TYPE, elementCollectionMapping.getValueType());
}
+
+ public void testUpdateMapKey() throws Exception {
+ createTestEntityWithElementCollectionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+
+ assertNull(elementCollectionMapping.getSpecifiedMapKey());
+ assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
+
+ //set mapKey in the resource model, verify context model does not change
+ attributeResource.addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ assertNull(elementCollectionMapping.getSpecifiedMapKey());
+ MapKeyAnnotation mapKey = (MapKeyAnnotation) attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ assertNotNull(mapKey);
+
+ //set mapKey name in the resource model, verify context model updated
+ mapKey.setName("myMapKey");
+ getJpaProject().synchronizeContextModel();
+
+ assertEquals("myMapKey", elementCollectionMapping.getSpecifiedMapKey());
+ assertEquals("myMapKey", mapKey.getName());
+
+ //set mapKey name to null in the resource model
+ mapKey.setName(null);
+ getJpaProject().synchronizeContextModel();
+ assertNull(elementCollectionMapping.getSpecifiedMapKey());
+ assertNull(mapKey.getName());
+
+ mapKey.setName("myMapKey");
+ attributeResource.removeAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ getJpaProject().synchronizeContextModel();
+ assertNull(elementCollectionMapping.getSpecifiedMapKey());
+ assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testModifyMapKey() throws Exception {
+ createTestEntityWithElementCollectionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+
+ assertNull(elementCollectionMapping.getSpecifiedMapKey());
+ assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
+
+ //set mapKey in the context model, verify resource model updated
+ elementCollectionMapping.setSpecifiedMapKey("myMapKey");
+ MapKeyAnnotation mapKey = (MapKeyAnnotation) attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ assertEquals("myMapKey", elementCollectionMapping.getSpecifiedMapKey());
+ assertEquals("myMapKey", mapKey.getName());
+
+ //set mapKey to null in the context model
+ elementCollectionMapping.setSpecifiedMapKey(null);
+ assertNull(elementCollectionMapping.getSpecifiedMapKey());
+ assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testCandidateMapKeyNames() throws Exception {
+ createTestEntityWithValidGenericMapElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+ createTestEmbeddableState();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ addXmlClassRef(PACKAGE_NAME + ".Address");
+ addXmlClassRef(PACKAGE_NAME + ".State");
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping2_0 = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ Iterator<String> mapKeyNames =
+ elementCollectionMapping2_0.candidateMapKeyNames();
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.name", mapKeyNames.next());
+ assertEquals("state.abbr", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+ }
+
+ public void testCandidateMapKeyNames2() throws Exception {
+ createTestEntityWithValidNonGenericMapElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+ createTestEmbeddableState();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ addXmlClassRef(PACKAGE_NAME + ".Address");
+ addXmlClassRef(PACKAGE_NAME + ".State");
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping2_0 = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ Iterator<String> mapKeyNames = elementCollectionMapping2_0.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+
+ elementCollectionMapping2_0.setSpecifiedTargetClass("Address");
+ mapKeyNames = elementCollectionMapping2_0.candidateMapKeyNames();
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.name", mapKeyNames.next());
+ assertEquals("state.abbr", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+
+ elementCollectionMapping2_0.setSpecifiedTargetClass("String");
+ mapKeyNames = elementCollectionMapping2_0.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+ }
+
+ public void testUpdateMapKeyClass() throws Exception {
+ createTestEntityWithElementCollectionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+
+ assertNull(elementCollectionMapping.getSpecifiedMapKeyClass());
+ assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
+
+ //set mapKey in the resource model, verify context model does not change
+ attributeResource.addAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ assertNull(elementCollectionMapping.getSpecifiedMapKeyClass());
+ MapKeyClass2_0Annotation mapKeyClass = (MapKeyClass2_0Annotation) attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ assertNotNull(mapKeyClass);
+
+ //set mapKey name in the resource model, verify context model updated
+ mapKeyClass.setValue("myMapKeyClass");
+ getJpaProject().synchronizeContextModel();
+
+ assertEquals("myMapKeyClass", elementCollectionMapping.getSpecifiedMapKeyClass());
+ assertEquals("myMapKeyClass", mapKeyClass.getValue());
+
+ //set mapKey name to null in the resource model
+ mapKeyClass.setValue(null);
+ getJpaProject().synchronizeContextModel();
+
+ assertNull(elementCollectionMapping.getSpecifiedMapKeyClass());
+ assertNull(mapKeyClass.getValue());
+
+ mapKeyClass.setValue("myMapKeyClass");
+ attributeResource.removeAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ getJpaProject().synchronizeContextModel();
+
+ assertNull(elementCollectionMapping.getSpecifiedMapKeyClass());
+ assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testModifyMapKeyClass() throws Exception {
+ createTestEntityWithElementCollectionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+
+ assertNull(elementCollectionMapping.getSpecifiedMapKeyClass());
+ assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
+
+ //set mapKey in the context model, verify resource model updated
+ elementCollectionMapping.setSpecifiedMapKeyClass("String");
+ MapKeyClass2_0Annotation mapKeyClass = (MapKeyClass2_0Annotation) attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ assertEquals("String", elementCollectionMapping.getSpecifiedMapKeyClass());
+ assertEquals("String", mapKeyClass.getValue());
+
+ //set mapKey to null in the context model
+ elementCollectionMapping.setSpecifiedMapKeyClass(null);
+ assertNull(elementCollectionMapping.getSpecifiedMapKeyClass());
+ assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testDefaultMapKeyClass() throws Exception {
+ createTestEntityWithValidGenericMapElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+ createTestEmbeddableState();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ assertEquals("java.lang.Integer", elementCollectionMapping.getDefaultMapKeyClass());
+
+ //test default still the same when specified target entity it set
+ elementCollectionMapping.setSpecifiedMapKeyClass("foo");
+ assertEquals("java.lang.Integer", elementCollectionMapping.getDefaultMapKeyClass());
+ }
+
+ public void testDefaultMapKeyClassCollectionType() throws Exception {
+ createTestEntityWithGenericBasicElementCollectionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ assertNull(elementCollectionMapping.getDefaultMapKeyClass());
+ }
+
+ public void testMapKeyClass() throws Exception {
+ createTestEntityWithValidGenericMapElementCollectionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ assertEquals("java.lang.Integer", elementCollectionMapping.getMapKeyClass());
+ elementCollectionMapping.setSpecifiedMapKeyClass("foo");
+ assertEquals("foo", elementCollectionMapping.getMapKeyClass());
+
+ elementCollectionMapping.setSpecifiedMapKeyClass(null);
+ assertEquals("java.lang.Integer", elementCollectionMapping.getMapKeyClass());
+ }
}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaManyToManyMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaManyToManyMapping2_0Tests.java
index 6679321e6e..1ec6bdc70d 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaManyToManyMapping2_0Tests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaManyToManyMapping2_0Tests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Oracle.
+ * Copyright (c) 2009, 2010 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
@@ -15,7 +15,11 @@ import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.core.context.AttributeMapping;
import org.eclipse.jpt.core.context.ManyToManyMapping;
import org.eclipse.jpt.core.context.PersistentAttribute;
+import org.eclipse.jpt.core.jpa2.resource.java.MapKeyClass2_0Annotation;
import org.eclipse.jpt.core.resource.java.JPA;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
+import org.eclipse.jpt.core.resource.java.MapKeyAnnotation;
import org.eclipse.jpt.core.tests.internal.jpa2.context.Generic2_0ContextModelTestCase;
import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
@@ -51,6 +55,50 @@ public class GenericJavaManyToManyMapping2_0Tests
}
});
}
+
+ private ICompilationUnit createTestEntityWithValidGenericMapManyToManyMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @ManyToMany").append(CR);
+ sb.append(" private java.util.Map<Integer, Address> addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
+ private ICompilationUnit createTestEntityWithValidNonGenericMapManyToManyMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @ManyToMany").append(CR);
+ sb.append(" private java.util.Map addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
private void createTestTargetEntityAddress() throws Exception {
SourceWriter sourceWriter = new SourceWriter() {
@@ -152,5 +200,224 @@ public class GenericJavaManyToManyMapping2_0Tests
AttributeMapping stateFooMapping = manyToManyMapping.getResolvedTargetEntity().resolveAttributeMapping("state.foo");
assertEquals("foo", stateFooMapping.getName());
}
+
+ public void testUpdateMapKey() throws Exception {
+ createTestEntityWithValidManyToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+
+ assertNull(manyToManyMapping.getSpecifiedMapKey());
+ assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
+
+ //set mapKey in the resource model, verify context model does not change
+ attributeResource.addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ assertNull(manyToManyMapping.getSpecifiedMapKey());
+ MapKeyAnnotation mapKey = (MapKeyAnnotation) attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ assertNotNull(mapKey);
+
+ //set mapKey name in the resource model, verify context model updated
+ mapKey.setName("myMapKey");
+ getJpaProject().synchronizeContextModel();
+
+ assertEquals("myMapKey", manyToManyMapping.getSpecifiedMapKey());
+ assertEquals("myMapKey", mapKey.getName());
+
+ //set mapKey name to null in the resource model
+ mapKey.setName(null);
+ getJpaProject().synchronizeContextModel();
+
+ assertNull(manyToManyMapping.getSpecifiedMapKey());
+ assertNull(mapKey.getName());
+
+ mapKey.setName("myMapKey");
+ attributeResource.removeAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ getJpaProject().synchronizeContextModel();
+
+ assertNull(manyToManyMapping.getSpecifiedMapKey());
+ assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testModifyMapKey() throws Exception {
+ createTestEntityWithValidManyToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+
+ assertNull(manyToManyMapping.getSpecifiedMapKey());
+ assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
+
+ //set mapKey in the context model, verify resource model updated
+ manyToManyMapping.setSpecifiedMapKey("myMapKey");
+ MapKeyAnnotation mapKey = (MapKeyAnnotation) attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ assertEquals("myMapKey", manyToManyMapping.getSpecifiedMapKey());
+ assertEquals("myMapKey", mapKey.getName());
+
+ //set mapKey to null in the context model
+ manyToManyMapping.setSpecifiedMapKey(null);
+ assertNull(manyToManyMapping.getSpecifiedMapKey());
+ assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testCandidateMapKeyNames() throws Exception {
+ createTestEntityWithValidGenericMapManyToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ addXmlClassRef(PACKAGE_NAME + ".Address");
+ addXmlClassRef(PACKAGE_NAME + ".State");
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ManyToManyMapping manyToManyMapping2_0 = (ManyToManyMapping) persistentAttribute.getMapping();
+
+ Iterator<String> mapKeyNames =
+ manyToManyMapping2_0.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.foo", mapKeyNames.next());
+ assertEquals("state.address", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+ }
+
+ public void testCandidateMapKeyNames2() throws Exception {
+ createTestEntityWithValidNonGenericMapManyToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ addXmlClassRef(PACKAGE_NAME + ".Address");
+ addXmlClassRef(PACKAGE_NAME + ".State");
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ManyToManyMapping manyToManyMapping2_0 = (ManyToManyMapping) persistentAttribute.getMapping();
+
+ Iterator<String> mapKeyNames = manyToManyMapping2_0.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+
+ manyToManyMapping2_0.setSpecifiedTargetEntity("Address");
+ mapKeyNames = manyToManyMapping2_0.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.foo", mapKeyNames.next());
+ assertEquals("state.address", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+
+ manyToManyMapping2_0.setSpecifiedTargetEntity("String");
+ mapKeyNames = manyToManyMapping2_0.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+ }
+
+ public void testUpdateMapKeyClass() throws Exception {
+ createTestEntityWithValidManyToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+
+ assertNull(manyToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
+
+ //set mapKey in the resource model, verify context model does not change
+ attributeResource.addAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ assertNull(manyToManyMapping.getSpecifiedMapKeyClass());
+ MapKeyClass2_0Annotation mapKeyClass = (MapKeyClass2_0Annotation) attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ assertNotNull(mapKeyClass);
+
+ //set mapKey name in the resource model, verify context model updated
+ mapKeyClass.setValue("myMapKeyClass");
+ assertEquals("myMapKeyClass", manyToManyMapping.getSpecifiedMapKeyClass());
+ assertEquals("myMapKeyClass", mapKeyClass.getValue());
+
+ //set mapKey name to null in the resource model
+ mapKeyClass.setValue(null);
+ assertNull(manyToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(mapKeyClass.getValue());
+
+ mapKeyClass.setValue("myMapKeyClass");
+ attributeResource.removeAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ getJpaProject().synchronizeContextModel();
+ assertNull(manyToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testModifyMapKeyClass() throws Exception {
+ createTestEntityWithValidManyToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+
+ assertNull(manyToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
+
+ //set mapKey in the context model, verify resource model updated
+ manyToManyMapping.setSpecifiedMapKeyClass("String");
+ MapKeyClass2_0Annotation mapKeyClass = (MapKeyClass2_0Annotation) attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ assertEquals("String", manyToManyMapping.getSpecifiedMapKeyClass());
+ assertEquals("String", mapKeyClass.getValue());
+
+ //set mapKey to null in the context model
+ manyToManyMapping.setSpecifiedMapKeyClass(null);
+ assertNull(manyToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
+ }
+ public void testDefaultMapKeyClass() throws Exception {
+ createTestEntityWithValidGenericMapManyToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
+
+ assertEquals("java.lang.Integer", manyToManyMapping.getDefaultMapKeyClass());
+
+ //test default still the same when specified target entity it set
+ manyToManyMapping.setSpecifiedMapKeyClass("foo");
+ assertEquals("java.lang.Integer", manyToManyMapping.getDefaultMapKeyClass());
+ }
+
+ public void testDefaultMapKeyClassCollectionType() throws Exception {
+ createTestEntityWithValidManyToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
+
+ assertNull(manyToManyMapping.getDefaultMapKeyClass());
+ }
+
+ public void testMapKeyClass() throws Exception {
+ createTestEntityWithValidGenericMapManyToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
+
+ assertEquals("java.lang.Integer", manyToManyMapping.getMapKeyClass());
+
+ manyToManyMapping.setSpecifiedMapKeyClass("foo");
+ assertEquals("foo", manyToManyMapping.getMapKeyClass());
+
+ manyToManyMapping.setSpecifiedMapKeyClass(null);
+ assertEquals("java.lang.Integer", manyToManyMapping.getMapKeyClass());
+ }
}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaOneToManyMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaOneToManyMapping2_0Tests.java
index d4eac6602b..790b506ed5 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaOneToManyMapping2_0Tests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaOneToManyMapping2_0Tests.java
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 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
- ******************************************************************************/
+* Copyright (c) 2009, 2010 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.core.tests.internal.jpa2.context.java;
import java.util.Iterator;
@@ -18,10 +18,12 @@ import org.eclipse.jpt.core.context.PersistentAttribute;
import org.eclipse.jpt.core.jpa2.context.OneToManyMapping2_0;
import org.eclipse.jpt.core.jpa2.context.java.JavaOrphanRemovable2_0;
import org.eclipse.jpt.core.jpa2.context.java.JavaOrphanRemovalHolder2_0;
+import org.eclipse.jpt.core.jpa2.resource.java.MapKeyClass2_0Annotation;
import org.eclipse.jpt.core.jpa2.resource.java.OneToMany2_0Annotation;
import org.eclipse.jpt.core.resource.java.JPA;
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
+import org.eclipse.jpt.core.resource.java.MapKeyAnnotation;
import org.eclipse.jpt.core.tests.internal.jpa2.context.Generic2_0ContextModelTestCase;
import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
@@ -78,6 +80,51 @@ public class GenericJavaOneToManyMapping2_0Tests
}
});
}
+
+ private ICompilationUnit createTestEntityWithValidGenericMapOneToManyMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @OneToMany").append(CR);
+ sb.append(" private java.util.Map<Integer, Address> addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
+ private ICompilationUnit createTestEntityWithValidNonGenericMapOneToManyMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @OneToMany").append(CR);
+ sb.append(" private java.util.Map addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
private void createTestTargetEntityAddress() throws Exception {
SourceWriter sourceWriter = new SourceWriter() {
@@ -323,4 +370,222 @@ public class GenericJavaOneToManyMapping2_0Tests
assertNull(persistentAttribute.getSpecifiedMapping());
}
+ public void testUpdateMapKey() throws Exception {
+ createTestEntityWithValidOneToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+
+ assertNull(oneToManyMapping.getSpecifiedMapKey());
+ assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
+
+ //set mapKey in the resource model, verify context model does not change
+ attributeResource.addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ assertNull(oneToManyMapping.getSpecifiedMapKey());
+ MapKeyAnnotation mapKey = (MapKeyAnnotation) attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ assertNotNull(mapKey);
+
+ //set mapKey name in the resource model, verify context model updated
+ mapKey.setName("myMapKey");
+ getJpaProject().synchronizeContextModel();
+ assertEquals("myMapKey", oneToManyMapping.getSpecifiedMapKey());
+ assertEquals("myMapKey", mapKey.getName());
+
+ //set mapKey name to null in the resource model
+ mapKey.setName(null);
+ getJpaProject().synchronizeContextModel();
+
+ assertNull(oneToManyMapping.getSpecifiedMapKey());
+ assertNull(mapKey.getName());
+
+ mapKey.setName("myMapKey");
+ attributeResource.removeAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ getJpaProject().synchronizeContextModel();
+
+ assertNull(oneToManyMapping.getSpecifiedMapKey());
+ assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testModifyMapKey() throws Exception {
+ createTestEntityWithValidOneToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+
+ assertNull(oneToManyMapping.getSpecifiedMapKey());
+ assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
+
+ //set mapKey in the context model, verify resource model updated
+ oneToManyMapping.setSpecifiedMapKey("myMapKey");
+ MapKeyAnnotation mapKey = (MapKeyAnnotation) attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ assertEquals("myMapKey", oneToManyMapping.getSpecifiedMapKey());
+ assertEquals("myMapKey", mapKey.getName());
+
+ //set mapKey to null in the context model
+ oneToManyMapping.setSpecifiedMapKey(null);
+ assertNull(oneToManyMapping.getSpecifiedMapKey());
+ assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testCandidateMapKeyNames() throws Exception {
+ createTestEntityWithValidGenericMapOneToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ addXmlClassRef(PACKAGE_NAME + ".Address");
+ addXmlClassRef(PACKAGE_NAME + ".State");
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ OneToManyMapping2_0 oneToManyMapping2_0 = (OneToManyMapping2_0) persistentAttribute.getMapping();
+
+ Iterator<String> mapKeyNames =
+ oneToManyMapping2_0.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.foo", mapKeyNames.next());
+ assertEquals("state.address", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+ }
+
+ public void testCandidateMapKeyNames2() throws Exception {
+ createTestEntityWithValidNonGenericMapOneToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ addXmlClassRef(PACKAGE_NAME + ".Address");
+ addXmlClassRef(PACKAGE_NAME + ".State");
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ OneToManyMapping2_0 oneToManyMapping2_0 = (OneToManyMapping2_0) persistentAttribute.getMapping();
+
+ Iterator<String> mapKeyNames = oneToManyMapping2_0.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+
+ oneToManyMapping2_0.setSpecifiedTargetEntity("Address");
+ mapKeyNames = oneToManyMapping2_0.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.foo", mapKeyNames.next());
+ assertEquals("state.address", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+
+ oneToManyMapping2_0.setSpecifiedTargetEntity("String");
+ mapKeyNames = oneToManyMapping2_0.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+ }
+
+ public void testUpdateMapKeyClass() throws Exception {
+ createTestEntityWithValidOneToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+
+ assertNull(oneToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
+
+ //set mapKey in the resource model, verify context model does not change
+ attributeResource.addAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ assertNull(oneToManyMapping.getSpecifiedMapKeyClass());
+ MapKeyClass2_0Annotation mapKeyClass = (MapKeyClass2_0Annotation) attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ assertNotNull(mapKeyClass);
+
+ //set mapKey name in the resource model, verify context model updated
+ mapKeyClass.setValue("myMapKeyClass");
+ assertEquals("myMapKeyClass", oneToManyMapping.getSpecifiedMapKeyClass());
+ assertEquals("myMapKeyClass", mapKeyClass.getValue());
+
+ //set mapKey name to null in the resource model
+ mapKeyClass.setValue(null);
+ assertNull(oneToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(mapKeyClass.getValue());
+
+ mapKeyClass.setValue("myMapKeyClass");
+ attributeResource.removeAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ getJpaProject().synchronizeContextModel();
+ assertNull(oneToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testModifyMapKeyClass() throws Exception {
+ createTestEntityWithValidOneToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+
+ assertNull(oneToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
+
+ //set mapKey in the context model, verify resource model updated
+ oneToManyMapping.setSpecifiedMapKeyClass("String");
+ MapKeyClass2_0Annotation mapKeyClass = (MapKeyClass2_0Annotation) attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ assertEquals("String", oneToManyMapping.getSpecifiedMapKeyClass());
+ assertEquals("String", mapKeyClass.getValue());
+
+ //set mapKey to null in the context model
+ oneToManyMapping.setSpecifiedMapKeyClass(null);
+ assertNull(oneToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testDefaultMapKeyClass() throws Exception {
+ createTestEntityWithValidGenericMapOneToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
+
+ assertEquals("java.lang.Integer", oneToManyMapping.getDefaultMapKeyClass());
+
+ //test default still the same when specified target entity it set
+ oneToManyMapping.setSpecifiedMapKeyClass("foo");
+ assertEquals("java.lang.Integer", oneToManyMapping.getDefaultMapKeyClass());
+ }
+
+ public void testDefaultMapKeyClassCollectionType() throws Exception {
+ createTestEntityWithValidOneToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
+
+ assertNull(oneToManyMapping.getDefaultMapKeyClass());
+ }
+
+ public void testMapKeyClass() throws Exception {
+ createTestEntityWithValidGenericMapOneToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
+
+ assertEquals("java.lang.Integer", oneToManyMapping.getMapKeyClass());
+
+ oneToManyMapping.setSpecifiedMapKeyClass("foo");
+ assertEquals("foo", oneToManyMapping.getMapKeyClass());
+
+ oneToManyMapping.setSpecifiedMapKeyClass(null);
+ assertEquals("java.lang.Integer", oneToManyMapping.getMapKeyClass());
+ }
}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/orm/GenericOrmElementCollectionMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/orm/GenericOrmElementCollectionMapping2_0Tests.java
index 339a266f17..30a8367873 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/orm/GenericOrmElementCollectionMapping2_0Tests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/orm/GenericOrmElementCollectionMapping2_0Tests.java
@@ -23,14 +23,18 @@ import org.eclipse.jpt.core.context.ManyToOneMapping;
import org.eclipse.jpt.core.context.OneToManyMapping;
import org.eclipse.jpt.core.context.TransientMapping;
import org.eclipse.jpt.core.context.VersionMapping;
+import org.eclipse.jpt.core.context.orm.OrmOneToManyMapping;
import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
import org.eclipse.jpt.core.context.orm.OrmPersistentType;
import org.eclipse.jpt.core.jpa2.MappingKeys2_0;
import org.eclipse.jpt.core.jpa2.context.ElementCollectionMapping2_0;
+import org.eclipse.jpt.core.jpa2.context.java.JavaElementCollectionMapping2_0;
import org.eclipse.jpt.core.jpa2.context.orm.OrmElementCollectionMapping2_0;
import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0;
import org.eclipse.jpt.core.resource.java.JPA;
+import org.eclipse.jpt.core.resource.orm.OrmFactory;
import org.eclipse.jpt.core.resource.orm.XmlElementCollection;
+import org.eclipse.jpt.core.resource.orm.XmlOneToMany;
import org.eclipse.jpt.core.resource.orm.v2_0.XmlElementCollection_2_0;
import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
@@ -95,9 +99,6 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex
sb.append("public class ").append("Address").append(" ");
sb.append("{").append(CR);
sb.append(CR);
- sb.append(" @Id").append(CR);
- sb.append(" private int id;").append(CR);
- sb.append(CR);
sb.append(" private String city;").append(CR);
sb.append(CR);
sb.append(" private State state;").append(CR);
@@ -175,6 +176,73 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex
sb.append(" @Id").append(CR);
}
});
+ }
+
+ private ICompilationUnit createTestEntityWithValidMapElementCollectionMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @ElementCollection").append(CR);
+ sb.append(" private java.util.Map<String, Address> addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
+ private void createTestEmbeddableState() 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("State").append(" ");
+ sb.append("{").append(CR);
+ sb.append(CR);
+ sb.append(" private String name;").append(CR);
+ sb.append(CR);
+ sb.append(" private String abbr;").append(CR);
+ sb.append(CR);
+ sb.append("}").append(CR);
+ }
+ };
+ this.javaProject.createCompilationUnit(PACKAGE_NAME, "State.java", sourceWriter);
+ }
+
+ private ICompilationUnit createTestEntityWithValidNonGenericMapElementCollectionMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @ElementCollection").append(CR);
+ sb.append(" private java.util.Map addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
}
public void testUpdateName() throws Exception {
@@ -587,4 +655,225 @@ public class GenericOrmElementCollectionMapping2_0Tests extends Generic2_0Contex
assertEquals(ElementCollectionMapping2_0.Type.BASIC_TYPE, elementCollectionMapping.getValueType());
}
+
+ public void testUpdateMapKey() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
+ OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping();
+ XmlOneToMany oneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0);
+
+ assertNull(ormOneToManyMapping.getSpecifiedMapKey());
+ assertNull(oneToMany.getMapKey());
+
+ //set mapKey in the resource model, verify context model does not change
+ oneToMany.setMapKey(OrmFactory.eINSTANCE.createMapKey());
+ assertNull(ormOneToManyMapping.getSpecifiedMapKey());
+ assertNotNull(oneToMany.getMapKey());
+
+ //set mapKey name in the resource model, verify context model updated
+ oneToMany.getMapKey().setName("myMapKey");
+ assertEquals("myMapKey", ormOneToManyMapping.getSpecifiedMapKey());
+ assertEquals("myMapKey", oneToMany.getMapKey().getName());
+
+ //set mapKey name to null in the resource model
+ oneToMany.getMapKey().setName(null);
+ assertNull(ormOneToManyMapping.getSpecifiedMapKey());
+ assertNull(oneToMany.getMapKey().getName());
+
+ oneToMany.getMapKey().setName("myMapKey");
+ oneToMany.setMapKey(null);
+ assertNull(ormOneToManyMapping.getSpecifiedMapKey());
+ assertNull(oneToMany.getMapKey());
+ }
+
+ public void testUpdateVirtualMapKey() throws Exception {
+ createTestEntityWithValidMapElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ JavaElementCollectionMapping2_0 javaElementCollectionMapping = (JavaElementCollectionMapping2_0) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+ assertNull(ormElementCollectionMapping.getSpecifiedMapKey());
+ assertNull(ormElementCollectionMapping.getMapKey());
+ assertFalse(ormElementCollectionMapping.isPkMapKey());
+ assertFalse(ormElementCollectionMapping.isCustomMapKey());
+ assertTrue(ormElementCollectionMapping.isNoMapKey());
+
+ //set pk mapKey in the java, verify virtual orm mapping updates
+ javaElementCollectionMapping.setPkMapKey(true);
+ assertEquals(null, ormElementCollectionMapping.getMapKey());//no primary key on an embeddable
+ assertTrue(ormElementCollectionMapping.isPkMapKey());
+ assertFalse(ormElementCollectionMapping.isCustomMapKey());
+ assertFalse(ormElementCollectionMapping.isNoMapKey());
+
+
+ //set custom specified mapKey in the java, verify virtual orm mapping updates
+ javaElementCollectionMapping.setCustomMapKey(true);
+ javaElementCollectionMapping.setSpecifiedMapKey("city");
+ assertEquals("city", ormElementCollectionMapping.getSpecifiedMapKey());
+ assertEquals("city", ormElementCollectionMapping.getMapKey());
+ assertFalse(ormElementCollectionMapping.isPkMapKey());
+ assertTrue(ormElementCollectionMapping.isCustomMapKey());
+ assertFalse(ormElementCollectionMapping.isNoMapKey());
+ }
+
+ public void testModifyMapKey() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
+ OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping();
+ XmlOneToMany oneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0);
+
+ assertNull(ormOneToManyMapping.getSpecifiedMapKey());
+ assertNull(oneToMany.getMapKey());
+
+ //set mapKey in the context model, verify resource model updated
+ ormOneToManyMapping.setSpecifiedMapKey("myMapKey");
+ assertEquals("myMapKey", ormOneToManyMapping.getSpecifiedMapKey());
+ assertEquals("myMapKey", oneToMany.getMapKey().getName());
+
+ //set mapKey to null in the context model
+ ormOneToManyMapping.setSpecifiedMapKey(null);
+ assertNull(ormOneToManyMapping.getSpecifiedMapKey());
+ assertNull(oneToMany.getMapKey());
+ }
+
+ public void testCandidateMapKeyNames() throws Exception {
+ createTestEntityWithValidMapElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentType.getAttributeNamed("addresses").getMapping();
+
+ Iterator<String> mapKeyNames =
+ ormElementCollectionMapping.candidateMapKeyNames();
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.name", mapKeyNames.next());
+ assertEquals("state.abbr", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+ }
+
+ public void testCandidateMapKeyNames2() throws Exception {
+ createTestEntityWithValidNonGenericMapElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ JavaElementCollectionMapping2_0 javaElementCollectionMapping = (JavaElementCollectionMapping2_0) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+
+ Iterator<String> mapKeyNames = ormElementCollectionMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+
+ javaElementCollectionMapping.setSpecifiedTargetClass("test.Address");
+ mapKeyNames = ormElementCollectionMapping.candidateMapKeyNames();
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.name", mapKeyNames.next());
+ assertEquals("state.abbr", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+
+ ormElementCollectionMapping.getPersistentAttribute().makeSpecified();
+ ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ mapKeyNames = ormElementCollectionMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+
+ ormElementCollectionMapping.setSpecifiedTargetClass("test.Address");
+ mapKeyNames = ormElementCollectionMapping.candidateMapKeyNames();
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.name", mapKeyNames.next());
+ assertEquals("state.abbr", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+
+ ormElementCollectionMapping.setSpecifiedTargetClass("String");
+ mapKeyNames = ormElementCollectionMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+ }
+
+ public void testUpdateMapKeyClass() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
+ OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
+ XmlElementCollection elementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
+
+ assertNull(ormElementCollectionMapping.getSpecifiedMapKeyClass());
+ assertNull(elementCollection.getMapKeyClass());
+
+ //set mapKey in the resource model, verify context model does not change
+ elementCollection.setMapKeyClass(OrmFactory.eINSTANCE.createXmlMapKeyClass());
+ assertNull(ormElementCollectionMapping.getSpecifiedMapKeyClass());
+ assertNotNull(elementCollection.getMapKeyClass());
+
+ //set mapKey name in the resource model, verify context model updated
+ elementCollection.getMapKeyClass().setClassName("String");
+ assertEquals("String", ormElementCollectionMapping.getSpecifiedMapKeyClass());
+ assertEquals("String", elementCollection.getMapKeyClass().getClassName());
+
+ //set mapKey name to null in the resource model
+ elementCollection.getMapKeyClass().setClassName(null);
+ assertNull(ormElementCollectionMapping.getSpecifiedMapKeyClass());
+ assertNull(elementCollection.getMapKeyClass().getClassName());
+
+ elementCollection.getMapKeyClass().setClassName("String");
+ elementCollection.setMapKeyClass(null);
+ assertNull(ormElementCollectionMapping.getSpecifiedMapKeyClass());
+ assertNull(elementCollection.getMapKeyClass());
+ }
+
+ public void testUpdateVirtualMapKeyClass() throws Exception {
+ createTestEntityWithValidMapElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ JavaElementCollectionMapping2_0 javaElementCollectionMapping = (JavaElementCollectionMapping2_0) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+ assertEquals(null, ormElementCollectionMapping.getSpecifiedMapKeyClass());
+ assertEquals("java.lang.String", ormElementCollectionMapping.getMapKeyClass());
+ assertEquals("java.lang.String", ormElementCollectionMapping.getDefaultMapKeyClass());
+
+ //set pk mapKey in the java, verify virtual orm mapping updates
+ javaElementCollectionMapping.setSpecifiedMapKeyClass("Integer");
+ assertEquals("Integer", ormElementCollectionMapping.getMapKeyClass());
+ assertEquals("Integer", ormElementCollectionMapping.getSpecifiedMapKeyClass());
+ assertEquals("java.lang.String", ormElementCollectionMapping.getDefaultMapKeyClass());
+ }
+
+ public void testModifyMapKeyClass() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
+ OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
+ XmlElementCollection elementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
+
+ assertNull(ormElementCollectionMapping.getSpecifiedMapKeyClass());
+ assertNull(elementCollection.getMapKeyClass());
+
+ //set mapKey in the context model, verify resource model updated
+ ormElementCollectionMapping.setSpecifiedMapKeyClass("String");
+ assertEquals("String", ormElementCollectionMapping.getSpecifiedMapKeyClass());
+ assertEquals("String", elementCollection.getMapKeyClass().getClassName());
+
+ //set mapKey to null in the context model
+ ormElementCollectionMapping.setSpecifiedMapKeyClass(null);
+ assertNull(ormElementCollectionMapping.getSpecifiedMapKeyClass());
+ assertNull(elementCollection.getMapKeyClass());
+ }
} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/orm/GenericOrmManyToManyMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/orm/GenericOrmManyToManyMapping2_0Tests.java
index fc15276a21..978800e372 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/orm/GenericOrmManyToManyMapping2_0Tests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/orm/GenericOrmManyToManyMapping2_0Tests.java
@@ -16,8 +16,13 @@ import org.eclipse.jpt.core.MappingKeys;
import org.eclipse.jpt.core.context.AttributeMapping;
import org.eclipse.jpt.core.context.ManyToManyMapping;
import org.eclipse.jpt.core.context.PersistentAttribute;
+import org.eclipse.jpt.core.context.java.JavaManyToManyMapping;
+import org.eclipse.jpt.core.context.orm.OrmManyToManyMapping;
+import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
import org.eclipse.jpt.core.context.orm.OrmPersistentType;
import org.eclipse.jpt.core.resource.java.JPA;
+import org.eclipse.jpt.core.resource.orm.OrmFactory;
+import org.eclipse.jpt.core.resource.orm.XmlManyToMany;
import org.eclipse.jpt.core.tests.internal.jpa2.context.Generic2_0ContextModelTestCase;
import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
@@ -86,6 +91,50 @@ public class GenericOrmManyToManyMapping2_0Tests
});
}
+ private ICompilationUnit createTestEntityWithValidMapManyToManyMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @ManyToMany").append(CR);
+ sb.append(" private java.util.Map<String, Address> addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
+ private ICompilationUnit createTestEntityWithValidNonGenericMapManyToManyMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @ManyToMany").append(CR);
+ sb.append(" private java.util.Map addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
private void createTestEmbeddableState() throws Exception {
SourceWriter sourceWriter = new SourceWriter() {
public void appendSourceTo(StringBuilder sb) {
@@ -154,4 +203,228 @@ public class GenericOrmManyToManyMapping2_0Tests
AttributeMapping stateFooMapping = manyToManyMapping.getResolvedTargetEntity().resolveAttributeMapping("state.foo");
assertEquals("foo", stateFooMapping.getName());
}
+
+ public void testUpdateMapKey() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
+ OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
+ XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
+
+ assertNull(ormManyToManyMapping.getSpecifiedMapKey());
+ assertNull(manyToMany.getMapKey());
+
+ //set mapKey in the resource model, verify context model does not change
+ manyToMany.setMapKey(OrmFactory.eINSTANCE.createMapKey());
+ assertNull(ormManyToManyMapping.getSpecifiedMapKey());
+ assertNotNull(manyToMany.getMapKey());
+
+ //set mapKey name in the resource model, verify context model updated
+ manyToMany.getMapKey().setName("myMapKey");
+ assertEquals("myMapKey", ormManyToManyMapping.getSpecifiedMapKey());
+ assertEquals("myMapKey", manyToMany.getMapKey().getName());
+
+ //set mapKey name to null in the resource model
+ manyToMany.getMapKey().setName(null);
+ assertNull(ormManyToManyMapping.getSpecifiedMapKey());
+ assertNull(manyToMany.getMapKey().getName());
+
+ manyToMany.getMapKey().setName("myMapKey");
+ manyToMany.setMapKey(null);
+ assertNull(ormManyToManyMapping.getSpecifiedMapKey());
+ assertNull(manyToMany.getMapKey());
+ }
+
+ public void testUpdateVirtualMapKey() throws Exception {
+ createTestEntityWithValidMapManyToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ JavaManyToManyMapping javaManyToManyMapping = (JavaManyToManyMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+ assertNull(ormManyToManyMapping.getSpecifiedMapKey());
+ assertNull(ormManyToManyMapping.getMapKey());
+ assertFalse(ormManyToManyMapping.isPkMapKey());
+ assertFalse(ormManyToManyMapping.isCustomMapKey());
+ assertTrue(ormManyToManyMapping.isNoMapKey());
+
+ //set pk mapKey in the java, verify virtual orm mapping updates
+ javaManyToManyMapping.setPkMapKey(true);
+ assertEquals("id", ormManyToManyMapping.getMapKey());
+ assertTrue(ormManyToManyMapping.isPkMapKey());
+ assertFalse(ormManyToManyMapping.isCustomMapKey());
+ assertFalse(ormManyToManyMapping.isNoMapKey());
+
+
+ //set custom specified mapKey in the java, verify virtual orm mapping updates
+ javaManyToManyMapping.setCustomMapKey(true);
+ javaManyToManyMapping.setSpecifiedMapKey("city");
+ assertEquals("city", ormManyToManyMapping.getSpecifiedMapKey());
+ assertEquals("city", ormManyToManyMapping.getMapKey());
+ assertFalse(ormManyToManyMapping.isPkMapKey());
+ assertTrue(ormManyToManyMapping.isCustomMapKey());
+ assertFalse(ormManyToManyMapping.isNoMapKey());
+ }
+
+ public void testModifyMapKey() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
+ OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
+ XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
+
+ assertNull(ormManyToManyMapping.getSpecifiedMapKey());
+ assertNull(manyToMany.getMapKey());
+
+ //set mapKey in the context model, verify resource model updated
+ ormManyToManyMapping.setSpecifiedMapKey("myMapKey");
+ assertEquals("myMapKey", ormManyToManyMapping.getSpecifiedMapKey());
+ assertEquals("myMapKey", manyToMany.getMapKey().getName());
+
+ //set mapKey to null in the context model
+ ormManyToManyMapping.setSpecifiedMapKey(null);
+ assertNull(ormManyToManyMapping.getSpecifiedMapKey());
+ assertNull(manyToMany.getMapKey());
+ }
+
+ public void testCandidateMapKeyNames() throws Exception {
+ createTestEntityWithValidMapManyToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+
+ Iterator<String> mapKeyNames =
+ ormManyToManyMapping.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.foo", mapKeyNames.next());
+ assertEquals("state.address", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+ }
+
+ public void testCandidateMapKeyNames2() throws Exception {
+ createTestEntityWithValidNonGenericMapManyToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ JavaManyToManyMapping javaManyToManyMapping = (JavaManyToManyMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+
+ Iterator<String> mapKeyNames = ormManyToManyMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+
+ javaManyToManyMapping.setSpecifiedTargetEntity("test.Address");
+ mapKeyNames = ormManyToManyMapping.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.foo", mapKeyNames.next());
+ assertEquals("state.address", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+
+ ormManyToManyMapping.getPersistentAttribute().makeSpecified();
+ ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ mapKeyNames = ormManyToManyMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+
+ ormManyToManyMapping.setSpecifiedTargetEntity("test.Address");
+ mapKeyNames = ormManyToManyMapping.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.foo", mapKeyNames.next());
+ assertEquals("state.address", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+
+ ormManyToManyMapping.setSpecifiedTargetEntity("String");
+ mapKeyNames = ormManyToManyMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+ }
+
+ public void testUpdateMapKeyClass() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
+ OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
+ XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
+
+ assertNull(ormManyToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(manyToMany.getMapKeyClass());
+
+ //set mapKey in the resource model, verify context model does not change
+ manyToMany.setMapKeyClass(OrmFactory.eINSTANCE.createXmlMapKeyClass());
+ assertNull(ormManyToManyMapping.getSpecifiedMapKeyClass());
+ assertNotNull(manyToMany.getMapKeyClass());
+
+ //set mapKey name in the resource model, verify context model updated
+ manyToMany.getMapKeyClass().setClassName("String");
+ assertEquals("String", ormManyToManyMapping.getSpecifiedMapKeyClass());
+ assertEquals("String", manyToMany.getMapKeyClass().getClassName());
+
+ //set mapKey name to null in the resource model
+ manyToMany.getMapKeyClass().setClassName(null);
+ assertNull(ormManyToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(manyToMany.getMapKeyClass().getClassName());
+
+ manyToMany.getMapKeyClass().setClassName("String");
+ manyToMany.setMapKeyClass(null);
+ assertNull(ormManyToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(manyToMany.getMapKeyClass());
+ }
+
+ public void testUpdateVirtualMapKeyClass() throws Exception {
+ createTestEntityWithValidMapManyToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ JavaManyToManyMapping javaManyToManyMapping = (JavaManyToManyMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+ assertEquals("java.lang.String", ormManyToManyMapping.getMapKeyClass());
+ assertEquals(null, ormManyToManyMapping.getSpecifiedMapKeyClass());
+ assertEquals("java.lang.String", ormManyToManyMapping.getDefaultMapKeyClass());
+
+ //set pk mapKey in the java, verify virtual orm mapping updates
+ javaManyToManyMapping.setSpecifiedMapKeyClass("Integer");
+ assertEquals("Integer", ormManyToManyMapping.getMapKeyClass());
+ assertEquals("Integer", ormManyToManyMapping.getSpecifiedMapKeyClass());
+ assertEquals("java.lang.String", ormManyToManyMapping.getDefaultMapKeyClass());
+ }
+
+ public void testModifyMapKeyClass() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
+ OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
+ XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
+
+ assertNull(ormManyToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(manyToMany.getMapKeyClass());
+
+ //set mapKey in the context model, verify resource model updated
+ ormManyToManyMapping.setSpecifiedMapKeyClass("String");
+ assertEquals("String", ormManyToManyMapping.getSpecifiedMapKeyClass());
+ assertEquals("String", manyToMany.getMapKeyClass().getClassName());
+
+ //set mapKey to null in the context model
+ ormManyToManyMapping.setSpecifiedMapKeyClass(null);
+ assertNull(ormManyToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(manyToMany.getMapKeyClass());
+ }
}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/orm/GenericOrmOneToManyMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/orm/GenericOrmOneToManyMapping2_0Tests.java
index def669cf2f..e3931e1cbe 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/orm/GenericOrmOneToManyMapping2_0Tests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/orm/GenericOrmOneToManyMapping2_0Tests.java
@@ -15,6 +15,8 @@ import org.eclipse.jpt.core.MappingKeys;
import org.eclipse.jpt.core.context.AttributeMapping;
import org.eclipse.jpt.core.context.OneToManyMapping;
import org.eclipse.jpt.core.context.PersistentAttribute;
+import org.eclipse.jpt.core.context.java.JavaOneToManyMapping;
+import org.eclipse.jpt.core.context.orm.OrmOneToManyMapping;
import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
import org.eclipse.jpt.core.context.orm.OrmPersistentType;
import org.eclipse.jpt.core.jpa2.context.OneToManyMapping2_0;
@@ -22,6 +24,7 @@ import org.eclipse.jpt.core.jpa2.context.orm.OrmOneToManyMapping2_0;
import org.eclipse.jpt.core.jpa2.context.orm.OrmOrphanRemovable2_0;
import org.eclipse.jpt.core.jpa2.context.orm.OrmOrphanRemovalHolder2_0;
import org.eclipse.jpt.core.resource.java.JPA;
+import org.eclipse.jpt.core.resource.orm.OrmFactory;
import org.eclipse.jpt.core.resource.orm.XmlOneToMany;
import org.eclipse.jpt.core.tests.internal.jpa2.context.Generic2_0ContextModelTestCase;
import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
@@ -91,6 +94,49 @@ public class GenericOrmOneToManyMapping2_0Tests
});
}
+ private ICompilationUnit createTestEntityWithValidMapOneToManyMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @OneToMany").append(CR);
+ sb.append(" private java.util.Map<String, Address> addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
+ private ICompilationUnit createTestEntityWithValidNonGenericMapOneToManyMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @OneToMany").append(CR);
+ sb.append(" private java.util.Map addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
private void createTestEmbeddableState() throws Exception {
SourceWriter sourceWriter = new SourceWriter() {
public void appendSourceTo(StringBuilder sb) {
@@ -104,9 +150,9 @@ public class GenericOrmOneToManyMapping2_0Tests
sb.append("public class ").append("State").append(" ");
sb.append("{").append(CR);
sb.append(CR);
- sb.append(" private String foo;").append(CR);
+ sb.append(" private String name;").append(CR);
sb.append(CR);
- sb.append(" private Address address;").append(CR);
+ sb.append(" private String abbr;").append(CR);
sb.append(CR);
sb.append("}").append(CR);
}
@@ -135,8 +181,8 @@ public class GenericOrmOneToManyMapping2_0Tests
assertEquals("id", attributeNames.next());
assertEquals("city", attributeNames.next());
assertEquals("state", attributeNames.next());
- assertEquals("state.foo", attributeNames.next());
- assertEquals("state.address", attributeNames.next());
+ assertEquals("state.name", attributeNames.next());
+ assertEquals("state.abbr", attributeNames.next());
assertEquals("zip", attributeNames.next());
assertFalse(attributeNames.hasNext());
@@ -151,13 +197,13 @@ public class GenericOrmOneToManyMapping2_0Tests
assertEquals("id", attributeNames.next());
assertEquals("city", attributeNames.next());
assertEquals("state", attributeNames.next());
- assertEquals("state.foo", attributeNames.next());
- assertEquals("state.address", attributeNames.next());
+ assertEquals("state.name", attributeNames.next());
+ assertEquals("state.abbr", attributeNames.next());
assertEquals("zip", attributeNames.next());
assertFalse(attributeNames.hasNext());
- AttributeMapping stateFooMapping = oneToManyMapping.getResolvedTargetEntity().resolveAttributeMapping("state.foo");
- assertEquals("foo", stateFooMapping.getName());
+ AttributeMapping stateFooMapping = oneToManyMapping.getResolvedTargetEntity().resolveAttributeMapping("state.name");
+ assertEquals("name", stateFooMapping.getName());
}
private OrmOrphanRemovable2_0 getOrphanRemovalOf(OneToManyMapping2_0 oneToManyMapping) {
@@ -202,5 +248,229 @@ public class GenericOrmOneToManyMapping2_0Tests
mappingsOrphanRemoval.setSpecifiedOrphanRemoval(Boolean.FALSE);
assertEquals(Boolean.FALSE, oneToManyResource.getOrphanRemoval());
assertEquals(Boolean.FALSE, mappingsOrphanRemoval.getSpecifiedOrphanRemoval());
+ }
+
+ public void testUpdateMapKey() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
+ OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping();
+ XmlOneToMany oneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0);
+
+ assertNull(ormOneToManyMapping.getSpecifiedMapKey());
+ assertNull(oneToMany.getMapKey());
+
+ //set mapKey in the resource model, verify context model does not change
+ oneToMany.setMapKey(OrmFactory.eINSTANCE.createMapKey());
+ assertNull(ormOneToManyMapping.getSpecifiedMapKey());
+ assertNotNull(oneToMany.getMapKey());
+
+ //set mapKey name in the resource model, verify context model updated
+ oneToMany.getMapKey().setName("myMapKey");
+ assertEquals("myMapKey", ormOneToManyMapping.getSpecifiedMapKey());
+ assertEquals("myMapKey", oneToMany.getMapKey().getName());
+
+ //set mapKey name to null in the resource model
+ oneToMany.getMapKey().setName(null);
+ assertNull(ormOneToManyMapping.getSpecifiedMapKey());
+ assertNull(oneToMany.getMapKey().getName());
+
+ oneToMany.getMapKey().setName("myMapKey");
+ oneToMany.setMapKey(null);
+ assertNull(ormOneToManyMapping.getSpecifiedMapKey());
+ assertNull(oneToMany.getMapKey());
+ }
+
+ public void testUpdateVirtualMapKey() throws Exception {
+ createTestEntityWithValidMapOneToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ JavaOneToManyMapping javaOneToManyMapping = (JavaOneToManyMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+ assertNull(ormOneToManyMapping.getSpecifiedMapKey());
+ assertNull(ormOneToManyMapping.getMapKey());
+ assertFalse(ormOneToManyMapping.isPkMapKey());
+ assertFalse(ormOneToManyMapping.isCustomMapKey());
+ assertTrue(ormOneToManyMapping.isNoMapKey());
+
+ //set pk mapKey in the java, verify virtual orm mapping updates
+ javaOneToManyMapping.setPkMapKey(true);
+ assertEquals("id", ormOneToManyMapping.getMapKey());
+ assertTrue(ormOneToManyMapping.isPkMapKey());
+ assertFalse(ormOneToManyMapping.isCustomMapKey());
+ assertFalse(ormOneToManyMapping.isNoMapKey());
+
+
+ //set custom specified mapKey in the java, verify virtual orm mapping updates
+ javaOneToManyMapping.setCustomMapKey(true);
+ javaOneToManyMapping.setSpecifiedMapKey("city");
+ assertEquals("city", ormOneToManyMapping.getSpecifiedMapKey());
+ assertEquals("city", ormOneToManyMapping.getMapKey());
+ assertFalse(ormOneToManyMapping.isPkMapKey());
+ assertTrue(ormOneToManyMapping.isCustomMapKey());
+ assertFalse(ormOneToManyMapping.isNoMapKey());
+ }
+
+ public void testModifyMapKey() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
+ OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping();
+ XmlOneToMany oneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0);
+
+ assertNull(ormOneToManyMapping.getSpecifiedMapKey());
+ assertNull(oneToMany.getMapKey());
+
+ //set mapKey in the context model, verify resource model updated
+ ormOneToManyMapping.setSpecifiedMapKey("myMapKey");
+ assertEquals("myMapKey", ormOneToManyMapping.getSpecifiedMapKey());
+ assertEquals("myMapKey", oneToMany.getMapKey().getName());
+
+ //set mapKey to null in the context model
+ ormOneToManyMapping.setSpecifiedMapKey(null);
+ assertNull(ormOneToManyMapping.getSpecifiedMapKey());
+ assertNull(oneToMany.getMapKey());
+ }
+
+ public void testCandidateMapKeyNames() throws Exception {
+ createTestEntityWithValidMapOneToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+
+ Iterator<String> mapKeyNames =
+ ormOneToManyMapping.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.name", mapKeyNames.next());
+ assertEquals("state.abbr", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+ }
+
+ public void testCandidateMapKeyNames2() throws Exception {
+ createTestEntityWithValidNonGenericMapOneToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ JavaOneToManyMapping javaOneToManyMapping = (JavaOneToManyMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+
+ Iterator<String> mapKeyNames = ormOneToManyMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+
+ javaOneToManyMapping.setSpecifiedTargetEntity("test.Address");
+ mapKeyNames = ormOneToManyMapping.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.name", mapKeyNames.next());
+ assertEquals("state.abbr", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+
+ ormOneToManyMapping.getPersistentAttribute().makeSpecified();
+ ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ mapKeyNames = ormOneToManyMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+
+ ormOneToManyMapping.setSpecifiedTargetEntity("test.Address");
+ mapKeyNames = ormOneToManyMapping.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.name", mapKeyNames.next());
+ assertEquals("state.abbr", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+
+ ormOneToManyMapping.setSpecifiedTargetEntity("String");
+ mapKeyNames = ormOneToManyMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+ }
+
+ public void testUpdateMapKeyClass() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
+ OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping();
+ XmlOneToMany oneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0);
+
+ assertNull(ormOneToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(oneToMany.getMapKeyClass());
+
+ //set mapKey in the resource model, verify context model does not change
+ oneToMany.setMapKeyClass(OrmFactory.eINSTANCE.createXmlMapKeyClass());
+ assertNull(ormOneToManyMapping.getSpecifiedMapKeyClass());
+ assertNotNull(oneToMany.getMapKeyClass());
+
+ //set mapKey name in the resource model, verify context model updated
+ oneToMany.getMapKeyClass().setClassName("String");
+ assertEquals("String", ormOneToManyMapping.getSpecifiedMapKeyClass());
+ assertEquals("String", oneToMany.getMapKeyClass().getClassName());
+
+ //set mapKey name to null in the resource model
+ oneToMany.getMapKeyClass().setClassName(null);
+ assertNull(ormOneToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(oneToMany.getMapKeyClass().getClassName());
+
+ oneToMany.getMapKeyClass().setClassName("String");
+ oneToMany.setMapKeyClass(null);
+ assertNull(ormOneToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(oneToMany.getMapKeyClass());
+ }
+
+ public void testUpdateVirtualMapKeyClass() throws Exception {
+ createTestEntityWithValidMapOneToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ JavaOneToManyMapping javaOneToManyMapping = (JavaOneToManyMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+ assertEquals("java.lang.String", ormOneToManyMapping.getMapKeyClass());
+ assertEquals(null, ormOneToManyMapping.getSpecifiedMapKeyClass());
+ assertEquals("java.lang.String", ormOneToManyMapping.getDefaultMapKeyClass());
+
+ //set pk mapKey in the java, verify virtual orm mapping updates
+ javaOneToManyMapping.setSpecifiedMapKeyClass("Integer");
+ assertEquals("Integer", ormOneToManyMapping.getMapKeyClass());
+ assertEquals("Integer", ormOneToManyMapping.getSpecifiedMapKeyClass());
+ assertEquals("java.lang.String", ormOneToManyMapping.getDefaultMapKeyClass());
+ }
+
+ public void testModifyMapKeyClass() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
+ OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping();
+ XmlOneToMany oneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0);
+
+ assertNull(ormOneToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(oneToMany.getMapKeyClass());
+
+ //set mapKey in the context model, verify resource model updated
+ ormOneToManyMapping.setSpecifiedMapKeyClass("String");
+ assertEquals("String", ormOneToManyMapping.getSpecifiedMapKeyClass());
+ assertEquals("String", oneToMany.getMapKeyClass().getClassName());
+
+ //set mapKey to null in the context model
+ ormOneToManyMapping.setSpecifiedMapKeyClass(null);
+ assertNull(ormOneToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(oneToMany.getMapKeyClass());
}
}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmOneToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmOneToManyMappingTests.java
index bd7900baf7..6fa2b76306 100644
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmOneToManyMappingTests.java
+++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmOneToManyMappingTests.java
@@ -9,7 +9,10 @@
*******************************************************************************/
package org.eclipse.jpt.eclipselink.core.tests.internal.context.orm;
+import java.util.Iterator;
+import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.core.MappingKeys;
+import org.eclipse.jpt.core.context.java.JavaOneToManyMapping;
import org.eclipse.jpt.core.context.orm.OrmJoinTable;
import org.eclipse.jpt.core.context.orm.OrmOneToManyMapping;
import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
@@ -23,6 +26,7 @@ import org.eclipse.jpt.eclipselink.core.internal.context.orm.OrmEclipseLinkOneTo
import org.eclipse.jpt.eclipselink.core.resource.orm.XmlEntity;
import org.eclipse.jpt.eclipselink.core.resource.orm.XmlJoinFetchType;
import org.eclipse.jpt.eclipselink.core.resource.orm.XmlOneToMany;
+import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
@SuppressWarnings("nls")
public class EclipseLinkOrmOneToManyMappingTests
@@ -84,7 +88,106 @@ public class EclipseLinkOrmOneToManyMappingTests
this.javaProject.createCompilationUnit(PACKAGE_NAME, "Employee.java", sourceWriter);
}
+ private void createTestTargetEntityAddress() throws Exception {
+ SourceWriter sourceWriter = new SourceWriter() {
+ public void appendSourceTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append("import ");
+ sb.append(JPA.ENTITY);
+ sb.append(";");
+ sb.append(CR);
+ sb.append("import ");
+ sb.append(JPA.ID);
+ sb.append(";");
+ sb.append(CR);
+ sb.append(CR);
+ sb.append("@Entity");
+ sb.append(CR);
+ sb.append("public class ").append("Address").append(" ");
+ sb.append("{").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ sb.append(" private int id;").append(CR);
+ sb.append(CR);
+ sb.append(" private String city;").append(CR);
+ sb.append(CR);
+ sb.append(" private State state;").append(CR);
+ sb.append(CR);
+ sb.append(" private int zip;").append(CR);
+ sb.append(CR);
+ sb.append("}").append(CR);
+ }
+ };
+ this.javaProject.createCompilationUnit(PACKAGE_NAME, "Address.java", sourceWriter);
+ }
+
+ private ICompilationUnit createTestEntityWithValidMapOneToManyMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @OneToMany").append(CR);
+ sb.append(" private java.util.Map<String, Address> addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
+ private ICompilationUnit createTestEntityWithValidNonGenericMapOneToManyMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @OneToMany").append(CR);
+ sb.append(" private java.util.Map addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+ private void createTestEmbeddableState() 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("State").append(" ");
+ sb.append("{").append(CR);
+ sb.append(CR);
+ sb.append(" private String foo;").append(CR);
+ sb.append(CR);
+ sb.append(" private Address address;").append(CR);
+ sb.append(CR);
+ sb.append("}").append(CR);
+ }
+ };
+ this.javaProject.createCompilationUnit(PACKAGE_NAME, "State.java", sourceWriter);
+ }
+
public void testUpdatePrivateOwned() throws Exception {
OrmPersistentType ormPersistentType =
getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
@@ -305,4 +408,109 @@ public class EclipseLinkOrmOneToManyMappingTests
assertEquals("employees_empId", ormJoinTable.getDefaultInverseJoinColumn().getName());
assertEquals("empId", ormJoinTable.getDefaultInverseJoinColumn().getReferencedColumnName());
}
+
+ public void testUpdateVirtualMapKey() throws Exception {
+ createTestEntityWithValidMapOneToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ JavaOneToManyMapping javaOneToManyMapping = (JavaOneToManyMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+ assertNull(ormOneToManyMapping.getSpecifiedMapKey());
+ assertNull(ormOneToManyMapping.getMapKey());
+ assertFalse(ormOneToManyMapping.isPkMapKey());
+ assertFalse(ormOneToManyMapping.isCustomMapKey());
+ assertTrue(ormOneToManyMapping.isNoMapKey());
+
+ //set pk mapKey in the java, verify virtual orm mapping updates
+ javaOneToManyMapping.setPkMapKey(true);
+ assertEquals("id", ormOneToManyMapping.getMapKey());
+ assertTrue(ormOneToManyMapping.isPkMapKey());
+ assertFalse(ormOneToManyMapping.isCustomMapKey());
+ assertFalse(ormOneToManyMapping.isNoMapKey());
+
+
+ //set custom specified mapKey in the java, verify virtual orm mapping updates
+ javaOneToManyMapping.setCustomMapKey(true);
+ javaOneToManyMapping.setSpecifiedMapKey("city");
+ assertEquals("city", ormOneToManyMapping.getSpecifiedMapKey());
+ assertEquals("city", ormOneToManyMapping.getMapKey());
+ assertFalse(ormOneToManyMapping.isPkMapKey());
+ assertTrue(ormOneToManyMapping.isCustomMapKey());
+ assertFalse(ormOneToManyMapping.isNoMapKey());
+
+ //set metadata complete and verify that the orm model ignores the java annotations
+ ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
+ ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ assertEquals(null, ormOneToManyMapping.getSpecifiedMapKey());
+ assertEquals(null, ormOneToManyMapping.getMapKey());
+ assertFalse(ormOneToManyMapping.isPkMapKey());
+ assertFalse(ormOneToManyMapping.isCustomMapKey());
+ assertTrue(ormOneToManyMapping.isNoMapKey());
+ }
+
+ public void testCandidateMapKeyNames() throws Exception {
+ createTestEntityWithValidMapOneToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmOneToManyMapping oneToManyMapping = (OrmOneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+
+ Iterator<String> mapKeyNames =
+ oneToManyMapping.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+ }
+
+ public void testCandidateMapKeyNames2() throws Exception {
+ createTestEntityWithValidNonGenericMapOneToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ JavaOneToManyMapping javaOneToManyMapping = (JavaOneToManyMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+
+ Iterator<String> mapKeyNames = ormOneToManyMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+
+ javaOneToManyMapping.setSpecifiedTargetEntity("test.Address");
+ mapKeyNames = ormOneToManyMapping.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+
+ ormOneToManyMapping.getPersistentAttribute().makeSpecified();
+ ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ mapKeyNames = ormOneToManyMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+
+ ormOneToManyMapping.setSpecifiedTargetEntity("test.Address");
+ mapKeyNames = ormOneToManyMapping.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+
+ ormOneToManyMapping.setSpecifiedTargetEntity("String");
+ mapKeyNames = ormOneToManyMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+ }
}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaElementCollectionMappingTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaElementCollectionMappingTests.java
new file mode 100644
index 0000000000..7386e83d6b
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaElementCollectionMappingTests.java
@@ -0,0 +1,930 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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.eclipselink2_0.core.tests.internal.context.java;
+
+import java.util.Iterator;
+import java.util.ListIterator;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jpt.core.MappingKeys;
+import org.eclipse.jpt.core.context.BasicMapping;
+import org.eclipse.jpt.core.context.EmbeddedIdMapping;
+import org.eclipse.jpt.core.context.EmbeddedMapping;
+import org.eclipse.jpt.core.context.FetchType;
+import org.eclipse.jpt.core.context.IdMapping;
+import org.eclipse.jpt.core.context.ManyToManyMapping;
+import org.eclipse.jpt.core.context.ManyToOneMapping;
+import org.eclipse.jpt.core.context.OneToManyMapping;
+import org.eclipse.jpt.core.context.PersistentAttribute;
+import org.eclipse.jpt.core.context.TransientMapping;
+import org.eclipse.jpt.core.context.TypeMapping;
+import org.eclipse.jpt.core.context.VersionMapping;
+import org.eclipse.jpt.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.core.context.persistence.ClassRef;
+import org.eclipse.jpt.core.jpa2.context.ElementCollectionMapping2_0;
+import org.eclipse.jpt.core.jpa2.resource.java.ElementCollection2_0Annotation;
+import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0;
+import org.eclipse.jpt.core.jpa2.resource.java.MapKeyClass2_0Annotation;
+import org.eclipse.jpt.core.resource.java.BasicAnnotation;
+import org.eclipse.jpt.core.resource.java.EmbeddedAnnotation;
+import org.eclipse.jpt.core.resource.java.EmbeddedIdAnnotation;
+import org.eclipse.jpt.core.resource.java.IdAnnotation;
+import org.eclipse.jpt.core.resource.java.JPA;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
+import org.eclipse.jpt.core.resource.java.ManyToManyAnnotation;
+import org.eclipse.jpt.core.resource.java.ManyToOneAnnotation;
+import org.eclipse.jpt.core.resource.java.MapKeyAnnotation;
+import org.eclipse.jpt.core.resource.java.OneToManyAnnotation;
+import org.eclipse.jpt.core.resource.java.TransientAnnotation;
+import org.eclipse.jpt.core.resource.java.VersionAnnotation;
+import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
+import org.eclipse.jpt.eclipselink2_0.core.tests.internal.context.EclipseLink2_0ContextModelTestCase;
+import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
+
+@SuppressWarnings("nls")
+public class EclipseLink2_0JavaElementCollectionMappingTests
+ extends EclipseLink2_0ContextModelTestCase
+{
+
+ private ICompilationUnit createTestEntityWithElementCollectionMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append("@ElementCollection").append(CR);
+ }
+ });
+ }
+
+ private ICompilationUnit createTestEntityWithGenericEmbeddableElementCollectionMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @ElementCollection").append(CR);
+ sb.append(" private java.util.Collection<Address> addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
+ private ICompilationUnit createTestEntityWithGenericBasicElementCollectionMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @ElementCollection").append(CR);
+ sb.append(" private java.util.Collection<String> addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
+ private ICompilationUnit createTestEntityWithNonGenericElementCollectionMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @ElementCollection").append(CR);
+ sb.append(" private java.util.Collection addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
+ private ICompilationUnit createTestEntityWithValidGenericMapElementCollectionMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @ElementCollection").append(CR);
+ sb.append(" private java.util.Map<Integer, Address> addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
+ private ICompilationUnit createTestEntityWithValidNonGenericMapElementCollectionMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @ElementCollection").append(CR);
+ sb.append(" private java.util.Map addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
+ private void createTestTargetEmbeddableAddress() 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("import ");
+ sb.append(JPA.ID);
+ sb.append(";");
+ sb.append(CR);
+ sb.append("import ");
+ sb.append(JPA.EMBEDDED);
+ sb.append(";");
+ sb.append(CR);
+ sb.append("@Embeddable");
+ sb.append(CR);
+ sb.append("public class ").append("Address").append(" ");
+ sb.append("{").append(CR);
+ sb.append(CR);
+ sb.append(" private String city;").append(CR);
+ sb.append(CR);
+ sb.append(" @Embedded").append(CR);
+ sb.append(" private State state;").append(CR);
+ sb.append(CR);
+ sb.append(" private int zip;").append(CR);
+ sb.append(CR);
+ sb.append("}").append(CR);
+ }
+ };
+ this.javaProject.createCompilationUnit(PACKAGE_NAME, "Address.java", sourceWriter);
+ }
+
+ private void createTestEmbeddableState() 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("State").append(" ");
+ sb.append("{").append(CR);
+ sb.append(CR);
+ sb.append(" private String name;").append(CR);
+ sb.append(CR);
+ sb.append(" private String abbr;").append(CR);
+ sb.append(CR);
+ sb.append("}").append(CR);
+ }
+ };
+ this.javaProject.createCompilationUnit(PACKAGE_NAME, "State.java", sourceWriter);
+ }
+
+ public EclipseLink2_0JavaElementCollectionMappingTests(String name) {
+ super(name);
+ }
+
+ public void testMorphToBasicMapping() throws Exception {
+ createTestEntityWithElementCollectionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+ assertFalse(elementCollectionMapping.isDefault());
+
+ persistentAttribute.setSpecifiedMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof BasicMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+ assertNull(attributeResource.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(attributeResource.getAnnotation(BasicAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToDefault() throws Exception {
+ createTestEntityWithElementCollectionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+ assertFalse(elementCollectionMapping.isDefault());
+
+ persistentAttribute.setSpecifiedMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
+ assertNull(persistentAttribute.getSpecifiedMapping());
+ assertTrue(persistentAttribute.getMapping().isDefault());
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+ assertNull(attributeResource.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToVersionMapping() throws Exception {
+ createTestEntityWithElementCollectionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+ assertFalse(elementCollectionMapping.isDefault());
+
+ persistentAttribute.setSpecifiedMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof VersionMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+ assertNull(attributeResource.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(attributeResource.getAnnotation(VersionAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToIdMapping() throws Exception {
+ createTestEntityWithElementCollectionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+ assertFalse(elementCollectionMapping.isDefault());
+
+ persistentAttribute.setSpecifiedMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof IdMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+ assertNull(attributeResource.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(attributeResource.getAnnotation(IdAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToEmbeddedMapping() throws Exception {
+ createTestEntityWithElementCollectionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+ assertFalse(elementCollectionMapping.isDefault());
+
+ persistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof EmbeddedMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+ assertNull(attributeResource.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(attributeResource.getAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToEmbeddedIdMapping() throws Exception {
+ createTestEntityWithElementCollectionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+ assertFalse(elementCollectionMapping.isDefault());
+
+ persistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof EmbeddedIdMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+ assertNull(attributeResource.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(attributeResource.getAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToTransientMapping() throws Exception {
+ createTestEntityWithElementCollectionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+ assertFalse(elementCollectionMapping.isDefault());
+
+ persistentAttribute.setSpecifiedMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof TransientMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+ assertNull(attributeResource.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(attributeResource.getAnnotation(TransientAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToManyToOneMapping() throws Exception {
+ createTestEntityWithElementCollectionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+ assertFalse(elementCollectionMapping.isDefault());
+
+ persistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof ManyToOneMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+ assertNull(attributeResource.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(attributeResource.getAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToOneToManyMapping() throws Exception {
+ createTestEntityWithElementCollectionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+ assertFalse(elementCollectionMapping.isDefault());
+
+ persistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof OneToManyMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+ assertNull(attributeResource.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(attributeResource.getAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testMorphToManyToManyMapping() throws Exception {
+ createTestEntityWithElementCollectionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+ assertFalse(elementCollectionMapping.isDefault());
+
+ persistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
+ assertTrue(persistentAttribute.getMapping() instanceof ManyToManyMapping);
+ assertFalse(persistentAttribute.getMapping().isDefault());
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+ assertNull(attributeResource.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
+ assertNotNull(attributeResource.getAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testUpdateSpecifiedTargetEntity() throws Exception {
+ createTestEntityWithElementCollectionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+ ElementCollection2_0Annotation elementCollection = (ElementCollection2_0Annotation) attributeResource.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME);
+
+ assertNull(elementCollectionMapping.getSpecifiedTargetClass());
+ assertNull(elementCollection.getTargetClass());
+
+ //set target class in the resource model, verify context model updated
+ elementCollection.setTargetClass("newTargetClass");
+ assertEquals("newTargetClass", elementCollectionMapping.getSpecifiedTargetClass());
+ assertEquals("newTargetClass", elementCollection.getTargetClass());
+
+ //set target class to null in the resource model
+ elementCollection.setTargetClass(null);
+ assertNull(elementCollectionMapping.getSpecifiedTargetClass());
+ assertNull(elementCollection.getTargetClass());
+ }
+
+ public void testModifySpecifiedTargetClass() throws Exception {
+ createTestEntityWithElementCollectionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+ ElementCollection2_0Annotation elementCollection = (ElementCollection2_0Annotation) attributeResource.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME);
+
+ assertNull(elementCollectionMapping.getSpecifiedTargetClass());
+ assertNull(elementCollection.getTargetClass());
+
+ //set target class in the context model, verify resource model updated
+ elementCollectionMapping.setSpecifiedTargetClass("newTargetClass");
+ assertEquals("newTargetClass", elementCollectionMapping.getSpecifiedTargetClass());
+ assertEquals("newTargetClass", elementCollection.getTargetClass());
+
+ //set target class to null in the context model
+ elementCollectionMapping.setSpecifiedTargetClass(null);
+ assertNull(elementCollectionMapping.getSpecifiedTargetClass());
+ assertNull(elementCollection.getTargetClass());
+ }
+
+ public void testDefaultTargetClass() throws Exception {
+ createTestEntityWithGenericEmbeddableElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ //targetEntity not in the persistence unit, default still set, handled by validation
+ assertEquals(PACKAGE_NAME + ".Address", elementCollectionMapping.getDefaultTargetClass());
+
+ //add targetEntity to the persistence unit
+ addXmlClassRef(PACKAGE_NAME + ".Address");
+ assertEquals(PACKAGE_NAME + ".Address", elementCollectionMapping.getDefaultTargetClass());
+
+ //test default still the same when specified target entity it set
+ elementCollectionMapping.setSpecifiedTargetClass("foo");
+ assertEquals(PACKAGE_NAME + ".Address", elementCollectionMapping.getDefaultTargetClass());
+
+ ListIterator<ClassRef> classRefs = getPersistenceUnit().specifiedClassRefs();
+ classRefs.next();
+ ClassRef addressClassRef = classRefs.next();
+ JavaPersistentType addressPersistentType = addressClassRef.getJavaPersistentType();
+
+ //test target is not an Embeddable, default target entity still exists, this case handled with validation
+ addressPersistentType.setMappingKey(MappingKeys.NULL_TYPE_MAPPING_KEY);
+ assertEquals(PACKAGE_NAME + ".Address", elementCollectionMapping.getDefaultTargetClass());
+ }
+
+ public void testDefaultTargetClassNonGenericCollection() throws Exception {
+ createTestEntityWithNonGenericElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ addXmlClassRef(PACKAGE_NAME + ".Address");
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ assertNull(elementCollectionMapping.getDefaultTargetClass());
+ }
+
+ public void testDefaultTargetClassGenericCollection() throws Exception {
+ createTestEntityWithGenericEmbeddableElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ addXmlClassRef(PACKAGE_NAME + ".Address");
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ assertEquals(PACKAGE_NAME + ".Address", elementCollectionMapping.getDefaultTargetClass());
+ }
+
+ public void testDefaultTargetClassNonGenericMap() throws Exception {
+ createTestEntityWithValidNonGenericMapElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ addXmlClassRef(PACKAGE_NAME + ".Address");
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ assertNull(elementCollectionMapping.getDefaultTargetClass());
+ }
+
+ public void testDefaultTargetClassGenericMap() throws Exception {
+ createTestEntityWithValidGenericMapElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ addXmlClassRef(PACKAGE_NAME + ".Address");
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ assertEquals(PACKAGE_NAME + ".Address", elementCollectionMapping.getDefaultTargetClass());
+ }
+
+ public void testTargetClass() throws Exception {
+ createTestEntityWithGenericEmbeddableElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ assertEquals(PACKAGE_NAME + ".Address", elementCollectionMapping.getTargetClass());
+
+ elementCollectionMapping.setSpecifiedTargetClass("foo");
+ assertEquals("foo", elementCollectionMapping.getTargetClass());
+
+ elementCollectionMapping.setSpecifiedTargetClass(null);
+ assertEquals(PACKAGE_NAME + ".Address", elementCollectionMapping.getTargetClass());
+ }
+
+ public void testResolvedTargetEmbeddable() throws Exception {
+ createTestEntityWithGenericEmbeddableElementCollectionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ //target embeddable not in the persistence unit
+ assertNull(elementCollectionMapping.getResolvedTargetEmbeddable());
+
+ //add target embeddable to the persistence unit, now target embeddable should resolve
+ createTestTargetEmbeddableAddress();
+ addXmlClassRef(PACKAGE_NAME + ".Address");
+ ListIterator<ClassRef> classRefs = getPersistenceUnit().specifiedClassRefs();
+ classRefs.next();
+ ClassRef addressClassRef = classRefs.next();
+ TypeMapping addressTypeMapping = addressClassRef.getJavaPersistentType().getMapping();
+ assertEquals(addressTypeMapping, elementCollectionMapping.getResolvedTargetEmbeddable());
+
+ //test default still the same when specified target entity it set
+ elementCollectionMapping.setSpecifiedTargetClass("foo");
+ assertNull(elementCollectionMapping.getResolvedTargetEmbeddable());
+
+
+ elementCollectionMapping.setSpecifiedTargetClass(PACKAGE_NAME + ".Address");
+ assertEquals(addressTypeMapping, elementCollectionMapping.getResolvedTargetEmbeddable());
+
+
+ elementCollectionMapping.setSpecifiedTargetClass(null);
+ assertEquals(addressTypeMapping, elementCollectionMapping.getResolvedTargetEmbeddable());
+ }
+
+ public void testResolvedTargetEmbeddableWithBasicType() throws Exception {
+ createTestEntityWithGenericBasicElementCollectionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ //target is a basic type, so resolved target embeddable is null
+ assertNull(elementCollectionMapping.getResolvedTargetEmbeddable());
+ }
+
+ public void testUpdateSpecifiedFetch() throws Exception {
+ createTestEntityWithElementCollectionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+ ElementCollection2_0Annotation elementCollection = (ElementCollection2_0Annotation) attributeResource.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME);
+
+ assertNull(elementCollectionMapping.getSpecifiedFetch());
+ assertNull(elementCollection.getFetch());
+
+ //set fetch in the resource model, verify context model updated
+ elementCollection.setFetch(org.eclipse.jpt.core.resource.java.FetchType.EAGER);
+ getJpaProject().synchronizeContextModel();
+
+ assertEquals(FetchType.EAGER, elementCollectionMapping.getSpecifiedFetch());
+ assertEquals(org.eclipse.jpt.core.resource.java.FetchType.EAGER, elementCollection.getFetch());
+
+ elementCollection.setFetch(org.eclipse.jpt.core.resource.java.FetchType.LAZY);
+ getJpaProject().synchronizeContextModel();
+
+ assertEquals(FetchType.LAZY, elementCollectionMapping.getSpecifiedFetch());
+ assertEquals(org.eclipse.jpt.core.resource.java.FetchType.LAZY, elementCollection.getFetch());
+
+ //set fetch to null in the resource model
+ elementCollection.setFetch(null);
+ getJpaProject().synchronizeContextModel();
+
+ assertNull(elementCollectionMapping.getSpecifiedFetch());
+ assertNull(elementCollection.getFetch());
+ }
+
+ public void testModifySpecifiedFetch() throws Exception {
+ createTestEntityWithElementCollectionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+ ElementCollection2_0Annotation elementCollection = (ElementCollection2_0Annotation) attributeResource.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME);
+
+ assertNull(elementCollectionMapping.getSpecifiedFetch());
+ assertNull(elementCollection.getFetch());
+
+ //set fetch in the context model, verify resource model updated
+ elementCollectionMapping.setSpecifiedFetch(FetchType.EAGER);
+ assertEquals(FetchType.EAGER, elementCollectionMapping.getSpecifiedFetch());
+ assertEquals(org.eclipse.jpt.core.resource.java.FetchType.EAGER, elementCollection.getFetch());
+
+ elementCollectionMapping.setSpecifiedFetch(FetchType.LAZY);
+ assertEquals(FetchType.LAZY, elementCollectionMapping.getSpecifiedFetch());
+ assertEquals(org.eclipse.jpt.core.resource.java.FetchType.LAZY, elementCollection.getFetch());
+
+ //set fetch to null in the context model
+ elementCollectionMapping.setSpecifiedFetch(null);
+ assertNull(elementCollectionMapping.getSpecifiedFetch());
+ assertNull(elementCollection.getFetch());
+ }
+
+ public void testGetValueTypeEmbeddable() throws Exception {
+ createTestEntityWithGenericEmbeddableElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ assertEquals(ElementCollectionMapping2_0.Type.EMBEDDABLE_TYPE, elementCollectionMapping.getValueType());
+ }
+
+ public void testGetValueTypeNone() throws Exception {
+ createTestEntityWithNonGenericElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ assertEquals(ElementCollectionMapping2_0.Type.NO_TYPE, elementCollectionMapping.getValueType());
+
+ elementCollectionMapping.setSpecifiedTargetClass("Address");
+ assertEquals(ElementCollectionMapping2_0.Type.EMBEDDABLE_TYPE, elementCollectionMapping.getValueType());
+ }
+
+ public void testGetValueTypeBasic() throws Exception {
+ createTestEntityWithGenericBasicElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ assertEquals(ElementCollectionMapping2_0.Type.BASIC_TYPE, elementCollectionMapping.getValueType());
+ }
+
+ public void testUpdateMapKey() throws Exception {
+ createTestEntityWithElementCollectionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+
+ assertNull(elementCollectionMapping.getSpecifiedMapKey());
+ assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
+
+ //set mapKey in the resource model, verify context model does not change
+ attributeResource.addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ getJpaProject().synchronizeContextModel();
+
+ assertNull(elementCollectionMapping.getSpecifiedMapKey());
+ MapKeyAnnotation mapKey = (MapKeyAnnotation) attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ assertNotNull(mapKey);
+
+ //set mapKey name in the resource model, verify context model updated
+ mapKey.setName("myMapKey");
+ getJpaProject().synchronizeContextModel();
+
+ assertEquals("myMapKey", elementCollectionMapping.getSpecifiedMapKey());
+ assertEquals("myMapKey", mapKey.getName());
+
+ //set mapKey name to null in the resource model
+ mapKey.setName(null);
+ getJpaProject().synchronizeContextModel();
+ assertNull(elementCollectionMapping.getSpecifiedMapKey());
+ assertNull(mapKey.getName());
+
+ mapKey.setName("myMapKey");
+ attributeResource.removeAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ assertNull(elementCollectionMapping.getSpecifiedMapKey());
+ assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testModifyMapKey() throws Exception {
+ createTestEntityWithElementCollectionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+
+ assertNull(elementCollectionMapping.getSpecifiedMapKey());
+ assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
+
+ //set mapKey in the context model, verify resource model updated
+ elementCollectionMapping.setSpecifiedMapKey("myMapKey");
+ MapKeyAnnotation mapKey = (MapKeyAnnotation) attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ assertEquals("myMapKey", elementCollectionMapping.getSpecifiedMapKey());
+ assertEquals("myMapKey", mapKey.getName());
+
+ //set mapKey to null in the context model
+ elementCollectionMapping.setSpecifiedMapKey(null);
+ assertNull(elementCollectionMapping.getSpecifiedMapKey());
+ assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testCandidateMapKeyNames() throws Exception {
+ createTestEntityWithValidGenericMapElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+ createTestEmbeddableState();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ addXmlClassRef(PACKAGE_NAME + ".Address");
+ addXmlClassRef(PACKAGE_NAME + ".State");
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping2_0 = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ Iterator<String> mapKeyNames =
+ elementCollectionMapping2_0.candidateMapKeyNames();
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.name", mapKeyNames.next());
+ assertEquals("state.abbr", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+ }
+
+ public void testCandidateMapKeyNames2() throws Exception {
+ createTestEntityWithValidNonGenericMapElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+ createTestEmbeddableState();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ addXmlClassRef(PACKAGE_NAME + ".Address");
+ addXmlClassRef(PACKAGE_NAME + ".State");
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping2_0 = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ Iterator<String> mapKeyNames = elementCollectionMapping2_0.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+
+ elementCollectionMapping2_0.setSpecifiedTargetClass("Address");
+ mapKeyNames = elementCollectionMapping2_0.candidateMapKeyNames();
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.name", mapKeyNames.next());
+ assertEquals("state.abbr", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+
+ elementCollectionMapping2_0.setSpecifiedTargetClass("String");
+ mapKeyNames = elementCollectionMapping2_0.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+ }
+
+ public void testUpdateMapKeyClass() throws Exception {
+ createTestEntityWithElementCollectionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+
+ assertNull(elementCollectionMapping.getSpecifiedMapKeyClass());
+ assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
+
+ //set mapKey in the resource model, verify context model does not change
+ attributeResource.addAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ assertNull(elementCollectionMapping.getSpecifiedMapKeyClass());
+ MapKeyClass2_0Annotation mapKeyClass = (MapKeyClass2_0Annotation) attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ assertNotNull(mapKeyClass);
+
+ //set mapKey name in the resource model, verify context model updated
+ mapKeyClass.setValue("myMapKeyClass");
+ assertEquals("myMapKeyClass", elementCollectionMapping.getSpecifiedMapKeyClass());
+ assertEquals("myMapKeyClass", mapKeyClass.getValue());
+
+ //set mapKey name to null in the resource model
+ mapKeyClass.setValue(null);
+ getJpaProject().synchronizeContextModel();
+
+ assertNull(elementCollectionMapping.getSpecifiedMapKeyClass());
+ assertNull(mapKeyClass.getValue());
+
+ mapKeyClass.setValue("myMapKeyClass");
+ attributeResource.removeAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ getJpaProject().synchronizeContextModel();
+
+ assertNull(elementCollectionMapping.getSpecifiedMapKeyClass());
+ assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testModifyMapKeyClass() throws Exception {
+ createTestEntityWithElementCollectionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+
+ assertNull(elementCollectionMapping.getSpecifiedMapKeyClass());
+ assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
+
+ //set mapKey in the context model, verify resource model updated
+ elementCollectionMapping.setSpecifiedMapKeyClass("String");
+ MapKeyClass2_0Annotation mapKeyClass = (MapKeyClass2_0Annotation) attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ assertEquals("String", elementCollectionMapping.getSpecifiedMapKeyClass());
+ assertEquals("String", mapKeyClass.getValue());
+
+ //set mapKey to null in the context model
+ elementCollectionMapping.setSpecifiedMapKeyClass(null);
+ assertNull(elementCollectionMapping.getSpecifiedMapKeyClass());
+ assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testDefaultMapKeyClass() throws Exception {
+ createTestEntityWithValidGenericMapElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+ createTestEmbeddableState();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ assertEquals("java.lang.Integer", elementCollectionMapping.getDefaultMapKeyClass());
+
+ //test default still the same when specified target entity it set
+ elementCollectionMapping.setSpecifiedMapKeyClass("foo");
+ assertEquals("java.lang.Integer", elementCollectionMapping.getDefaultMapKeyClass());
+ }
+
+ public void testDefaultMapKeyClassCollectionType() throws Exception {
+ createTestEntityWithGenericBasicElementCollectionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ assertNull(elementCollectionMapping.getDefaultMapKeyClass());
+ }
+
+ public void testMapKeyClass() throws Exception {
+ createTestEntityWithValidGenericMapElementCollectionMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
+
+ assertEquals("java.lang.Integer", elementCollectionMapping.getMapKeyClass());
+
+ elementCollectionMapping.setSpecifiedMapKeyClass("foo");
+ assertEquals("foo", elementCollectionMapping.getMapKeyClass());
+
+ elementCollectionMapping.setSpecifiedMapKeyClass(null);
+ assertEquals("java.lang.Integer", elementCollectionMapping.getMapKeyClass());
+ }
+}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaManyToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaManyToManyMappingTests.java
new file mode 100644
index 0000000000..df82f19223
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaManyToManyMappingTests.java
@@ -0,0 +1,537 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.eclipselink2_0.core.tests.internal.context.java;
+
+import java.util.Iterator;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jpt.core.context.AttributeMapping;
+import org.eclipse.jpt.core.context.ManyToManyMapping;
+import org.eclipse.jpt.core.context.PersistentAttribute;
+import org.eclipse.jpt.core.jpa2.resource.java.MapKeyClass2_0Annotation;
+import org.eclipse.jpt.core.resource.java.JPA;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
+import org.eclipse.jpt.core.resource.java.MapKeyAnnotation;
+import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
+import org.eclipse.jpt.eclipselink.core.context.EclipseLinkJoinFetch;
+import org.eclipse.jpt.eclipselink.core.context.EclipseLinkJoinFetchType;
+import org.eclipse.jpt.eclipselink.core.context.EclipseLinkRelationshipMapping;
+import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLink;
+import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJoinFetchAnnotation;
+import org.eclipse.jpt.eclipselink2_0.core.tests.internal.context.EclipseLink2_0ContextModelTestCase;
+import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
+
+@SuppressWarnings("nls")
+public class EclipseLink2_0JavaManyToManyMappingTests
+ extends EclipseLink2_0ContextModelTestCase
+{
+ public EclipseLink2_0JavaManyToManyMappingTests(String name) {
+ super(name);
+ }
+
+ private ICompilationUnit createTestEntityWithJoinFetchManyToMany() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, EclipseLink.JOIN_FETCH);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append("@ManyToMany").append(CR);
+ sb.append("@JoinFetch").append(CR);
+ }
+ });
+ }
+
+ private ICompilationUnit createTestEntityWithValidManyToManyMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, JPA.ID, "java.util.Collection");
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @ManyToMany").append(CR);
+ sb.append(" private Collection<Address> addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
+ private ICompilationUnit createTestEntityWithValidGenericMapManyToManyMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @ManyToMany").append(CR);
+ sb.append(" private java.util.Map<Integer, Address> addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
+ private ICompilationUnit createTestEntityWithValidNonGenericMapManyToManyMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @ManyToMany").append(CR);
+ sb.append(" private java.util.Map addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
+ private void createTestTargetEntityAddress() throws Exception {
+ SourceWriter sourceWriter = new SourceWriter() {
+ public void appendSourceTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append("import ");
+ sb.append(JPA.ENTITY);
+ sb.append(";");
+ sb.append(CR);
+ sb.append("import ");
+ sb.append(JPA.ID);
+ sb.append(";");
+ sb.append(CR);
+ sb.append("import ");
+ sb.append(JPA.EMBEDDED);
+ sb.append(";");
+ sb.append(CR);
+ sb.append("@Entity");
+ sb.append(CR);
+ sb.append("public class ").append("Address").append(" ");
+ sb.append("{").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ sb.append(" private int id;").append(CR);
+ sb.append(CR);
+ sb.append(" private String city;").append(CR);
+ sb.append(CR);
+ sb.append(" @Embedded").append(CR);
+ sb.append(" private State state;").append(CR);
+ sb.append(CR);
+ sb.append(" private int zip;").append(CR);
+ sb.append(CR);
+ sb.append("}").append(CR);
+ }
+ };
+ this.javaProject.createCompilationUnit(PACKAGE_NAME, "Address.java", sourceWriter);
+ }
+
+ private void createTestEmbeddableState() 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("State").append(" ");
+ sb.append("{").append(CR);
+ sb.append(CR);
+ sb.append(" private String foo;").append(CR);
+ sb.append(CR);
+ sb.append(" private Address address;").append(CR);
+ sb.append(CR);
+ sb.append("}").append(CR);
+ }
+ };
+ this.javaProject.createCompilationUnit(PACKAGE_NAME, "State.java", sourceWriter);
+ }
+
+ public void testGetJoinFetchValue() throws Exception {
+ createTestEntityWithJoinFetchManyToMany();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ EclipseLinkRelationshipMapping manyToManyMapping = (EclipseLinkRelationshipMapping) persistentAttribute.getSpecifiedMapping();
+ EclipseLinkJoinFetch contextJoinFetch = manyToManyMapping.getJoinFetch();
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+ EclipseLinkJoinFetchAnnotation joinFetchAnnotation = (EclipseLinkJoinFetchAnnotation) attributeResource.getAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME);
+
+ // base annotated, test context value
+
+ assertNull(joinFetchAnnotation.getValue());
+ assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
+
+ // change resource to INNER specifically, test context
+
+ joinFetchAnnotation.setValue(org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchType.INNER);
+
+ assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchType.INNER, joinFetchAnnotation.getValue());
+ assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
+
+ // change resource to OUTER, test context
+
+ joinFetchAnnotation.setValue(org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchType.OUTER);
+ getJpaProject().synchronizeContextModel();
+
+ assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchType.OUTER, joinFetchAnnotation.getValue());
+ assertEquals(EclipseLinkJoinFetchType.OUTER, contextJoinFetch.getValue());
+
+ // remove value from resource, test context
+
+ joinFetchAnnotation.setValue(null);
+ getJpaProject().synchronizeContextModel();
+
+ assertNull(joinFetchAnnotation.getValue());
+ assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
+
+ // remove annotation, text context
+
+ attributeResource.removeAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME);
+ getJpaProject().synchronizeContextModel();
+
+ assertNull(joinFetchAnnotation.getValue());
+ assertNull(contextJoinFetch.getValue());
+ }
+
+ public void testSetJoinFetchValue() throws Exception {
+ createTestEntityWithJoinFetchManyToMany();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ EclipseLinkRelationshipMapping manyToManyMapping = (EclipseLinkRelationshipMapping) persistentAttribute.getSpecifiedMapping();
+ EclipseLinkJoinFetch contextJoinFetch = manyToManyMapping.getJoinFetch();
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+ EclipseLinkJoinFetchAnnotation joinFetchAnnotation = (EclipseLinkJoinFetchAnnotation) attributeResource.getAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME);
+
+ // base annotated, test resource value
+
+ assertNull(joinFetchAnnotation.getValue());
+ assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
+
+ // change context to INNER specifically, test resource
+
+ contextJoinFetch.setValue(EclipseLinkJoinFetchType.INNER);
+
+ assertNull(joinFetchAnnotation.getValue());
+ assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
+
+ // change context to OUTER, test resource
+
+ contextJoinFetch.setValue(EclipseLinkJoinFetchType.OUTER);
+
+ assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchType.OUTER, joinFetchAnnotation.getValue());
+ assertEquals(EclipseLinkJoinFetchType.OUTER, contextJoinFetch.getValue());
+
+ // set context to null, test resource
+
+ contextJoinFetch.setValue(null);
+
+ assertNull(attributeResource.getAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME));
+ assertNull(contextJoinFetch.getValue());
+
+ // change context to INNER specifically (this time from no annotation), test resource
+
+ contextJoinFetch.setValue(EclipseLinkJoinFetchType.INNER);
+ joinFetchAnnotation = (EclipseLinkJoinFetchAnnotation) attributeResource.getAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME);
+
+ assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchType.INNER, joinFetchAnnotation.getValue());
+ assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
+ }
+ public void testCandidateMappedByAttributeNames() throws Exception {
+ createTestEntityWithValidManyToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ addXmlClassRef(PACKAGE_NAME + ".Address");
+ addXmlClassRef(PACKAGE_NAME + ".State");
+
+ PersistentAttribute persistentAttribute = (getJavaPersistentType()).attributes().next();
+ ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
+
+ Iterator<String> attributeNames =
+ manyToManyMapping.getRelationshipReference().getMappedByJoiningStrategy().candidateMappedByAttributeNames();
+ assertEquals("id", attributeNames.next());
+ assertEquals("city", attributeNames.next());
+ assertEquals("state", attributeNames.next());
+ assertEquals("state.foo", attributeNames.next());
+ assertEquals("state.address", attributeNames.next());
+ assertEquals("zip", attributeNames.next());
+ assertFalse(attributeNames.hasNext());
+
+ manyToManyMapping.setSpecifiedTargetEntity("foo");
+ attributeNames =
+ manyToManyMapping.getRelationshipReference().getMappedByJoiningStrategy().candidateMappedByAttributeNames();
+ assertFalse(attributeNames.hasNext());
+
+ manyToManyMapping.setSpecifiedTargetEntity(null);
+ attributeNames =
+ manyToManyMapping.getRelationshipReference().getMappedByJoiningStrategy().candidateMappedByAttributeNames();
+ assertEquals("id", attributeNames.next());
+ assertEquals("city", attributeNames.next());
+ assertEquals("state", attributeNames.next());
+ assertEquals("state.foo", attributeNames.next());
+ assertEquals("state.address", attributeNames.next());
+ assertEquals("zip", attributeNames.next());
+ assertFalse(attributeNames.hasNext());
+
+ AttributeMapping stateFooMapping = manyToManyMapping.getResolvedTargetEntity().resolveAttributeMapping("state.foo");
+ assertEquals("foo", stateFooMapping.getName());
+ }
+
+ public void testUpdateMapKey() throws Exception {
+ createTestEntityWithValidManyToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+
+ assertNull(manyToManyMapping.getSpecifiedMapKey());
+ assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
+
+ //set mapKey in the resource model, verify context model does not change
+ attributeResource.addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ assertNull(manyToManyMapping.getSpecifiedMapKey());
+ MapKeyAnnotation mapKey = (MapKeyAnnotation) attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ assertNotNull(mapKey);
+
+ //set mapKey name in the resource model, verify context model updated
+ mapKey.setName("myMapKey");
+ getJpaProject().synchronizeContextModel();
+
+ assertEquals("myMapKey", manyToManyMapping.getSpecifiedMapKey());
+ assertEquals("myMapKey", mapKey.getName());
+
+ //set mapKey name to null in the resource model
+ mapKey.setName(null);
+ getJpaProject().synchronizeContextModel();
+
+ assertNull(manyToManyMapping.getSpecifiedMapKey());
+ assertNull(mapKey.getName());
+
+ mapKey.setName("myMapKey");
+ attributeResource.removeAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ assertNull(manyToManyMapping.getSpecifiedMapKey());
+ assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testModifyMapKey() throws Exception {
+ createTestEntityWithValidManyToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+
+ assertNull(manyToManyMapping.getSpecifiedMapKey());
+ assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
+
+ //set mapKey in the context model, verify resource model updated
+ manyToManyMapping.setSpecifiedMapKey("myMapKey");
+ MapKeyAnnotation mapKey = (MapKeyAnnotation) attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ assertEquals("myMapKey", manyToManyMapping.getSpecifiedMapKey());
+ assertEquals("myMapKey", mapKey.getName());
+
+ //set mapKey to null in the context model
+ manyToManyMapping.setSpecifiedMapKey(null);
+ assertNull(manyToManyMapping.getSpecifiedMapKey());
+ assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testCandidateMapKeyNames() throws Exception {
+ createTestEntityWithValidGenericMapManyToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ addXmlClassRef(PACKAGE_NAME + ".Address");
+ addXmlClassRef(PACKAGE_NAME + ".State");
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ManyToManyMapping manyToManyMapping2_0 = (ManyToManyMapping) persistentAttribute.getMapping();
+
+ Iterator<String> mapKeyNames =
+ manyToManyMapping2_0.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.foo", mapKeyNames.next());
+ assertEquals("state.address", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+ }
+
+ public void testCandidateMapKeyNames2() throws Exception {
+ createTestEntityWithValidNonGenericMapManyToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ addXmlClassRef(PACKAGE_NAME + ".Address");
+ addXmlClassRef(PACKAGE_NAME + ".State");
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ManyToManyMapping manyToManyMapping2_0 = (ManyToManyMapping) persistentAttribute.getMapping();
+
+ Iterator<String> mapKeyNames = manyToManyMapping2_0.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+
+ manyToManyMapping2_0.setSpecifiedTargetEntity("Address");
+ mapKeyNames = manyToManyMapping2_0.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.foo", mapKeyNames.next());
+ assertEquals("state.address", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+
+ manyToManyMapping2_0.setSpecifiedTargetEntity("String");
+ mapKeyNames = manyToManyMapping2_0.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+ }
+
+ public void testUpdateMapKeyClass() throws Exception {
+ createTestEntityWithValidManyToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+
+ assertNull(manyToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
+
+ //set mapKey in the resource model, verify context model does not change
+ attributeResource.addAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ assertNull(manyToManyMapping.getSpecifiedMapKeyClass());
+ MapKeyClass2_0Annotation mapKeyClass = (MapKeyClass2_0Annotation) attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ assertNotNull(mapKeyClass);
+
+ //set mapKey name in the resource model, verify context model updated
+ mapKeyClass.setValue("myMapKeyClass");
+ assertEquals("myMapKeyClass", manyToManyMapping.getSpecifiedMapKeyClass());
+ assertEquals("myMapKeyClass", mapKeyClass.getValue());
+
+ //set mapKey name to null in the resource model
+ mapKeyClass.setValue(null);
+ assertNull(manyToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(mapKeyClass.getValue());
+
+ mapKeyClass.setValue("myMapKeyClass");
+ attributeResource.removeAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ getJpaProject().synchronizeContextModel();
+
+ assertNull(manyToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testModifyMapKeyClass() throws Exception {
+ createTestEntityWithValidManyToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+
+ assertNull(manyToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
+
+ //set mapKey in the context model, verify resource model updated
+ manyToManyMapping.setSpecifiedMapKeyClass("String");
+ MapKeyClass2_0Annotation mapKeyClass = (MapKeyClass2_0Annotation) attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ assertEquals("String", manyToManyMapping.getSpecifiedMapKeyClass());
+ assertEquals("String", mapKeyClass.getValue());
+
+ //set mapKey to null in the context model
+ manyToManyMapping.setSpecifiedMapKeyClass(null);
+ assertNull(manyToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testDefaultMapKeyClass() throws Exception {
+ createTestEntityWithValidGenericMapManyToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
+
+ assertEquals("java.lang.Integer", manyToManyMapping.getDefaultMapKeyClass());
+
+ //test default still the same when specified target entity it set
+ manyToManyMapping.setSpecifiedMapKeyClass("foo");
+ assertEquals("java.lang.Integer", manyToManyMapping.getDefaultMapKeyClass());
+ }
+
+ public void testDefaultMapKeyClassCollectionType() throws Exception {
+ createTestEntityWithValidManyToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
+
+ assertNull(manyToManyMapping.getDefaultMapKeyClass());
+ }
+
+ public void testMapKeyClass() throws Exception {
+ createTestEntityWithValidGenericMapManyToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
+
+ assertEquals("java.lang.Integer", manyToManyMapping.getMapKeyClass());
+
+ manyToManyMapping.setSpecifiedMapKeyClass("foo");
+ assertEquals("foo", manyToManyMapping.getMapKeyClass());
+
+ manyToManyMapping.setSpecifiedMapKeyClass(null);
+ assertEquals("java.lang.Integer", manyToManyMapping.getMapKeyClass());
+ }
+}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaOneToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaOneToManyMappingTests.java
index 16bcfaadd0..fe110775a4 100644
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaOneToManyMappingTests.java
+++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaOneToManyMappingTests.java
@@ -12,14 +12,19 @@ package org.eclipse.jpt.eclipselink2_0.core.tests.internal.context.java;
import java.util.Iterator;
import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jpt.core.context.OneToManyMapping;
import org.eclipse.jpt.core.context.PersistentAttribute;
+import org.eclipse.jpt.core.context.java.JavaOneToManyMapping;
import org.eclipse.jpt.core.jpa2.context.OneToManyMapping2_0;
import org.eclipse.jpt.core.jpa2.context.java.JavaOrphanRemovable2_0;
import org.eclipse.jpt.core.jpa2.context.java.JavaOrphanRemovalHolder2_0;
+import org.eclipse.jpt.core.jpa2.resource.java.MapKeyClass2_0Annotation;
import org.eclipse.jpt.core.jpa2.resource.java.OneToMany2_0Annotation;
import org.eclipse.jpt.core.resource.java.JPA;
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
+import org.eclipse.jpt.core.resource.java.MapKeyAnnotation;
+import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
import org.eclipse.jpt.eclipselink2_0.core.tests.internal.context.EclipseLink2_0ContextModelTestCase;
import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
@@ -56,7 +61,128 @@ public class EclipseLink2_0JavaOneToManyMappingTests
}
});
}
-
+
+ private ICompilationUnit createTestEntityWithOneToManyMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append("@OneToMany").append(CR);
+ }
+ });
+ }
+
+ private ICompilationUnit createTestEntityWithValidGenericMapOneToManyMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @OneToMany").append(CR);
+ sb.append(" private java.util.Map<String, Address> addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
+ private ICompilationUnit createTestEntityWithValidNonGenericMapOneToManyMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @OneToMany").append(CR);
+ sb.append(" private java.util.Map addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+ private void createTestTargetEntityAddress() throws Exception {
+ SourceWriter sourceWriter = new SourceWriter() {
+ public void appendSourceTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append("import ");
+ sb.append(JPA.ENTITY);
+ sb.append(";");
+ sb.append(CR);
+ sb.append("import ");
+ sb.append(JPA.ID);
+ sb.append(";");
+ sb.append(CR);
+ sb.append("import ");
+ sb.append(JPA.EMBEDDED);
+ sb.append(";");
+ sb.append(CR);
+ sb.append("@Entity");
+ sb.append(CR);
+ sb.append("public class ").append("Address").append(" ");
+ sb.append("{").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ sb.append(" private int id;").append(CR);
+ sb.append(CR);
+ sb.append(" private String city;").append(CR);
+ sb.append(CR);
+ sb.append(" @Embedded").append(CR);
+ sb.append(" private State state;").append(CR);
+ sb.append(CR);
+ sb.append(" private int zip;").append(CR);
+ sb.append(CR);
+ sb.append("}").append(CR);
+ }
+ };
+ this.javaProject.createCompilationUnit(PACKAGE_NAME, "Address.java", sourceWriter);
+ }
+
+ private void createTestEmbeddableState() 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("State").append(" ");
+ sb.append("{").append(CR);
+ sb.append(CR);
+ sb.append(" private String foo;").append(CR);
+ sb.append(CR);
+ sb.append(" private Address address;").append(CR);
+ sb.append(CR);
+ sb.append("}").append(CR);
+ }
+ };
+ this.javaProject.createCompilationUnit(PACKAGE_NAME, "State.java", sourceWriter);
+ }
+
private ICompilationUnit createTestEntityWithValidOneToManyMappingOrphanRemovalSpecified() throws Exception {
return this.createTestType(new DefaultAnnotationWriter() {
@Override
@@ -223,4 +349,218 @@ public class EclipseLink2_0JavaOneToManyMappingTests
assertNull(persistentAttribute.getSpecifiedMapping());
}
+ public void testUpdateMapKey() throws Exception {
+ createTestEntityWithOneToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+
+ assertNull(oneToManyMapping.getSpecifiedMapKey());
+ assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
+
+ //set mapKey in the resource model, verify context model does not change
+ attributeResource.addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ assertNull(oneToManyMapping.getSpecifiedMapKey());
+ MapKeyAnnotation mapKey = (MapKeyAnnotation) attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ assertNotNull(mapKey);
+
+ //set mapKey name in the resource model, verify context model updated
+ mapKey.setName("myMapKey");
+ getJpaProject().synchronizeContextModel();
+
+ assertEquals("myMapKey", oneToManyMapping.getSpecifiedMapKey());
+ assertEquals("myMapKey", mapKey.getName());
+
+ //set mapKey name to null in the resource model
+ mapKey.setName(null);
+ getJpaProject().synchronizeContextModel();
+
+ assertNull(oneToManyMapping.getSpecifiedMapKey());
+ assertNull(mapKey.getName());
+
+ mapKey.setName("myMapKey");
+ attributeResource.removeAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ assertNull(oneToManyMapping.getSpecifiedMapKey());
+ assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testModifyMapKey() throws Exception {
+ createTestEntityWithOneToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+
+ assertNull(oneToManyMapping.getSpecifiedMapKey());
+ assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
+
+ //set mapKey in the context model, verify resource model updated
+ oneToManyMapping.setSpecifiedMapKey("myMapKey");
+ MapKeyAnnotation mapKey = (MapKeyAnnotation) attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ assertEquals("myMapKey", oneToManyMapping.getSpecifiedMapKey());
+ assertEquals("myMapKey", mapKey.getName());
+
+ //set mapKey to null in the context model
+ oneToManyMapping.setSpecifiedMapKey(null);
+ assertNull(oneToManyMapping.getSpecifiedMapKey());
+ assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
+ }
+
+ public void testCandidateMapKeyNames() throws Exception {
+ createTestEntityWithValidGenericMapOneToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ addXmlClassRef(PACKAGE_NAME + ".Address");
+ addXmlClassRef(PACKAGE_NAME + ".State");
+
+ JavaOneToManyMapping javaOneToManyMapping = (JavaOneToManyMapping) getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+
+ Iterator<String> mapKeyNames =
+ javaOneToManyMapping.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.foo", mapKeyNames.next());
+ assertEquals("state.address", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+ }
+
+ public void testCandidateMapKeyNames2() throws Exception {
+ createTestEntityWithValidNonGenericMapOneToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ addXmlClassRef(PACKAGE_NAME + ".Address");
+ addXmlClassRef(PACKAGE_NAME + ".State");
+
+ JavaOneToManyMapping javaOneToManyMapping = (JavaOneToManyMapping) getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+
+ Iterator<String> mapKeyNames = javaOneToManyMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+
+ javaOneToManyMapping.setSpecifiedTargetEntity("test.Address");
+ mapKeyNames = javaOneToManyMapping.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.foo", mapKeyNames.next());
+ assertEquals("state.address", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+ }
+
+ public void testUpdateMapKeyClass() throws Exception {
+ createTestEntityWithValidGenericMapOneToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+
+ assertNull(oneToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
+
+ //set mapKey in the resource model, verify context model does not change
+ attributeResource.addAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ assertNull(oneToManyMapping.getSpecifiedMapKeyClass());
+ MapKeyClass2_0Annotation mapKeyClass = (MapKeyClass2_0Annotation) attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ assertNotNull(mapKeyClass);
+
+ //set mapKey name in the resource model, verify context model updated
+ mapKeyClass.setValue("myMapKeyClass");
+ assertEquals("myMapKeyClass", oneToManyMapping.getSpecifiedMapKeyClass());
+ assertEquals("myMapKeyClass", mapKeyClass.getValue());
+
+ //set mapKey name to null in the resource model
+ mapKeyClass.setValue(null);
+ assertNull(oneToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(mapKeyClass.getValue());
+
+ mapKeyClass.setValue("myMapKeyClass");
+ attributeResource.removeAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ getJpaProject().synchronizeContextModel();
+
+ assertNull(oneToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testModifyMapKeyClass() throws Exception {
+ createTestEntityWithValidGenericMapOneToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
+
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+ JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
+
+ assertNull(oneToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
+
+ //set mapKey in the context model, verify resource model updated
+ oneToManyMapping.setSpecifiedMapKeyClass("String");
+ MapKeyClass2_0Annotation mapKeyClass = (MapKeyClass2_0Annotation) attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
+ assertEquals("String", oneToManyMapping.getSpecifiedMapKeyClass());
+ assertEquals("String", mapKeyClass.getValue());
+
+ //set mapKey to null in the context model
+ oneToManyMapping.setSpecifiedMapKeyClass(null);
+ assertNull(oneToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
+ }
+
+ public void testDefaultMapKeyClass() throws Exception {
+ createTestEntityWithValidGenericMapOneToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
+
+ assertEquals("java.lang.String", oneToManyMapping.getDefaultMapKeyClass());
+
+ //test default still the same when specified target entity it set
+ oneToManyMapping.setSpecifiedMapKeyClass("foo");
+ assertEquals("java.lang.String", oneToManyMapping.getDefaultMapKeyClass());
+ }
+
+ public void testDefaultMapKeyClassCollectionType() throws Exception {
+ createTestEntityWithValidOneToManyMappingOrphanRemovalSpecified();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
+
+ assertNull(oneToManyMapping.getDefaultMapKeyClass());
+ }
+
+ public void testMapKeyClass() throws Exception {
+ createTestEntityWithValidGenericMapOneToManyMapping();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
+ OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
+
+ assertEquals("java.lang.String", oneToManyMapping.getMapKeyClass());
+
+ oneToManyMapping.setSpecifiedMapKeyClass("foo");
+ assertEquals("foo", oneToManyMapping.getMapKeyClass());
+
+ oneToManyMapping.setSpecifiedMapKeyClass(null);
+ assertEquals("java.lang.String", oneToManyMapping.getMapKeyClass());
+ }
}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/JptEclipseLink2_0JavaContextModelTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/JptEclipseLink2_0JavaContextModelTests.java
index 7704bb3392..018f0875ef 100644
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/JptEclipseLink2_0JavaContextModelTests.java
+++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/JptEclipseLink2_0JavaContextModelTests.java
@@ -17,7 +17,9 @@ public class JptEclipseLink2_0JavaContextModelTests extends TestCase
{
public static Test suite() {
TestSuite suite = new TestSuite(JptEclipseLink2_0JavaContextModelTests.class.getName());
+ suite.addTestSuite(EclipseLink2_0JavaElementCollectionMappingTests.class);
suite.addTestSuite(EclipseLink2_0JavaEntityTests.class);
+ suite.addTestSuite(EclipseLink2_0JavaManyToManyMappingTests.class);
suite.addTestSuite(EclipseLink2_0JavaManyToOneMappingTests.class);
suite.addTestSuite(EclipseLink2_0JavaMappedSuperclassTests.class);
suite.addTestSuite(EclipseLink2_0JavaOneToManyMappingTests.class);
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/orm/EclipseLink2_0OrmElementCollectionMappingTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/orm/EclipseLink2_0OrmElementCollectionMappingTests.java
new file mode 100644
index 0000000000..3637645d15
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/orm/EclipseLink2_0OrmElementCollectionMappingTests.java
@@ -0,0 +1,878 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.eclipselink2_0.core.tests.internal.context.orm;
+
+import java.util.Iterator;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jpt.core.JptCorePlugin;
+import org.eclipse.jpt.core.MappingKeys;
+import org.eclipse.jpt.core.context.BasicMapping;
+import org.eclipse.jpt.core.context.EmbeddedIdMapping;
+import org.eclipse.jpt.core.context.EmbeddedMapping;
+import org.eclipse.jpt.core.context.FetchType;
+import org.eclipse.jpt.core.context.IdMapping;
+import org.eclipse.jpt.core.context.ManyToManyMapping;
+import org.eclipse.jpt.core.context.ManyToOneMapping;
+import org.eclipse.jpt.core.context.OneToManyMapping;
+import org.eclipse.jpt.core.context.TransientMapping;
+import org.eclipse.jpt.core.context.VersionMapping;
+import org.eclipse.jpt.core.context.orm.OrmOneToManyMapping;
+import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
+import org.eclipse.jpt.core.context.orm.OrmPersistentType;
+import org.eclipse.jpt.core.jpa2.MappingKeys2_0;
+import org.eclipse.jpt.core.jpa2.context.ElementCollectionMapping2_0;
+import org.eclipse.jpt.core.jpa2.context.java.JavaElementCollectionMapping2_0;
+import org.eclipse.jpt.core.jpa2.context.orm.OrmElementCollectionMapping2_0;
+import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0;
+import org.eclipse.jpt.core.resource.java.JPA;
+import org.eclipse.jpt.core.resource.orm.OrmFactory;
+import org.eclipse.jpt.core.resource.orm.XmlElementCollection;
+import org.eclipse.jpt.core.resource.orm.XmlOneToMany;
+import org.eclipse.jpt.core.resource.orm.v2_0.XmlElementCollection_2_0;
+import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
+import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
+import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
+import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
+
+@SuppressWarnings("nls")
+public class EclipseLink2_0OrmElementCollectionMappingTests extends EclipseLink2_0OrmContextModelTestCase
+{
+ public EclipseLink2_0OrmElementCollectionMappingTests(String name) {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
+ mappingFileRef.setFileName(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
+ getXmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
+ getPersistenceXmlResource().save(null);
+ }
+
+ private ICompilationUnit createTestEntityWithElementCollectionMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION, JPA.FETCH_TYPE);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity");
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @ElementCollection(targetClass=String.class, fetch=FetchType.EAGER)");
+ sb.append(CR);
+ sb.append(" private java.util.Collection<Address> address;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id");
+ }
+ });
+ }
+
+ private void createTestTargetEmbeddableAddress() 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("import ");
+ sb.append(JPA.ID);
+ sb.append(";");
+ sb.append(CR);
+ sb.append(CR);
+ sb.append("@Embeddable");
+ sb.append(CR);
+ sb.append("public class ").append("Address").append(" ");
+ sb.append("{").append(CR);
+ sb.append(CR);
+ sb.append(" private String city;").append(CR);
+ sb.append(CR);
+ sb.append(" private State state;").append(CR);
+ sb.append(CR);
+ sb.append(" private int zip;").append(CR);
+ sb.append(CR);
+ sb.append("}").append(CR);
+ }
+ };
+ this.javaProject.createCompilationUnit(PACKAGE_NAME, "Address.java", sourceWriter);
+ }
+
+ private ICompilationUnit createTestEntityWithEmbeddableElementCollectionMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION, JPA.FETCH_TYPE);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity");
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @ElementCollection");
+ sb.append(CR);
+ sb.append(" private java.util.Collection<Address> addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id");
+ }
+ });
+ }
+
+ private ICompilationUnit createTestEntityWithNonGenericElementCollectionMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @ElementCollection").append(CR);
+ sb.append(" private java.util.Collection addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
+ private ICompilationUnit createTestEntityWithGenericBasicElementCollectionMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @ElementCollection").append(CR);
+ sb.append(" private java.util.Collection<String> addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
+ private ICompilationUnit createTestEntityWithValidMapElementCollectionMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @ElementCollection").append(CR);
+ sb.append(" private java.util.Map<String, Address> addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
+ private void createTestEmbeddableState() 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("State").append(" ");
+ sb.append("{").append(CR);
+ sb.append(CR);
+ sb.append(" private String name;").append(CR);
+ sb.append(CR);
+ sb.append(" private String abbr;").append(CR);
+ sb.append(CR);
+ sb.append("}").append(CR);
+ }
+ };
+ this.javaProject.createCompilationUnit(PACKAGE_NAME, "State.java", sourceWriter);
+ }
+
+ private ICompilationUnit createTestEntityWithValidNonGenericMapElementCollectionMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @ElementCollection").append(CR);
+ sb.append(" private java.util.Map addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
+ public void testUpdateName() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
+ OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
+ XmlElementCollection elementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
+
+ assertEquals("oneToOneMapping", ormElementCollectionMapping.getName());
+ assertEquals("oneToOneMapping", elementCollection.getName());
+
+ //set name in the resource model, verify context model updated
+ elementCollection.setName("newName");
+ assertEquals("newName", ormElementCollectionMapping.getName());
+ assertEquals("newName", elementCollection.getName());
+
+ //set name to null in the resource model
+ elementCollection.setName(null);
+ assertNull(ormElementCollectionMapping.getName());
+ assertNull(elementCollection.getName());
+ }
+
+ public void testModifyName() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
+ OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
+ XmlElementCollection elementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
+
+ assertEquals("oneToOneMapping", ormElementCollectionMapping.getName());
+ assertEquals("oneToOneMapping", elementCollection.getName());
+
+ //set name in the context model, verify resource model updated
+ ormElementCollectionMapping.setName("newName");
+ assertEquals("newName", ormElementCollectionMapping.getName());
+ assertEquals("newName", elementCollection.getName());
+
+ //set name to null in the context model
+ ormElementCollectionMapping.setName(null);
+ assertNull(ormElementCollectionMapping.getName());
+ assertNull(elementCollection.getName());
+ }
+
+ public void testMappingNoUnderylingJavaAttribute() throws Exception {
+ createTestEntityWithElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "foo");
+ assertEquals(3, ormPersistentType.virtualAttributesSize());
+
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.specifiedAttributes().next();
+ OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
+
+ assertEquals("foo", ormElementCollectionMapping.getName());
+
+ assertNull(ormElementCollectionMapping.getSpecifiedFetch());
+ assertEquals(FetchType.LAZY, ormElementCollectionMapping.getFetch());
+ }
+
+
+ public void testVirtualMappingMetadataCompleteFalse() throws Exception {
+ createTestEntityWithElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ assertEquals(3, ormPersistentType.virtualAttributesSize());
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
+
+ OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
+ assertEquals("address", ormElementCollectionMapping.getName());
+ assertEquals(FetchType.EAGER, ormElementCollectionMapping.getSpecifiedFetch());
+ assertEquals("String", ormElementCollectionMapping.getSpecifiedTargetClass());
+
+ ormPersistentAttribute.makeSpecified();
+ ormPersistentAttribute = ormPersistentType.specifiedAttributes().next();
+ ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
+ assertEquals("address", ormElementCollectionMapping.getName());
+ assertEquals(null, ormElementCollectionMapping.getSpecifiedFetch());
+ assertEquals(FetchType.LAZY, ormElementCollectionMapping.getDefaultFetch());
+ assertEquals(null, ormElementCollectionMapping.getSpecifiedTargetClass());
+ assertEquals(PACKAGE_NAME + ".Address", ormElementCollectionMapping.getDefaultTargetClass());
+ }
+
+ public void testVirtualMappingMetadataCompleteTrue() throws Exception {
+ createTestEntityWithElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
+ assertEquals(3, ormPersistentType.virtualAttributesSize());
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
+
+ assertEquals(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMappingKey());
+
+ ormPersistentAttribute.makeSpecified(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY);
+ ormPersistentAttribute= ormPersistentType.specifiedAttributes().next();
+
+ OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
+ assertEquals("address", ormElementCollectionMapping.getName());
+ assertEquals(FetchType.LAZY, ormElementCollectionMapping.getFetch());
+ }
+
+ public void testSpecifiedMapping() throws Exception {
+ createTestEntityWithElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+
+ ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "address");
+ assertEquals(2, ormPersistentType.virtualAttributesSize());
+
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.specifiedAttributes().next();
+ OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
+
+ assertEquals("address", ormElementCollectionMapping.getName());
+ assertNull(ormElementCollectionMapping.getSpecifiedFetch());
+ assertEquals(FetchType.LAZY, ormElementCollectionMapping.getFetch());
+ }
+
+
+ public void testMorphToIdMapping() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOne");
+
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
+ assertFalse(elementCollectionMapping.isDefault());
+ elementCollectionMapping.setSpecifiedFetch(FetchType.EAGER);
+ assertFalse(elementCollectionMapping.isDefault());
+
+ ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
+ assertEquals(1, ormPersistentType.specifiedAttributesSize());
+ assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
+ assertTrue(ormPersistentAttribute.getMapping() instanceof IdMapping);
+ assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName());
+ }
+
+ public void testMorphToVersionMapping() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOne");
+
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
+ assertFalse(elementCollectionMapping.isDefault());
+ elementCollectionMapping.setSpecifiedFetch(FetchType.EAGER);
+ assertFalse(elementCollectionMapping.isDefault());
+
+ ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
+ assertEquals(1, ormPersistentType.specifiedAttributesSize());
+ assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
+ assertTrue(ormPersistentAttribute.getMapping() instanceof VersionMapping);
+ assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName());
+ }
+
+ public void testMorphToTransientMapping() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOne");
+
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
+ assertFalse(elementCollectionMapping.isDefault());
+ elementCollectionMapping.setSpecifiedFetch(FetchType.EAGER);
+ assertFalse(elementCollectionMapping.isDefault());
+
+ ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
+ assertEquals(1, ormPersistentType.specifiedAttributesSize());
+ assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
+ assertTrue(ormPersistentAttribute.getMapping() instanceof TransientMapping);
+ assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName());
+ }
+
+ public void testMorphToEmbeddedMapping() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOne");
+
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
+ assertFalse(elementCollectionMapping.isDefault());
+ elementCollectionMapping.setSpecifiedFetch(FetchType.EAGER);
+ assertFalse(elementCollectionMapping.isDefault());
+
+ ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
+ assertEquals(1, ormPersistentType.specifiedAttributesSize());
+ assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
+ assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedMapping);
+ assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName());
+ }
+
+ public void testMorphToEmbeddedIdMapping() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOne");
+
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
+ assertFalse(elementCollectionMapping.isDefault());
+ elementCollectionMapping.setSpecifiedFetch(FetchType.EAGER);
+ assertFalse(elementCollectionMapping.isDefault());
+
+ ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
+ assertEquals(1, ormPersistentType.specifiedAttributesSize());
+ assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
+ assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedIdMapping);
+ assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName());
+ }
+
+ public void testMorphToManyToManyMapping() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOne");
+
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
+ assertFalse(elementCollectionMapping.isDefault());
+ elementCollectionMapping.setSpecifiedFetch(FetchType.EAGER);
+ assertFalse(elementCollectionMapping.isDefault());
+
+ ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
+ assertEquals(1, ormPersistentType.specifiedAttributesSize());
+ assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
+ assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToManyMapping);
+ assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName());
+// assertEquals(FetchType.EAGER, ((ManyToManyMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch());
+ }
+
+ public void testMorphToOneToManyMapping() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOne");
+
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
+ assertFalse(elementCollectionMapping.isDefault());
+ elementCollectionMapping.setSpecifiedFetch(FetchType.EAGER);
+ assertFalse(elementCollectionMapping.isDefault());
+
+ ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
+ assertEquals(1, ormPersistentType.specifiedAttributesSize());
+ assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
+ assertTrue(ormPersistentAttribute.getMapping() instanceof OneToManyMapping);
+ assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName());
+// assertEquals(FetchType.EAGER, ((OneToManyMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch());
+ }
+
+ public void testMorphToManyToOneMapping() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOne");
+
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
+ assertFalse(elementCollectionMapping.isDefault());
+ elementCollectionMapping.setSpecifiedFetch(FetchType.EAGER);
+ assertFalse(elementCollectionMapping.isDefault());
+
+ ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
+ assertEquals(1, ormPersistentType.specifiedAttributesSize());
+ assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
+ assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToOneMapping);
+ assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName());
+// assertEquals(FetchType.EAGER, ((ManyToOneMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch());
+ }
+
+ public void testMorphToBasicMapping() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOne");
+
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
+ assertFalse(elementCollectionMapping.isDefault());
+ elementCollectionMapping.setSpecifiedFetch(FetchType.EAGER);
+ assertFalse(elementCollectionMapping.isDefault());
+
+ ormPersistentAttribute.setSpecifiedMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
+ assertEquals(1, ormPersistentType.specifiedAttributesSize());
+ assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
+ assertTrue(ormPersistentAttribute.getMapping() instanceof BasicMapping);
+ assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName());
+//TODO assertEquals(FetchType.EAGER, ((IBasicMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch());
+ }
+
+ public void testUpdateSpecifiedFetch() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
+ OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
+ XmlElementCollection elementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
+
+ assertNull(ormElementCollectionMapping.getSpecifiedFetch());
+ assertNull(elementCollection.getFetch());
+
+ //set fetch in the resource model, verify context model updated
+ elementCollection.setFetch(org.eclipse.jpt.core.resource.orm.FetchType.EAGER);
+ assertEquals(FetchType.EAGER, ormElementCollectionMapping.getSpecifiedFetch());
+ assertEquals(org.eclipse.jpt.core.resource.orm.FetchType.EAGER, elementCollection.getFetch());
+
+ elementCollection.setFetch(org.eclipse.jpt.core.resource.orm.FetchType.LAZY);
+ assertEquals(FetchType.LAZY, ormElementCollectionMapping.getSpecifiedFetch());
+ assertEquals(org.eclipse.jpt.core.resource.orm.FetchType.LAZY, elementCollection.getFetch());
+
+ //set fetch to null in the resource model
+ elementCollection.setFetch(null);
+ assertNull(ormElementCollectionMapping.getSpecifiedFetch());
+ assertNull(elementCollection.getFetch());
+ }
+
+ public void testModifySpecifiedFetch() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
+ OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
+ XmlElementCollection elementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
+
+ assertNull(ormElementCollectionMapping.getSpecifiedFetch());
+ assertNull(elementCollection.getFetch());
+
+ //set fetch in the context model, verify resource model updated
+ ormElementCollectionMapping.setSpecifiedFetch(FetchType.EAGER);
+ assertEquals(org.eclipse.jpt.core.resource.orm.FetchType.EAGER, elementCollection.getFetch());
+ assertEquals(FetchType.EAGER, ormElementCollectionMapping.getSpecifiedFetch());
+
+ ormElementCollectionMapping.setSpecifiedFetch(FetchType.LAZY);
+ assertEquals(org.eclipse.jpt.core.resource.orm.FetchType.LAZY, elementCollection.getFetch());
+ assertEquals(FetchType.LAZY, ormElementCollectionMapping.getSpecifiedFetch());
+
+ //set fetch to null in the context model
+ ormElementCollectionMapping.setSpecifiedFetch(null);
+ assertNull(elementCollection.getFetch());
+ assertNull(ormElementCollectionMapping.getSpecifiedFetch());
+ }
+
+ public void testUpdateSpecifiedTargetClass() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping");
+ OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
+ XmlElementCollection_2_0 elementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
+
+ assertNull(ormElementCollectionMapping.getSpecifiedTargetClass());
+ assertNull(elementCollection.getTargetClass());
+
+ //set target class in the resource model, verify context model updated
+ elementCollection.setTargetClass("newTargetClass");
+ assertEquals("newTargetClass", ormElementCollectionMapping.getSpecifiedTargetClass());
+ assertEquals("newTargetClass", elementCollection.getTargetClass());
+
+ //set target class to null in the resource model
+ elementCollection.setTargetClass(null);
+ assertNull(ormElementCollectionMapping.getSpecifiedTargetClass());
+ assertNull(elementCollection.getTargetClass());
+ }
+
+ public void testModifySpecifiedTargetClass() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping");
+ OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
+ XmlElementCollection_2_0 elementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
+
+ assertNull(ormElementCollectionMapping.getSpecifiedTargetClass());
+ assertNull(elementCollection.getTargetClass());
+
+ //set target class in the context model, verify resource model updated
+ ormElementCollectionMapping.setSpecifiedTargetClass("newTargetClass");
+ assertEquals("newTargetClass", ormElementCollectionMapping.getSpecifiedTargetClass());
+ assertEquals("newTargetClass", elementCollection.getTargetClass());
+
+ //set target class to null in the context model
+ ormElementCollectionMapping.setSpecifiedTargetClass(null);
+ assertNull(ormElementCollectionMapping.getSpecifiedTargetClass());
+ assertNull(elementCollection.getTargetClass());
+ }
+
+
+ public void testGetValueTypeEmbeddable() throws Exception {
+ createTestEntityWithEmbeddableElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, "test.Address");
+
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "addresses");
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
+
+ assertEquals(ElementCollectionMapping2_0.Type.EMBEDDABLE_TYPE, elementCollectionMapping.getValueType());
+ }
+
+ public void testGetValueTypeEntity() throws Exception {
+ createTestEntityWithEmbeddableElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.Address");
+
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "addresses");
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
+
+ assertEquals(ElementCollectionMapping2_0.Type.BASIC_TYPE, elementCollectionMapping.getValueType());
+ }
+
+ public void testGetValueTypeNone() throws Exception {
+ createTestEntityWithNonGenericElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, "test.Address");
+
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "addresses");
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
+
+ assertEquals(ElementCollectionMapping2_0.Type.NO_TYPE, elementCollectionMapping.getValueType());
+
+ elementCollectionMapping.setSpecifiedTargetClass("test.Address");
+ assertEquals(ElementCollectionMapping2_0.Type.EMBEDDABLE_TYPE, elementCollectionMapping.getValueType());
+ }
+
+ public void testGetValueTypeBasic() throws Exception {
+ createTestEntityWithGenericBasicElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.Address");
+
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "addresses");
+ ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
+
+ assertEquals(ElementCollectionMapping2_0.Type.BASIC_TYPE, elementCollectionMapping.getValueType());
+ }
+
+
+ public void testUpdateMapKey() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
+ OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping();
+ XmlOneToMany oneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0);
+
+ assertNull(ormOneToManyMapping.getSpecifiedMapKey());
+ assertNull(oneToMany.getMapKey());
+
+ //set mapKey in the resource model, verify context model does not change
+ oneToMany.setMapKey(OrmFactory.eINSTANCE.createMapKey());
+ assertNull(ormOneToManyMapping.getSpecifiedMapKey());
+ assertNotNull(oneToMany.getMapKey());
+
+ //set mapKey name in the resource model, verify context model updated
+ oneToMany.getMapKey().setName("myMapKey");
+ assertEquals("myMapKey", ormOneToManyMapping.getSpecifiedMapKey());
+ assertEquals("myMapKey", oneToMany.getMapKey().getName());
+
+ //set mapKey name to null in the resource model
+ oneToMany.getMapKey().setName(null);
+ assertNull(ormOneToManyMapping.getSpecifiedMapKey());
+ assertNull(oneToMany.getMapKey().getName());
+
+ oneToMany.getMapKey().setName("myMapKey");
+ oneToMany.setMapKey(null);
+ assertNull(ormOneToManyMapping.getSpecifiedMapKey());
+ assertNull(oneToMany.getMapKey());
+ }
+
+ public void testUpdateVirtualMapKey() throws Exception {
+ createTestEntityWithValidMapElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ JavaElementCollectionMapping2_0 javaElementCollectionMapping = (JavaElementCollectionMapping2_0) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+ assertNull(ormElementCollectionMapping.getSpecifiedMapKey());
+ assertNull(ormElementCollectionMapping.getMapKey());
+ assertFalse(ormElementCollectionMapping.isPkMapKey());
+ assertFalse(ormElementCollectionMapping.isCustomMapKey());
+ assertTrue(ormElementCollectionMapping.isNoMapKey());
+
+ //set pk mapKey in the java, verify virtual orm mapping updates
+ javaElementCollectionMapping.setPkMapKey(true);
+ assertEquals(null, ormElementCollectionMapping.getMapKey());//no primary key on an embeddable
+ assertTrue(ormElementCollectionMapping.isPkMapKey());
+ assertFalse(ormElementCollectionMapping.isCustomMapKey());
+ assertFalse(ormElementCollectionMapping.isNoMapKey());
+
+
+ //set custom specified mapKey in the java, verify virtual orm mapping updates
+ javaElementCollectionMapping.setCustomMapKey(true);
+ javaElementCollectionMapping.setSpecifiedMapKey("city");
+ assertEquals("city", ormElementCollectionMapping.getSpecifiedMapKey());
+ assertEquals("city", ormElementCollectionMapping.getMapKey());
+ assertFalse(ormElementCollectionMapping.isPkMapKey());
+ assertTrue(ormElementCollectionMapping.isCustomMapKey());
+ assertFalse(ormElementCollectionMapping.isNoMapKey());
+ }
+
+ public void testModifyMapKey() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
+ OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping();
+ XmlOneToMany oneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0);
+
+ assertNull(ormOneToManyMapping.getSpecifiedMapKey());
+ assertNull(oneToMany.getMapKey());
+
+ //set mapKey in the context model, verify resource model updated
+ ormOneToManyMapping.setSpecifiedMapKey("myMapKey");
+ assertEquals("myMapKey", ormOneToManyMapping.getSpecifiedMapKey());
+ assertEquals("myMapKey", oneToMany.getMapKey().getName());
+
+ //set mapKey to null in the context model
+ ormOneToManyMapping.setSpecifiedMapKey(null);
+ assertNull(ormOneToManyMapping.getSpecifiedMapKey());
+ assertNull(oneToMany.getMapKey());
+ }
+
+ public void testCandidateMapKeyNames() throws Exception {
+ createTestEntityWithValidMapElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentType.getAttributeNamed("addresses").getMapping();
+
+ Iterator<String> mapKeyNames =
+ ormElementCollectionMapping.candidateMapKeyNames();
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.name", mapKeyNames.next());
+ assertEquals("state.abbr", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+ }
+
+ public void testCandidateMapKeyNames2() throws Exception {
+ createTestEntityWithValidNonGenericMapElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ JavaElementCollectionMapping2_0 javaElementCollectionMapping = (JavaElementCollectionMapping2_0) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+
+ Iterator<String> mapKeyNames = ormElementCollectionMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+
+ javaElementCollectionMapping.setSpecifiedTargetClass("test.Address");
+ mapKeyNames = ormElementCollectionMapping.candidateMapKeyNames();
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.name", mapKeyNames.next());
+ assertEquals("state.abbr", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+
+ ormElementCollectionMapping.getPersistentAttribute().makeSpecified();
+ ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ mapKeyNames = ormElementCollectionMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+
+ ormElementCollectionMapping.setSpecifiedTargetClass("test.Address");
+ mapKeyNames = ormElementCollectionMapping.candidateMapKeyNames();
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.name", mapKeyNames.next());
+ assertEquals("state.abbr", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+
+ ormElementCollectionMapping.setSpecifiedTargetClass("String");
+ mapKeyNames = ormElementCollectionMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+ }
+
+ public void testUpdateMapKeyClass() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
+ OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
+ XmlElementCollection elementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
+
+ assertNull(ormElementCollectionMapping.getSpecifiedMapKeyClass());
+ assertNull(elementCollection.getMapKeyClass());
+
+ //set mapKey in the resource model, verify context model does not change
+ elementCollection.setMapKeyClass(OrmFactory.eINSTANCE.createXmlMapKeyClass());
+ assertNull(ormElementCollectionMapping.getSpecifiedMapKeyClass());
+ assertNotNull(elementCollection.getMapKeyClass());
+
+ //set mapKey name in the resource model, verify context model updated
+ elementCollection.getMapKeyClass().setClassName("String");
+ assertEquals("String", ormElementCollectionMapping.getSpecifiedMapKeyClass());
+ assertEquals("String", elementCollection.getMapKeyClass().getClassName());
+
+ //set mapKey name to null in the resource model
+ elementCollection.getMapKeyClass().setClassName(null);
+ assertNull(ormElementCollectionMapping.getSpecifiedMapKeyClass());
+ assertNull(elementCollection.getMapKeyClass().getClassName());
+
+ elementCollection.getMapKeyClass().setClassName("String");
+ elementCollection.setMapKeyClass(null);
+ assertNull(ormElementCollectionMapping.getSpecifiedMapKeyClass());
+ assertNull(elementCollection.getMapKeyClass());
+ }
+
+ public void testUpdateVirtualMapKeyClass() throws Exception {
+ createTestEntityWithValidMapElementCollectionMapping();
+ createTestTargetEmbeddableAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ JavaElementCollectionMapping2_0 javaElementCollectionMapping = (JavaElementCollectionMapping2_0) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+ assertEquals(null, ormElementCollectionMapping.getSpecifiedMapKeyClass());
+ assertEquals("java.lang.String", ormElementCollectionMapping.getMapKeyClass());
+ assertEquals("java.lang.String", ormElementCollectionMapping.getDefaultMapKeyClass());
+
+ //set pk mapKey in the java, verify virtual orm mapping updates
+ javaElementCollectionMapping.setSpecifiedMapKeyClass("Integer");
+ assertEquals("Integer", ormElementCollectionMapping.getMapKeyClass());
+ assertEquals("Integer", ormElementCollectionMapping.getSpecifiedMapKeyClass());
+ assertEquals("java.lang.String", ormElementCollectionMapping.getDefaultMapKeyClass());
+ }
+
+ public void testModifyMapKeyClass() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
+ OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
+ XmlElementCollection elementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
+
+ assertNull(ormElementCollectionMapping.getSpecifiedMapKeyClass());
+ assertNull(elementCollection.getMapKeyClass());
+
+ //set mapKey in the context model, verify resource model updated
+ ormElementCollectionMapping.setSpecifiedMapKeyClass("String");
+ assertEquals("String", ormElementCollectionMapping.getSpecifiedMapKeyClass());
+ assertEquals("String", elementCollection.getMapKeyClass().getClassName());
+
+ //set mapKey to null in the context model
+ ormElementCollectionMapping.setSpecifiedMapKeyClass(null);
+ assertNull(ormElementCollectionMapping.getSpecifiedMapKeyClass());
+ assertNull(elementCollection.getMapKeyClass());
+ }
+} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/orm/EclipseLink2_0OrmManyToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/orm/EclipseLink2_0OrmManyToManyMappingTests.java
new file mode 100644
index 0000000000..9e53eaca49
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/orm/EclipseLink2_0OrmManyToManyMappingTests.java
@@ -0,0 +1,429 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.eclipselink2_0.core.tests.internal.context.orm;
+
+import java.util.Iterator;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jpt.core.MappingKeys;
+import org.eclipse.jpt.core.context.AttributeMapping;
+import org.eclipse.jpt.core.context.ManyToManyMapping;
+import org.eclipse.jpt.core.context.PersistentAttribute;
+import org.eclipse.jpt.core.context.java.JavaManyToManyMapping;
+import org.eclipse.jpt.core.context.orm.OrmManyToManyMapping;
+import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
+import org.eclipse.jpt.core.context.orm.OrmPersistentType;
+import org.eclipse.jpt.core.resource.java.JPA;
+import org.eclipse.jpt.core.resource.orm.OrmFactory;
+import org.eclipse.jpt.core.resource.orm.XmlManyToMany;
+import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
+import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
+
+@SuppressWarnings("nls")
+public class EclipseLink2_0OrmManyToManyMappingTests
+ extends EclipseLink2_0OrmContextModelTestCase
+{
+ public EclipseLink2_0OrmManyToManyMappingTests(String name) {
+ super(name);
+ }
+
+
+ private void createTestTargetEntityAddress() throws Exception {
+ SourceWriter sourceWriter = new SourceWriter() {
+ public void appendSourceTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append("import ");
+ sb.append(JPA.ENTITY);
+ sb.append(";");
+ sb.append(CR);
+ sb.append("import ");
+ sb.append(JPA.ID);
+ sb.append(";");
+ sb.append(CR);
+ sb.append(CR);
+ sb.append("@Entity");
+ sb.append(CR);
+ sb.append("public class ").append("Address").append(" ");
+ sb.append("{").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ sb.append(" private int id;").append(CR);
+ sb.append(CR);
+ sb.append(" private String city;").append(CR);
+ sb.append(CR);
+ sb.append(" private State state;").append(CR);
+ sb.append(CR);
+ sb.append(" private int zip;").append(CR);
+ sb.append(CR);
+ sb.append("}").append(CR);
+ }
+ };
+ this.javaProject.createCompilationUnit(PACKAGE_NAME, "Address.java", sourceWriter);
+ }
+
+ private ICompilationUnit createTestEntityWithValidManyToManyMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @ManyToMany").append(CR);
+ sb.append(" private java.util.Collection<Address> addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
+ private ICompilationUnit createTestEntityWithValidMapManyToManyMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @ManyToMany").append(CR);
+ sb.append(" private java.util.Map<String, Address> addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
+ private ICompilationUnit createTestEntityWithValidNonGenericMapManyToManyMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @ManyToMany").append(CR);
+ sb.append(" private java.util.Map addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
+ private void createTestEmbeddableState() 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("State").append(" ");
+ sb.append("{").append(CR);
+ sb.append(CR);
+ sb.append(" private String foo;").append(CR);
+ sb.append(CR);
+ sb.append(" private Address address;").append(CR);
+ sb.append(CR);
+ sb.append("}").append(CR);
+ }
+ };
+ this.javaProject.createCompilationUnit(PACKAGE_NAME, "State.java", sourceWriter);
+ }
+
+ public void testCandidateMappedByAttributeNames() throws Exception {
+ createTestEntityWithValidManyToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+ ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "addresses");
+
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ addXmlClassRef(PACKAGE_NAME + ".Address");
+ addXmlClassRef(PACKAGE_NAME + ".State");
+
+ PersistentAttribute persistentAttribute = ormPersistentType.attributes().next();
+ ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
+
+ Iterator<String> attributeNames =
+ manyToManyMapping.getRelationshipReference().getMappedByJoiningStrategy().candidateMappedByAttributeNames();
+ assertEquals("id", attributeNames.next());
+ assertEquals("city", attributeNames.next());
+ assertEquals("state", attributeNames.next());
+ assertEquals("state.foo", attributeNames.next());
+ assertEquals("state.address", attributeNames.next());
+ assertEquals("zip", attributeNames.next());
+ assertFalse(attributeNames.hasNext());
+
+ manyToManyMapping.setSpecifiedTargetEntity("foo");
+ attributeNames =
+ manyToManyMapping.getRelationshipReference().getMappedByJoiningStrategy().candidateMappedByAttributeNames();
+ assertFalse(attributeNames.hasNext());
+
+ manyToManyMapping.setSpecifiedTargetEntity(null);
+ attributeNames =
+ manyToManyMapping.getRelationshipReference().getMappedByJoiningStrategy().candidateMappedByAttributeNames();
+ assertEquals("id", attributeNames.next());
+ assertEquals("city", attributeNames.next());
+ assertEquals("state", attributeNames.next());
+ assertEquals("state.foo", attributeNames.next());
+ assertEquals("state.address", attributeNames.next());
+ assertEquals("zip", attributeNames.next());
+ assertFalse(attributeNames.hasNext());
+
+ AttributeMapping stateFooMapping = manyToManyMapping.getResolvedTargetEntity().resolveAttributeMapping("state.foo");
+ assertEquals("foo", stateFooMapping.getName());
+ }
+
+ public void testUpdateMapKey() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
+ OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
+ XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
+
+ assertNull(ormManyToManyMapping.getSpecifiedMapKey());
+ assertNull(manyToMany.getMapKey());
+
+ //set mapKey in the resource model, verify context model does not change
+ manyToMany.setMapKey(OrmFactory.eINSTANCE.createMapKey());
+ assertNull(ormManyToManyMapping.getSpecifiedMapKey());
+ assertNotNull(manyToMany.getMapKey());
+
+ //set mapKey name in the resource model, verify context model updated
+ manyToMany.getMapKey().setName("myMapKey");
+ assertEquals("myMapKey", ormManyToManyMapping.getSpecifiedMapKey());
+ assertEquals("myMapKey", manyToMany.getMapKey().getName());
+
+ //set mapKey name to null in the resource model
+ manyToMany.getMapKey().setName(null);
+ assertNull(ormManyToManyMapping.getSpecifiedMapKey());
+ assertNull(manyToMany.getMapKey().getName());
+
+ manyToMany.getMapKey().setName("myMapKey");
+ manyToMany.setMapKey(null);
+ assertNull(ormManyToManyMapping.getSpecifiedMapKey());
+ assertNull(manyToMany.getMapKey());
+ }
+
+ public void testUpdateVirtualMapKey() throws Exception {
+ createTestEntityWithValidMapManyToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ JavaManyToManyMapping javaManyToManyMapping = (JavaManyToManyMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+ assertNull(ormManyToManyMapping.getSpecifiedMapKey());
+ assertNull(ormManyToManyMapping.getMapKey());
+ assertFalse(ormManyToManyMapping.isPkMapKey());
+ assertFalse(ormManyToManyMapping.isCustomMapKey());
+ assertTrue(ormManyToManyMapping.isNoMapKey());
+
+ //set pk mapKey in the java, verify virtual orm mapping updates
+ javaManyToManyMapping.setPkMapKey(true);
+ assertEquals("id", ormManyToManyMapping.getMapKey());
+ assertTrue(ormManyToManyMapping.isPkMapKey());
+ assertFalse(ormManyToManyMapping.isCustomMapKey());
+ assertFalse(ormManyToManyMapping.isNoMapKey());
+
+
+ //set custom specified mapKey in the java, verify virtual orm mapping updates
+ javaManyToManyMapping.setCustomMapKey(true);
+ javaManyToManyMapping.setSpecifiedMapKey("city");
+ assertEquals("city", ormManyToManyMapping.getSpecifiedMapKey());
+ assertEquals("city", ormManyToManyMapping.getMapKey());
+ assertFalse(ormManyToManyMapping.isPkMapKey());
+ assertTrue(ormManyToManyMapping.isCustomMapKey());
+ assertFalse(ormManyToManyMapping.isNoMapKey());
+ }
+
+ public void testModifyMapKey() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
+ OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
+ XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
+
+ assertNull(ormManyToManyMapping.getSpecifiedMapKey());
+ assertNull(manyToMany.getMapKey());
+
+ //set mapKey in the context model, verify resource model updated
+ ormManyToManyMapping.setSpecifiedMapKey("myMapKey");
+ assertEquals("myMapKey", ormManyToManyMapping.getSpecifiedMapKey());
+ assertEquals("myMapKey", manyToMany.getMapKey().getName());
+
+ //set mapKey to null in the context model
+ ormManyToManyMapping.setSpecifiedMapKey(null);
+ assertNull(ormManyToManyMapping.getSpecifiedMapKey());
+ assertNull(manyToMany.getMapKey());
+ }
+
+ public void testCandidateMapKeyNames() throws Exception {
+ createTestEntityWithValidMapManyToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+
+ Iterator<String> mapKeyNames =
+ ormManyToManyMapping.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.foo", mapKeyNames.next());
+ assertEquals("state.address", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+ }
+
+ public void testCandidateMapKeyNames2() throws Exception {
+ createTestEntityWithValidNonGenericMapManyToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ JavaManyToManyMapping javaManyToManyMapping = (JavaManyToManyMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+
+ Iterator<String> mapKeyNames = ormManyToManyMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+
+ javaManyToManyMapping.setSpecifiedTargetEntity("test.Address");
+ mapKeyNames = ormManyToManyMapping.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.foo", mapKeyNames.next());
+ assertEquals("state.address", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+
+ ormManyToManyMapping.getPersistentAttribute().makeSpecified();
+ ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ mapKeyNames = ormManyToManyMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+
+ ormManyToManyMapping.setSpecifiedTargetEntity("test.Address");
+ mapKeyNames = ormManyToManyMapping.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.foo", mapKeyNames.next());
+ assertEquals("state.address", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+
+ ormManyToManyMapping.setSpecifiedTargetEntity("String");
+ mapKeyNames = ormManyToManyMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+ }
+
+ public void testUpdateMapKeyClass() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
+ OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
+ XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
+
+ assertNull(ormManyToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(manyToMany.getMapKeyClass());
+
+ //set mapKey in the resource model, verify context model does not change
+ manyToMany.setMapKeyClass(OrmFactory.eINSTANCE.createXmlMapKeyClass());
+ assertNull(ormManyToManyMapping.getSpecifiedMapKeyClass());
+ assertNotNull(manyToMany.getMapKeyClass());
+
+ //set mapKey name in the resource model, verify context model updated
+ manyToMany.getMapKeyClass().setClassName("String");
+ assertEquals("String", ormManyToManyMapping.getSpecifiedMapKeyClass());
+ assertEquals("String", manyToMany.getMapKeyClass().getClassName());
+
+ //set mapKey name to null in the resource model
+ manyToMany.getMapKeyClass().setClassName(null);
+ assertNull(ormManyToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(manyToMany.getMapKeyClass().getClassName());
+
+ manyToMany.getMapKeyClass().setClassName("String");
+ manyToMany.setMapKeyClass(null);
+ assertNull(ormManyToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(manyToMany.getMapKeyClass());
+ }
+
+ public void testUpdateVirtualMapKeyClass() throws Exception {
+ createTestEntityWithValidMapManyToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ JavaManyToManyMapping javaManyToManyMapping = (JavaManyToManyMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+ assertEquals("java.lang.String", ormManyToManyMapping.getMapKeyClass());
+ assertEquals(null, ormManyToManyMapping.getSpecifiedMapKeyClass());
+ assertEquals("java.lang.String", ormManyToManyMapping.getDefaultMapKeyClass());
+
+ //set pk mapKey in the java, verify virtual orm mapping updates
+ javaManyToManyMapping.setSpecifiedMapKeyClass("Integer");
+ assertEquals("Integer", ormManyToManyMapping.getMapKeyClass());
+ assertEquals("Integer", ormManyToManyMapping.getSpecifiedMapKeyClass());
+ assertEquals("java.lang.String", ormManyToManyMapping.getDefaultMapKeyClass());
+ }
+
+ public void testModifyMapKeyClass() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
+ OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
+ XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
+
+ assertNull(ormManyToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(manyToMany.getMapKeyClass());
+
+ //set mapKey in the context model, verify resource model updated
+ ormManyToManyMapping.setSpecifiedMapKeyClass("String");
+ assertEquals("String", ormManyToManyMapping.getSpecifiedMapKeyClass());
+ assertEquals("String", manyToMany.getMapKeyClass().getClassName());
+
+ //set mapKey to null in the context model
+ ormManyToManyMapping.setSpecifiedMapKeyClass(null);
+ assertNull(ormManyToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(manyToMany.getMapKeyClass());
+ }
+}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/orm/EclipseLink2_0OrmOneToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/orm/EclipseLink2_0OrmOneToManyMappingTests.java
index 41e6ae9112..a8a9b584a9 100644
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/orm/EclipseLink2_0OrmOneToManyMappingTests.java
+++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/orm/EclipseLink2_0OrmOneToManyMappingTests.java
@@ -9,24 +9,132 @@
*******************************************************************************/
package org.eclipse.jpt.eclipselink2_0.core.tests.internal.context.orm;
+import java.util.Iterator;
+import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.core.MappingKeys;
+import org.eclipse.jpt.core.context.java.JavaOneToManyMapping;
+import org.eclipse.jpt.core.context.orm.OrmOneToManyMapping;
import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
import org.eclipse.jpt.core.context.orm.OrmPersistentType;
import org.eclipse.jpt.core.jpa2.context.OneToManyMapping2_0;
import org.eclipse.jpt.core.jpa2.context.orm.OrmOneToManyMapping2_0;
import org.eclipse.jpt.core.jpa2.context.orm.OrmOrphanRemovable2_0;
import org.eclipse.jpt.core.jpa2.context.orm.OrmOrphanRemovalHolder2_0;
+import org.eclipse.jpt.core.resource.java.JPA;
+import org.eclipse.jpt.core.resource.orm.OrmFactory;
import org.eclipse.jpt.core.resource.orm.XmlOneToMany;
+import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
+import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
/**
* EclipseLink2_0OrmOneToManyMappingTests
*/
+@SuppressWarnings("nls")
public class EclipseLink2_0OrmOneToManyMappingTests
extends EclipseLink2_0OrmContextModelTestCase
{
public EclipseLink2_0OrmOneToManyMappingTests(String name) {
super(name);
}
+ private void createTestTargetEntityAddress() throws Exception {
+ SourceWriter sourceWriter = new SourceWriter() {
+ public void appendSourceTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append("import ");
+ sb.append(JPA.ENTITY);
+ sb.append(";");
+ sb.append(CR);
+ sb.append("import ");
+ sb.append(JPA.ID);
+ sb.append(";");
+ sb.append(CR);
+ sb.append(CR);
+ sb.append("@Entity");
+ sb.append(CR);
+ sb.append("public class ").append("Address").append(" ");
+ sb.append("{").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ sb.append(" private int id;").append(CR);
+ sb.append(CR);
+ sb.append(" private String city;").append(CR);
+ sb.append(CR);
+ sb.append(" private State state;").append(CR);
+ sb.append(CR);
+ sb.append(" private int zip;").append(CR);
+ sb.append(CR);
+ sb.append("}").append(CR);
+ }
+ };
+ this.javaProject.createCompilationUnit(PACKAGE_NAME, "Address.java", sourceWriter);
+ }
+
+ private ICompilationUnit createTestEntityWithValidMapOneToManyMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @OneToMany").append(CR);
+ sb.append(" private java.util.Map<String, Address> addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
+ private ICompilationUnit createTestEntityWithValidNonGenericMapOneToManyMapping() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.ID);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append(" @OneToMany").append(CR);
+ sb.append(" private java.util.Map addresses;").append(CR);
+ sb.append(CR);
+ sb.append(" @Id").append(CR);
+ }
+ });
+ }
+
+ private void createTestEmbeddableState() 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("State").append(" ");
+ sb.append("{").append(CR);
+ sb.append(CR);
+ sb.append(" private String name;").append(CR);
+ sb.append(CR);
+ sb.append(" private String abbr;").append(CR);
+ sb.append(CR);
+ sb.append("}").append(CR);
+ }
+ };
+ this.javaProject.createCompilationUnit(PACKAGE_NAME, "State.java", sourceWriter);
+ }
private OrmOrphanRemovable2_0 getOrphanRemovalOf(OneToManyMapping2_0 oneToManyMapping) {
return ((OrmOrphanRemovalHolder2_0) oneToManyMapping).getOrphanRemoval();
@@ -71,4 +179,192 @@ public class EclipseLink2_0OrmOneToManyMappingTests
assertEquals(Boolean.FALSE, oneToManyResource.getOrphanRemoval());
assertEquals(Boolean.FALSE, mappingsOrphanRemoval.getSpecifiedOrphanRemoval());
}
+ public void testUpdateVirtualMapKey() throws Exception {
+ createTestEntityWithValidMapOneToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ JavaOneToManyMapping javaOneToManyMapping = (JavaOneToManyMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+ assertNull(ormOneToManyMapping.getSpecifiedMapKey());
+ assertNull(ormOneToManyMapping.getMapKey());
+ assertFalse(ormOneToManyMapping.isPkMapKey());
+ assertFalse(ormOneToManyMapping.isCustomMapKey());
+ assertTrue(ormOneToManyMapping.isNoMapKey());
+
+ //set pk mapKey in the java, verify virtual orm mapping updates
+ javaOneToManyMapping.setPkMapKey(true);
+ assertEquals("id", ormOneToManyMapping.getMapKey());
+ assertTrue(ormOneToManyMapping.isPkMapKey());
+ assertFalse(ormOneToManyMapping.isCustomMapKey());
+ assertFalse(ormOneToManyMapping.isNoMapKey());
+
+
+ //set custom specified mapKey in the java, verify virtual orm mapping updates
+ javaOneToManyMapping.setCustomMapKey(true);
+ javaOneToManyMapping.setSpecifiedMapKey("city");
+ assertEquals("city", ormOneToManyMapping.getSpecifiedMapKey());
+ assertEquals("city", ormOneToManyMapping.getMapKey());
+ assertFalse(ormOneToManyMapping.isPkMapKey());
+ assertTrue(ormOneToManyMapping.isCustomMapKey());
+ assertFalse(ormOneToManyMapping.isNoMapKey());
+
+ //set metadata complete and verify that the orm model ignores the java annotations
+ ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
+ assertEquals(null, ormOneToManyMapping.getSpecifiedMapKey());
+ assertEquals(null, ormOneToManyMapping.getMapKey());
+ assertFalse(ormOneToManyMapping.isPkMapKey());
+ assertFalse(ormOneToManyMapping.isCustomMapKey());
+ assertTrue(ormOneToManyMapping.isNoMapKey());
+ }
+
+ public void testCandidateMapKeyNames() throws Exception {
+ createTestEntityWithValidMapOneToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+
+ Iterator<String> mapKeyNames =
+ ormOneToManyMapping.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.name", mapKeyNames.next());
+ assertEquals("state.abbr", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+ }
+
+ public void testCandidateMapKeyNames2() throws Exception {
+ createTestEntityWithValidNonGenericMapOneToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ JavaOneToManyMapping javaOneToManyMapping = (JavaOneToManyMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+
+ Iterator<String> mapKeyNames = ormOneToManyMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+
+ javaOneToManyMapping.setSpecifiedTargetEntity("test.Address");
+ mapKeyNames = ormOneToManyMapping.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.name", mapKeyNames.next());
+ assertEquals("state.abbr", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+
+ ormOneToManyMapping.getPersistentAttribute().makeSpecified();
+ ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ mapKeyNames = ormOneToManyMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+
+ ormOneToManyMapping.setSpecifiedTargetEntity("test.Address");
+ mapKeyNames = ormOneToManyMapping.candidateMapKeyNames();
+ assertEquals("id", mapKeyNames.next());
+ assertEquals("city", mapKeyNames.next());
+ assertEquals("state", mapKeyNames.next());
+ assertEquals("state.name", mapKeyNames.next());
+ assertEquals("state.abbr", mapKeyNames.next());
+ assertEquals("zip", mapKeyNames.next());
+ assertFalse(mapKeyNames.hasNext());
+
+ ormOneToManyMapping.setSpecifiedTargetEntity("String");
+ mapKeyNames = ormOneToManyMapping.candidateMapKeyNames();
+ assertEquals(false, mapKeyNames.hasNext());
+ }
+
+ public void testUpdateMapKeyClass() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
+ OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping();
+ XmlOneToMany oneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0);
+
+ assertNull(ormOneToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(oneToMany.getMapKeyClass());
+
+ //set mapKey in the resource model, verify context model does not change
+ oneToMany.setMapKeyClass(OrmFactory.eINSTANCE.createXmlMapKeyClass());
+ assertNull(ormOneToManyMapping.getSpecifiedMapKeyClass());
+ assertNotNull(oneToMany.getMapKeyClass());
+
+ //set mapKey name in the resource model, verify context model updated
+ oneToMany.getMapKeyClass().setClassName("String");
+ assertEquals("String", ormOneToManyMapping.getSpecifiedMapKeyClass());
+ assertEquals("String", oneToMany.getMapKeyClass().getClassName());
+
+ //set mapKey name to null in the resource model
+ oneToMany.getMapKeyClass().setClassName(null);
+ assertNull(ormOneToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(oneToMany.getMapKeyClass().getClassName());
+
+ oneToMany.getMapKeyClass().setClassName("String");
+ oneToMany.setMapKeyClass(null);
+ assertNull(ormOneToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(oneToMany.getMapKeyClass());
+ }
+
+ public void testUpdateVirtualMapKeyClass() throws Exception {
+ createTestEntityWithValidMapOneToManyMapping();
+ createTestTargetEntityAddress();
+ createTestEmbeddableState();
+
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
+ getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
+
+ OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
+ JavaOneToManyMapping javaOneToManyMapping = (JavaOneToManyMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
+ assertEquals(null, ormOneToManyMapping.getSpecifiedMapKeyClass());
+ assertEquals("java.lang.String", ormOneToManyMapping.getMapKeyClass());
+ assertEquals("java.lang.String", ormOneToManyMapping.getDefaultMapKeyClass());
+
+ //set pk mapKey in the java, verify virtual orm mapping updates
+ javaOneToManyMapping.setSpecifiedMapKeyClass("Integer");
+ assertEquals("Integer", ormOneToManyMapping.getMapKeyClass());
+ assertEquals("Integer", ormOneToManyMapping.getSpecifiedMapKeyClass());
+ assertEquals("java.lang.String", ormOneToManyMapping.getDefaultMapKeyClass());
+
+
+ //set custom specified mapKey in the java, verify virtual orm mapping updates
+ ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
+ assertEquals(null, ormOneToManyMapping.getSpecifiedMapKeyClass());
+ assertEquals("java.lang.String", ormOneToManyMapping.getMapKeyClass());
+ assertEquals("java.lang.String", ormOneToManyMapping.getDefaultMapKeyClass());
+ }
+
+ public void testModifyMapKeyClass() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
+ OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping();
+ XmlOneToMany oneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0);
+
+ assertNull(ormOneToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(oneToMany.getMapKeyClass());
+
+ //set mapKey in the context model, verify resource model updated
+ ormOneToManyMapping.setSpecifiedMapKeyClass("String");
+ assertEquals("String", ormOneToManyMapping.getSpecifiedMapKeyClass());
+ assertEquals("String", oneToMany.getMapKeyClass().getClassName());
+
+ //set mapKey to null in the context model
+ ormOneToManyMapping.setSpecifiedMapKeyClass(null);
+ assertNull(ormOneToManyMapping.getSpecifiedMapKeyClass());
+ assertNull(oneToMany.getMapKeyClass());
+ }
}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/orm/JptEclipseLink2_0OrmContextModelTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/orm/JptEclipseLink2_0OrmContextModelTests.java
index 136bdb6f11..dd36269174 100644
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/orm/JptEclipseLink2_0OrmContextModelTests.java
+++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/orm/JptEclipseLink2_0OrmContextModelTests.java
@@ -17,7 +17,9 @@ public class JptEclipseLink2_0OrmContextModelTests extends TestCase
{
public static Test suite() {
TestSuite suite = new TestSuite(JptEclipseLink2_0OrmContextModelTests.class.getName());
+ suite.addTestSuite(EclipseLink2_0OrmElementCollectionMappingTests.class);
suite.addTestSuite(EclipseLink2_0OrmEntityTests.class);
+ suite.addTestSuite(EclipseLink2_0OrmManyToManyMappingTests.class);
suite.addTestSuite(Eclipselink2_0OrmManyToOneMappingTests.class);
suite.addTestSuite(EclipseLink2_0OrmMappedSuperclassTests.class);
suite.addTestSuite(EclipseLink2_0OrmOneToOneMappingTests.class);

Back to the top