summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaren Butzke2012-11-19 15:41:41 (EST)
committerKaren Butzke2012-11-19 15:41:41 (EST)
commit5356a5ed339c87dc85478975707b3ef60617a957 (patch)
treed65d80bfceeb1637e58c6d0e53535689fd341651
parentcd9b5ac8c5cc54381482501e4c09af1a087a50fc (diff)
downloadwebtools.dali-5356a5ed339c87dc85478975707b3ef60617a957.zip
webtools.dali-5356a5ed339c87dc85478975707b3ef60617a957.tar.gz
webtools.dali-5356a5ed339c87dc85478975707b3ef60617a957.tar.bz2
Bug 263954 - [EclipseLink] EclipseLink 1.1 support for generators on basic mappings
Bug 374404 - [EclipseLink] generators need to be supported on mapped superclasses in 2.1 and higher
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/property_files/jpa_validation.properties2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaFactory.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/GeneratedValueHolder.java31
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/IdMapping.java11
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaGeneratedValueHolder.java27
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaIdMapping.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmGeneratedValueHolder.java31
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmIdMapping.java9
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaFactory.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaGeneratedValue.java24
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmGeneratedValue.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/validation/JpaValidationMessages.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/EclipseLinkBasicMapping.java10
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/EclipseLinkNonEmbeddableTypeMapping.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/java/JavaEclipseLinkNonEmbeddableTypeMapping.java5
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/orm/OrmEclipseLinkNonEmbeddableTypeMapping.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLink2_1JpaPlatformProvider.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaBasicMappingDefinition.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaMappedSuperclassDefinition2_1.java63
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaMappedSuperclassDefinition2_2.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkBasicMapping.java146
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkMappedSuperclassImpl.java49
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkBasicMapping.java114
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkMappedSuperclassImpl.java30
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/java/AbstractJavaEclipseLinkMappedSuperclassComposite.java32
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/java/JavaEclipseLinkMappedSuperclass2_1Composite.java84
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/java/JavaEclipseLinkMappedSuperclass2_3Composite.java1
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/orm/AbstractOrmEclipseLinkMappedSuperclassComposite.java32
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/orm/OrmEclipseLinkMappedSuperclass2_1Composite.java1
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/orm/OrmEclipseLinkMappedSuperclass2_3Composite.java1
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui_validation_preferences.properties2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiValidationPreferenceMessages.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/prefs/JpaProblemSeveritiesPage.java14
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLink2_1JavaMappedSuperclassTests.java171
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLink2_2JavaEntityTests.java11
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLink2_2JavaMappedSuperclassTests.java15
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/JptEclipseLinkCoreJavaContextModelTests.java5
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLink2_1OrmMappedSuperclassTests.java149
38 files changed, 1050 insertions, 63 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/property_files/jpa_validation.properties b/jpa/plugins/org.eclipse.jpt.jpa.core/property_files/jpa_validation.properties
index 882870c..3d25621 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/property_files/jpa_validation.properties
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/property_files/jpa_validation.properties
@@ -258,7 +258,7 @@ ENTITY_TABLE_PER_CLASS_NOT_SUPPORTED_ON_PLATFORM=Entity \"{0}\" cannot use table
### Generator ###
GENERATOR_DUPLICATE_NAME=Duplicate generator named \"{0}\" defined in this persistence unit
GENERATOR_NAME_UNDEFINED=Generator is unnamed. All generators require a name.
-ID_MAPPING_UNRESOLVED_GENERATOR_NAME=No generator named \"{0}\" is defined in the persistence unit
+UNRESOLVED_GENERATOR_NAME=No generator named \"{0}\" is defined in the persistence unit
### Query ###
QUERY_DUPLICATE_NAME=Duplicate query named \"{0}\" defined in this persistence unit
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaFactory.java
index 1a165bd..e2ece84 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaFactory.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaFactory.java
@@ -241,7 +241,7 @@ public interface JpaFactory
JavaTableGenerator buildJavaTableGenerator(JavaGeneratorContainer parent, TableGeneratorAnnotation tableGeneratorAnnotation);
- JavaGeneratedValue buildJavaGeneratedValue(JavaIdMapping parent, GeneratedValueAnnotation generatedValueAnnotation);
+ JavaGeneratedValue buildJavaGeneratedValue(JavaAttributeMapping parent, GeneratedValueAnnotation generatedValueAnnotation);
JavaPrimaryKeyJoinColumn buildJavaPrimaryKeyJoinColumn(JpaContextNode parent, ReadOnlyBaseJoinColumn.Owner owner, PrimaryKeyJoinColumnAnnotation pkJoinColumnAnnotation);
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/GeneratedValueHolder.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/GeneratedValueHolder.java
new file mode 100644
index 0000000..120dc50
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/GeneratedValueHolder.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.context;
+
+/**
+ *
+ * <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.
+ *
+ * @version 3.3
+ * @since 3.3
+ */
+public interface GeneratedValueHolder
+ extends JpaContextNode
+{
+ GeneratedValue getGeneratedValue();
+ GeneratedValue addGeneratedValue();
+ void removeGeneratedValue();
+ String GENERATED_VALUE_PROPERTY = "generatedValue"; //$NON-NLS-1$
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/IdMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/IdMapping.java
index d4f117f..eeabc77 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/IdMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/IdMapping.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
+ * Copyright (c) 2006, 2012 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -18,16 +18,11 @@ package org.eclipse.jpt.jpa.core.context;
* pioneering adopters on the understanding that any code that uses this API
* will almost certainly be broken (repeatedly) as the API evolves.
*
- * @version 2.3
+ * @version 3.3
* @since 2.0
*/
public interface IdMapping
- extends ColumnMapping, ConvertibleMapping
+ extends ColumnMapping, ConvertibleMapping, GeneratedValueHolder
{
GeneratorContainer getGeneratorContainer();
-
- GeneratedValue getGeneratedValue();
- GeneratedValue addGeneratedValue();
- void removeGeneratedValue();
- String GENERATED_VALUE_PROPERTY = "generatedValue"; //$NON-NLS-1$
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaGeneratedValueHolder.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaGeneratedValueHolder.java
new file mode 100644
index 0000000..5a7eab8
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaGeneratedValueHolder.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.context.java;
+
+import org.eclipse.jpt.jpa.core.context.GeneratedValueHolder;
+
+/**
+ * <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 JavaGeneratedValueHolder
+ extends GeneratedValueHolder, JavaAttributeMapping
+{
+ JavaGeneratedValue getGeneratedValue();
+ JavaGeneratedValue addGeneratedValue();
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaIdMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaIdMapping.java
index db9520b..385f593 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaIdMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaIdMapping.java
@@ -21,16 +21,13 @@ import org.eclipse.jpt.jpa.core.resource.java.IdAnnotation;
* pioneering adopters on the understanding that any code that uses this API
* will almost certainly be broken (repeatedly) as the API evolves.
*
- * @version 2.3
+ * @version 3.3
* @since 2.0
*/
public interface JavaIdMapping
- extends IdMapping, JavaColumnMapping, JavaConvertibleMapping, JavaGeneratorContainer.ParentAdapter
+ extends IdMapping, JavaColumnMapping, JavaConvertibleMapping, JavaGeneratorContainer.ParentAdapter, JavaGeneratedValueHolder
{
IdAnnotation getMappingAnnotation();
JavaGeneratorContainer getGeneratorContainer();
-
- JavaGeneratedValue getGeneratedValue();
- JavaGeneratedValue addGeneratedValue();
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmGeneratedValueHolder.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmGeneratedValueHolder.java
new file mode 100644
index 0000000..467b8fa
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmGeneratedValueHolder.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.context.orm;
+
+import org.eclipse.jpt.jpa.core.context.GeneratedValueHolder;
+
+/**
+ * <code>orm.xml</code> ID mapping
+ * <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.
+ *
+ * @version 3.3
+ * @since 3.3
+ */
+public interface OrmGeneratedValueHolder
+ extends GeneratedValueHolder
+{
+ OrmGeneratedValue getGeneratedValue();
+ OrmGeneratedValue addGeneratedValue();
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmIdMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmIdMapping.java
index 1b6be0b..f33facc 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmIdMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmIdMapping.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -21,16 +21,13 @@ import org.eclipse.jpt.jpa.core.resource.orm.XmlId;
* pioneering adopters on the understanding that any code that uses this API
* will almost certainly be broken (repeatedly) as the API evolves.
*
- * @version 2.3
+ * @version 3.3
* @since 2.0
*/
public interface OrmIdMapping
- extends IdMapping, OrmColumnMapping, OrmConvertibleMapping
+ extends IdMapping, OrmColumnMapping, OrmConvertibleMapping, OrmGeneratedValueHolder
{
XmlId getXmlAttributeMapping();
OrmGeneratorContainer getGeneratorContainer();
-
- OrmGeneratedValue getGeneratedValue();
- OrmGeneratedValue addGeneratedValue();
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaFactory.java
index 621839d..7a6b753 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaFactory.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaFactory.java
@@ -333,7 +333,7 @@ public abstract class AbstractJpaFactory
return new GenericJavaTableGenerator(parent, tableGeneratorAnnotation);
}
- public JavaGeneratedValue buildJavaGeneratedValue(JavaIdMapping parent, GeneratedValueAnnotation generatedValueAnnotation) {
+ public JavaGeneratedValue buildJavaGeneratedValue(JavaAttributeMapping parent, GeneratedValueAnnotation generatedValueAnnotation) {
return new GenericJavaGeneratedValue(parent, generatedValueAnnotation);
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaGeneratedValue.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaGeneratedValue.java
index e899ec1..c5f104b 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaGeneratedValue.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaGeneratedValue.java
@@ -15,8 +15,8 @@ import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.jpt.common.utility.internal.iterable.TransformationIterable;
import org.eclipse.jpt.jpa.core.context.GenerationType;
import org.eclipse.jpt.jpa.core.context.Generator;
+import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
import org.eclipse.jpt.jpa.core.context.java.JavaGeneratedValue;
-import org.eclipse.jpt.jpa.core.context.java.JavaIdMapping;
import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode;
import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
@@ -40,7 +40,7 @@ public class GenericJavaGeneratedValue
protected String defaultGenerator;
- public GenericJavaGeneratedValue(JavaIdMapping parent, GeneratedValueAnnotation generatedValueAnnotation) {
+ public GenericJavaGeneratedValue(JavaAttributeMapping parent, GeneratedValueAnnotation generatedValueAnnotation) {
super(parent);
this.generatedValueAnnotation = generatedValueAnnotation;
this.specifiedStrategy = this.buildSpecifiedStrategy();
@@ -144,11 +144,11 @@ public class GenericJavaGeneratedValue
// ********** misc **********
@Override
- public JavaIdMapping getParent() {
- return (JavaIdMapping) super.getParent();
+ public JavaAttributeMapping getParent() {
+ return (JavaAttributeMapping) super.getParent();
}
- protected JavaIdMapping getIdMapping() {
+ protected JavaAttributeMapping getAttributeMapping() {
return this.getParent();
}
@@ -202,14 +202,14 @@ public class GenericJavaGeneratedValue
}
}
- if (getIdMapping().getPersistentAttribute().isVirtual()) {
+ if (getAttributeMapping().getPersistentAttribute().isVirtual()) {
messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
- JpaValidationMessages.ID_MAPPING_UNRESOLVED_GENERATOR_NAME, //TODO KFB need a different message for virtual
+ JpaValidationMessages.UNRESOLVED_GENERATOR_NAME, //TODO KFB need a different message for virtual
new String[] {generator},
- this.getIdMapping(),
- this.getIdMapping().getPersistentAttribute().getValidationTextRange()
+ this.getAttributeMapping(),
+ this.getAttributeMapping().getPersistentAttribute().getValidationTextRange()
)
);
}
@@ -217,9 +217,9 @@ public class GenericJavaGeneratedValue
messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
- JpaValidationMessages.ID_MAPPING_UNRESOLVED_GENERATOR_NAME,
+ JpaValidationMessages.UNRESOLVED_GENERATOR_NAME,
new String[] {generator},
- this.getIdMapping(),
+ this.getAttributeMapping(),
this.getGeneratorTextRange()
)
);
@@ -228,7 +228,7 @@ public class GenericJavaGeneratedValue
public TextRange getValidationTextRange() {
TextRange textRange = this.getAnnotationTextRange();
- return (textRange != null) ? textRange : this.getIdMapping().getValidationTextRange();
+ return (textRange != null) ? textRange : this.getAttributeMapping().getValidationTextRange();
}
protected TextRange getAnnotationTextRange() {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmGeneratedValue.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmGeneratedValue.java
index 45800a1..f2eee2e 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmGeneratedValue.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmGeneratedValue.java
@@ -168,7 +168,7 @@ public class GenericOrmGeneratedValue
messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
- JpaValidationMessages.ID_MAPPING_UNRESOLVED_GENERATOR_NAME,
+ JpaValidationMessages.UNRESOLVED_GENERATOR_NAME,
new String[] {generator},
this.getParent(),
this.getGeneratorTextRange()
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/validation/JpaValidationMessages.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/validation/JpaValidationMessages.java
index 9bb97ed..eaf456a 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/validation/JpaValidationMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/validation/JpaValidationMessages.java
@@ -293,7 +293,7 @@ public interface JpaValidationMessages {
//Generator
public static final String GENERATOR_DUPLICATE_NAME = "GENERATOR_DUPLICATE_NAME";
public static final String GENERATOR_NAME_UNDEFINED = "GENERATOR_NAME_UNDEFINED";
- public static final String ID_MAPPING_UNRESOLVED_GENERATOR_NAME = "ID_MAPPING_UNRESOLVED_GENERATOR_NAME";
+ public static final String UNRESOLVED_GENERATOR_NAME = "UNRESOLVED_GENERATOR_NAME";
//Query
public static final String JPQL_QUERY_VALIDATION = "JPQL_QUERY_VALIDATION";
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/EclipseLinkBasicMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/EclipseLinkBasicMapping.java
index 7483180..bd4fd4d 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/EclipseLinkBasicMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/EclipseLinkBasicMapping.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2012 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -10,6 +10,8 @@
package org.eclipse.jpt.jpa.eclipselink.core.context;
import org.eclipse.jpt.jpa.core.context.BasicMapping;
+import org.eclipse.jpt.jpa.core.context.GeneratedValueHolder;
+import org.eclipse.jpt.jpa.core.context.GeneratorContainer;
/**
* EclipseLink basic mapping.
@@ -20,11 +22,13 @@ import org.eclipse.jpt.jpa.core.context.BasicMapping;
* pioneering adopters on the understanding that any code that uses this API
* will almost certainly be broken (repeatedly) as the API evolves.
*
- * @version 3.2
+ * @version 3.3
* @since 2.1
*/
public interface EclipseLinkBasicMapping
- extends BasicMapping, EclipseLinkConvertibleMapping
+ extends BasicMapping, EclipseLinkConvertibleMapping, GeneratedValueHolder
{
EclipseLinkMutable getMutable();
+
+ GeneratorContainer getGeneratorContainer(); //supported on Basic in EL 1.1
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/EclipseLinkNonEmbeddableTypeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/EclipseLinkNonEmbeddableTypeMapping.java
index 710f10a..2eb269b 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/EclipseLinkNonEmbeddableTypeMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/EclipseLinkNonEmbeddableTypeMapping.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2012 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -9,6 +9,8 @@
******************************************************************************/
package org.eclipse.jpt.jpa.eclipselink.core.context;
+import org.eclipse.jpt.jpa.core.context.GeneratorContainer;
+
/**
* EclipseLink non-embeddable type mapping
@@ -32,4 +34,7 @@ public interface EclipseLinkNonEmbeddableTypeMapping
* Used for validating whether tenant discriminator columns may be specified
*/
boolean isMultitenantMetadataAllowed();
+
+ GeneratorContainer getGeneratorContainer(); //supported on MappedSuperclasses in EL 2.1
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/java/JavaEclipseLinkNonEmbeddableTypeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/java/JavaEclipseLinkNonEmbeddableTypeMapping.java
index 4d89e38..183ab1a 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/java/JavaEclipseLinkNonEmbeddableTypeMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/java/JavaEclipseLinkNonEmbeddableTypeMapping.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2012 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -9,6 +9,7 @@
******************************************************************************/
package org.eclipse.jpt.jpa.eclipselink.core.context.java;
+import org.eclipse.jpt.jpa.core.context.java.JavaGeneratorContainer;
import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkNonEmbeddableTypeMapping;
/**
@@ -26,4 +27,6 @@ public interface JavaEclipseLinkNonEmbeddableTypeMapping
JavaEclipseLinkCaching getCaching();
JavaEclipseLinkMultitenancy2_3 getMultitenancy();
+
+ JavaGeneratorContainer getGeneratorContainer();
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/orm/OrmEclipseLinkNonEmbeddableTypeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/orm/OrmEclipseLinkNonEmbeddableTypeMapping.java
index d77de36..980f985 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/orm/OrmEclipseLinkNonEmbeddableTypeMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/orm/OrmEclipseLinkNonEmbeddableTypeMapping.java
@@ -9,6 +9,7 @@
******************************************************************************/
package org.eclipse.jpt.jpa.eclipselink.core.context.orm;
+import org.eclipse.jpt.jpa.core.context.orm.OrmGeneratorContainer;
import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkNonEmbeddableTypeMapping;
import org.eclipse.jpt.jpa.eclipselink.core.context.java.JavaEclipseLinkNonEmbeddableTypeMapping;
@@ -30,4 +31,6 @@ public interface OrmEclipseLinkNonEmbeddableTypeMapping
JavaEclipseLinkNonEmbeddableTypeMapping getJavaTypeMappingForDefaults();
OrmEclipseLinkMultitenancy2_3 getMultitenancy();
+
+ OrmGeneratorContainer getGeneratorContainer();
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLink2_1JpaPlatformProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLink2_1JpaPlatformProvider.java
index e0d65e4..365f024 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLink2_1JpaPlatformProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLink2_1JpaPlatformProvider.java
@@ -40,7 +40,7 @@ import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJav
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaIdMappingDefinition2_0;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaManyToManyMappingDefinition2_0;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaManyToOneMappingDefinition2_0;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaMappedSuperclassDefinition2_0;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaMappedSuperclassDefinition2_1;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaOneToManyMappingDefinition2_0;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaOneToOneMappingDefinition2_0;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaTransformationMappingDefinition2_0;
@@ -121,7 +121,7 @@ public class EclipseLink2_1JpaPlatformProvider
protected static final JavaTypeMappingDefinition[] JAVA_TYPE_MAPPING_DEFINITIONS = new JavaTypeMappingDefinition[] {
EclipseLinkJavaEntityDefinition2_0.instance(),
EclipseLinkJavaEmbeddableDefinition2_0.instance(),
- EclipseLinkJavaMappedSuperclassDefinition2_0.instance()
+ EclipseLinkJavaMappedSuperclassDefinition2_1.instance()
};
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaBasicMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaBasicMappingDefinition.java
index 46d900e..552c505 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaBasicMappingDefinition.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaBasicMappingDefinition.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2012 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -14,6 +14,9 @@ import org.eclipse.jpt.common.utility.internal.iterable.CompositeIterable;
import org.eclipse.jpt.jpa.core.context.java.DefaultJavaAttributeMappingDefinition;
import org.eclipse.jpt.jpa.core.internal.context.java.DefaultJavaAttributeMappingDefinitionWrapper;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaBasicMappingDefinition;
+import org.eclipse.jpt.jpa.core.resource.java.GeneratedValueAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.SequenceGeneratorAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.TableGeneratorAnnotation;
import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkConvertAnnotation;
import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkConverterAnnotation;
import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkMutableAnnotation;
@@ -61,6 +64,9 @@ public class EclipseLinkJavaBasicMappingDefinition
EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME,
EclipseLinkStructConverterAnnotation.ANNOTATION_NAME,
EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME,
+ GeneratedValueAnnotation.ANNOTATION_NAME,
+ TableGeneratorAnnotation.ANNOTATION_NAME,
+ SequenceGeneratorAnnotation.ANNOTATION_NAME
};
// 'public' because the EclipseLink Id and Version mappings also support these annotations
public static final Iterable<String> ECLIPSE_LINK_SUPPORTING_ANNOTATION_NAMES = new ArrayIterable<String>(ECLIPSE_LINK_SUPPORTING_ANNOTATION_NAMES_ARRAY);
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaMappedSuperclassDefinition2_1.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaMappedSuperclassDefinition2_1.java
new file mode 100644
index 0000000..59a108d
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaMappedSuperclassDefinition2_1.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.eclipselink.core.internal.context.java;
+
+import org.eclipse.jpt.common.utility.internal.iterable.ArrayIterable;
+import org.eclipse.jpt.common.utility.internal.iterable.CompositeIterable;
+import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaTypeMappingDefinitionWrapper;
+import org.eclipse.jpt.jpa.core.resource.java.SequenceGeneratorAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.TableGeneratorAnnotation;
+
+public class EclipseLinkJavaMappedSuperclassDefinition2_1
+ extends JavaTypeMappingDefinitionWrapper
+{
+ private static final JavaTypeMappingDefinition DELEGATE = EclipseLinkJavaMappedSuperclassDefinition2_0.instance();
+
+ // singleton
+ private static final JavaTypeMappingDefinition INSTANCE = new EclipseLinkJavaMappedSuperclassDefinition2_1();
+
+ /**
+ * Return the singleton.
+ */
+ public static JavaTypeMappingDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Enforce singleton usage
+ */
+ private EclipseLinkJavaMappedSuperclassDefinition2_1() {
+ super();
+ }
+
+ @Override
+ protected JavaTypeMappingDefinition getDelegate() {
+ return DELEGATE;
+ }
+
+ @Override
+ public Iterable<String> getSupportingAnnotationNames() {
+ return COMBINED_SUPPORTING_ANNOTATION_NAMES;
+ }
+
+ public static final String[] ECLIPSE_LINK2_1_SUPPORTING_ANNOTATION_NAMES_ARRAY = new String[] {
+ TableGeneratorAnnotation.ANNOTATION_NAME,
+ SequenceGeneratorAnnotation.ANNOTATION_NAME
+ };
+ public static final Iterable<String> ECLIPSE_LINK2_1_SUPPORTING_ANNOTATION_NAMES = new ArrayIterable<String>(ECLIPSE_LINK2_1_SUPPORTING_ANNOTATION_NAMES_ARRAY);
+
+ @SuppressWarnings("unchecked")
+ private static final Iterable<String> COMBINED_SUPPORTING_ANNOTATION_NAMES = new CompositeIterable<String>(
+ DELEGATE.getSupportingAnnotationNames(),
+ ECLIPSE_LINK2_1_SUPPORTING_ANNOTATION_NAMES
+ );
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaMappedSuperclassDefinition2_2.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaMappedSuperclassDefinition2_2.java
index 46f2a72..584c49c 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaMappedSuperclassDefinition2_2.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaMappedSuperclassDefinition2_2.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
+ * Copyright (c) 2011, 2012 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -18,7 +18,7 @@ import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
public class EclipseLinkJavaMappedSuperclassDefinition2_2
extends JavaTypeMappingDefinitionWrapper
{
- private static final JavaTypeMappingDefinition DELEGATE = EclipseLinkJavaMappedSuperclassDefinition2_0.instance();
+ private static final JavaTypeMappingDefinition DELEGATE = EclipseLinkJavaMappedSuperclassDefinition2_1.instance();
// singleton
private static final JavaTypeMappingDefinition INSTANCE = new EclipseLinkJavaMappedSuperclassDefinition2_2();
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkBasicMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkBasicMapping.java
index 328b7b1..ff9e3a2 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkBasicMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkBasicMapping.java
@@ -11,11 +11,17 @@ package org.eclipse.jpt.jpa.eclipselink.core.internal.context.java;
import java.util.List;
import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceMember;
import org.eclipse.jpt.common.utility.internal.iterable.CompositeIterable;
+import org.eclipse.jpt.jpa.core.context.Generator;
import org.eclipse.jpt.jpa.core.context.JpaContextNode;
import org.eclipse.jpt.jpa.core.context.java.JavaConverter;
+import org.eclipse.jpt.jpa.core.context.java.JavaGeneratedValue;
+import org.eclipse.jpt.jpa.core.context.java.JavaGeneratedValueHolder;
+import org.eclipse.jpt.jpa.core.context.java.JavaGeneratorContainer;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaBasicMapping;
+import org.eclipse.jpt.jpa.core.resource.java.GeneratedValueAnnotation;
import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkBasicMapping;
import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkMutable;
import org.eclipse.jpt.jpa.eclipselink.core.context.java.EclipseLinkJavaConvertibleMapping;
@@ -25,17 +31,27 @@ import org.eclipse.wst.validation.internal.provisional.core.IReporter;
public class JavaEclipseLinkBasicMapping
extends AbstractJavaBasicMapping
- implements EclipseLinkBasicMapping, EclipseLinkJavaConvertibleMapping
+ implements
+ EclipseLinkBasicMapping,
+ EclipseLinkJavaConvertibleMapping,
+ JavaGeneratorContainer.ParentAdapter,
+ JavaGeneratedValueHolder
{
protected final JavaEclipseLinkMutable mutable;
protected final JavaEclipseLinkConverterContainer converterContainer;
+ protected final JavaGeneratorContainer generatorContainer;
+
+ protected JavaGeneratedValue generatedValue;
+
public JavaEclipseLinkBasicMapping(JavaPersistentAttribute parent) {
super(parent);
this.mutable = new JavaEclipseLinkMutable(this);
this.converterContainer = this.buildConverterContainer();
+ this.generatorContainer = this.buildGeneratorContainer();
+ this.generatedValue = this.buildGeneratedValue();
}
@@ -46,6 +62,8 @@ public class JavaEclipseLinkBasicMapping
super.synchronizeWithResourceModel();
this.mutable.synchronizeWithResourceModel();
this.converterContainer.synchronizeWithResourceModel();
+ this.generatorContainer.synchronizeWithResourceModel();
+ this.syncGeneratedValue();
}
@Override
@@ -53,6 +71,10 @@ public class JavaEclipseLinkBasicMapping
super.update();
this.mutable.update();
this.converterContainer.update();
+ this.generatorContainer.update();
+ if (this.generatedValue != null) {
+ this.generatedValue.update();
+ }
}
@@ -100,6 +122,123 @@ public class JavaEclipseLinkBasicMapping
);
}
+ // ********** generator container **********
+
+ public JavaGeneratorContainer getGeneratorContainer() {
+ return this.generatorContainer;
+ }
+
+ protected JavaGeneratorContainer buildGeneratorContainer() {
+ return this.getJpaFactory().buildJavaGeneratorContainer(this);
+ }
+
+ @Override
+ public Iterable<Generator> getGenerators() {
+ return this.generatorContainer.getGenerators();
+ }
+
+
+ // ********** generator container parent adapter **********
+
+ public JpaContextNode getGeneratorContainerParent() {
+ return this; // no adapter
+ }
+
+ public JavaResourceMember getResourceAnnotatedElement() {
+ return this.getResourceAttribute();
+ }
+
+ public boolean parentSupportsGenerators() {
+ return ! this.getPersistentAttribute().isVirtual();
+ }
+
+
+ // ********** generated value **********
+
+ public JavaGeneratedValue getGeneratedValue() {
+ return this.generatedValue;
+ }
+
+ public JavaGeneratedValue addGeneratedValue() {
+ if (this.generatedValue != null) {
+ throw new IllegalStateException("generated value already exists: " + this.generatedValue); //$NON-NLS-1$
+ }
+ GeneratedValueAnnotation annotation = this.buildGeneratedValueAnnotation();
+ JavaGeneratedValue value = this.buildGeneratedValue(annotation);
+ this.setGeneratedValue(value);
+ return value;
+ }
+
+ protected GeneratedValueAnnotation buildGeneratedValueAnnotation() {
+ return (GeneratedValueAnnotation) this.getResourceAttribute().addAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME);
+ }
+
+ public void removeGeneratedValue() {
+ if (this.generatedValue == null) {
+ throw new IllegalStateException("generated value does not exist"); //$NON-NLS-1$
+ }
+ this.getResourceAttribute().removeAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME);
+ this.setGeneratedValue(null);
+ }
+
+ protected JavaGeneratedValue buildGeneratedValue() {
+ GeneratedValueAnnotation annotation = this.getGeneratedValueAnnotation();
+ return (annotation == null) ? null : this.buildGeneratedValue(annotation);
+ }
+
+ protected GeneratedValueAnnotation getGeneratedValueAnnotation() {
+ return (GeneratedValueAnnotation) this.getResourceAttribute().getAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME);
+ }
+
+ protected JavaGeneratedValue buildGeneratedValue(GeneratedValueAnnotation generatedValueAnnotation) {
+ return this.getJpaFactory().buildJavaGeneratedValue(this, generatedValueAnnotation);
+ }
+
+ protected void syncGeneratedValue() {
+ GeneratedValueAnnotation annotation = this.getGeneratedValueAnnotation();
+ if (annotation == null) {
+ if (this.generatedValue != null) {
+ this.setGeneratedValue(null);
+ }
+ }
+ else {
+ if ((this.generatedValue != null) && (this.generatedValue.getGeneratedValueAnnotation() == annotation)) {
+ this.generatedValue.synchronizeWithResourceModel();
+ } else {
+ this.setGeneratedValue(this.buildGeneratedValue(annotation));
+ }
+ }
+ }
+
+ protected void setGeneratedValue(JavaGeneratedValue value) {
+ JavaGeneratedValue old = this.generatedValue;
+ this.generatedValue = value;
+ this.firePropertyChanged(GENERATED_VALUE_PROPERTY, old, value);
+ }
+
+ // ********** Java completion proposals **********
+
+ @Override
+ public Iterable<String> getCompletionProposals(int pos) {
+ Iterable<String> result = super.getCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+
+ result = this.generatorContainer.getCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+
+ if (this.generatedValue != null) {
+ result = this.generatedValue.getCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
+
// ********** validation **********
@@ -107,5 +246,10 @@ public class JavaEclipseLinkBasicMapping
public void validate(List<IMessage> messages, IReporter reporter) {
super.validate(messages, reporter);
this.mutable.validate(messages, reporter);
+
+ this.generatorContainer.validate(messages, reporter);
+ if (this.generatedValue != null) {
+ this.generatedValue.validate(messages, reporter);
+ }
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkMappedSuperclassImpl.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkMappedSuperclassImpl.java
index d83e3ef..bdd13c9 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkMappedSuperclassImpl.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkMappedSuperclassImpl.java
@@ -16,7 +16,9 @@ import org.eclipse.jpt.common.utility.internal.iterable.CompositeIterable;
import org.eclipse.jpt.common.utility.internal.iterable.FilteringIterable;
import org.eclipse.jpt.common.utility.internal.iterable.TransformationIterable;
import org.eclipse.jpt.jpa.core.context.AttributeMapping;
+import org.eclipse.jpt.jpa.core.context.Generator;
import org.eclipse.jpt.jpa.core.context.JpaContextNode;
+import org.eclipse.jpt.jpa.core.context.java.JavaGeneratorContainer;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaMappedSuperclass;
@@ -46,7 +48,11 @@ import org.eclipse.wst.validation.internal.provisional.core.IReporter;
*/
public class JavaEclipseLinkMappedSuperclassImpl
extends AbstractJavaMappedSuperclass
- implements JavaEclipseLinkMappedSuperclass, JavaCacheableHolder2_0, JavaEclipseLinkConverterContainer.ParentAdapter
+ implements
+ JavaEclipseLinkMappedSuperclass,
+ JavaCacheableHolder2_0,
+ JavaEclipseLinkConverterContainer.ParentAdapter,
+ JavaGeneratorContainer.ParentAdapter
{
protected final JavaEclipseLinkCaching caching;
@@ -60,6 +66,8 @@ public class JavaEclipseLinkMappedSuperclassImpl
protected final JavaEclipseLinkMultitenancy2_3 multitenancy;
+ protected final JavaGeneratorContainer generatorContainer;
+
public JavaEclipseLinkMappedSuperclassImpl(JavaPersistentType parent, MappedSuperclassAnnotation mappingAnnotation) {
super(parent, mappingAnnotation);
this.caching = this.buildCaching();
@@ -68,6 +76,7 @@ public class JavaEclipseLinkMappedSuperclassImpl
this.changeTracking = this.buildChangeTracking();
this.customizer = this.buildCustomizer();
this.multitenancy = this.buildMultitenancy();
+ this.generatorContainer = this.buildGeneratorContainer();
}
@@ -81,6 +90,7 @@ public class JavaEclipseLinkMappedSuperclassImpl
this.converterContainer.synchronizeWithResourceModel();
this.changeTracking.synchronizeWithResourceModel();
this.customizer.synchronizeWithResourceModel();
+ this.generatorContainer.synchronizeWithResourceModel();
this.multitenancy.synchronizeWithResourceModel();
}
@@ -93,6 +103,7 @@ public class JavaEclipseLinkMappedSuperclassImpl
this.changeTracking.update();
this.customizer.update();
this.multitenancy.update();
+ this.generatorContainer.update();
}
@@ -200,6 +211,37 @@ public class JavaEclipseLinkMappedSuperclassImpl
return true;
}
+
+ // ********** generator container **********
+
+ public JavaGeneratorContainer getGeneratorContainer() {
+ return this.generatorContainer;
+ }
+
+ protected JavaGeneratorContainer buildGeneratorContainer() {
+ return this.getJpaFactory().buildJavaGeneratorContainer(this);
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public Iterable<Generator> getGenerators() {
+ return new CompositeIterable<Generator>(
+ super.getGenerators(),
+ this.generatorContainer.getGenerators()
+ );
+ }
+
+ // ********** generator container parent adapter **********
+
+ public JpaContextNode getGeneratorContainerParent() {
+ return this; // no adapter
+ }
+
+ public boolean parentSupportsGenerators() {
+ return true;
+ }
+
+
// ********** misc **********
public boolean usesPrimaryKeyColumns() {
@@ -244,6 +286,10 @@ public class JavaEclipseLinkMappedSuperclassImpl
if (result != null) {
return result;
}
+ result = this.generatorContainer.getCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
return null;
}
@@ -258,6 +304,7 @@ public class JavaEclipseLinkMappedSuperclassImpl
this.changeTracking.validate(messages, reporter);
this.customizer.validate(messages, reporter);
this.multitenancy.validate(messages, reporter);
+ this.generatorContainer.validate(messages, reporter);
}
@Override
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkBasicMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkBasicMapping.java
index 7f168b5..3d0b412 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkBasicMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkBasicMapping.java
@@ -16,10 +16,16 @@ import org.eclipse.jpt.common.core.internal.utility.JDTTools;
import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.jpt.common.utility.internal.iterable.CompositeIterable;
+import org.eclipse.jpt.jpa.core.context.Generator;
import org.eclipse.jpt.jpa.core.context.orm.OrmConverter;
+import org.eclipse.jpt.jpa.core.context.orm.OrmGeneratedValue;
+import org.eclipse.jpt.jpa.core.context.orm.OrmGeneratedValueHolder;
+import org.eclipse.jpt.jpa.core.context.orm.OrmGeneratorContainer;
import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
import org.eclipse.jpt.jpa.core.internal.context.MappingTools;
import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmBasicMapping;
+import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlGeneratedValue;
import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkAccessType;
import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkBasicMapping;
import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkMutable;
@@ -37,17 +43,23 @@ public class OrmEclipseLinkBasicMapping
implements
EclipseLinkBasicMapping,
EclipseLinkOrmConvertibleMapping,
- OrmEclipseLinkConverterContainer.Owner
+ OrmEclipseLinkConverterContainer.Owner,
+ OrmGeneratedValueHolder
{
protected final OrmEclipseLinkMutable mutable;
protected final OrmEclipseLinkConverterContainer converterContainer;
+ protected final OrmGeneratorContainer generatorContainer;//supported in EL 1.1 and higher
+
+ protected OrmGeneratedValue generatedValue;//supported in EL 1.1 and higher
public OrmEclipseLinkBasicMapping(OrmPersistentAttribute parent, XmlBasic xmlMapping) {
super(parent, xmlMapping);
this.mutable = new OrmEclipseLinkMutable(this);
this.converterContainer = this.buildConverterContainer();
+ this.generatorContainer = this.buildGeneratorContainer();
+ this.generatedValue = this.buildGeneratedValue();
}
@@ -58,6 +70,8 @@ public class OrmEclipseLinkBasicMapping
super.synchronizeWithResourceModel();
this.mutable.synchronizeWithResourceModel();
this.converterContainer.synchronizeWithResourceModel();
+ this.generatorContainer.synchronizeWithResourceModel();
+ this.syncGeneratedValue();
}
@Override
@@ -65,6 +79,10 @@ public class OrmEclipseLinkBasicMapping
super.update();
this.mutable.update();
this.converterContainer.update();
+ this.generatorContainer.update();
+ if (this.generatedValue != null) {
+ this.generatedValue.update();
+ }
}
@@ -102,6 +120,85 @@ public class OrmEclipseLinkBasicMapping
return 1;
}
+ // ********** generator container **********
+
+ public OrmGeneratorContainer getGeneratorContainer() {
+ return this.generatorContainer;
+ }
+
+ protected OrmGeneratorContainer buildGeneratorContainer() {
+ return this.getContextNodeFactory().buildOrmGeneratorContainer(this, this.xmlAttributeMapping);
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public Iterable<Generator> getGenerators() {
+ return new CompositeIterable<Generator>(
+ super.getGenerators(),
+ this.generatorContainer.getGenerators()
+ );
+ }
+
+
+ // ********** generated value **********
+
+ public OrmGeneratedValue getGeneratedValue() {
+ return this.generatedValue;
+ }
+
+ public OrmGeneratedValue addGeneratedValue() {
+ if (this.generatedValue != null) {
+ throw new IllegalStateException("generated value already exists: " + this.generatedValue); //$NON-NLS-1$
+ }
+ XmlGeneratedValue xmlGeneratedValue = this.buildXmlGeneratedValue();
+ OrmGeneratedValue value = this.buildGeneratedValue(xmlGeneratedValue);
+ this.setGeneratedValue(value);
+ this.xmlAttributeMapping.setGeneratedValue(xmlGeneratedValue);
+ return value;
+ }
+
+ protected XmlGeneratedValue buildXmlGeneratedValue() {
+ return OrmFactory.eINSTANCE.createXmlGeneratedValue();
+ }
+
+ public void removeGeneratedValue() {
+ if (this.generatedValue == null) {
+ throw new IllegalStateException("generated value does not exist"); //$NON-NLS-1$
+ }
+ this.setGeneratedValue(null);
+ this.xmlAttributeMapping.setGeneratedValue(null);
+ }
+
+ protected void setGeneratedValue(OrmGeneratedValue value) {
+ OrmGeneratedValue old = this.generatedValue;
+ this.generatedValue = value;
+ this.firePropertyChanged(GENERATED_VALUE_PROPERTY, old, value);
+ }
+
+ protected OrmGeneratedValue buildGeneratedValue() {
+ XmlGeneratedValue xmlGeneratedValue = this.xmlAttributeMapping.getGeneratedValue();
+ return (xmlGeneratedValue == null) ? null : this.buildGeneratedValue(xmlGeneratedValue);
+ }
+
+ protected OrmGeneratedValue buildGeneratedValue(XmlGeneratedValue xmlGeneratedValue) {
+ return this.getContextNodeFactory().buildOrmGeneratedValue(this, xmlGeneratedValue);
+ }
+
+ protected void syncGeneratedValue() {
+ XmlGeneratedValue xmlGeneratedValue = this.xmlAttributeMapping.getGeneratedValue();
+ if (xmlGeneratedValue == null) {
+ if (this.generatedValue != null) {
+ this.setGeneratedValue(null);
+ }
+ } else {
+ if ((this.generatedValue != null) && (this.generatedValue.getXmlGeneratedValue() == xmlGeneratedValue)) {
+ this.generatedValue.synchronizeWithResourceModel();
+ } else {
+ this.setGeneratedValue(this.buildGeneratedValue(xmlGeneratedValue));
+ }
+ }
+ }
+
// ********** converter adapters **********
@@ -153,6 +250,11 @@ public class OrmEclipseLinkBasicMapping
public void validate(List<IMessage> messages, IReporter reporter) {
super.validate(messages, reporter);
this.validateAttributeType(messages);
+
+ if (this.generatedValue != null) {
+ this.generatedValue.validate(messages, reporter);
+ }
+ this.generatorContainer.validate(messages, reporter);
// TODO mutable validation
}
@@ -211,6 +313,16 @@ public class OrmEclipseLinkBasicMapping
if (result != null) {
return result;
}
+ result = this.generatorContainer.getCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ if (this.generatedValue != null) {
+ result = this.generatedValue.getCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ }
if (this.attributeTypeTouches(pos)) {
return this.getCandidateAttributeTypeNames();
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkMappedSuperclassImpl.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkMappedSuperclassImpl.java
index 433fcc6..360d2a5 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkMappedSuperclassImpl.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkMappedSuperclassImpl.java
@@ -20,7 +20,9 @@ import org.eclipse.jpt.common.utility.internal.iterable.FilteringIterable;
import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
import org.eclipse.jpt.common.utility.internal.iterable.TransformationIterable;
import org.eclipse.jpt.jpa.core.context.AttributeMapping;
+import org.eclipse.jpt.jpa.core.context.Generator;
import org.eclipse.jpt.jpa.core.context.Query;
+import org.eclipse.jpt.jpa.core.context.orm.OrmGeneratorContainer;
import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
import org.eclipse.jpt.jpa.core.context.orm.OrmQueryContainer;
import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
@@ -74,6 +76,7 @@ public class OrmEclipseLinkMappedSuperclassImpl
protected final OrmQueryContainer queryContainer;
+ protected final OrmGeneratorContainer generatorContainer;//supported in EL 2.1 and higher
public OrmEclipseLinkMappedSuperclassImpl(OrmPersistentType parent, XmlMappedSuperclass xmlMappedSuperclass) {
super(parent, xmlMappedSuperclass);
@@ -84,6 +87,7 @@ public class OrmEclipseLinkMappedSuperclassImpl
this.customizer = this.buildCustomizer();
this.multitenancy = this.buildMultitenancy();
this.queryContainer = this.buildQueryContainer();
+ this.generatorContainer = this.buildGeneratorContainer();
}
@@ -99,6 +103,7 @@ public class OrmEclipseLinkMappedSuperclassImpl
this.customizer.synchronizeWithResourceModel();
this.multitenancy.synchronizeWithResourceModel();
this.queryContainer.synchronizeWithResourceModel();
+ this.generatorContainer.synchronizeWithResourceModel();
}
@Override
@@ -111,6 +116,7 @@ public class OrmEclipseLinkMappedSuperclassImpl
this.customizer.update();
this.multitenancy.update();
this.queryContainer.update();
+ this.generatorContainer.update();
}
@@ -219,6 +225,25 @@ public class OrmEclipseLinkMappedSuperclassImpl
}
+ // ********** generator container **********
+
+ public OrmGeneratorContainer getGeneratorContainer() {
+ return this.generatorContainer;
+ }
+
+ protected OrmGeneratorContainer buildGeneratorContainer() {
+ return this.getContextNodeFactory().buildOrmGeneratorContainer(this, this.xmlTypeMapping);
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public Iterable<Generator> getGenerators() {
+ return new CompositeIterable<Generator>(
+ super.getGenerators(),
+ this.generatorContainer.getGenerators()
+ );
+ }
+
// ********** query container **********
public OrmQueryContainer getQueryContainer() {
@@ -370,6 +395,7 @@ public class OrmEclipseLinkMappedSuperclassImpl
this.changeTracking.validate(messages, reporter);
this.customizer.validate(messages, reporter);
this.multitenancy.validate(messages, reporter);
+ this.generatorContainer.validate(messages, reporter);
}
@Override
@@ -426,6 +452,10 @@ public class OrmEclipseLinkMappedSuperclassImpl
if (result != null) {
return result;
}
+ result = this.generatorContainer.getCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
if (this.xmlTypeMapping.parentClassTouches(pos)) {
return this.getCandidateParentClassNames();
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/java/AbstractJavaEclipseLinkMappedSuperclassComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/java/AbstractJavaEclipseLinkMappedSuperclassComposite.java
index 3bbd2ab..67612bd 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/java/AbstractJavaEclipseLinkMappedSuperclassComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/java/AbstractJavaEclipseLinkMappedSuperclassComposite.java
@@ -12,6 +12,8 @@ package org.eclipse.jpt.jpa.eclipselink.ui.internal.details.java;
import org.eclipse.jpt.common.ui.WidgetFactory;
import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.context.GeneratorContainer;
+import org.eclipse.jpt.jpa.core.context.MappedSuperclass;
import org.eclipse.jpt.jpa.core.context.java.JavaMappedSuperclass;
import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkMappedSuperclass;
import org.eclipse.jpt.jpa.eclipselink.core.context.java.JavaEclipseLinkCaching;
@@ -22,6 +24,8 @@ import org.eclipse.jpt.jpa.eclipselink.ui.internal.details.EclipseLinkNonEmbedda
import org.eclipse.jpt.jpa.eclipselink.ui.internal.details.EclipseLinkUiDetailsMessages;
import org.eclipse.jpt.jpa.ui.details.JpaComposite;
import org.eclipse.jpt.jpa.ui.internal.details.AbstractJavaMappedSuperclassComposite;
+import org.eclipse.jpt.jpa.ui.internal.details.JptUiDetailsMessages;
+import org.eclipse.jpt.jpa.ui.internal.jpa2.details.Generation2_0Composite;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@@ -142,4 +146,32 @@ public abstract class AbstractJavaEclipseLinkMappedSuperclassComposite
protected Control initializeAdvancedSection(Composite container) {
return new EclipseLinkNonEmbeddableTypeMappingAdvancedComposite(this, container).getControl();
}
+
+ protected void initializeGeneratorsCollapsibleSection(Composite container) {
+ final Section section = this.getWidgetFactory().createSection(container, ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE);
+ section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ section.setText(JptUiDetailsMessages.IdMappingComposite_primaryKeyGenerationSection);
+
+ section.addExpansionListener(new ExpansionAdapter() {
+ @Override
+ public void expansionStateChanging(ExpansionEvent e) {
+ if (e.getState() && section.getClient() == null) {
+ section.setClient(initializeGeneratorsSection(section));
+ }
+ }
+ });
+ }
+
+ protected Control initializeGeneratorsSection(Composite container) {
+ return new Generation2_0Composite(this, this.buildGeneratorContainerHolder(), container).getControl();
+ }
+
+ protected PropertyValueModel<GeneratorContainer> buildGeneratorContainerHolder() {
+ return new PropertyAspectAdapter<MappedSuperclass, GeneratorContainer>(getSubjectHolder()) {
+ @Override
+ protected GeneratorContainer buildValue_() {
+ return ((EclipseLinkMappedSuperclass) this.subject).getGeneratorContainer();
+ }
+ };
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/java/JavaEclipseLinkMappedSuperclass2_1Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/java/JavaEclipseLinkMappedSuperclass2_1Composite.java
new file mode 100644
index 0000000..59a9d12
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/java/JavaEclipseLinkMappedSuperclass2_1Composite.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.eclipselink.ui.internal.details.java;
+
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.context.AccessHolder;
+import org.eclipse.jpt.jpa.core.context.java.JavaMappedSuperclass;
+import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkMappedSuperclass;
+import org.eclipse.jpt.jpa.ui.internal.JptUiMessages;
+import org.eclipse.jpt.jpa.ui.internal.details.AccessTypeComboViewer;
+import org.eclipse.jpt.jpa.ui.internal.details.IdClassChooser;
+import org.eclipse.jpt.jpa.ui.internal.details.JptUiDetailsMessages;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.forms.widgets.Hyperlink;
+
+/**
+ * The pane used for an EclipseLink Java Mapped Superclass.
+ *
+ * @see EclipseLinkMappedSuperclass
+ * @see EclipselinkJpaUiFactory - The factory creating this pane
+ *
+ * @version 3.3
+ * @since 3.3
+ */
+public class JavaEclipseLinkMappedSuperclass2_1Composite
+ extends AbstractJavaEclipseLinkMappedSuperclassComposite
+{
+ public JavaEclipseLinkMappedSuperclass2_1Composite(
+ PropertyValueModel<? extends JavaMappedSuperclass> subjectHolder,
+ Composite parent,
+ WidgetFactory widgetFactory) {
+
+ super(subjectHolder, parent, widgetFactory);
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+ this.initializeMappedSuperclassCollapsibleSection(container);
+ this.initializeCachingCollapsibleSection(container);
+ this.initializeQueriesCollapsibleSection(container);
+ this.initializeGeneratorsCollapsibleSection(container);
+ this.initializeConvertersCollapsibleSection(container);
+ this.initializeAdvancedCollapsibleSection(container);
+ }
+
+ @Override
+ protected Control initializeMappedSuperclassSection(Composite container) {
+ container = this.addSubPane(container, 2, 0, 0, 0, 0);
+
+ // Access type widgets
+ this.addLabel(container, JptUiMessages.AccessTypeComposite_access);
+ new AccessTypeComboViewer(this, this.buildAccessHolder(), container);
+
+ // Id class widgets
+ Hyperlink hyperlink = this.addHyperlink(container,JptUiDetailsMessages.IdClassComposite_label);
+ new IdClassChooser(this, this.buildIdClassReferenceHolder(), container, hyperlink);
+
+ return container;
+ }
+
+ protected PropertyValueModel<AccessHolder> buildAccessHolder() {
+ return new PropertyAspectAdapter<JavaMappedSuperclass, AccessHolder>(getSubjectHolder()) {
+ @Override
+ protected AccessHolder buildValue_() {
+ return this.subject.getPersistentType();
+ }
+ };
+ }
+
+ @Override
+ protected Control initializeCachingSection(Composite container) {
+ return new JavaEclipseLinkCaching2_0Composite(this, this.buildCachingHolder(), container).getControl();
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/java/JavaEclipseLinkMappedSuperclass2_3Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/java/JavaEclipseLinkMappedSuperclass2_3Composite.java
index 1207370..4c0ddf0 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/java/JavaEclipseLinkMappedSuperclass2_3Composite.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/java/JavaEclipseLinkMappedSuperclass2_3Composite.java
@@ -65,6 +65,7 @@ public class JavaEclipseLinkMappedSuperclass2_3Composite
this.initializeCachingCollapsibleSection(container);
this.initializeQueriesCollapsibleSection(container);
this.initializeMultitenancyCollapsibleSection(container);
+ this.initializeGeneratorsCollapsibleSection(container);
this.initializeConvertersCollapsibleSection(container);
this.initializeAdvancedCollapsibleSection(container);
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/orm/AbstractOrmEclipseLinkMappedSuperclassComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/orm/AbstractOrmEclipseLinkMappedSuperclassComposite.java
index ec9f0bf..f62211c 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/orm/AbstractOrmEclipseLinkMappedSuperclassComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/orm/AbstractOrmEclipseLinkMappedSuperclassComposite.java
@@ -13,8 +13,11 @@ import org.eclipse.jpt.common.ui.WidgetFactory;
import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.jpa.core.context.AccessHolder;
+import org.eclipse.jpt.jpa.core.context.GeneratorContainer;
+import org.eclipse.jpt.jpa.core.context.MappedSuperclass;
import org.eclipse.jpt.jpa.core.context.orm.OrmMappedSuperclass;
import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkCaching;
+import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkMappedSuperclass;
import org.eclipse.jpt.jpa.eclipselink.core.context.orm.OrmEclipseLinkConverterContainer;
import org.eclipse.jpt.jpa.eclipselink.core.context.orm.OrmEclipseLinkMappedSuperclass;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.details.EclipseLinkConvertersComposite;
@@ -29,6 +32,7 @@ import org.eclipse.jpt.jpa.ui.internal.details.JptUiDetailsMessages;
import org.eclipse.jpt.jpa.ui.internal.details.orm.JptUiDetailsOrmMessages;
import org.eclipse.jpt.jpa.ui.internal.details.orm.MetadataCompleteTriStateCheckBox;
import org.eclipse.jpt.jpa.ui.internal.details.orm.OrmJavaClassChooser;
+import org.eclipse.jpt.jpa.ui.internal.jpa2.details.Generation2_0Composite;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@@ -166,4 +170,32 @@ public abstract class AbstractOrmEclipseLinkMappedSuperclassComposite
protected Control initializeAdvancedSection(Composite container) {
return new EclipseLinkNonEmbeddableTypeMappingAdvancedComposite(this, container).getControl();
}
+
+ protected void initializeGeneratorsCollapsibleSection(Composite container) {
+ final Section section = this.getWidgetFactory().createSection(container, ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE);
+ section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ section.setText(JptUiDetailsMessages.IdMappingComposite_primaryKeyGenerationSection);
+
+ section.addExpansionListener(new ExpansionAdapter() {
+ @Override
+ public void expansionStateChanging(ExpansionEvent e) {
+ if (e.getState() && section.getClient() == null) {
+ section.setClient(initializeGeneratorsSection(section));
+ }
+ }
+ });
+ }
+
+ protected Control initializeGeneratorsSection(Composite container) {
+ return new Generation2_0Composite(this, this.buildGeneratorContainerHolder(), container).getControl();
+ }
+
+ protected PropertyValueModel<GeneratorContainer> buildGeneratorContainerHolder() {
+ return new PropertyAspectAdapter<MappedSuperclass, GeneratorContainer>(getSubjectHolder()) {
+ @Override
+ protected GeneratorContainer buildValue_() {
+ return ((EclipseLinkMappedSuperclass) this.subject).getGeneratorContainer();
+ }
+ };
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/orm/OrmEclipseLinkMappedSuperclass2_1Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/orm/OrmEclipseLinkMappedSuperclass2_1Composite.java
index 59991b0..b70434d 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/orm/OrmEclipseLinkMappedSuperclass2_1Composite.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/orm/OrmEclipseLinkMappedSuperclass2_1Composite.java
@@ -40,6 +40,7 @@ public class OrmEclipseLinkMappedSuperclass2_1Composite
this.initializeMappedSuperclassCollapsibleSection(container);
this.initializeCachingCollapsibleSection(container);
this.initializeQueriesCollapsibleSection(container);
+ this.initializeGeneratorsCollapsibleSection(container);
this.initializeConvertersCollapsibleSection(container);
this.initializeAdvancedCollapsibleSection(container);
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/orm/OrmEclipseLinkMappedSuperclass2_3Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/orm/OrmEclipseLinkMappedSuperclass2_3Composite.java
index e8ca80a..e845ebf 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/orm/OrmEclipseLinkMappedSuperclass2_3Composite.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/orm/OrmEclipseLinkMappedSuperclass2_3Composite.java
@@ -44,6 +44,7 @@ public class OrmEclipseLinkMappedSuperclass2_3Composite
this.initializeCachingCollapsibleSection(container);
this.initializeQueriesCollapsibleSection(container);
this.initializeMultitenancyCollapsibleSection(container);
+ this.initializeGeneratorsCollapsibleSection(container);
this.initializeConvertersCollapsibleSection(container);
this.initializeAdvancedCollapsibleSection(container);
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui_validation_preferences.properties b/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui_validation_preferences.properties
index de5ad21..bc615ac 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui_validation_preferences.properties
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui_validation_preferences.properties
@@ -290,7 +290,7 @@ QUERIES_GENERATORS_CATEGORY=Queries and generators
GENERATOR_DUPLICATE_NAME=Duplicate generator defined:
GENERATOR_NAME_UNDEFINED=Generator is unnamed:
-ID_MAPPING_UNRESOLVED_GENERATOR_NAME=Generator is not defined in the persistence unit:
+UNRESOLVED_GENERATOR_NAME=Generator is not defined in the persistence unit:
JPQL_QUERY_VALIDATION=Invalid or incomplete JPQL queries:
QUERY_DUPLICATE_NAME=Duplicate query defined:
QUERY_NAME_UNDEFINED=Query is unnamed:
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiValidationPreferenceMessages.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiValidationPreferenceMessages.java
index 70bd057..ba46079 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiValidationPreferenceMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiValidationPreferenceMessages.java
@@ -308,7 +308,7 @@ public class JptUiValidationPreferenceMessages {
public static String GENERATOR_DUPLICATE_NAME;
public static String GENERATOR_NAME_UNDEFINED; // 3.0 M7
- public static String ID_MAPPING_UNRESOLVED_GENERATOR_NAME;
+ public static String UNRESOLVED_GENERATOR_NAME;
public static String JPQL_QUERY_VALIDATION; //3.0 M7
public static String QUERY_DUPLICATE_NAME;
public static String QUERY_NAME_UNDEFINED; // 3.0 M7
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/prefs/JpaProblemSeveritiesPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/prefs/JpaProblemSeveritiesPage.java
index 1363398..ba23b39 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/prefs/JpaProblemSeveritiesPage.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/prefs/JpaProblemSeveritiesPage.java
@@ -581,13 +581,13 @@ public class JpaProblemSeveritiesPage extends PropertyAndPreferencePage {
parent = addExpandableSection(parent, JptUiValidationPreferenceMessages.QUERIES_GENERATORS_CATEGORY);
- addLabeledCombo(parent, JptUiValidationPreferenceMessages.GENERATOR_DUPLICATE_NAME, JpaValidationMessages.GENERATOR_DUPLICATE_NAME);
- addLabeledCombo(parent, JptUiValidationPreferenceMessages.GENERATOR_NAME_UNDEFINED, JpaValidationMessages.GENERATOR_NAME_UNDEFINED); //3.0 M7
- addLabeledCombo(parent, JptUiValidationPreferenceMessages.ID_MAPPING_UNRESOLVED_GENERATOR_NAME, JpaValidationMessages.ID_MAPPING_UNRESOLVED_GENERATOR_NAME);
- addLabeledCombo(parent, JptUiValidationPreferenceMessages.JPQL_QUERY_VALIDATION, JpaValidationMessages.JPQL_QUERY_VALIDATION);
- addLabeledCombo(parent, JptUiValidationPreferenceMessages.QUERY_DUPLICATE_NAME, JpaValidationMessages.QUERY_DUPLICATE_NAME);
- addLabeledCombo(parent, JptUiValidationPreferenceMessages.QUERY_NAME_UNDEFINED, JpaValidationMessages.QUERY_NAME_UNDEFINED); //3.0 M7
- addLabeledCombo(parent, JptUiValidationPreferenceMessages.QUERY_STATEMENT_UNDEFINED, JpaValidationMessages.QUERY_STATEMENT_UNDEFINED); //3.0 M7
+ addLabeledCombo(parent, JptUiValidationPreferenceMessages.GENERATOR_DUPLICATE_NAME, JpaValidationMessages.GENERATOR_DUPLICATE_NAME);
+ addLabeledCombo(parent, JptUiValidationPreferenceMessages.GENERATOR_NAME_UNDEFINED, JpaValidationMessages.GENERATOR_NAME_UNDEFINED); //3.0 M7
+ addLabeledCombo(parent, JptUiValidationPreferenceMessages.UNRESOLVED_GENERATOR_NAME, JpaValidationMessages.UNRESOLVED_GENERATOR_NAME);
+ addLabeledCombo(parent, JptUiValidationPreferenceMessages.JPQL_QUERY_VALIDATION, JpaValidationMessages.JPQL_QUERY_VALIDATION);
+ addLabeledCombo(parent, JptUiValidationPreferenceMessages.QUERY_DUPLICATE_NAME, JpaValidationMessages.QUERY_DUPLICATE_NAME);
+ addLabeledCombo(parent, JptUiValidationPreferenceMessages.QUERY_NAME_UNDEFINED, JpaValidationMessages.QUERY_NAME_UNDEFINED); //3.0 M7
+ addLabeledCombo(parent, JptUiValidationPreferenceMessages.QUERY_STATEMENT_UNDEFINED, JpaValidationMessages.QUERY_STATEMENT_UNDEFINED); //3.0 M7
}
private Composite addExpandableSection(Composite parent, String text) {
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLink2_1JavaMappedSuperclassTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLink2_1JavaMappedSuperclassTests.java
new file mode 100644
index 0000000..40a1b17
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLink2_1JavaMappedSuperclassTests.java
@@ -0,0 +1,171 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.java;
+
+import java.util.Iterator;
+
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement.Kind;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.common.utility.internal.iterator.ArrayIterator;
+import org.eclipse.jpt.jpa.core.resource.java.JPA;
+import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.EclipseLink2_2ContextModelTestCase;
+
+@SuppressWarnings("nls")
+public class EclipseLink2_1JavaMappedSuperclassTests extends EclipseLink2_2ContextModelTestCase
+{
+ protected static final String SUB_TYPE_NAME = "AnnotationTestTypeChild";
+ protected static final String FULLY_QUALIFIED_SUB_TYPE_NAME = PACKAGE_NAME + "." + SUB_TYPE_NAME;
+
+ private ICompilationUnit createTestMappedSuperclass() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@MappedSuperclass").append(CR);
+ }
+ });
+ }
+
+
+ public EclipseLink2_1JavaMappedSuperclassTests(String name) {
+ super(name);
+ }
+
+ public void testGetSequenceGenerator() throws Exception {
+ createTestMappedSuperclass();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ assertNull(getJavaMappedSuperclass().getGeneratorContainer().getSequenceGenerator());
+ assertEquals(0, getPersistenceUnit().getGeneratorsSize());
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ resourceType.addAnnotation(JPA.SEQUENCE_GENERATOR);
+ getJpaProject().synchronizeContextModel();
+
+ assertNotNull(getJavaMappedSuperclass().getGeneratorContainer().getSequenceGenerator());
+ assertEquals(2, resourceType.getAnnotationsSize());
+ assertEquals(1, getPersistenceUnit().getGeneratorsSize());
+
+ getJavaMappedSuperclass().getGeneratorContainer().getSequenceGenerator().setName("foo");
+ assertEquals(1, getPersistenceUnit().getGeneratorsSize());
+ }
+
+ public void testAddSequenceGenerator() throws Exception {
+ createTestMappedSuperclass();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ assertNull(getJavaMappedSuperclass().getGeneratorContainer().getSequenceGenerator());
+
+ getJavaMappedSuperclass().getGeneratorContainer().addSequenceGenerator();
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+
+ assertNotNull(resourceType.getAnnotation(JPA.SEQUENCE_GENERATOR));
+ assertNotNull(getJavaMappedSuperclass().getGeneratorContainer().getSequenceGenerator());
+
+ //try adding another sequence generator, should get an IllegalStateException
+ try {
+ getJavaMappedSuperclass().getGeneratorContainer().addSequenceGenerator();
+ } catch (IllegalStateException e) {
+ return;
+ }
+ fail("IllegalStateException not thrown");
+ }
+
+ public void testRemoveSequenceGenerator() throws Exception {
+ createTestMappedSuperclass();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ resourceType.addAnnotation(JPA.SEQUENCE_GENERATOR);
+ getJpaProject().synchronizeContextModel();
+
+ getJavaMappedSuperclass().getGeneratorContainer().removeSequenceGenerator();
+
+ assertNull(getJavaMappedSuperclass().getGeneratorContainer().getSequenceGenerator());
+ assertNull(resourceType.getAnnotation(JPA.SEQUENCE_GENERATOR));
+
+ //try removing the sequence generator again, should get an IllegalStateException
+ try {
+ getJavaMappedSuperclass().getGeneratorContainer().removeSequenceGenerator();
+ } catch (IllegalStateException e) {
+ return;
+ }
+ fail("IllegalStateException not thrown");
+ }
+
+ public void testGetTableGenerator() throws Exception {
+ createTestMappedSuperclass();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ assertNull(getJavaMappedSuperclass().getGeneratorContainer().getTableGenerator());
+ assertEquals(0, getPersistenceUnit().getGeneratorsSize());
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ resourceType.addAnnotation(JPA.TABLE_GENERATOR);
+ getJpaProject().synchronizeContextModel();
+
+ assertNotNull(getJavaMappedSuperclass().getGeneratorContainer().getTableGenerator());
+ assertEquals(2, resourceType.getAnnotationsSize());
+ assertEquals(1, getPersistenceUnit().getGeneratorsSize());
+
+ getJavaMappedSuperclass().getGeneratorContainer().getTableGenerator().setName("foo");
+ assertEquals(1, getPersistenceUnit().getGeneratorsSize());
+ }
+
+ public void testAddTableGenerator() throws Exception {
+ createTestMappedSuperclass();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ assertNull(getJavaMappedSuperclass().getGeneratorContainer().getTableGenerator());
+
+ getJavaMappedSuperclass().getGeneratorContainer().addTableGenerator();
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+
+ assertNotNull(resourceType.getAnnotation(JPA.TABLE_GENERATOR));
+ assertNotNull(getJavaMappedSuperclass().getGeneratorContainer().getTableGenerator());
+
+ //try adding another table generator, should get an IllegalStateException
+ try {
+ getJavaMappedSuperclass().getGeneratorContainer().addTableGenerator();
+ } catch (IllegalStateException e) {
+ return;
+ }
+ fail("IllegalStateException not thrown");
+ }
+
+ public void testRemoveTableGenerator() throws Exception {
+ createTestMappedSuperclass();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, Kind.TYPE);
+ resourceType.addAnnotation(JPA.TABLE_GENERATOR);
+ getJpaProject().synchronizeContextModel();
+
+ getJavaMappedSuperclass().getGeneratorContainer().removeTableGenerator();
+
+ assertNull(getJavaMappedSuperclass().getGeneratorContainer().getTableGenerator());
+ assertNull(resourceType.getAnnotation(JPA.TABLE_GENERATOR));
+
+ //try removing the table generator again, should get an IllegalStateException
+ try {
+ getJavaMappedSuperclass().getGeneratorContainer().removeTableGenerator();
+ } catch (IllegalStateException e) {
+ return;
+ }
+ fail("IllegalStateException not thrown");
+ }
+
+}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLink2_2JavaEntityTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLink2_2JavaEntityTests.java
index c6fb5da..79270e8 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLink2_2JavaEntityTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLink2_2JavaEntityTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
+ * Copyright (c) 2011, 2012 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -37,6 +37,7 @@ import org.eclipse.jpt.jpa.core.resource.java.TableGeneratorAnnotation;
import org.eclipse.jpt.jpa.eclipselink.core.context.java.JavaEclipseLinkEntity;
import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkConverterAnnotation;
import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkObjectTypeConverterAnnotation;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkReadOnlyAnnotation;
import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkStructConverterAnnotation;
import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkTypeConverterAnnotation;
import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.EclipseLink2_2ContextModelTestCase;
@@ -92,6 +93,7 @@ public class EclipseLink2_2JavaEntityTests extends EclipseLink2_2ContextModelTes
entity.getConverterContainer().addTypeConverter(1);
entity.getConverterContainer().addStructConverter(0);
entity.getConverterContainer().addStructConverter(1);
+ entity.getReadOnly().setSpecifiedReadOnly(Boolean.TRUE);
getJavaPersistentType().setMappingKey(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY);
assertTrue(getJavaPersistentType().getMapping() instanceof MappedSuperclass);
@@ -105,8 +107,8 @@ public class EclipseLink2_2JavaEntityTests extends EclipseLink2_2ContextModelTes
assertNull(resourceType.getAnnotation(InheritanceAnnotation.ANNOTATION_NAME));
assertNull(resourceType.getAnnotation(DiscriminatorValueAnnotation.ANNOTATION_NAME));
assertNull(resourceType.getAnnotation(DiscriminatorColumnAnnotation.ANNOTATION_NAME));
- assertNull(resourceType.getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME));
- assertNull(resourceType.getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceType.getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceType.getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME));
assertNotNull(resourceType.getAnnotation(IdClassAnnotation.ANNOTATION_NAME));
assertNotNull(resourceType.getAnnotation(0, NamedQueryAnnotation.ANNOTATION_NAME));
assertNotNull(resourceType.getAnnotation(0, NamedNativeQueryAnnotation.ANNOTATION_NAME));
@@ -118,6 +120,7 @@ public class EclipseLink2_2JavaEntityTests extends EclipseLink2_2ContextModelTes
assertNotNull(resourceType.getAnnotation(1, EclipseLinkStructConverterAnnotation.ANNOTATION_NAME));
assertNotNull(resourceType.getAnnotation(0, EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME));
assertNotNull(resourceType.getAnnotation(1, EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceType.getAnnotation(EclipseLinkReadOnlyAnnotation.ANNOTATION_NAME));
}
public void testMorphToEmbeddable() throws Exception {
@@ -147,6 +150,7 @@ public class EclipseLink2_2JavaEntityTests extends EclipseLink2_2ContextModelTes
entity.getConverterContainer().addTypeConverter(1);
entity.getConverterContainer().addStructConverter(0);
entity.getConverterContainer().addStructConverter(1);
+ entity.getReadOnly().setSpecifiedReadOnly(Boolean.TRUE);
getJavaPersistentType().setMappingKey(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY);
assertTrue(getJavaPersistentType().getMapping() instanceof Embeddable);
@@ -172,5 +176,6 @@ public class EclipseLink2_2JavaEntityTests extends EclipseLink2_2ContextModelTes
assertNotNull(resourceType.getAnnotation(1, EclipseLinkStructConverterAnnotation.ANNOTATION_NAME));
assertNotNull(resourceType.getAnnotation(0, EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME));
assertNotNull(resourceType.getAnnotation(1, EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME));
+ assertNull(resourceType.getAnnotation(EclipseLinkReadOnlyAnnotation.ANNOTATION_NAME));
}
}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLink2_2JavaMappedSuperclassTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLink2_2JavaMappedSuperclassTests.java
index e5cb53c..ee595d9 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLink2_2JavaMappedSuperclassTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLink2_2JavaMappedSuperclassTests.java
@@ -22,9 +22,12 @@ import org.eclipse.jpt.jpa.core.internal.context.java.JavaNullTypeMapping;
import org.eclipse.jpt.jpa.core.resource.java.IdClassAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.JPA;
import org.eclipse.jpt.jpa.core.resource.java.MappedSuperclassAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.SequenceGeneratorAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.TableGeneratorAnnotation;
import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkMappedSuperclass;
import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkConverterAnnotation;
import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkObjectTypeConverterAnnotation;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkReadOnlyAnnotation;
import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkStructConverterAnnotation;
import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkTypeConverterAnnotation;
import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.EclipseLink2_2ContextModelTestCase;
@@ -68,6 +71,9 @@ public class EclipseLink2_2JavaMappedSuperclassTests extends EclipseLink2_2Conte
mappedSuperclass.getConverterContainer().addTypeConverter(1);
mappedSuperclass.getConverterContainer().addStructConverter(0);
mappedSuperclass.getConverterContainer().addStructConverter(1);
+ mappedSuperclass.getGeneratorContainer().addTableGenerator();
+ mappedSuperclass.getGeneratorContainer().addSequenceGenerator();
+ mappedSuperclass.getReadOnly().setSpecifiedReadOnly(Boolean.TRUE);
getJavaPersistentType().setMappingKey(MappingKeys.ENTITY_TYPE_MAPPING_KEY);
assertTrue(getJavaPersistentType().getMapping() instanceof Entity);
@@ -82,6 +88,9 @@ public class EclipseLink2_2JavaMappedSuperclassTests extends EclipseLink2_2Conte
assertNotNull(resourceType.getAnnotation(1, EclipseLinkStructConverterAnnotation.ANNOTATION_NAME));
assertNotNull(resourceType.getAnnotation(0, EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME));
assertNotNull(resourceType.getAnnotation(1, EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceType.getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceType.getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME));
+ assertNotNull(resourceType.getAnnotation(EclipseLinkReadOnlyAnnotation.ANNOTATION_NAME));
}
public void testMorphToEmbeddable() throws Exception {
@@ -98,6 +107,9 @@ public class EclipseLink2_2JavaMappedSuperclassTests extends EclipseLink2_2Conte
mappedSuperclass.getConverterContainer().addTypeConverter(1);
mappedSuperclass.getConverterContainer().addStructConverter(0);
mappedSuperclass.getConverterContainer().addStructConverter(1);
+ mappedSuperclass.getGeneratorContainer().addTableGenerator();
+ mappedSuperclass.getGeneratorContainer().addSequenceGenerator();
+ mappedSuperclass.getReadOnly().setSpecifiedReadOnly(Boolean.TRUE);
getJavaPersistentType().setMappingKey(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY);
assertTrue(getJavaPersistentType().getMapping() instanceof Embeddable);
@@ -113,6 +125,9 @@ public class EclipseLink2_2JavaMappedSuperclassTests extends EclipseLink2_2Conte
assertNotNull(resourceType.getAnnotation(1, EclipseLinkStructConverterAnnotation.ANNOTATION_NAME));
assertNotNull(resourceType.getAnnotation(0, EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME));
assertNotNull(resourceType.getAnnotation(1, EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME));
+ assertNull(resourceType.getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME));
+ assertNull(resourceType.getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME));
+ assertNull(resourceType.getAnnotation(EclipseLinkReadOnlyAnnotation.ANNOTATION_NAME));
}
public void testMorphToNull() throws Exception {
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/JptEclipseLinkCoreJavaContextModelTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/JptEclipseLinkCoreJavaContextModelTests.java
index aeaa2d3..efc4dc1 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/JptEclipseLinkCoreJavaContextModelTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/JptEclipseLinkCoreJavaContextModelTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2012 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -41,9 +41,10 @@ public class JptEclipseLinkCoreJavaContextModelTests extends TestCase
suite.addTestSuite(EclipseLink2_0JavaMappedSuperclassTests.class);
suite.addTestSuite(EclipseLink2_0JavaOneToManyMappingTests.class);
suite.addTestSuite(EclipseLink2_0JavaOneToOneMappingTests.class);
- suite.addTestSuite(EclipseLink2_3JavaMultitenancyTests.class);
+ suite.addTestSuite(EclipseLink2_1JavaMappedSuperclassTests.class);
suite.addTestSuite(EclipseLink2_2JavaEntityTests.class);
suite.addTestSuite(EclipseLink2_2JavaMappedSuperclassTests.class);
+ suite.addTestSuite(EclipseLink2_3JavaMultitenancyTests.class);
return suite;
}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLink2_1OrmMappedSuperclassTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLink2_1OrmMappedSuperclassTests.java
index 1b16d12..131237f 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLink2_1OrmMappedSuperclassTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLink2_1OrmMappedSuperclassTests.java
@@ -10,8 +10,12 @@
package org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.orm;
import org.eclipse.jpt.jpa.core.MappingKeys;
+import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
+import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
import org.eclipse.jpt.jpa.eclipselink.core.context.orm.EclipseLinkOrmTypeMapping;
import org.eclipse.jpt.jpa.eclipselink.core.context.orm.EclipseLinkOrmPersistentType;
+import org.eclipse.jpt.jpa.eclipselink.core.context.orm.OrmEclipseLinkMappedSuperclass;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlMappedSuperclass;
import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlTypeMapping;
import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.EclipseLink2_1ContextModelTestCase;
@@ -58,4 +62,149 @@ public class EclipseLink2_1OrmMappedSuperclassTests
assertNull(ormTypeMapping.getSpecifiedParentClass());
assertNull(xmlTypeMapping.getParentClass());
}
+
+
+ public void testAddSequenceGenerator() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEclipseLinkMappedSuperclass ormMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
+ XmlMappedSuperclass mappedSuperclassResource = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
+
+ assertNull(ormMappedSuperclass.getGeneratorContainer().getSequenceGenerator());
+ assertNull(mappedSuperclassResource.getSequenceGenerator());
+
+ ormMappedSuperclass.getGeneratorContainer().addSequenceGenerator();
+
+ assertNotNull(mappedSuperclassResource.getSequenceGenerator());
+ assertNotNull(ormMappedSuperclass.getGeneratorContainer().getSequenceGenerator());
+
+ //try adding another sequence generator, should get an IllegalStateException
+ try {
+ ormMappedSuperclass.getGeneratorContainer().addSequenceGenerator();
+ } catch (IllegalStateException e) {
+ return;
+ }
+ fail("IllegalStateException not thrown");
+ }
+
+ public void testRemoveSequenceGenerator() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEclipseLinkMappedSuperclass ormMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
+ XmlMappedSuperclass mappedSuperclassResource = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
+
+ assertNull(ormMappedSuperclass.getGeneratorContainer().getSequenceGenerator());
+ assertNull(mappedSuperclassResource.getSequenceGenerator());
+
+ ormMappedSuperclass.getGeneratorContainer().addSequenceGenerator();
+ assertNotNull(mappedSuperclassResource.getSequenceGenerator());
+ assertNotNull(ormMappedSuperclass.getGeneratorContainer().getSequenceGenerator());
+
+ ormMappedSuperclass.getGeneratorContainer().removeSequenceGenerator();
+
+ assertNull(ormMappedSuperclass.getGeneratorContainer().getSequenceGenerator());
+ assertNull(mappedSuperclassResource.getSequenceGenerator());
+
+ //try removing the sequence generator again, should get an IllegalStateException
+ try {
+ ormMappedSuperclass.getGeneratorContainer().removeSequenceGenerator();
+ } catch (IllegalStateException e) {
+ return;
+ }
+ fail("IllegalStateException not thrown");
+ }
+
+ public void testUpdateSequenceGenerator() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEclipseLinkMappedSuperclass ormMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
+ XmlMappedSuperclass mappedSuperclassResource = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
+
+ assertNull(ormMappedSuperclass.getGeneratorContainer().getSequenceGenerator());
+ assertNull(mappedSuperclassResource.getSequenceGenerator());
+ assertEquals(0, ormMappedSuperclass.getPersistenceUnit().getGeneratorsSize());
+
+ mappedSuperclassResource.setSequenceGenerator(OrmFactory.eINSTANCE.createXmlSequenceGenerator());
+
+ assertNotNull(ormMappedSuperclass.getGeneratorContainer().getSequenceGenerator());
+ assertNotNull(mappedSuperclassResource.getSequenceGenerator());
+ assertEquals(1, ormMappedSuperclass.getPersistenceUnit().getGeneratorsSize());
+
+ ormMappedSuperclass.getGeneratorContainer().getSequenceGenerator().setName("foo");
+ assertEquals(1, ormMappedSuperclass.getPersistenceUnit().getGeneratorsSize());
+
+ mappedSuperclassResource.setSequenceGenerator(null);
+ assertNull(ormMappedSuperclass.getGeneratorContainer().getSequenceGenerator());
+ assertNull(mappedSuperclassResource.getSequenceGenerator());
+ assertEquals(0, ormMappedSuperclass.getPersistenceUnit().getGeneratorsSize());
+ }
+
+ public void testAddTableGenerator() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEclipseLinkMappedSuperclass ormMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
+ XmlMappedSuperclass mappedSuperclassResource = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
+
+ assertNull(ormMappedSuperclass.getGeneratorContainer().getTableGenerator());
+ assertNull(mappedSuperclassResource.getTableGenerator());
+
+ ormMappedSuperclass.getGeneratorContainer().addTableGenerator();
+
+ assertNotNull(mappedSuperclassResource.getTableGenerator());
+ assertNotNull(ormMappedSuperclass.getGeneratorContainer().getTableGenerator());
+
+ //try adding another table generator, should get an IllegalStateException
+ try {
+ ormMappedSuperclass.getGeneratorContainer().addTableGenerator();
+ } catch (IllegalStateException e) {
+ return;
+ }
+ fail("IllegalStateException not thrown");
+ }
+
+ public void testRemoveTableGenerator() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEclipseLinkMappedSuperclass ormMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
+ XmlMappedSuperclass mappedSuperclassResource = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
+
+ assertNull(ormMappedSuperclass.getGeneratorContainer().getTableGenerator());
+ assertNull(mappedSuperclassResource.getTableGenerator());
+
+ ormMappedSuperclass.getGeneratorContainer().addTableGenerator();
+ assertNotNull(mappedSuperclassResource.getTableGenerator());
+ assertNotNull(ormMappedSuperclass.getGeneratorContainer().getTableGenerator());
+
+ ormMappedSuperclass.getGeneratorContainer().removeTableGenerator();
+
+ assertNull(ormMappedSuperclass.getGeneratorContainer().getTableGenerator());
+ assertNull(mappedSuperclassResource.getTableGenerator());
+
+ //try removing the table generator again, should get an IllegalStateException
+ try {
+ ormMappedSuperclass.getGeneratorContainer().removeTableGenerator();
+ } catch (IllegalStateException e) {
+ return;
+ }
+ fail("IllegalStateException not thrown");
+ }
+
+ public void testUpdateTableGenerator() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEclipseLinkMappedSuperclass ormMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
+ XmlMappedSuperclass mappedSuperclassResource = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
+
+ assertNull(ormMappedSuperclass.getGeneratorContainer().getTableGenerator());
+ assertNull(mappedSuperclassResource.getTableGenerator());
+ assertEquals(0, ormMappedSuperclass.getPersistenceUnit().getGeneratorsSize());
+
+ mappedSuperclassResource.setTableGenerator(OrmFactory.eINSTANCE.createXmlTableGenerator());
+
+ assertNotNull(ormMappedSuperclass.getGeneratorContainer().getTableGenerator());
+ assertNotNull(mappedSuperclassResource.getTableGenerator());
+ assertEquals(1, ormMappedSuperclass.getPersistenceUnit().getGeneratorsSize());
+
+ ormMappedSuperclass.getGeneratorContainer().getTableGenerator().setName("foo");
+ assertEquals(1, ormMappedSuperclass.getPersistenceUnit().getGeneratorsSize());
+
+ mappedSuperclassResource.setTableGenerator(null);
+ assertNull(ormMappedSuperclass.getGeneratorContainer().getTableGenerator());
+ assertNull(mappedSuperclassResource.getTableGenerator());
+ assertEquals(0, ormMappedSuperclass.getPersistenceUnit().getGeneratorsSize());
+ }
} \ No newline at end of file