summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNan Li2013-02-21 13:03:29 (EST)
committer Karen Butzke2013-02-21 13:11:31 (EST)
commit4ed32f9a1700483375bb15dd67c53fab3de4860c (patch)
tree3b6205f46f30424eb30bd9876ba289db1a1c3db8
parent619b7fe9b9160ce2d1d177b033ac51fa6c0bfcbb (diff)
downloadwebtools.dali-4ed32f9a1700483375bb15dd67c53fab3de4860c.zip
webtools.dali-4ed32f9a1700483375bb15dd67c53fab3de4860c.tar.gz
webtools.dali-4ed32f9a1700483375bb15dd67c53fab3de4860c.tar.bz2
392701 - [JPA 2.1] Named Stored Procedure Query support - java and orm context model
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/META-INF/MANIFEST.MF1
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/model/src/org/eclipse/jpt/jpa/core/resource/orm/XmlStoredProcedureParameter.java14
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaNode.java1
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryContainer.java104
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmQueryContainer.java101
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/GenericJpaFactory2_1.java19
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/NamedStoredProcedureQuery2_1.java168
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/StoredProcedureParameter2_1.java82
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/java/GenericJavaNamedStoredProcedureQuery2_1.java329
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/java/GenericJavaStoredProcedureParameter2_1.java186
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/java/JavaNamedStoredProcedureQuery2_1.java41
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/java/JavaQueryContainer2_1.java39
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/java/JavaStoredProcedureParameter2_1.java31
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/GenericOrmNamedStoredProcedureQuery2_1.java338
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/GenericOrmStoredProcedureParameter2_1.java199
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/GenericOrmXml2_1ContextNodeFactory.java16
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/OrmConverterTypeDefinition.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/OrmNamedStoredProcedureQuery2_1.java39
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/OrmQueryContainer2_1.java27
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/OrmStoredProcedureParameter2_1.java28
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/resource/java/binary/BinaryStoredProcedureParameter2_1Annotation.java20
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/resource/java/source/SourceStoredProcedureParameter2_1Annotation.java22
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/JpaFactory2_1.java14
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/ParameterMode2_1.java106
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/context/QueryContainer2_1.java74
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/context/orm/OrmXml2_1ContextNodeFactory.java15
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/resource/java/NamedStoredProcedureQuery2_1Annotation.java10
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/resource/java/ParameterMode_2_1.java (renamed from jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/resource/java/ParameterMode2_1.java)12
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/resource/java/StoredProcedureParameter2_1Annotation.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLink2_5JpaFactory.java19
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmXml2_5ContextNodeFactory.java21
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/META-INF/MANIFEST.MF2
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/JptJpaCoreContextModelTests.java4
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/Generic2_1ContextModelTestCase.java3
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/java/Generic2_1JavaContextModelTests.java30
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/java/GenericJavaNamedStoredProcedureQuery2_1Tests.java869
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/java/GenericJavaStoredProcedureParameter2_1Tests.java219
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/orm/Generic2_1OrmContextModelTests.java35
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/orm/GenericOrmNamedStoredProcedureQuery2_1Tests.java713
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/orm/GenericOrmStoredProcedureParameter2_1Tests.java198
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/persistence/Generic2_1JpaMetadataConversionTests.java388
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/resource/java/StoredProcedureParameter2_1AnnotationTests.java26
42 files changed, 4504 insertions, 69 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/META-INF/MANIFEST.MF b/jpa/plugins/org.eclipse.jpt.jpa.core/META-INF/MANIFEST.MF
index da72c36..8080be2 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/META-INF/MANIFEST.MF
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/META-INF/MANIFEST.MF
@@ -65,6 +65,7 @@ Export-Package: org.eclipse.jpt.jpa.core,
org.eclipse.jpt.jpa.core.internal.jpa2.resource.java.binary;x-internal:=true,
org.eclipse.jpt.jpa.core.internal.jpa2.resource.java.source;x-internal:=true,
org.eclipse.jpt.jpa.core.internal.jpa2_1;x-internal:=true,
+ org.eclipse.jpt.jpa.core.internal.jpa2_1.context;x-internal:=true,
org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java;x-internal:=true,
org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm;x-internal:=true,
org.eclipse.jpt.jpa.core.internal.jpa2_1.resource.java;x-internal:=true,
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/model/src/org/eclipse/jpt/jpa/core/resource/orm/XmlStoredProcedureParameter.java b/jpa/plugins/org.eclipse.jpt.jpa.core/model/src/org/eclipse/jpt/jpa/core/resource/orm/XmlStoredProcedureParameter.java
index be716cf..7c34127 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/model/src/org/eclipse/jpt/jpa/core/resource/orm/XmlStoredProcedureParameter.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/model/src/org/eclipse/jpt/jpa/core/resource/orm/XmlStoredProcedureParameter.java
@@ -10,15 +10,11 @@
package org.eclipse.jpt.jpa.core.resource.orm;
import org.eclipse.emf.common.notify.Notification;
-
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
-
import org.eclipse.emf.ecore.impl.ENotificationImpl;
-
import org.eclipse.jpt.common.core.internal.utility.translators.SimpleTranslator;
import org.eclipse.jpt.common.core.resource.xml.EBaseObjectImpl;
-
import org.eclipse.jpt.jpa.core.resource.orm.v2_1.JPA2_1;
import org.eclipse.jpt.jpa.core.resource.orm.v2_1.OrmV2_1Package;
import org.eclipse.jpt.jpa.core.resource.orm.v2_1.ParameterMode_2_1;
@@ -64,14 +60,10 @@ public class XmlStoredProcedureParameter extends EBaseObjectImpl implements XmlS
protected String description = DESCRIPTION_EDEFAULT;
/**
- * The default value of the '{@link #getMode() <em>Mode</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getMode()
- * @generated
- * @ordered
+ * changed this to null and removed the generated flag so emf won't generate over it
+ * we don't want a default for enums, just null if the tag does not exist
*/
- protected static final ParameterMode_2_1 MODE_EDEFAULT = ParameterMode_2_1.IN;
+ protected static final ParameterMode_2_1 MODE_EDEFAULT = null;
/**
* The cached value of the '{@link #getMode() <em>Mode</em>}' attribute.
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaNode.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaNode.java
index fb2fab7..174f910 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaNode.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaNode.java
@@ -158,6 +158,7 @@ public abstract class AbstractJpaNode
protected JpaFactory2_0 getJpaFactory2_0() {
return (JpaFactory2_0) this.getJpaFactory();
}
+
/**
* Call {@link #isJpa2_1Compatible()} before calling this method.
*/
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryContainer.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryContainer.java
index aeb46d6..8dcb0bd 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryContainer.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryContainer.java
@@ -13,7 +13,6 @@ import java.util.List;
import org.eclipse.jpt.common.core.resource.java.NestableAnnotation;
import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
-import org.eclipse.jpt.common.utility.internal.iterable.SubListIterableWrapper;
import org.eclipse.jpt.common.utility.iterable.ListIterable;
import org.eclipse.jpt.jpa.core.context.JpaContextNode;
import org.eclipse.jpt.jpa.core.context.NamedNativeQuery;
@@ -21,8 +20,11 @@ import org.eclipse.jpt.jpa.core.context.NamedQuery;
import org.eclipse.jpt.jpa.core.context.Query;
import org.eclipse.jpt.jpa.core.context.java.JavaNamedNativeQuery;
import org.eclipse.jpt.jpa.core.context.java.JavaNamedQuery;
-import org.eclipse.jpt.jpa.core.context.java.JavaQueryContainer;
import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.NamedStoredProcedureQuery2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java.JavaNamedStoredProcedureQuery2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java.JavaQueryContainer2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.NamedStoredProcedureQuery2_1Annotation;
import org.eclipse.jpt.jpa.core.resource.java.NamedNativeQueryAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.NamedQueryAnnotation;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
@@ -33,12 +35,13 @@ import org.eclipse.wst.validation.internal.provisional.core.IReporter;
*/
public class GenericJavaQueryContainer
extends AbstractJavaJpaContextNode
- implements JavaQueryContainer
+ implements JavaQueryContainer2_1
{
protected final Owner owner;
protected final ContextListContainer<JavaNamedQuery, NamedQueryAnnotation> namedQueryContainer;
protected final ContextListContainer<JavaNamedNativeQuery, NamedNativeQueryAnnotation> namedNativeQueryContainer;
+ protected final ContextListContainer<JavaNamedStoredProcedureQuery2_1, NamedStoredProcedureQuery2_1Annotation> namedStoredProcedureQueryContainer;
public GenericJavaQueryContainer(JpaContextNode parent, Owner owner) {
@@ -46,6 +49,7 @@ public class GenericJavaQueryContainer
this.owner = owner;
this.namedQueryContainer = this.buildNamedQueryContainer();
this.namedNativeQueryContainer = this.buildNamedNativeQueryContainer();
+ this.namedStoredProcedureQueryContainer = this.buildNamedStoredProcedureQueryContainer();
}
@@ -56,6 +60,7 @@ public class GenericJavaQueryContainer
super.synchronizeWithResourceModel();
this.syncNamedQueries();
this.syncNamedNativeQueries();
+ this.syncNamedStoredProcedureQueries();
}
@Override
@@ -63,6 +68,7 @@ public class GenericJavaQueryContainer
super.update();
this.updateNodes(this.getNamedQueries());
this.updateNodes(this.getNamedNativeQueries());
+ this.updateNodes(this.getNamedStoredProcedureQueries());
}
@@ -70,7 +76,10 @@ public class GenericJavaQueryContainer
@SuppressWarnings("unchecked")
public Iterable<Query> getQueries() {
- return IterableTools.<Query>concatenate(this.getNamedQueries(), this.getNamedNativeQueries());
+ return IterableTools.<Query>concatenate(
+ this.getNamedQueries(),
+ this.getNamedNativeQueries(),
+ this.getNamedStoredProcedureQueries());
}
@@ -121,7 +130,7 @@ public class GenericJavaQueryContainer
}
protected ListIterable<NamedQueryAnnotation> getNamedQueryAnnotations() {
- return new SubListIterableWrapper<NestableAnnotation, NamedQueryAnnotation>(this.getNestableNamedQueryAnnotations_());
+ return IterableTools.downCast(this.getNestableNamedQueryAnnotations_());
}
protected ListIterable<NestableAnnotation> getNestableNamedQueryAnnotations_() {
@@ -205,7 +214,7 @@ public class GenericJavaQueryContainer
}
protected ListIterable<NamedNativeQueryAnnotation> getNamedNativeQueryAnnotations() {
- return new SubListIterableWrapper<NestableAnnotation, NamedNativeQueryAnnotation>(this.getNestableNamedNativeQueryAnnotations_());
+ return IterableTools.downCast(this.getNestableNamedNativeQueryAnnotations_());
}
protected ListIterable<NestableAnnotation> getNestableNamedNativeQueryAnnotations_() {
@@ -242,6 +251,89 @@ public class GenericJavaQueryContainer
}
}
+ // ********** named stored procedure queries **********
+
+ public ListIterable<JavaNamedStoredProcedureQuery2_1> getNamedStoredProcedureQueries() {
+ return this.namedStoredProcedureQueryContainer.getContextElements();
+ }
+
+ public int getNamedStoredProcedureQueriesSize() {
+ return this.namedStoredProcedureQueryContainer.getContextElementsSize();
+ }
+
+ public JavaNamedStoredProcedureQuery2_1 addNamedStoredProcedureQuery() {
+ return this.addNamedStoredProcedureQuery(this.getNamedNativeQueriesSize());
+ }
+
+ public JavaNamedStoredProcedureQuery2_1 addNamedStoredProcedureQuery(int index) {
+ NamedStoredProcedureQuery2_1Annotation annotation = this.addNamedStoredProcedureQueryAnnotation(index);
+ return this.namedStoredProcedureQueryContainer.addContextElement(index, annotation);
+ }
+
+ protected NamedStoredProcedureQuery2_1Annotation addNamedStoredProcedureQueryAnnotation(int index) {
+ return (NamedStoredProcedureQuery2_1Annotation) this.owner.getResourceAnnotatedElement().addAnnotation(index, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME);
+ }
+
+ public void removeNamedStoredProcedureQuery(NamedStoredProcedureQuery2_1 namedStoredProcedureQuery) {
+ this.removeNamedStoredProcedureQuery(this.namedStoredProcedureQueryContainer.indexOfContextElement((JavaNamedStoredProcedureQuery2_1) namedStoredProcedureQuery));
+ }
+
+ public void removeNamedStoredProcedureQuery(int index) {
+ this.owner.getResourceAnnotatedElement().removeAnnotation(index, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME);
+ this.namedStoredProcedureQueryContainer.removeContextElement(index);
+ }
+
+ public void moveNamedStoredProcedureQuery(int targetIndex, int sourceIndex) {
+ this.owner.getResourceAnnotatedElement().moveAnnotation(targetIndex, sourceIndex, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME);
+ this.namedStoredProcedureQueryContainer.moveContextElement(targetIndex, sourceIndex);
+ }
+
+ protected JavaNamedStoredProcedureQuery2_1 buildNamedStoredProcedureQuery(NamedStoredProcedureQuery2_1Annotation namedStoredProcedureQueryAnnotation) {
+ return this.getJpaFactory2_1().buildJavaNamedStoredProcedureQuery2_1(this, namedStoredProcedureQueryAnnotation);
+ }
+
+ protected void syncNamedStoredProcedureQueries() {
+ this.namedStoredProcedureQueryContainer.synchronizeWithResourceModel();
+ }
+
+ protected ListIterable<NamedStoredProcedureQuery2_1Annotation> getNamedStoredProcedureQueryAnnotations() {
+ return IterableTools.downCast(this.getNestableNamedStoredProcedureQueryAnnotations_());
+ }
+
+ protected ListIterable<NestableAnnotation> getNestableNamedStoredProcedureQueryAnnotations_() {
+ return this.owner.getResourceAnnotatedElement().getAnnotations(NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME);
+ }
+
+ protected ContextListContainer<JavaNamedStoredProcedureQuery2_1, NamedStoredProcedureQuery2_1Annotation> buildNamedStoredProcedureQueryContainer() {
+ NamedStoredProcedureQueryContainer container = new NamedStoredProcedureQueryContainer();
+ container.initialize();
+ return container;
+ }
+
+ /**
+ * named query container
+ */
+ protected class NamedStoredProcedureQueryContainer
+ extends ContextListContainer<JavaNamedStoredProcedureQuery2_1, NamedStoredProcedureQuery2_1Annotation>
+ {
+ @Override
+ protected String getContextElementsPropertyName() {
+ return NAMED_STORED_PROCEDURE_QUERIES_LIST;
+ }
+ @Override
+ protected JavaNamedStoredProcedureQuery2_1 buildContextElement(NamedStoredProcedureQuery2_1Annotation resourceElement) {
+ return GenericJavaQueryContainer.this.buildNamedStoredProcedureQuery(resourceElement);
+ }
+ @Override
+ protected ListIterable<NamedStoredProcedureQuery2_1Annotation> getResourceElements() {
+ return GenericJavaQueryContainer.this.getNamedStoredProcedureQueryAnnotations();
+ }
+ @Override
+ protected NamedStoredProcedureQuery2_1Annotation getResourceElement(JavaNamedStoredProcedureQuery2_1 contextElement) {
+ return contextElement.getQueryAnnotation();
+ }
+ }
+
// ********** validation **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmQueryContainer.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmQueryContainer.java
index eacb2b7..facfe26 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmQueryContainer.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmQueryContainer.java
@@ -19,11 +19,14 @@ import org.eclipse.jpt.jpa.core.context.NamedQuery;
import org.eclipse.jpt.jpa.core.context.Query;
import org.eclipse.jpt.jpa.core.context.orm.OrmNamedNativeQuery;
import org.eclipse.jpt.jpa.core.context.orm.OrmNamedQuery;
-import org.eclipse.jpt.jpa.core.context.orm.OrmQueryContainer;
import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmXmlContextNode;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.NamedStoredProcedureQuery2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm.OrmNamedStoredProcedureQuery2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm.OrmQueryContainer2_1;
import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
import org.eclipse.jpt.jpa.core.resource.orm.XmlNamedNativeQuery;
import org.eclipse.jpt.jpa.core.resource.orm.XmlNamedQuery;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlNamedStoredProcedureQuery;
import org.eclipse.jpt.jpa.core.resource.orm.XmlQueryContainer;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
@@ -33,12 +36,13 @@ import org.eclipse.wst.validation.internal.provisional.core.IReporter;
*/
public class GenericOrmQueryContainer
extends AbstractOrmXmlContextNode
- implements OrmQueryContainer
+ implements OrmQueryContainer2_1
{
protected final XmlQueryContainer xmlQueryContainer;
protected final ContextListContainer<OrmNamedQuery, XmlNamedQuery> namedQueryContainer;
protected final ContextListContainer<OrmNamedNativeQuery, XmlNamedNativeQuery> namedNativeQueryContainer;
+ protected final ContextListContainer<OrmNamedStoredProcedureQuery2_1, XmlNamedStoredProcedureQuery> namedStoredProcedureQueryContainer;
public GenericOrmQueryContainer(JpaContextNode parent, XmlQueryContainer xmlQueryContainer) {
@@ -46,6 +50,7 @@ public class GenericOrmQueryContainer
this.xmlQueryContainer = xmlQueryContainer;
this.namedQueryContainer = this.buildNamedQueryContainer();
this.namedNativeQueryContainer = this.buildNamedNativeQueryContainer();
+ this.namedStoredProcedureQueryContainer = this.buildNamedStoredProcedureQueryContainer();
}
@@ -56,6 +61,7 @@ public class GenericOrmQueryContainer
super.synchronizeWithResourceModel();
this.syncNamedQueries();
this.syncNamedNativeQueries();
+ this.syncNamedStoredProcedureQueries();
}
@Override
@@ -63,6 +69,7 @@ public class GenericOrmQueryContainer
super.update();
this.updateNodes(this.getNamedQueries());
this.updateNodes(this.getNamedNativeQueries());
+ this.updateNodes(this.getNamedStoredProcedureQueries());
}
@@ -70,7 +77,10 @@ public class GenericOrmQueryContainer
@SuppressWarnings("unchecked")
public Iterable<Query> getQueries() {
- return IterableTools.<Query>concatenate(this.getNamedQueries(), this.getNamedNativeQueries());
+ return IterableTools.<Query>concatenate(
+ this.getNamedQueries(),
+ this.getNamedNativeQueries(),
+ this.getNamedStoredProcedureQueries());
}
@@ -239,6 +249,91 @@ public class GenericOrmQueryContainer
}
+ // ********** named stored procedure queries **********
+
+ public ListIterable<OrmNamedStoredProcedureQuery2_1> getNamedStoredProcedureQueries() {
+ return this.namedStoredProcedureQueryContainer.getContextElements();
+ }
+
+ public int getNamedStoredProcedureQueriesSize() {
+ return this.namedStoredProcedureQueryContainer.getContextElementsSize();
+ }
+
+ public OrmNamedStoredProcedureQuery2_1 addNamedStoredProcedureQuery() {
+ return this.addNamedStoredProcedureQuery(this.getNamedStoredProcedureQueriesSize());
+ }
+
+ public OrmNamedStoredProcedureQuery2_1 addNamedStoredProcedureQuery(int index) {
+ XmlNamedStoredProcedureQuery xmlQuery = this.buildXmlNamedStoredProcedureQuery();
+ OrmNamedStoredProcedureQuery2_1 query = this.namedStoredProcedureQueryContainer.addContextElement(index, xmlQuery);
+ this.xmlQueryContainer.getNamedStoredProcedureQueries().add(index, xmlQuery);
+ return query;
+ }
+
+ protected XmlNamedStoredProcedureQuery buildXmlNamedStoredProcedureQuery() {
+ return OrmFactory.eINSTANCE.createXmlNamedStoredProcedureQuery();
+ }
+
+ public void removeNamedStoredProcedureQuery(NamedStoredProcedureQuery2_1 namedQuery) {
+ this.removeNamedStoredProcedureQuery(this.namedStoredProcedureQueryContainer.indexOfContextElement((OrmNamedStoredProcedureQuery2_1) namedQuery));
+ }
+
+ public void removeNamedStoredProcedureQuery(int index) {
+ this.namedStoredProcedureQueryContainer.removeContextElement(index);
+ this.xmlQueryContainer.getNamedStoredProcedureQueries().remove(index);
+ }
+
+ public void moveNamedStoredProcedureQuery(int targetIndex, int sourceIndex) {
+ this.namedStoredProcedureQueryContainer.moveContextElement(targetIndex, sourceIndex);
+ this.xmlQueryContainer.getNamedStoredProcedureQueries().move(targetIndex, sourceIndex);
+ }
+
+ protected OrmNamedStoredProcedureQuery2_1 buildNamedStoredProcedureQuery(XmlNamedStoredProcedureQuery xmlNamedQuery) {
+ return this.isOrmXml2_1Compatible() ?
+ this.getContextNodeFactory2_1().buildOrmNamedStoredProcedureQuery2_1(this, xmlNamedQuery) :
+ null;
+ }
+
+ protected void syncNamedStoredProcedureQueries() {
+ this.namedStoredProcedureQueryContainer.synchronizeWithResourceModel();
+ }
+
+ protected ListIterable<XmlNamedStoredProcedureQuery> getXmlNamedStoredProcedureQueries() {
+ // clone to reduce chance of concurrency problems
+ return IterableTools.cloneLive(this.xmlQueryContainer.getNamedStoredProcedureQueries());
+ }
+
+ protected ContextListContainer<OrmNamedStoredProcedureQuery2_1, XmlNamedStoredProcedureQuery> buildNamedStoredProcedureQueryContainer() {
+ NamedStoredProcedureQueryContainer container = new NamedStoredProcedureQueryContainer();
+ container.initialize();
+ return container;
+ }
+
+ /**
+ * named query container
+ */
+ protected class NamedStoredProcedureQueryContainer
+ extends ContextListContainer<OrmNamedStoredProcedureQuery2_1, XmlNamedStoredProcedureQuery>
+ {
+ @Override
+ protected String getContextElementsPropertyName() {
+ return NAMED_STORED_PROCEDURE_QUERIES_LIST;
+ }
+ @Override
+ protected OrmNamedStoredProcedureQuery2_1 buildContextElement(XmlNamedStoredProcedureQuery resourceElement) {
+ return GenericOrmQueryContainer.this.buildNamedStoredProcedureQuery(resourceElement);
+ }
+ @Override
+ protected ListIterable<XmlNamedStoredProcedureQuery> getResourceElements() {
+ return GenericOrmQueryContainer.this.getXmlNamedStoredProcedureQueries();
+ }
+ @Override
+ protected XmlNamedStoredProcedureQuery getResourceElement(OrmNamedStoredProcedureQuery2_1 contextElement) {
+ return contextElement.getXmlQuery();
+ }
+ }
+
+
// ********** validation **********
/**
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/GenericJpaFactory2_1.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/GenericJpaFactory2_1.java
index 7662d29..33e3ccc 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/GenericJpaFactory2_1.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/GenericJpaFactory2_1.java
@@ -13,8 +13,15 @@ import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.jpa.core.context.JpaContextNode;
import org.eclipse.jpt.jpa.core.internal.jpa2.GenericJpaFactory2_0;
import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java.GenericJavaConverterType;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java.GenericJavaNamedStoredProcedureQuery2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java.GenericJavaStoredProcedureParameter2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java.JavaNamedStoredProcedureQuery2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java.JavaQueryContainer2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java.JavaStoredProcedureParameter2_1;
import org.eclipse.jpt.jpa.core.jpa2_1.JpaFactory2_1;
import org.eclipse.jpt.jpa.core.jpa2_1.context.java.JavaConverterType2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.NamedStoredProcedureQuery2_1Annotation;
+import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.StoredProcedureParameter2_1Annotation;
/**
@@ -33,4 +40,16 @@ public class GenericJpaFactory2_1
public JavaConverterType2_1 buildJavaConverterType(JpaContextNode parent, JavaResourceType jrt) {
return new GenericJavaConverterType(parent, jrt);
}
+
+ public JavaNamedStoredProcedureQuery2_1 buildJavaNamedStoredProcedureQuery2_1(
+ JavaQueryContainer2_1 parent,
+ NamedStoredProcedureQuery2_1Annotation namedStoredProcedureQueryAnnotation) {
+ return new GenericJavaNamedStoredProcedureQuery2_1(parent, namedStoredProcedureQueryAnnotation);
+ }
+
+ public JavaStoredProcedureParameter2_1 buildJavaStoredProcedureParameter2_1(
+ JavaNamedStoredProcedureQuery2_1 parent,
+ StoredProcedureParameter2_1Annotation parameterAnnotation) {
+ return new GenericJavaStoredProcedureParameter2_1(parent, parameterAnnotation);
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/NamedStoredProcedureQuery2_1.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/NamedStoredProcedureQuery2_1.java
new file mode 100644
index 0000000..60b532f
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/NamedStoredProcedureQuery2_1.java
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.jpa2_1.context;
+
+import org.eclipse.jpt.common.utility.iterable.ListIterable;
+import org.eclipse.jpt.jpa.core.context.Query;
+
+/**
+ * named stored procedure query
+ * <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 NamedStoredProcedureQuery2_1
+ extends Query
+{
+
+ // ********** procedure name **********
+
+ String getProcedureName();
+ String PROCEDURE_NAME_PROPERTY = "procedureName"; //$NON-NLS-1$
+
+ void setProcedureName(String procedureName);
+
+
+ // ********** parameters **********
+
+ /**
+ * Return the query's parameters.
+ */
+ ListIterable<? extends StoredProcedureParameter2_1> getParameters();
+ String PARAMETERS_LIST = "parameters"; //$NON-NLS-1$
+
+ /**
+ * Return the number of parameters in the query.
+ */
+ int getParametersSize();
+
+ /**
+ * Add a parameter to the query and return the object representing it.
+ */
+ StoredProcedureParameter2_1 addParameter();
+
+ /**
+ * Add a parameter to the index and return the object representing it.
+ */
+ StoredProcedureParameter2_1 addParameter(int index);
+
+ /**
+ * Remove the parameter from the query.
+ */
+ void removeParameter(StoredProcedureParameter2_1 parameter);
+
+ /**
+ * Remove the parameter at the index from the query.
+ */
+ void removeParameter(int index);
+
+ /**
+ * Move the hint from the source index to the target index.
+ */
+ void moveParameter(int targetIndex, int sourceIndex);
+
+ /**
+ * Return the parameter at the index.
+ */
+ StoredProcedureParameter2_1 getParameter(int index);
+
+ // ********** result classes **********
+
+ /**
+ * Return the query's result classes.
+ */
+ ListIterable<String> getResultClasses();
+ String RESULT_CLASSES_LIST = "resultClasses"; //$NON-NLS-1$
+
+ /**
+ * Return the number of result classes in the query.
+ */
+ int getResultClassesSize();
+
+ /**
+ * Return the result class at the index.
+ */
+ String getResultClass(int index);
+
+ /**
+ * Add the result class to the query.
+ */
+ void addResultClass(String resultClass);
+
+ /**
+ * Add the result class to the index.
+ */
+ void addResultClass(int index, String resultClass);
+
+ /**
+ * Remove the result class from the query's list of result classes.
+ */
+ void removeResultClass(String resultClass);
+
+ /**
+ * Remove the result class at the index.
+ */
+ void removeResultClass(int index);
+
+ /**
+ * Move the result class from the source index to the target index.
+ */
+ void moveResultClass(int targetIndex, int sourceIndex);
+
+
+ // ********** result set mappings **********
+
+ /**
+ * Return the query's result set mappings.
+ */
+ ListIterable<String> getResultSetMappings();
+ String RESULT_SET_MAPPINGS_LIST = "resultSetMappings"; //$NON-NLS-1$
+
+ /**
+ * Return the number of result set mappings in the query.
+ */
+ int getResultSetMappingsSize();
+
+ /**
+ * Return the result class at the index.
+ */
+ String getResultSetMapping(int index);
+
+ /**
+ * Add the result set mapping to the query.
+ */
+ void addResultSetMapping(String resultClass);
+
+ /**
+ * Add the result set mapping to the index.
+ */
+ void addResultSetMapping(int index, String resultClass);
+
+ /**
+ * Remove the result set mapping from the query's list of result set mappings.
+ */
+ void removeResultSetMapping(String resultClass);
+
+ /**
+ * Remove the result set mapping at the index.
+ */
+ void removeResultSetMapping(int index);
+
+ /**
+ * Move the result set mapping from the source index to the target index.
+ */
+ void moveResultSetMapping(int targetIndex, int sourceIndex);
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/StoredProcedureParameter2_1.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/StoredProcedureParameter2_1.java
new file mode 100644
index 0000000..2c6aa98
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/StoredProcedureParameter2_1.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.jpa2_1.context;
+
+import org.eclipse.jpt.jpa.core.context.JpaContextNode;
+import org.eclipse.jpt.jpa.core.jpa2_1.ParameterMode2_1;
+
+/**
+ * stored procedure parameter
+ * <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 StoredProcedureParameter2_1
+ extends JpaContextNode
+{
+
+ // ********* name **********
+ String getName();
+ String NAME_PROPERTY = "name"; //$NON-NLS-1$
+
+ void setName(String name);
+
+
+ // *********** mode *************
+
+ /**
+ * Return the specified mode if present,
+ * otherwise return the default lock mode.
+ */
+ ParameterMode2_1 getMode();
+ ParameterMode2_1 getSpecifiedMode();
+ void setSpecifiedMode(ParameterMode2_1 mode);
+ String SPECIFIED_MODE_PROPERTY = "specifiedParameterMode"; //$NON-NLS-1$
+ ParameterMode2_1 getDefaultMode();
+ String DEFAULT_MODE_PROPERTY = "defaultParameterMode"; //$NON-NLS-1$
+
+
+ // ********** type ***********
+
+ String getTypeName();
+ String TYPE_NAME_PROPERTY = "typeName"; //$NON-NLS-1$
+
+ void setTypeName(String type);
+
+ /**
+ * If the type name is specified, this will return it fully qualified. If not
+ * specified, then it will return null
+ */
+ String getFullyQualifiedTypeName();
+ String FULLY_QUALIFIED_TYPE_NAME_PROPERTY = "fullyQualifiedTypeName"; //$NON-NLS-1$
+
+ /**
+ * Return the character to be used for browsing or
+ * creating the type {@link org.eclipse.jdt.core.IType IType}.
+ * @see org.eclipse.jdt.core.IType#getFullyQualifiedName(char)
+ */
+ char getTypeEnclosingTypeSeparator();
+
+
+ // ********** validation ***********
+
+ /**
+ * Return whether this stored procedure parameter is <em>equivalent</em>
+ * to the specified stored procedure parameter.
+ */
+ boolean isEquivalentTo(StoredProcedureParameter2_1 parameter);
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/java/GenericJavaNamedStoredProcedureQuery2_1.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/java/GenericJavaNamedStoredProcedureQuery2_1.java
new file mode 100644
index 0000000..bd8f9f2
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/java/GenericJavaNamedStoredProcedureQuery2_1.java
@@ -0,0 +1,329 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java;
+
+import java.util.ArrayList;
+import java.util.Vector;
+import org.eclipse.jpt.common.utility.internal.ObjectTools;
+import org.eclipse.jpt.common.utility.internal.collection.ListTools;
+import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
+import org.eclipse.jpt.common.utility.iterable.ListIterable;
+import org.eclipse.jpt.jpa.core.context.Query;
+import org.eclipse.jpt.jpa.core.context.orm.OrmQueryContainer;
+import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaQuery;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.NamedStoredProcedureQuery2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.StoredProcedureParameter2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm.OrmQueryContainer2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.NamedStoredProcedureQuery2_1Annotation;
+import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.StoredProcedureParameter2_1Annotation;
+
+/**
+ * <code>orm.xml</code> named stored procedure query
+ */
+public class GenericJavaNamedStoredProcedureQuery2_1
+ extends AbstractJavaQuery<NamedStoredProcedureQuery2_1Annotation>
+ implements JavaNamedStoredProcedureQuery2_1
+{
+ protected String procedureName;
+
+ protected final ContextListContainer<JavaStoredProcedureParameter2_1, StoredProcedureParameter2_1Annotation> parameterContainer;
+
+ protected final Vector<String> resultClasses = new Vector<String>();
+
+ protected final Vector<String> resultSetMappings = new Vector<String>();
+
+
+ public GenericJavaNamedStoredProcedureQuery2_1(JavaQueryContainer2_1 parent, NamedStoredProcedureQuery2_1Annotation queryAnnotation) {
+ super(parent, queryAnnotation);
+ this.procedureName = queryAnnotation.getProcedureName();
+ this.parameterContainer = this.buildParameterContainer();
+ this.initializeResultClasses();
+ this.initializeResultSetMappings();
+ }
+
+
+ // ********** synchronize/update **********
+
+ @Override
+ public void synchronizeWithResourceModel() {
+ super.synchronizeWithResourceModel();
+ this.setProcedureName_(this.queryAnnotation.getProcedureName());
+ this.syncParameters();
+ this.syncResultClasses();
+ this.syncResultSetMappings();
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ this.updateNodes(this.getParameters());
+ }
+
+
+ // ********* procedure name ********
+
+ public String getProcedureName() {
+ return this.procedureName;
+ }
+
+ public void setProcedureName(String procedureName) {
+ this.queryAnnotation.setProcedureName(procedureName);
+ this.setProcedureName_(procedureName);
+ }
+
+ protected void setProcedureName_(String procedureName) {
+ String old = this.procedureName;
+ this.procedureName = procedureName;
+ this.firePropertyChanged(PROCEDURE_NAME_PROPERTY, old, procedureName);
+ }
+
+ // ************ parameters ***********
+
+ public ListIterable<JavaStoredProcedureParameter2_1> getParameters() {
+ return this.parameterContainer.getContextElements();
+ }
+
+ public int getParametersSize() {
+ return this.parameterContainer.getContextElementsSize();
+ }
+
+ public JavaStoredProcedureParameter2_1 addParameter() {
+ return this.addParameter(this.getParametersSize());
+ }
+
+ public JavaStoredProcedureParameter2_1 addParameter(int index) {
+ StoredProcedureParameter2_1Annotation annotation = this.queryAnnotation.addParameter(index);
+ return this.parameterContainer.addContextElement(index, annotation);
+ }
+
+ public void removeParameter(StoredProcedureParameter2_1 parameter) {
+ this.removeParameter(this.parameterContainer.indexOfContextElement((JavaStoredProcedureParameter2_1) parameter));
+ }
+
+ public void removeParameter(int index) {
+ this.queryAnnotation.removeParameter(index);
+ this.parameterContainer.removeContextElement(index);
+ }
+
+ public void moveParameter(int targetIndex, int sourceIndex) {
+ this.queryAnnotation.moveParameter(targetIndex, sourceIndex);
+ this.parameterContainer.moveContextElement(targetIndex, sourceIndex);
+ }
+
+ public JavaStoredProcedureParameter2_1 getParameter(int index) {
+ return this.parameterContainer.get(index);
+ }
+
+ protected JavaStoredProcedureParameter2_1 buildParameter(StoredProcedureParameter2_1Annotation parameterAnnotation) {
+ return this.getJpaFactory2_1().buildJavaStoredProcedureParameter2_1(this, parameterAnnotation);
+ }
+
+ protected void syncParameters() {
+ this.parameterContainer.synchronizeWithResourceModel();
+ }
+
+ protected ListIterable<StoredProcedureParameter2_1Annotation> getParameterAnnotations() {
+ return this.queryAnnotation.getParameters();
+ }
+
+ protected ContextListContainer<JavaStoredProcedureParameter2_1, StoredProcedureParameter2_1Annotation> buildParameterContainer() {
+ ParameterContainer container = new ParameterContainer();
+ container.initialize();
+ return container;
+ }
+
+ /**
+ * stored procedure parameter container
+ */
+ protected class ParameterContainer
+ extends ContextListContainer<JavaStoredProcedureParameter2_1, StoredProcedureParameter2_1Annotation>
+ {
+ @Override
+ protected String getContextElementsPropertyName() {
+ return PARAMETERS_LIST;
+ }
+ @Override
+ protected JavaStoredProcedureParameter2_1 buildContextElement(StoredProcedureParameter2_1Annotation resourceElement) {
+ return GenericJavaNamedStoredProcedureQuery2_1.this.buildParameter(resourceElement);
+ }
+ @Override
+ protected ListIterable<StoredProcedureParameter2_1Annotation> getResourceElements() {
+ return GenericJavaNamedStoredProcedureQuery2_1.this.getParameterAnnotations();
+ }
+ @Override
+ protected StoredProcedureParameter2_1Annotation getResourceElement(JavaStoredProcedureParameter2_1 contextElement) {
+ return contextElement.getStoredProcedureParameter2_1Annotation();
+ }
+ }
+
+
+ // *********** result classes **********
+
+ public ListIterable<String> getResultClasses() {
+ return IterableTools.cloneLive(this.resultClasses);
+ }
+
+ public int getResultClassesSize() {
+ return this.resultClasses.size();
+ }
+
+ public String getResultClass(int index) {
+ return this.resultClasses.get(index);
+ }
+
+ public void addResultClass(String resultClass) {
+ this.addResultClass(this.resultClasses.size(), resultClass);
+ }
+
+ public void addResultClass(int index, String resultClass) {
+ this.queryAnnotation.addResultClass(index, resultClass);
+ this.addItemToList(index, resultClass, this.resultClasses, RESULT_CLASSES_LIST);
+ }
+
+ public void removeResultClass(String resultClass) {
+ this.removeResultClass(this.resultClasses.indexOf(resultClass));
+ }
+
+ public void removeResultClass(int index) {
+ this.queryAnnotation.removeResultClass(index);
+ this.removeItemFromList(index, this.resultClasses, RESULT_CLASSES_LIST);
+ }
+
+ public void moveResultClass(int targetIndex, int sourceIndex) {
+ this.queryAnnotation.moveResultClass(targetIndex, sourceIndex);
+ this.moveItemInList(targetIndex, sourceIndex, this.resultClasses, RESULT_CLASSES_LIST);
+ }
+
+ protected void initializeResultClasses() {
+ for (String resultClass : this.getResourceResultClasses()) {
+ this.resultClasses.add(resultClass);
+ }
+ }
+
+ protected void syncResultClasses() {
+ this.synchronizeList(this.getResourceResultClasses(), this.resultClasses, RESULT_CLASSES_LIST);
+ }
+
+ protected Iterable<String> getResourceResultClasses() {
+ return this.queryAnnotation.getResultClasses();
+ }
+
+
+ // *********** result set mappings *********
+
+ public ListIterable<String> getResultSetMappings() {
+ return IterableTools.cloneLive(this.resultSetMappings);
+ }
+
+ public int getResultSetMappingsSize() {
+ return this.resultSetMappings.size();
+ }
+
+ public String getResultSetMapping(int index) {
+ return this.resultSetMappings.get(index);
+ }
+
+ public void addResultSetMapping(String resultSetMapping) {
+ this.addResultSetMapping(this.resultSetMappings.size(), resultSetMapping);
+ }
+
+ public void addResultSetMapping(int index, String resultSetMapping) {
+ this.queryAnnotation.addResultSetMapping(index, resultSetMapping);
+ this.addItemToList(index, resultSetMapping, this.resultSetMappings, RESULT_SET_MAPPINGS_LIST);
+ }
+
+ public void removeResultSetMapping(String resultSetMapping) {
+ this.removeResultSetMapping(this.resultSetMappings.indexOf(resultSetMapping));
+ }
+
+ public void removeResultSetMapping(int index) {
+ this.queryAnnotation.removeResultSetMapping(index);
+ this.removeItemFromList(index, this.resultSetMappings, RESULT_SET_MAPPINGS_LIST);
+ }
+
+ public void moveResultSetMapping(int targetIndex, int sourceIndex) {
+ this.queryAnnotation.moveResultSetMapping(targetIndex, sourceIndex);
+ this.moveItemInList(targetIndex, sourceIndex, this.resultSetMappings, RESULT_SET_MAPPINGS_LIST);
+ }
+
+ protected void initializeResultSetMappings() {
+ for (String resultSetMapping : this.getResourceResultSetMappings()) {
+ this.resultSetMappings.add(resultSetMapping);
+ }
+ }
+
+ protected void syncResultSetMappings() {
+ this.synchronizeList(this.getResourceResultSetMappings(), this.resultSetMappings, RESULT_SET_MAPPINGS_LIST);
+ }
+
+ protected Iterable<String> getResourceResultSetMappings() {
+ return this.queryAnnotation.getResultSetMappings();
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.resultClasses);
+ sb.append(this.resultSetMappings);
+ }
+
+
+ // ********** metadata conversion *********
+
+ public void convertTo(OrmQueryContainer queryContainer) {
+ ((OrmQueryContainer2_1) queryContainer).addNamedStoredProcedureQuery().convertFrom(this);
+ }
+
+ public void delete() {
+ this.getParent().removeNamedStoredProcedureQuery(this);
+ }
+
+
+ // ********** validation **********
+
+ @Override
+ protected boolean isEquivalentTo(Query other) {
+ return super.isEquivalentTo(other)
+ && this.isEquivalentTo((NamedStoredProcedureQuery2_1) other);
+ }
+
+ protected boolean isEquivalentTo(NamedStoredProcedureQuery2_1 other) {
+ return ObjectTools.equals(this.procedureName, other.getProcedureName()) &&
+ this.parametersAreEquivalentTo(other) &&
+ IterableTools.elementsAreEqual(this.getResultClasses(), other.getResultClasses()) &&
+ IterableTools.elementsAreEqual(this.getResultSetMappings(), other.getResultSetMappings());
+ }
+
+ protected boolean parametersAreEquivalentTo(NamedStoredProcedureQuery2_1 other) {
+ // get fixed lists of the stored procedure parameters
+ ArrayList<JavaStoredProcedureParameter2_1> parameter1 = ListTools.list(this.getParameters());
+ ArrayList<? extends StoredProcedureParameter2_1> parameter2 = ListTools.list(other.getParameters());
+ if (parameter1.size() != parameter2.size()) {
+ return false;
+ }
+ for (int i = 0; i < parameter1.size(); i++) {
+ if ( ! parameter1.get(i).isEquivalentTo(parameter2.get(i))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ // ********** misc **********
+
+ public Class<NamedStoredProcedureQuery2_1> getType() {
+ return NamedStoredProcedureQuery2_1.class;
+ }
+
+ @Override
+ public JavaQueryContainer2_1 getParent() {
+ return (JavaQueryContainer2_1) super.getParent();
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/java/GenericJavaStoredProcedureParameter2_1.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/java/GenericJavaStoredProcedureParameter2_1.java
new file mode 100644
index 0000000..ac49b38
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/java/GenericJavaStoredProcedureParameter2_1.java
@@ -0,0 +1,186 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java;
+
+import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.utility.internal.ObjectTools;
+import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.StoredProcedureParameter2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.ParameterMode2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.StoredProcedureParameter2_1Annotation;
+
+/**
+ * Java stored procedure parameter
+ */
+public class GenericJavaStoredProcedureParameter2_1
+ extends AbstractJavaJpaContextNode
+ implements JavaStoredProcedureParameter2_1
+{
+ protected final StoredProcedureParameter2_1Annotation parameterAnnotation;
+
+ protected String name;
+
+ protected ParameterMode2_1 specifiedMode;
+ protected ParameterMode2_1 defaultMode;
+
+ protected String typeName;
+ protected String fullyQualifiedTypeName;
+
+
+ public GenericJavaStoredProcedureParameter2_1(JavaNamedStoredProcedureQuery2_1 parent, StoredProcedureParameter2_1Annotation parameterAnnotation) {
+ super(parent);
+ this.parameterAnnotation = parameterAnnotation;
+ this.name = parameterAnnotation.getName();
+ this.specifiedMode = this.buildSpecifiedMode();
+ this.typeName = parameterAnnotation.getTypeName();
+ }
+
+
+ // ********** synchronize/update **********
+
+ @Override
+ public void synchronizeWithResourceModel() {
+ super.synchronizeWithResourceModel();
+ this.setName_(this.parameterAnnotation.getName());
+ this.setSpecifiedMode_(this.buildSpecifiedMode());
+ this.setTypeName_(this.parameterAnnotation.getTypeName());
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ this.setDefaultMode(this.buildDefaultMode());
+ this.setFullyQualifiedTypeName(this.buildFullyQualifiedTypeName());
+ }
+
+ // ********* name **************
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.parameterAnnotation.setName(name);
+ this.setName_(name);
+ }
+
+ protected void setName_(String name) {
+ String old = this.name;
+ this.name = name;
+ this.firePropertyChanged(NAME_PROPERTY, old, name);
+ }
+
+
+ // ********** mode **********
+
+ public ParameterMode2_1 getMode() {
+ return (this.specifiedMode != null) ? this.specifiedMode : this.defaultMode;
+ }
+
+ public ParameterMode2_1 getSpecifiedMode() {
+ return this.specifiedMode;
+ }
+
+ public void setSpecifiedMode(ParameterMode2_1 mode) {
+ this.parameterAnnotation.setMode(ParameterMode2_1.toJavaResourceModel(mode));
+ this.setSpecifiedMode_(mode);
+ }
+
+ protected void setSpecifiedMode_(ParameterMode2_1 mode) {
+ ParameterMode2_1 old = this.specifiedMode;
+ this.specifiedMode = mode;
+ this.firePropertyChanged(SPECIFIED_MODE_PROPERTY, old, mode);
+ }
+
+ protected ParameterMode2_1 buildSpecifiedMode() {
+ return ParameterMode2_1.fromJavaResourceModel(this.parameterAnnotation.getMode());
+ }
+
+ public ParameterMode2_1 getDefaultMode() {
+ return this.defaultMode;
+ }
+
+ protected void setDefaultMode(ParameterMode2_1 mode) {
+ ParameterMode2_1 old = this.defaultMode;
+ this.defaultMode = mode;
+ this.firePropertyChanged(DEFAULT_MODE_PROPERTY, old, mode);
+ }
+
+ protected ParameterMode2_1 buildDefaultMode() {
+ return ParameterMode2_1.IN;
+ }
+
+
+ // ********** type **********
+
+ public String getTypeName() {
+ return this.typeName;
+ }
+
+ public void setTypeName(String typeName) {
+ this.parameterAnnotation.setTypeName(typeName);
+ this.setTypeName_(typeName);
+ }
+
+ protected void setTypeName_(String typeName) {
+ String old = this.typeName;
+ this.typeName = typeName;
+ this.firePropertyChanged(TYPE_NAME_PROPERTY, old, typeName);
+ }
+
+ public String getFullyQualifiedTypeName() {
+ return this.fullyQualifiedTypeName;
+ }
+
+ protected void setFullyQualifiedTypeName(String typeName) {
+ String old = this.fullyQualifiedTypeName;
+ this.fullyQualifiedTypeName = typeName;
+ this.firePropertyChanged(FULLY_QUALIFIED_TYPE_NAME_PROPERTY, old, typeName);
+ }
+
+ protected String buildFullyQualifiedTypeName() {
+ return this.parameterAnnotation.getFullyQualifiedTypeName();
+ }
+
+ public char getTypeEnclosingTypeSeparator() {
+ return '.';
+ }
+
+
+ // ********** validation **********
+
+ public TextRange getValidationTextRange() {
+ TextRange textRange = this.parameterAnnotation.getTextRange();
+ return (textRange != null) ? textRange : this.getQuery().getValidationTextRange();
+ }
+
+ public boolean isEquivalentTo(StoredProcedureParameter2_1 parameter) {
+ return ObjectTools.equals(this.name, parameter.getName()) &&
+ ObjectTools.equals(this.specifiedMode, parameter.getMode()) &&
+ ObjectTools.equals(this.typeName, parameter.getTypeName()) ;
+ }
+
+
+ // ********** misc **********
+
+ @Override
+ public JavaNamedStoredProcedureQuery2_1 getParent() {
+ return (JavaNamedStoredProcedureQuery2_1) super.getParent();
+ }
+
+ protected JavaNamedStoredProcedureQuery2_1 getQuery() {
+ return this.getParent();
+ }
+
+ public StoredProcedureParameter2_1Annotation getStoredProcedureParameter2_1Annotation() {
+ return this.parameterAnnotation;
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/java/JavaNamedStoredProcedureQuery2_1.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/java/JavaNamedStoredProcedureQuery2_1.java
new file mode 100644
index 0000000..ed0d6ce
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/java/JavaNamedStoredProcedureQuery2_1.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java;
+
+import org.eclipse.jpt.common.utility.iterable.ListIterable;
+import org.eclipse.jpt.jpa.core.context.java.JavaQuery;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.NamedStoredProcedureQuery2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.NamedStoredProcedureQuery2_1Annotation;
+
+/**
+ * Java named stored procedure query
+ * <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 JavaNamedStoredProcedureQuery2_1
+ extends NamedStoredProcedureQuery2_1, JavaQuery
+{
+ NamedStoredProcedureQuery2_1Annotation getQueryAnnotation();
+
+ // *********** parameters ************
+
+ ListIterable<JavaStoredProcedureParameter2_1> getParameters();
+
+ JavaStoredProcedureParameter2_1 addParameter();
+
+ JavaStoredProcedureParameter2_1 addParameter(int index);
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/java/JavaQueryContainer2_1.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/java/JavaQueryContainer2_1.java
new file mode 100644
index 0000000..8d695f2
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/java/JavaQueryContainer2_1.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java;
+
+import org.eclipse.jpt.common.utility.iterable.ListIterable;
+import org.eclipse.jpt.jpa.core.context.java.JavaQueryContainer;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.QueryContainer2_1;
+
+/**
+ * Java query container for JPA 2.1
+ * <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 JavaQueryContainer2_1
+ extends QueryContainer2_1, JavaQueryContainer
+{
+ // ********** named stored procedure queries **********
+
+ ListIterable<JavaNamedStoredProcedureQuery2_1> getNamedStoredProcedureQueries();
+
+ JavaNamedStoredProcedureQuery2_1 addNamedStoredProcedureQuery();
+
+ JavaNamedStoredProcedureQuery2_1 addNamedStoredProcedureQuery(int index);
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/java/JavaStoredProcedureParameter2_1.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/java/JavaStoredProcedureParameter2_1.java
new file mode 100644
index 0000000..fc99d52
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/java/JavaStoredProcedureParameter2_1.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java;
+
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.StoredProcedureParameter2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.StoredProcedureParameter2_1Annotation;
+
+/**
+ * Java stored procedure parameter
+ * <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 JavaStoredProcedureParameter2_1
+ extends StoredProcedureParameter2_1
+{
+ StoredProcedureParameter2_1Annotation getStoredProcedureParameter2_1Annotation();
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/GenericOrmNamedStoredProcedureQuery2_1.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/GenericOrmNamedStoredProcedureQuery2_1.java
new file mode 100644
index 0000000..e08b504
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/GenericOrmNamedStoredProcedureQuery2_1.java
@@ -0,0 +1,338 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm;
+
+import java.util.ArrayList;
+import java.util.Vector;
+import org.eclipse.jpt.common.utility.internal.ObjectTools;
+import org.eclipse.jpt.common.utility.internal.collection.ListTools;
+import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
+import org.eclipse.jpt.common.utility.iterable.ListIterable;
+import org.eclipse.jpt.jpa.core.context.JpaContextNode;
+import org.eclipse.jpt.jpa.core.context.Query;
+import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmQuery;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.NamedStoredProcedureQuery2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.StoredProcedureParameter2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java.JavaNamedStoredProcedureQuery2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java.JavaStoredProcedureParameter2_1;
+import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlNamedStoredProcedureQuery;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlStoredProcedureParameter;
+
+public class GenericOrmNamedStoredProcedureQuery2_1
+ extends AbstractOrmQuery<XmlNamedStoredProcedureQuery>
+ implements OrmNamedStoredProcedureQuery2_1
+{
+ protected String procedureName;
+
+ protected final ContextListContainer<OrmStoredProcedureParameter2_1, XmlStoredProcedureParameter> parameterContainer;
+
+ protected final Vector<String> resultClasses = new Vector<String>();
+
+ protected final Vector<String> resultSetMappings = new Vector<String>();
+
+
+ public GenericOrmNamedStoredProcedureQuery2_1(JpaContextNode parent, XmlNamedStoredProcedureQuery xmlNamedStoredProcedureQuery) {
+ super(parent, xmlNamedStoredProcedureQuery);
+ this.procedureName = this.xmlQuery.getProcedureName();
+ this.parameterContainer = this.buildParameterContainer();
+ this.initializeResultClasses();
+ this.initializeResultSetMappings();
+ }
+
+
+ // ********** synchronize/update **********
+
+ @Override
+ public void synchronizeWithResourceModel() {
+ super.synchronizeWithResourceModel();
+ this.setProcedureName_(this.xmlQuery.getProcedureName());
+ this.syncParameters();
+ this.syncResultClasses();
+ this.syncResultSetMappings();
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ this.updateNodes(this.getParameters());
+ }
+
+
+ // ********* procedure name ********
+
+ public String getProcedureName() {
+ return this.procedureName;
+ }
+
+ public void setProcedureName(String procedureName) {
+ this.xmlQuery.setProcedureName(procedureName);
+ this.setProcedureName_(procedureName);
+ }
+
+ protected void setProcedureName_(String procedureName) {
+ String old = this.procedureName;
+ this.procedureName = procedureName;
+ this.firePropertyChanged(PROCEDURE_NAME_PROPERTY, old, procedureName);
+ }
+
+ // ********** parameters **********
+
+ public ListIterable<OrmStoredProcedureParameter2_1> getParameters() {
+ return this.parameterContainer.getContextElements();
+ }
+
+ public int getParametersSize() {
+ return this.parameterContainer.getContextElementsSize();
+ }
+
+ public OrmStoredProcedureParameter2_1 addParameter() {
+ return this.addParameter(this.getParametersSize());
+ }
+
+ public OrmStoredProcedureParameter2_1 addParameter(int index) {
+ XmlStoredProcedureParameter xmlParameter = this.buildXmlStoredProcedureParameter();
+ OrmStoredProcedureParameter2_1 parameter = this.parameterContainer.addContextElement(index, xmlParameter);
+ this.xmlQuery.getParameters().add(index, xmlParameter);
+ return parameter;
+ }
+
+ protected XmlStoredProcedureParameter buildXmlStoredProcedureParameter() {
+ return OrmFactory.eINSTANCE.createXmlStoredProcedureParameter();
+ }
+
+ public void removeParameter(StoredProcedureParameter2_1 parameter) {
+ this.removeParameter(this.parameterContainer.indexOfContextElement((OrmStoredProcedureParameter2_1) parameter));
+ }
+
+ public void removeParameter(int index) {
+ this.parameterContainer.removeContextElement(index);
+ this.xmlQuery.getParameters().remove(index);
+ }
+
+ public void moveParameter(int targetIndex, int sourceIndex) {
+ this.parameterContainer.moveContextElement(targetIndex, sourceIndex);
+ this.xmlQuery.getParameters().move(targetIndex, sourceIndex);
+ }
+
+ public OrmStoredProcedureParameter2_1 getParameter(int index) {
+ return this.parameterContainer.get(index);
+ }
+
+ protected OrmStoredProcedureParameter2_1 buildParameter(XmlStoredProcedureParameter xmlParameter) {
+ return this.isOrmXml2_1Compatible() ?
+ this.getContextNodeFactory2_1().buildOrmStoredProcedureParameter(this, xmlParameter) :
+ null;
+ }
+
+ protected void syncParameters() {
+ this.parameterContainer.synchronizeWithResourceModel();
+ }
+
+ protected ListIterable<XmlStoredProcedureParameter> getXmlParameters() {
+ // clone to reduce chance of concurrency problems
+ return IterableTools.cloneLive(this.xmlQuery.getParameters());
+ }
+
+ protected ContextListContainer<OrmStoredProcedureParameter2_1, XmlStoredProcedureParameter> buildParameterContainer() {
+ ParameterContainer container = new ParameterContainer();
+ container.initialize();
+ return container;
+ }
+
+ /**
+ * parameter container
+ */
+ protected class ParameterContainer
+ extends ContextListContainer<OrmStoredProcedureParameter2_1, XmlStoredProcedureParameter>
+ {
+ @Override
+ protected String getContextElementsPropertyName() {
+ return PARAMETERS_LIST;
+ }
+ @Override
+ protected OrmStoredProcedureParameter2_1 buildContextElement(XmlStoredProcedureParameter resourceElement) {
+ return GenericOrmNamedStoredProcedureQuery2_1.this.buildParameter(resourceElement);
+ }
+ @Override
+ protected ListIterable<XmlStoredProcedureParameter> getResourceElements() {
+ return GenericOrmNamedStoredProcedureQuery2_1.this.getXmlParameters();
+ }
+ @Override
+ protected XmlStoredProcedureParameter getResourceElement(OrmStoredProcedureParameter2_1 contextElement) {
+ return contextElement.getXmlStoredProcedureParameter();
+ }
+ }
+
+
+ // *********** result classes **********
+
+ public ListIterable<String> getResultClasses() {
+ return IterableTools.cloneLive(this.resultClasses);
+ }
+
+ public int getResultClassesSize() {
+ return this.resultClasses.size();
+ }
+
+ public String getResultClass(int index) {
+ return this.resultClasses.get(index);
+ }
+
+ public void addResultClass(String resultClass) {
+ this.addResultClass(this.resultClasses.size(), resultClass);
+ }
+
+ public void addResultClass(int index, String resultClass) {
+ this.addItemToList(index, resultClass, this.resultClasses, RESULT_CLASSES_LIST);
+ this.xmlQuery.getResultClasses().add(index, resultClass);
+ }
+
+ public void removeResultClass(String resultClass) {
+ this.removeResultClass(this.resultClasses.indexOf(resultClass));
+ }
+
+ public void removeResultClass(int index) {
+ this.removeItemFromList(index, this.resultClasses, RESULT_CLASSES_LIST);
+ this.xmlQuery.getResultClasses().remove(index);
+ }
+
+ public void moveResultClass(int targetIndex, int sourceIndex) {
+ this.moveItemInList(targetIndex, sourceIndex, this.resultClasses, RESULT_CLASSES_LIST);
+ this.xmlQuery.getResultClasses().move(targetIndex, sourceIndex);
+ }
+
+ protected void initializeResultClasses() {
+ for (String resultClass : this.getResourceResultClasses()) {
+ this.resultClasses.add(resultClass);
+ }
+ }
+
+ protected void syncResultClasses() {
+ this.synchronizeList(this.getResourceResultClasses(), this.resultClasses, RESULT_CLASSES_LIST);
+ }
+
+ protected Iterable<String> getResourceResultClasses() {
+ return this.xmlQuery.getResultClasses();
+ }
+
+
+ // *********** result set mappings *********
+
+ public ListIterable<String> getResultSetMappings() {
+ return IterableTools.cloneLive(this.resultSetMappings);
+ }
+
+ public int getResultSetMappingsSize() {
+ return this.resultSetMappings.size();
+ }
+
+ public String getResultSetMapping(int index) {
+ return this.resultSetMappings.get(index);
+ }
+
+ public void addResultSetMapping(String resultSetMapping) {
+ this.addResultSetMapping(this.resultSetMappings.size(), resultSetMapping);
+ }
+
+ public void addResultSetMapping(int index, String resultSetMapping) {
+ this.addItemToList(index, resultSetMapping, this.resultSetMappings, RESULT_SET_MAPPINGS_LIST);
+ this.xmlQuery.getResultSetMappings().add(index, resultSetMapping);
+ }
+
+ public void removeResultSetMapping(String resultSetMapping) {
+ this.removeResultSetMapping(this.resultSetMappings.indexOf(resultSetMapping));
+ }
+
+ public void removeResultSetMapping(int index) {
+ this.removeItemFromList(index, this.resultSetMappings, RESULT_SET_MAPPINGS_LIST);
+ this.xmlQuery.getResultSetMappings().remove(index);
+ }
+
+ public void moveResultSetMapping(int targetIndex, int sourceIndex) {
+ this.moveItemInList(targetIndex, sourceIndex, this.resultSetMappings, RESULT_SET_MAPPINGS_LIST);
+ this.xmlQuery.getResultSetMappings().move(targetIndex, sourceIndex);
+ }
+
+ protected void initializeResultSetMappings() {
+ for (String resultSetMapping : this.getResourceResultSetMappings()) {
+ this.resultSetMappings.add(resultSetMapping);
+ }
+ }
+
+ protected void syncResultSetMappings() {
+ this.synchronizeList(this.getResourceResultSetMappings(), this.resultSetMappings, RESULT_SET_MAPPINGS_LIST);
+ }
+
+ protected Iterable<String> getResourceResultSetMappings() {
+ return this.xmlQuery.getResultSetMappings();
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.resultClasses);
+ sb.append(this.resultSetMappings);
+ }
+
+
+ // ********** metadata conversion *********
+
+ public void convertFrom(JavaNamedStoredProcedureQuery2_1 javaQuery) {
+ super.convertFrom(javaQuery);
+ this.setProcedureName(javaQuery.getProcedureName());
+ for (JavaStoredProcedureParameter2_1 javaParameter : javaQuery.getParameters()) {
+ this.addParameter().convertFrom(javaParameter);
+ }
+ for (String resultClass : javaQuery.getResultClasses()) {
+ this.addResultClass(resultClass);
+ }
+ for (String resultSetMapping : javaQuery.getResultSetMappings()) {
+ this.addResultSetMapping(resultSetMapping);
+ }
+ }
+
+
+ // ********** validation **********
+
+ @Override
+ protected boolean isEquivalentTo(Query other) {
+ return super.isEquivalentTo(other)
+ && this.isEquivalentTo((NamedStoredProcedureQuery2_1) other);
+ }
+
+ protected boolean isEquivalentTo(NamedStoredProcedureQuery2_1 other) {
+ return ObjectTools.equals(this.procedureName, other.getProcedureName()) &&
+ this.parametersAreEquivalentTo(other) &&
+ IterableTools.elementsAreEqual(this.getResultClasses(), other.getResultClasses()) &&
+ IterableTools.elementsAreEqual(this.getResultSetMappings(), other.getResultSetMappings());
+ }
+
+ protected boolean parametersAreEquivalentTo(NamedStoredProcedureQuery2_1 other) {
+ // get fixed lists of the stored procedure parameters
+ ArrayList<OrmStoredProcedureParameter2_1> parameter1 = ListTools.list(this.getParameters());
+ ArrayList<? extends StoredProcedureParameter2_1> parameter2 = ListTools.list(other.getParameters());
+ if (parameter1.size() != parameter2.size()) {
+ return false;
+ }
+ for (int i = 0; i < parameter1.size(); i++) {
+ if ( ! parameter1.get(i).isEquivalentTo(parameter2.get(i))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ // ********** misc **********
+
+ public Class<NamedStoredProcedureQuery2_1> getType() {
+ return NamedStoredProcedureQuery2_1.class;
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/GenericOrmStoredProcedureParameter2_1.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/GenericOrmStoredProcedureParameter2_1.java
new file mode 100644
index 0000000..e2d2024
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/GenericOrmStoredProcedureParameter2_1.java
@@ -0,0 +1,199 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm;
+
+import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.utility.internal.ObjectTools;
+import org.eclipse.jpt.jpa.core.context.orm.OrmQuery;
+import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmXmlContextNode;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.StoredProcedureParameter2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java.JavaStoredProcedureParameter2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.ParameterMode2_1;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlStoredProcedureParameter;
+
+public class GenericOrmStoredProcedureParameter2_1
+ extends AbstractOrmXmlContextNode
+ implements OrmStoredProcedureParameter2_1
+{
+
+ protected final XmlStoredProcedureParameter xmlStoredProcedureParameter;
+
+ protected String name;
+
+ protected ParameterMode2_1 specifiedMode;
+ protected ParameterMode2_1 defaultMode;
+
+ protected String typeName;
+ protected String fullyQualifiedTypeName;
+
+
+ public GenericOrmStoredProcedureParameter2_1(
+ OrmQuery parent,
+ XmlStoredProcedureParameter xmlStoredProcedureParameter) {
+ super(parent);
+ this.xmlStoredProcedureParameter = xmlStoredProcedureParameter;
+ this.name = xmlStoredProcedureParameter.getName();
+ this.specifiedMode = this.buildSpecifiedMode();
+ this.typeName = xmlStoredProcedureParameter.getClassName();
+ }
+
+
+ // ********** synchronize/update **********
+
+ @Override
+ public void synchronizeWithResourceModel() {
+ super.synchronizeWithResourceModel();
+ this.setName_(this.xmlStoredProcedureParameter.getName());
+ this.setSpecifiedMode_(this.buildSpecifiedMode());
+ this.setTypeName_(this.xmlStoredProcedureParameter.getClassName());
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ this.setDefaultMode(this.buildDefaultMode());
+ this.setFullyQualifiedTypeName(this.buildFullyQualifiedTypeName());
+ }
+
+ // ********** name **********
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.setName_(name);
+ this.xmlStoredProcedureParameter.setName(name);
+ }
+
+ protected void setName_(String name) {
+ String old = this.name;
+ this.name = name;
+ this.firePropertyChanged(NAME_PROPERTY, old, name);
+ }
+
+
+ // ********** mode **********
+
+ public ParameterMode2_1 getMode() {
+ return (this.specifiedMode != null) ? this.specifiedMode : this.defaultMode;
+ }
+
+ public ParameterMode2_1 getSpecifiedMode() {
+ return this.specifiedMode;
+ }
+
+ public void setSpecifiedMode(ParameterMode2_1 mode) {
+ this.xmlStoredProcedureParameter.setMode(ParameterMode2_1.toOrmResourceModel(mode));
+ this.setSpecifiedMode_(mode);
+ }
+
+ public void setSpecifiedMode_(ParameterMode2_1 mode) {
+ ParameterMode2_1 old = this.specifiedMode;
+ this.specifiedMode = mode;
+ this.firePropertyChanged(SPECIFIED_MODE_PROPERTY, old, mode);
+ }
+
+ protected ParameterMode2_1 buildSpecifiedMode() {
+ return ParameterMode2_1.fromOrmResourceModel(this.xmlStoredProcedureParameter.getMode());
+ }
+
+ public ParameterMode2_1 getDefaultMode() {
+ return this.defaultMode;
+ }
+
+ protected void setDefaultMode(ParameterMode2_1 mode) {
+ ParameterMode2_1 old = this.defaultMode;
+ this.defaultMode = mode;
+ this.firePropertyChanged(DEFAULT_MODE_PROPERTY, old, mode);
+ }
+
+ protected ParameterMode2_1 buildDefaultMode() {
+ return ParameterMode2_1.IN;
+ }
+
+
+ // ********** type **********
+
+ public String getTypeName() {
+ return this.typeName;
+ }
+
+ public void setTypeName(String typeName) {
+ this.xmlStoredProcedureParameter.setClassName(typeName);
+ this.setTypeName_(typeName);
+ }
+
+ protected void setTypeName_(String typeName) {
+ String old = this.typeName;
+ this.typeName = typeName;
+ this.firePropertyChanged(TYPE_NAME_PROPERTY, old, typeName);
+ }
+
+ public String getFullyQualifiedTypeName() {
+ return this.fullyQualifiedTypeName;
+ }
+
+ protected void setFullyQualifiedTypeName(String typeName) {
+ String old = this.fullyQualifiedTypeName;
+ this.fullyQualifiedTypeName = typeName;
+ this.firePropertyChanged(FULLY_QUALIFIED_TYPE_NAME_PROPERTY, old, typeName);
+ }
+
+ protected String buildFullyQualifiedTypeName() {
+ return this.getMappingFileRoot().qualify(this.typeName);
+ }
+
+ public char getTypeEnclosingTypeSeparator() {
+ return '$';
+ }
+
+ // ********** metadata conversion **********
+
+ public void convertFrom(JavaStoredProcedureParameter2_1 javaParameter) {
+ this.setName(javaParameter.getName());
+ this.setSpecifiedMode(javaParameter.getMode());
+ this.setTypeName(javaParameter.getTypeName());
+ }
+
+ // ********** validation **********
+
+ public TextRange getValidationTextRange() {
+ TextRange textRange = this.xmlStoredProcedureParameter.getValidationTextRange();
+ return (textRange != null) ? textRange : this.getQuery().getValidationTextRange();
+ }
+
+ public boolean isEquivalentTo(StoredProcedureParameter2_1 parameter) {
+ return ObjectTools.equals(this.name, parameter.getName()) &&
+ ObjectTools.equals(this.specifiedMode, parameter.getSpecifiedMode()) &&
+ ObjectTools.equals(this.typeName, parameter.getTypeName());
+ }
+
+ // ********** misc **********
+
+ @Override
+ public OrmQuery getParent() {
+ return (OrmQuery) super.getParent();
+ }
+
+ protected OrmQuery getQuery() {
+ return this.getParent();
+ }
+
+ public XmlStoredProcedureParameter getXmlStoredProcedureParameter() {
+ return this.xmlStoredProcedureParameter;
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.name);
+ sb.append(this.typeName);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/GenericOrmXml2_1ContextNodeFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/GenericOrmXml2_1ContextNodeFactory.java
index 08e285d..b1c682a 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/GenericOrmXml2_1ContextNodeFactory.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/GenericOrmXml2_1ContextNodeFactory.java
@@ -14,13 +14,27 @@ import org.eclipse.jpt.jpa.core.jpa2_1.context.orm.EntityMappings2_1;
import org.eclipse.jpt.jpa.core.jpa2_1.context.orm.OrmConverterType2_1;
import org.eclipse.jpt.jpa.core.jpa2_1.context.orm.OrmXml2_1ContextNodeFactory;
import org.eclipse.jpt.jpa.core.resource.orm.XmlConverter;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlNamedStoredProcedureQuery;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlStoredProcedureParameter;
public class GenericOrmXml2_1ContextNodeFactory
extends GenericOrmXml2_0ContextNodeFactory
implements OrmXml2_1ContextNodeFactory
{
- public OrmConverterType2_1 buildOrmConverter(EntityMappings2_1 parent, XmlConverter xmlConverter) {
+ public OrmConverterType2_1 buildOrmConverterType(EntityMappings2_1 parent, XmlConverter xmlConverter) {
return new GenericOrmConverterType(parent, xmlConverter);
}
+
+ public OrmNamedStoredProcedureQuery2_1 buildOrmNamedStoredProcedureQuery2_1(
+ OrmQueryContainer2_1 parent,
+ XmlNamedStoredProcedureQuery xmlNamedStoredProcedureQuery) {
+ return new GenericOrmNamedStoredProcedureQuery2_1(parent, xmlNamedStoredProcedureQuery);
+ }
+
+ public OrmStoredProcedureParameter2_1 buildOrmStoredProcedureParameter(
+ OrmNamedStoredProcedureQuery2_1 parent,
+ XmlStoredProcedureParameter xmlParameter) {
+ return new GenericOrmStoredProcedureParameter2_1(parent, xmlParameter);
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/OrmConverterTypeDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/OrmConverterTypeDefinition.java
index 71e0731..31f9900 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/OrmConverterTypeDefinition.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/OrmConverterTypeDefinition.java
@@ -48,6 +48,6 @@ public class OrmConverterTypeDefinition
}
public OrmManagedType buildContextManagedType(JpaContextNode parent, XmlManagedType resourceManagedType, OrmXmlContextNodeFactory factory) {
- return ((OrmXml2_1ContextNodeFactory) factory).buildOrmConverter((EntityMappings2_1) parent, (XmlConverter) resourceManagedType);
+ return ((OrmXml2_1ContextNodeFactory) factory).buildOrmConverterType((EntityMappings2_1) parent, (XmlConverter) resourceManagedType);
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/OrmNamedStoredProcedureQuery2_1.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/OrmNamedStoredProcedureQuery2_1.java
new file mode 100644
index 0000000..6324233
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/OrmNamedStoredProcedureQuery2_1.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm;
+
+import org.eclipse.jpt.common.utility.iterable.ListIterable;
+import org.eclipse.jpt.jpa.core.context.orm.OrmQuery;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.NamedStoredProcedureQuery2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java.JavaNamedStoredProcedureQuery2_1;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlNamedStoredProcedureQuery;
+
+public interface OrmNamedStoredProcedureQuery2_1
+ extends OrmQuery, NamedStoredProcedureQuery2_1
+{
+ XmlNamedStoredProcedureQuery getXmlQuery();
+
+ // *********** parameters ************
+
+ ListIterable<OrmStoredProcedureParameter2_1> getParameters();
+
+ OrmStoredProcedureParameter2_1 addParameter();
+
+ OrmStoredProcedureParameter2_1 addParameter(int index);
+
+ // ********** metadata conversion *********
+
+ /**
+ * Build up a mapping file query from
+ * the given Java query
+ */
+ void convertFrom(JavaNamedStoredProcedureQuery2_1 javaQuery);
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/OrmQueryContainer2_1.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/OrmQueryContainer2_1.java
new file mode 100644
index 0000000..166ef47
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/OrmQueryContainer2_1.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm;
+
+import org.eclipse.jpt.common.utility.iterable.ListIterable;
+import org.eclipse.jpt.jpa.core.context.orm.OrmQueryContainer;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.QueryContainer2_1;
+
+public interface OrmQueryContainer2_1
+ extends QueryContainer2_1, OrmQueryContainer
+{
+ // ********** named stored procedure queries **********
+
+ ListIterable<OrmNamedStoredProcedureQuery2_1> getNamedStoredProcedureQueries();
+
+ OrmNamedStoredProcedureQuery2_1 addNamedStoredProcedureQuery();
+
+ OrmNamedStoredProcedureQuery2_1 addNamedStoredProcedureQuery(int index);
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/OrmStoredProcedureParameter2_1.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/OrmStoredProcedureParameter2_1.java
new file mode 100644
index 0000000..febe7a7
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/OrmStoredProcedureParameter2_1.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm;
+
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.StoredProcedureParameter2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java.JavaStoredProcedureParameter2_1;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlStoredProcedureParameter;
+
+public interface OrmStoredProcedureParameter2_1
+ extends StoredProcedureParameter2_1
+{
+ XmlStoredProcedureParameter getXmlStoredProcedureParameter();
+
+ // ****** metadata conversion ****
+ /**
+ * Build up a mapping file stored procedure parameter
+ * from the given Java stored procedure parameter
+ */
+ void convertFrom(JavaStoredProcedureParameter2_1 javaStoredProcedureParameter);
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/resource/java/binary/BinaryStoredProcedureParameter2_1Annotation.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/resource/java/binary/BinaryStoredProcedureParameter2_1Annotation.java
index 244ff1c..05e61c6 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/resource/java/binary/BinaryStoredProcedureParameter2_1Annotation.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/resource/java/binary/BinaryStoredProcedureParameter2_1Annotation.java
@@ -14,7 +14,7 @@ import org.eclipse.jpt.common.core.internal.resource.java.binary.BinaryAnnotatio
import org.eclipse.jpt.common.core.resource.java.JavaResourceNode;
import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.JPA2_1;
-import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.ParameterMode2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.ParameterMode_2_1;
import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.StoredProcedureParameter2_1Annotation;
/**
@@ -25,7 +25,7 @@ public final class BinaryStoredProcedureParameter2_1Annotation
implements StoredProcedureParameter2_1Annotation
{
private String name;
- private ParameterMode2_1 mode;
+ private ParameterMode_2_1 mode;
private String type;
@@ -89,22 +89,22 @@ public final class BinaryStoredProcedureParameter2_1Annotation
}
// ***** mode
- public ParameterMode2_1 getMode() {
+ public ParameterMode_2_1 getMode() {
return this.mode;
}
- public void setMode(ParameterMode2_1 mode) {
+ public void setMode(ParameterMode_2_1 mode) {
throw new UnsupportedOperationException();
}
- private void setMode_(ParameterMode2_1 mode) {
- ParameterMode2_1 old = this.mode;
+ private void setMode_(ParameterMode_2_1 mode) {
+ ParameterMode_2_1 old = this.mode;
this.mode = mode;
this.firePropertyChanged(MODE_PROPERTY, old, mode);
}
- private ParameterMode2_1 buildMode() {
- return ParameterMode2_1.fromJavaAnnotationValue(this.getJdtMemberValue(this.getModeElementName()));
+ private ParameterMode_2_1 buildMode() {
+ return ParameterMode_2_1.fromJavaAnnotationValue(this.getJdtMemberValue(this.getModeElementName()));
}
public TextRange getModeTextRange() {
@@ -112,11 +112,11 @@ public final class BinaryStoredProcedureParameter2_1Annotation
}
// ***** type
- public String getType() {
+ public String getTypeName() {
return this.type;
}
- public void setType(String type) {
+ public void setTypeName(String type) {
throw new UnsupportedOperationException();
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/resource/java/source/SourceStoredProcedureParameter2_1Annotation.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/resource/java/source/SourceStoredProcedureParameter2_1Annotation.java
index c610e32..46b550c 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/resource/java/source/SourceStoredProcedureParameter2_1Annotation.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/resource/java/source/SourceStoredProcedureParameter2_1Annotation.java
@@ -26,7 +26,7 @@ import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationElementAdapt
import org.eclipse.jpt.common.core.utility.jdt.ExpressionConverter;
import org.eclipse.jpt.common.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.JPA2_1;
-import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.ParameterMode2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.ParameterMode_2_1;
import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.StoredProcedureParameter2_1Annotation;
/**
@@ -43,7 +43,7 @@ public final class SourceStoredProcedureParameter2_1Annotation
private DeclarationAnnotationElementAdapter<String> modeDeclarationAdapter;
private AnnotationElementAdapter<String> modeAdapter;
- private ParameterMode2_1 mode;
+ private ParameterMode_2_1 mode;
private TextRange modeTextRange;
private DeclarationAnnotationElementAdapter<String> typeDeclarationAdapter;
@@ -166,25 +166,25 @@ public final class SourceStoredProcedureParameter2_1Annotation
}
// ***** mode
- public ParameterMode2_1 getMode() {
+ public ParameterMode_2_1 getMode() {
return this.mode;
}
- public void setMode(ParameterMode2_1 mode) {
+ public void setMode(ParameterMode_2_1 mode) {
if (this.attributeValueHasChanged(this.mode, mode)) {
this.mode = mode;
- this.modeAdapter.setValue(ParameterMode2_1.toJavaAnnotationValue(mode));
+ this.modeAdapter.setValue(ParameterMode_2_1.toJavaAnnotationValue(mode));
}
}
- private void syncMode(ParameterMode2_1 astValue) {
- ParameterMode2_1 old = this.mode;
+ private void syncMode(ParameterMode_2_1 astValue) {
+ ParameterMode_2_1 old = this.mode;
this.mode = astValue;
this.firePropertyChanged(MODE_PROPERTY, old, astValue);
}
- private ParameterMode2_1 buildMode(Annotation astAnnotation) {
- return ParameterMode2_1.fromJavaAnnotationValue(this.modeAdapter.getValue(astAnnotation));
+ private ParameterMode_2_1 buildMode(Annotation astAnnotation) {
+ return ParameterMode_2_1.fromJavaAnnotationValue(this.modeAdapter.getValue(astAnnotation));
}
public TextRange getModeTextRange() {
@@ -204,11 +204,11 @@ public final class SourceStoredProcedureParameter2_1Annotation
}
// ***** type
- public String getType() {
+ public String getTypeName() {
return this.type;
}
- public void setType(String type) {
+ public void setTypeName(String type) {
if (this.attributeValueHasChanged(this.type, type)) {
this.type = type;
this.fqTypeNameStale = true;
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/JpaFactory2_1.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/JpaFactory2_1.java
index 71001de..4cc5087 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/JpaFactory2_1.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/JpaFactory2_1.java
@@ -11,8 +11,13 @@ package org.eclipse.jpt.jpa.core.jpa2_1;
import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.jpa.core.context.JpaContextNode;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java.JavaNamedStoredProcedureQuery2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java.JavaQueryContainer2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java.JavaStoredProcedureParameter2_1;
import org.eclipse.jpt.jpa.core.jpa2.JpaFactory2_0;
import org.eclipse.jpt.jpa.core.jpa2_1.context.java.JavaConverterType2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.NamedStoredProcedureQuery2_1Annotation;
+import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.StoredProcedureParameter2_1Annotation;
/**
* JPA 2.1 factory
@@ -29,6 +34,15 @@ import org.eclipse.jpt.jpa.core.jpa2_1.context.java.JavaConverterType2_1;
public interface JpaFactory2_1
extends JpaFactory2_0
{
+ // ********** Java Context Model **********
JavaConverterType2_1 buildJavaConverterType(JpaContextNode parent, JavaResourceType jrt);
+
+ JavaNamedStoredProcedureQuery2_1 buildJavaNamedStoredProcedureQuery2_1(
+ JavaQueryContainer2_1 parent,
+ NamedStoredProcedureQuery2_1Annotation namedStoredProcedureQueryAnnotation);
+
+ JavaStoredProcedureParameter2_1 buildJavaStoredProcedureParameter2_1(
+ JavaNamedStoredProcedureQuery2_1 parent,
+ StoredProcedureParameter2_1Annotation parameterAnnotation);
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/ParameterMode2_1.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/ParameterMode2_1.java
new file mode 100644
index 0000000..afd74e1
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/ParameterMode2_1.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+* Copyright (c) 2013 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.jpa2_1;
+
+
+/**
+ * parameter mode
+ *
+ * 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 enum ParameterMode2_1
+{
+ IN(
+ org.eclipse.jpt.jpa.core.jpa2_1.resource.java.ParameterMode_2_1.IN,
+ org.eclipse.jpt.jpa.core.resource.orm.v2_1.ParameterMode_2_1.IN
+ ),
+ INOUT(
+ org.eclipse.jpt.jpa.core.jpa2_1.resource.java.ParameterMode_2_1.INOUT,
+ org.eclipse.jpt.jpa.core.resource.orm.v2_1.ParameterMode_2_1.INOUT
+ ),
+ OUT(
+ org.eclipse.jpt.jpa.core.jpa2_1.resource.java.ParameterMode_2_1.OUT,
+ org.eclipse.jpt.jpa.core.resource.orm.v2_1.ParameterMode_2_1.OUT
+ ),
+ REF_CURSOR(
+ org.eclipse.jpt.jpa.core.jpa2_1.resource.java.ParameterMode_2_1.REF_CURSOR,
+ org.eclipse.jpt.jpa.core.resource.orm.v2_1.ParameterMode_2_1.REF_CURSOR
+ );
+
+
+ private org.eclipse.jpt.jpa.core.jpa2_1.resource.java.ParameterMode_2_1 javaParameterMode;
+ private org.eclipse.jpt.jpa.core.resource.orm.v2_1.ParameterMode_2_1 ormParameterMode;
+
+ ParameterMode2_1(
+ org.eclipse.jpt.jpa.core.jpa2_1.resource.java.ParameterMode_2_1 javaParameterMode,
+ org.eclipse.jpt.jpa.core.resource.orm.v2_1.ParameterMode_2_1 ormParameterMode) {
+ if (javaParameterMode == null) {
+ throw new NullPointerException();
+ }
+ if (ormParameterMode == null) {
+ throw new NullPointerException();
+ }
+ this.javaParameterMode = javaParameterMode;
+ this.ormParameterMode = ormParameterMode;
+ }
+
+ public org.eclipse.jpt.jpa.core.jpa2_1.resource.java.ParameterMode_2_1 getJavaParameterMode() {
+ return this.javaParameterMode;
+ }
+
+ public org.eclipse.jpt.jpa.core.resource.orm.v2_1.ParameterMode_2_1 getOrmParameterMode() {
+ return this.ormParameterMode;
+ }
+
+
+ // ********** static methods **********
+
+ public static ParameterMode2_1 fromJavaResourceModel(org.eclipse.jpt.jpa.core.jpa2_1.resource.java.ParameterMode_2_1 javaParameterMode) {
+ return (javaParameterMode == null) ? null : fromJavaResourceModel_(javaParameterMode);
+ }
+
+ private static ParameterMode2_1 fromJavaResourceModel_(org.eclipse.jpt.jpa.core.jpa2_1.resource.java.ParameterMode_2_1 javaParameterMode) {
+ for (ParameterMode2_1 parameterMode : ParameterMode2_1.values()) {
+ if (parameterMode.getJavaParameterMode() == javaParameterMode) {
+ return parameterMode;
+ }
+ }
+ return null;
+ }
+
+ public static org.eclipse.jpt.jpa.core.jpa2_1.resource.java.ParameterMode_2_1 toJavaResourceModel(ParameterMode2_1 parameterMode) {
+ return (parameterMode == null) ? null : parameterMode.getJavaParameterMode();
+ }
+
+
+ public static ParameterMode2_1 fromOrmResourceModel(org.eclipse.jpt.jpa.core.resource.orm.v2_1.ParameterMode_2_1 ormParameterMode) {
+ return (ormParameterMode == null) ? null : fromOrmResourceModel_(ormParameterMode);
+ }
+
+ private static ParameterMode2_1 fromOrmResourceModel_(org.eclipse.jpt.jpa.core.resource.orm.v2_1.ParameterMode_2_1 ormParameterMode) {
+ for (ParameterMode2_1 parameterMode : ParameterMode2_1.values()) {
+ if (parameterMode.getOrmParameterMode() == ormParameterMode) {
+ return parameterMode;
+ }
+ }
+ return null;
+ }
+
+ public static org.eclipse.jpt.jpa.core.resource.orm.v2_1.ParameterMode_2_1 toOrmResourceModel(ParameterMode2_1 parameterMode) {
+ return (parameterMode == null) ? null : parameterMode.getOrmParameterMode();
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/context/QueryContainer2_1.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/context/QueryContainer2_1.java
new file mode 100644
index 0000000..907cf49
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/context/QueryContainer2_1.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.jpa2_1.context;
+
+import org.eclipse.jpt.common.utility.iterable.ListIterable;
+import org.eclipse.jpt.jpa.core.context.QueryContainer;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.NamedStoredProcedureQuery2_1;
+
+/**
+ * Container for named stored procedure queries.
+ * Used by entities and the <code>orm.xml</code>
+ * </code>entity-mappings</code> element.
+ * <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 QueryContainer2_1
+ extends QueryContainer
+{
+
+ // ********** named stored procedure queries **********
+
+ /**
+ * Return the container's named stored procedure queries.
+ */
+ ListIterable<? extends NamedStoredProcedureQuery2_1> getNamedStoredProcedureQueries();
+
+ String NAMED_STORED_PROCEDURE_QUERIES_LIST = "namedStoredProcedureQueries"; //$NON-NLS-1$
+
+ /**
+ * Return the number of named stored procedure queries.
+ */
+ int getNamedStoredProcedureQueriesSize();
+
+ /**
+ * Add a new named stored procedure query to the container and return it.
+ */
+ NamedStoredProcedureQuery2_1 addNamedStoredProcedureQuery();
+
+ /**
+ * Add a new named stored procedure query to the container at the specified index
+ * and return it.
+ */
+ NamedStoredProcedureQuery2_1 addNamedStoredProcedureQuery(int index);
+
+ /**
+ * Remove from the container the named stored procedure query at the specified index.
+ */
+ void removeNamedStoredProcedureQuery(int index);
+
+ /**
+ * Remove the specified named stored procedure query from the container.
+ */
+ void removeNamedStoredProcedureQuery(NamedStoredProcedureQuery2_1 namedStoredProcedureQuery);
+
+ /**
+ * Move a named stored procedure query as specified.
+ */
+ void moveNamedStoredProcedureQuery(int targetIndex, int sourceIndex);
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/context/orm/OrmXml2_1ContextNodeFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/context/orm/OrmXml2_1ContextNodeFactory.java
index 45d8a98..4bdffdf 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/context/orm/OrmXml2_1ContextNodeFactory.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/context/orm/OrmXml2_1ContextNodeFactory.java
@@ -11,6 +11,11 @@ package org.eclipse.jpt.jpa.core.jpa2_1.context.orm;
import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
import org.eclipse.jpt.jpa.core.resource.orm.XmlConverter;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm.OrmNamedStoredProcedureQuery2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm.OrmQueryContainer2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm.OrmStoredProcedureParameter2_1;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlNamedStoredProcedureQuery;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlStoredProcedureParameter;
/**
* JPA 2.1 <code>orm.xml</code> context node factory
@@ -27,5 +32,13 @@ import org.eclipse.jpt.jpa.core.resource.orm.XmlConverter;
public interface OrmXml2_1ContextNodeFactory
extends OrmXmlContextNodeFactory
{
- OrmConverterType2_1 buildOrmConverter(EntityMappings2_1 parent, XmlConverter xmlConverter);
+ OrmConverterType2_1 buildOrmConverterType(EntityMappings2_1 parent, XmlConverter xmlConverter);
+
+ OrmNamedStoredProcedureQuery2_1 buildOrmNamedStoredProcedureQuery2_1(
+ OrmQueryContainer2_1 parent,
+ XmlNamedStoredProcedureQuery xmlNamedQuery);
+
+ OrmStoredProcedureParameter2_1 buildOrmStoredProcedureParameter(
+ OrmNamedStoredProcedureQuery2_1 parent,
+ XmlStoredProcedureParameter xmlParameter);
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/resource/java/NamedStoredProcedureQuery2_1Annotation.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/resource/java/NamedStoredProcedureQuery2_1Annotation.java
index 23d5317..227303c 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/resource/java/NamedStoredProcedureQuery2_1Annotation.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/resource/java/NamedStoredProcedureQuery2_1Annotation.java
@@ -116,6 +116,11 @@ public interface NamedStoredProcedureQuery2_1Annotation
/**
* Corresponds to the 'resultClasses' element of the NamedStoredProcedureQuery annotation.
*/
+ void addResultClass(int index, String resultClass);
+
+ /**
+ * Corresponds to the 'resultClasses' element of the NamedStoredProcedureQuery annotation.
+ */
void moveResultClass(int targetIndex, int sourceIndex);
/**
@@ -156,6 +161,11 @@ public interface NamedStoredProcedureQuery2_1Annotation
/**
* Corresponds to the 'resultSetMappings' element of the NamedStoredProcedureQuery annotation.
*/
+ void addResultSetMapping(int index, String resultSetMapping);
+
+ /**
+ * Corresponds to the 'resultSetMappings' element of the NamedStoredProcedureQuery annotation.
+ */
void moveResultSetMapping(int targetIndex, int sourceIndex);
/**
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/resource/java/ParameterMode2_1.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/resource/java/ParameterMode_2_1.java
index 8e4dc8c..5f27dd8 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/resource/java/ParameterMode2_1.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/resource/java/ParameterMode_2_1.java
@@ -23,7 +23,7 @@ package org.eclipse.jpt.jpa.core.jpa2_1.resource.java;
* @version 3.3
* @since 3.3
*/
-public enum ParameterMode2_1
+public enum ParameterMode_2_1
{
IN(JPA2_1.PARAMETER_MODE__IN),
@@ -34,7 +34,7 @@ public enum ParameterMode2_1
private String javaAnnotationValue;
- ParameterMode2_1(String javaAnnotationValue) {
+ ParameterMode_2_1(String javaAnnotationValue) {
if (javaAnnotationValue == null) {
throw new NullPointerException();
}
@@ -48,12 +48,12 @@ public enum ParameterMode2_1
// ********** static methods **********
- public static ParameterMode2_1 fromJavaAnnotationValue(Object javaAnnotationValue) {
+ public static ParameterMode_2_1 fromJavaAnnotationValue(Object javaAnnotationValue) {
return (javaAnnotationValue == null) ? null : fromJavaAnnotationValue_(javaAnnotationValue);
}
- private static ParameterMode2_1 fromJavaAnnotationValue_(Object javaAnnotationValue) {
- for (ParameterMode2_1 parameterMode : ParameterMode2_1.values()) {
+ private static ParameterMode_2_1 fromJavaAnnotationValue_(Object javaAnnotationValue) {
+ for (ParameterMode_2_1 parameterMode : ParameterMode_2_1.values()) {
if (parameterMode.getJavaAnnotationValue().equals(javaAnnotationValue)) {
return parameterMode;
}
@@ -61,7 +61,7 @@ public enum ParameterMode2_1
return null;
}
- public static String toJavaAnnotationValue(ParameterMode2_1 parameterMode) {
+ public static String toJavaAnnotationValue(ParameterMode_2_1 parameterMode) {
return (parameterMode == null) ? null : parameterMode.getJavaAnnotationValue();
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/resource/java/StoredProcedureParameter2_1Annotation.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/resource/java/StoredProcedureParameter2_1Annotation.java
index 1f0a943..9e0ba2a 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/resource/java/StoredProcedureParameter2_1Annotation.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/resource/java/StoredProcedureParameter2_1Annotation.java
@@ -56,14 +56,14 @@ public interface StoredProcedureParameter2_1Annotation
* Corresponds to the 'mode' element of the StoredProcedureParameter annotation.
* Return null if the element does not exist in the annotation
*/
- ParameterMode2_1 getMode();
+ ParameterMode_2_1 getMode();
String MODE_PROPERTY = "mode"; //$NON-NLS-1$
/**
* Corresponds to the 'mode' element of the StoredProcedureParameter annotation.
* Setting to null will remove the element.
*/
- void setMode(ParameterMode2_1 mode);
+ void setMode(ParameterMode_2_1 mode);
/**
* Return the {@link TextRange} for the 'mode' element. If the element
@@ -77,14 +77,14 @@ public interface StoredProcedureParameter2_1Annotation
* Corresponds to the 'type' element of the StoredProcedureParameter annotation.
* Return null if the element does not exist in the annotation
*/
- String getType();
+ String getTypeName();
String TYPE_PROPERTY = "type"; //$NON-NLS-1$
/**
* Corresponds to the 'type' element of the StoredProcedureParameter annotation.
* Setting to null will remove the element.
*/
- void setType(String type);
+ void setTypeName(String type);
/**
* Return the {@link TextRange} for the 'type' element. If the element
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLink2_5JpaFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLink2_5JpaFactory.java
index 42fe680..856c122 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLink2_5JpaFactory.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLink2_5JpaFactory.java
@@ -12,8 +12,15 @@ package org.eclipse.jpt.jpa.eclipselink.core.internal;
import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.jpa.core.context.JpaContextNode;
import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java.GenericJavaConverterType;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java.GenericJavaNamedStoredProcedureQuery2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java.GenericJavaStoredProcedureParameter2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java.JavaNamedStoredProcedureQuery2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java.JavaQueryContainer2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java.JavaStoredProcedureParameter2_1;
import org.eclipse.jpt.jpa.core.jpa2_1.JpaFactory2_1;
import org.eclipse.jpt.jpa.core.jpa2_1.context.java.JavaConverterType2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.NamedStoredProcedureQuery2_1Annotation;
+import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.StoredProcedureParameter2_1Annotation;
/**
* EclipseLink 2.5 factory
@@ -29,4 +36,16 @@ public class EclipseLink2_5JpaFactory
public JavaConverterType2_1 buildJavaConverterType(JpaContextNode parent, JavaResourceType jrt) {
return new GenericJavaConverterType(parent, jrt);
}
+
+ public JavaNamedStoredProcedureQuery2_1 buildJavaNamedStoredProcedureQuery2_1(
+ JavaQueryContainer2_1 parent,
+ NamedStoredProcedureQuery2_1Annotation namedStoredProcedureQueryAnnotation) {
+ return new GenericJavaNamedStoredProcedureQuery2_1(parent, namedStoredProcedureQueryAnnotation);
+ }
+
+ public JavaStoredProcedureParameter2_1 buildJavaStoredProcedureParameter2_1(
+ JavaNamedStoredProcedureQuery2_1 parent,
+ StoredProcedureParameter2_1Annotation parameterAnnotation) {
+ return new GenericJavaStoredProcedureParameter2_1(parent, parameterAnnotation);
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmXml2_5ContextNodeFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmXml2_5ContextNodeFactory.java
index d5d0669..6c0dc6a 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmXml2_5ContextNodeFactory.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmXml2_5ContextNodeFactory.java
@@ -10,16 +10,35 @@
package org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm;
import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm.GenericOrmConverterType;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm.GenericOrmNamedStoredProcedureQuery2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm.GenericOrmStoredProcedureParameter2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm.OrmNamedStoredProcedureQuery2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm.OrmQueryContainer2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm.OrmStoredProcedureParameter2_1;
import org.eclipse.jpt.jpa.core.jpa2_1.context.orm.EntityMappings2_1;
import org.eclipse.jpt.jpa.core.jpa2_1.context.orm.OrmConverterType2_1;
import org.eclipse.jpt.jpa.core.jpa2_1.context.orm.OrmXml2_1ContextNodeFactory;
import org.eclipse.jpt.jpa.core.resource.orm.XmlConverter;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlNamedStoredProcedureQuery;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlStoredProcedureParameter;
public class EclipseLinkOrmXml2_5ContextNodeFactory
extends EclipseLinkOrmXml2_4ContextNodeFactory
implements OrmXml2_1ContextNodeFactory
{
- public OrmConverterType2_1 buildOrmConverter(EntityMappings2_1 parent, XmlConverter xmlConverter) {
+ public OrmConverterType2_1 buildOrmConverterType(EntityMappings2_1 parent, XmlConverter xmlConverter) {
return new GenericOrmConverterType(parent, xmlConverter);
}
+
+ public OrmNamedStoredProcedureQuery2_1 buildOrmNamedStoredProcedureQuery2_1(
+ OrmQueryContainer2_1 parent,
+ XmlNamedStoredProcedureQuery xmlNamedStoredProcedureQuery) {
+ return new GenericOrmNamedStoredProcedureQuery2_1(parent, xmlNamedStoredProcedureQuery);
+ }
+
+ public OrmStoredProcedureParameter2_1 buildOrmStoredProcedureParameter(
+ OrmNamedStoredProcedureQuery2_1 parent,
+ XmlStoredProcedureParameter xmlParameter) {
+ return new GenericOrmStoredProcedureParameter2_1(parent, xmlParameter);
+ }
}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/META-INF/MANIFEST.MF b/jpa/tests/org.eclipse.jpt.jpa.core.tests/META-INF/MANIFEST.MF
index da067da..a90ca28 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/META-INF/MANIFEST.MF
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/META-INF/MANIFEST.MF
@@ -40,6 +40,8 @@ Export-Package: org.eclipse.jpt.jpa.core.tests.internal;x-internal:=true,
org.eclipse.jpt.jpa.core.tests.internal.jpa2.context.persistence;x-internal:=true,
org.eclipse.jpt.jpa.core.tests.internal.jpa2.resource.java;x-internal:=true,
org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context;x-internal:=true,
+ org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context.java;x-internal:=true,
+ org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context.orm;x-internal:=true,
org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context.persistence;x-internal:=true,
org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.resource.java;x-internal:=true,
org.eclipse.jpt.jpa.core.tests.internal.model;x-internal:=true,
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/JptJpaCoreContextModelTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/JptJpaCoreContextModelTests.java
index 8a22329..1cfce1b 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/JptJpaCoreContextModelTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/JptJpaCoreContextModelTests.java
@@ -20,6 +20,8 @@ import org.eclipse.jpt.jpa.core.tests.internal.jpa2.context.java.Generic2_0JavaC
import org.eclipse.jpt.jpa.core.tests.internal.jpa2.context.orm.Generic2_0OrmContextModelTests;
import org.eclipse.jpt.jpa.core.tests.internal.jpa2.context.persistence.Generic2_0PersistenceContextModelTests;
import org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context.JpaProject2_1Tests;
+import org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context.java.Generic2_1JavaContextModelTests;
+import org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context.orm.Generic2_1OrmContextModelTests;
import org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context.persistence.JptJpa2_1ContextPersistenceModelTests;
/**
@@ -43,6 +45,8 @@ public class JptJpaCoreContextModelTests
suite.addTest(Generic2_0OrmContextModelTests.suite());
suite.addTest(Generic2_0PersistenceContextModelTests.suite());
suite.addTest(JptJpa2_1ContextPersistenceModelTests.suite());
+ suite.addTest(Generic2_1JavaContextModelTests.suite());
+ suite.addTest(Generic2_1OrmContextModelTests.suite());
} else {
suite.addTest(TestSuite.warning(JptJpaCoreTests.buildMissingJarErrorMessage()));
}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/Generic2_1ContextModelTestCase.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/Generic2_1ContextModelTestCase.java
index cdf2c1d..064436c 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/Generic2_1ContextModelTestCase.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/Generic2_1ContextModelTestCase.java
@@ -13,7 +13,8 @@ import org.eclipse.jpt.jpa.core.internal.jpa2_1.Generic2_1JpaPlatformFactory;
import org.eclipse.jpt.jpa.core.jpa2_1.JpaProject2_1;
import org.eclipse.jpt.jpa.core.tests.internal.context.ContextModelTestCase;
-public abstract class Generic2_1ContextModelTestCase extends ContextModelTestCase
+public abstract class Generic2_1ContextModelTestCase
+ extends ContextModelTestCase
{
protected Generic2_1ContextModelTestCase(String name) {
super(name);
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/java/Generic2_1JavaContextModelTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/java/Generic2_1JavaContextModelTests.java
new file mode 100644
index 0000000..fdd84ac
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/java/Generic2_1JavaContextModelTests.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context.java;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class Generic2_1JavaContextModelTests
+ extends TestCase
+{
+ public static Test suite() {
+ TestSuite suite = new TestSuite(Generic2_1JavaContextModelTests.class.getPackage().getName());
+ suite.addTestSuite(GenericJavaNamedStoredProcedureQuery2_1Tests.class);
+ suite.addTestSuite(GenericJavaStoredProcedureParameter2_1Tests.class);
+ return suite;
+ }
+
+ private Generic2_1JavaContextModelTests() {
+ super();
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/java/GenericJavaNamedStoredProcedureQuery2_1Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/java/GenericJavaNamedStoredProcedureQuery2_1Tests.java
new file mode 100644
index 0000000..131db4c
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/java/GenericJavaNamedStoredProcedureQuery2_1Tests.java
@@ -0,0 +1,869 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context.java;
+
+import java.util.Iterator;
+import java.util.ListIterator;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement.AstNodeType;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.common.utility.internal.iterator.IteratorTools;
+import org.eclipse.jpt.jpa.core.context.Entity;
+import org.eclipse.jpt.jpa.core.context.QueryHint;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.NamedStoredProcedureQuery2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.StoredProcedureParameter2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.QueryContainer2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.JPA2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.NamedStoredProcedureQuery2_1Annotation;
+import org.eclipse.jpt.jpa.core.resource.java.JPA;
+import org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context.Generic2_1ContextModelTestCase;
+
+@SuppressWarnings("nls")
+public class GenericJavaNamedStoredProcedureQuery2_1Tests
+ extends Generic2_1ContextModelTestCase
+{
+ public GenericJavaNamedStoredProcedureQuery2_1Tests(String name) {
+ super(name);
+ }
+
+
+ private static final String QUERY_NAME = "QUERY_NAME";
+ private static final String PROCEDURE_NAME = "MY_PROCEDURE";
+
+ private ICompilationUnit createTestEntityWithNamedStoredProcedureQuery() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return IteratorTools.iterator(JPA.ENTITY, JPA2_1.NAMED_STORED_PROCEDURE_QUERY);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ sb.append("@NamedStoredProcedureQuery(name=\"" + QUERY_NAME + "\", procedureName=\"" + PROCEDURE_NAME + "\")");
+ }
+ });
+ }
+
+
+ // ********** name ***********
+
+ public void testUpdateName() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ Entity entity = getJavaEntity();
+ NamedStoredProcedureQuery2_1 procedureQuery = ((QueryContainer2_1) entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next();
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation procedureQueryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+
+ assertEquals(QUERY_NAME, procedureQueryAnnotation.getName());
+ assertEquals(QUERY_NAME, procedureQuery.getName());
+
+ //set name to null in the resource model
+ procedureQueryAnnotation.setName(null);
+ getJpaProject().synchronizeContextModel();
+ assertNull(procedureQueryAnnotation.getName());
+ assertNull(procedureQuery.getName());
+
+ //set name in the resource model, verify context model updated
+ procedureQueryAnnotation.setName("foo");
+ getJpaProject().synchronizeContextModel();
+ assertEquals("foo", procedureQueryAnnotation.getName());
+ assertEquals("foo", procedureQuery.getName());
+ }
+
+ public void testModifyName() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ Entity entity = getJavaEntity();
+ NamedStoredProcedureQuery2_1 procedureQuery = ((QueryContainer2_1) entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next();
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation procedureQueryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+
+ assertEquals(QUERY_NAME, procedureQueryAnnotation.getName());
+ assertEquals(QUERY_NAME, procedureQuery.getName());
+
+ //set name to null in the context model
+ procedureQuery.setName(null);
+ assertNull(procedureQueryAnnotation.getName());
+ assertNull(procedureQuery.getName());
+
+ //set name in the context model, verify resource model updated
+ procedureQuery.setName("foo");
+ assertEquals("foo", procedureQueryAnnotation.getName());
+ assertEquals("foo", procedureQuery.getName());
+ }
+
+ // ********** procedure name ***********
+
+ public void testUpdateProcedureName() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ Entity entity = getJavaEntity();
+ NamedStoredProcedureQuery2_1 procedureQuery = ((QueryContainer2_1) entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next();
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation procedureQueryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+
+ assertEquals(PROCEDURE_NAME, procedureQueryAnnotation.getProcedureName());
+ assertEquals(PROCEDURE_NAME, procedureQuery.getProcedureName());
+
+ //set procedure name to null in the resource model
+ procedureQueryAnnotation.setProcedureName(null);
+ getJpaProject().synchronizeContextModel();
+ assertNull(procedureQueryAnnotation.getProcedureName());
+ assertNull(procedureQuery.getProcedureName());
+
+ //set procedure name in the resource model, verify context model updated
+ procedureQueryAnnotation.setProcedureName("foo");
+ getJpaProject().synchronizeContextModel();
+ assertEquals("foo", procedureQueryAnnotation.getProcedureName());
+ assertEquals("foo", procedureQuery.getProcedureName());
+ }
+
+ public void testModifyProcedureName() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ Entity entity = getJavaEntity();
+ NamedStoredProcedureQuery2_1 procedureQuery = ((QueryContainer2_1) entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next();
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation procedureQueryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+
+ assertEquals(PROCEDURE_NAME, procedureQueryAnnotation.getProcedureName());
+ assertEquals(PROCEDURE_NAME, procedureQuery.getProcedureName());
+
+ //set procedure name to null in the context model
+ procedureQuery.setProcedureName(null);
+ assertNull(procedureQueryAnnotation.getProcedureName());
+ assertNull(procedureQuery.getProcedureName());
+
+ //set procedure name in the context model, verify resource model updated
+ procedureQuery.setProcedureName("foo");
+ assertEquals("foo", procedureQueryAnnotation.getProcedureName());
+ assertEquals("foo", procedureQuery.getProcedureName());
+ }
+
+
+ // ******** parameters **********
+
+ public void testAddParameter() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ Entity entity = getJavaEntity();
+ NamedStoredProcedureQuery2_1 procedureQuery = ((QueryContainer2_1) entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next();
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation procedureQueryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+
+ StoredProcedureParameter2_1 parameter1 = procedureQuery.addParameter(0);
+ parameter1.setName("FOO");
+
+ assertEquals("FOO", procedureQueryAnnotation.parameterAt(0).getName());
+
+ StoredProcedureParameter2_1 parameter2 = procedureQuery.addParameter(0);
+ parameter2.setName("BAR");
+
+ assertEquals("BAR", procedureQueryAnnotation.parameterAt(0).getName());
+ assertEquals("FOO", procedureQueryAnnotation.parameterAt(1).getName());
+
+ StoredProcedureParameter2_1 parameter3 = procedureQuery.addParameter(1);
+ parameter3.setName("BAZ");
+
+ assertEquals("BAR", procedureQueryAnnotation.parameterAt(0).getName());
+ assertEquals("BAZ", procedureQueryAnnotation.parameterAt(1).getName());
+ assertEquals("FOO", procedureQueryAnnotation.parameterAt(2).getName());
+
+ ListIterator<? extends StoredProcedureParameter2_1> parameters = procedureQuery.getParameters().iterator();
+ assertEquals(parameter2, parameters.next());
+ assertEquals(parameter3, parameters.next());
+ assertEquals(parameter1, parameters.next());
+
+ parameters = procedureQuery.getParameters().iterator();
+ assertEquals("BAR", parameters.next().getName());
+ assertEquals("BAZ", parameters.next().getName());
+ assertEquals("FOO", parameters.next().getName());
+ }
+
+ public void testRemoveParameter() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ Entity entity = getJavaEntity();
+ NamedStoredProcedureQuery2_1 procedureQuery = ((QueryContainer2_1) entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next();
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation procedureQueryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+
+ procedureQuery.addParameter(0).setName("FOO");
+ procedureQuery.addParameter(1).setName("BAR");
+ procedureQuery.addParameter(2).setName("BAZ");
+
+ assertEquals(3, procedureQueryAnnotation.getParametersSize());
+
+ procedureQuery.removeParameter(0);
+ assertEquals(2, procedureQueryAnnotation.getParametersSize());
+ assertEquals("BAR", procedureQueryAnnotation.parameterAt(0).getName());
+ assertEquals("BAZ", procedureQueryAnnotation.parameterAt(1).getName());
+
+ procedureQuery.removeParameter(0);
+ assertEquals(1, procedureQueryAnnotation.getParametersSize());
+ assertEquals("BAZ", procedureQueryAnnotation.parameterAt(0).getName());
+
+ procedureQuery.removeParameter(0);
+ assertEquals(0, procedureQueryAnnotation.getParametersSize());
+ }
+
+ public void testMoveParameter() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ Entity entity = getJavaEntity();
+ NamedStoredProcedureQuery2_1 procedureQuery = ((QueryContainer2_1) entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next();
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation procedureQueryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+
+ procedureQuery.addParameter(0).setName("FOO");
+ procedureQuery.addParameter(1).setName("BAR");
+ procedureQuery.addParameter(2).setName("BAZ");
+
+ assertEquals(3, procedureQueryAnnotation.getParametersSize());
+
+
+ procedureQuery.moveParameter(2, 0);
+ ListIterator<? extends StoredProcedureParameter2_1> parameters = procedureQuery.getParameters().iterator();
+ assertEquals("BAR", parameters.next().getName());
+ assertEquals("BAZ", parameters.next().getName());
+ assertEquals("FOO", parameters.next().getName());
+
+ assertEquals("BAR", procedureQueryAnnotation.parameterAt(0).getName());
+ assertEquals("BAZ", procedureQueryAnnotation.parameterAt(1).getName());
+ assertEquals("FOO", procedureQueryAnnotation.parameterAt(2).getName());
+
+
+ procedureQuery.moveParameter(0, 1);
+ parameters = procedureQuery.getParameters().iterator();
+ assertEquals("BAZ", parameters.next().getName());
+ assertEquals("BAR", parameters.next().getName());
+ assertEquals("FOO", parameters.next().getName());
+
+ assertEquals("BAZ", procedureQueryAnnotation.parameterAt(0).getName());
+ assertEquals("BAR", procedureQueryAnnotation.parameterAt(1).getName());
+ assertEquals("FOO", procedureQueryAnnotation.parameterAt(2).getName());
+ }
+
+ public void testUpdateParameters() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ Entity entity = getJavaEntity();
+ NamedStoredProcedureQuery2_1 procedureQuery = ((QueryContainer2_1) entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next();
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation procedureQueryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+
+ procedureQueryAnnotation.addParameter(0).setName("FOO");
+ procedureQueryAnnotation.addParameter(1).setName("BAR");
+ procedureQueryAnnotation.addParameter(2).setName("BAZ");
+ getJpaProject().synchronizeContextModel();
+
+ ListIterator<? extends StoredProcedureParameter2_1> parameters = procedureQuery.getParameters().iterator();
+ assertEquals("FOO", parameters.next().getName());
+ assertEquals("BAR", parameters.next().getName());
+ assertEquals("BAZ", parameters.next().getName());
+ assertFalse(parameters.hasNext());
+
+ procedureQueryAnnotation.moveParameter(2, 0);
+ getJpaProject().synchronizeContextModel();
+ parameters = procedureQuery.getParameters().iterator();
+ assertEquals("BAR", parameters.next().getName());
+ assertEquals("BAZ", parameters.next().getName());
+ assertEquals("FOO", parameters.next().getName());
+ assertFalse(parameters.hasNext());
+
+ procedureQueryAnnotation.moveParameter(0, 1);
+ getJpaProject().synchronizeContextModel();
+ parameters = procedureQuery.getParameters().iterator();
+ assertEquals("BAZ", parameters.next().getName());
+ assertEquals("BAR", parameters.next().getName());
+ assertEquals("FOO", parameters.next().getName());
+ assertFalse(parameters.hasNext());
+
+ procedureQueryAnnotation.removeParameter(1);
+ getJpaProject().synchronizeContextModel();
+ parameters = procedureQuery.getParameters().iterator();
+ assertEquals("BAZ", parameters.next().getName());
+ assertEquals("FOO", parameters.next().getName());
+ assertFalse(parameters.hasNext());
+
+ procedureQueryAnnotation.removeParameter(1);
+ getJpaProject().synchronizeContextModel();
+ parameters = procedureQuery.getParameters().iterator();
+ assertEquals("BAZ", parameters.next().getName());
+ assertFalse(parameters.hasNext());
+
+ procedureQueryAnnotation.removeParameter(0);
+ getJpaProject().synchronizeContextModel();
+ assertFalse(procedureQuery.getParameters().iterator().hasNext());
+ }
+
+ public void testParametersSize() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ Entity entity = getJavaEntity();
+ NamedStoredProcedureQuery2_1 procedureQuery = ((QueryContainer2_1) entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next();
+ assertEquals(0, procedureQuery.getParametersSize());
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation procedureQueryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+
+ procedureQueryAnnotation.addParameter(0);
+ getJpaProject().synchronizeContextModel();
+ assertEquals(1, procedureQuery.getParametersSize());
+
+ procedureQueryAnnotation.addParameter(0);
+ getJpaProject().synchronizeContextModel();
+ assertEquals(2, procedureQuery.getParametersSize());
+
+ procedureQueryAnnotation.removeParameter(0);
+ procedureQueryAnnotation.removeParameter(0);
+ getJpaProject().synchronizeContextModel();
+ assertEquals(0, procedureQuery.getParametersSize());
+ }
+
+ // ********** result classes **********
+
+ public void testAddResultClass() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ Entity entity = getJavaEntity();
+ NamedStoredProcedureQuery2_1 procedureQuery = ((QueryContainer2_1) entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next();
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation procedureQueryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+
+ procedureQuery.addResultClass("Employee");
+ assertEquals("Employee", procedureQueryAnnotation.resultClassAt(0));
+
+ procedureQuery.addResultClass("Address");
+ assertEquals("Employee", procedureQueryAnnotation.resultClassAt(0));
+ assertEquals("Address", procedureQueryAnnotation.resultClassAt(1));
+
+ procedureQuery.addResultClass(1, "Project");
+ assertEquals("Employee", procedureQueryAnnotation.resultClassAt(0));
+ assertEquals("Project", procedureQueryAnnotation.resultClassAt(1));
+ assertEquals("Address", procedureQueryAnnotation.resultClassAt(2));
+
+ ListIterator<String> resultClasses = procedureQuery.getResultClasses().iterator();
+ assertEquals("Employee", resultClasses.next());
+ assertEquals("Project", resultClasses.next());
+ assertEquals("Address", resultClasses.next());
+ }
+
+ public void testRemoveResultClass() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ Entity entity = getJavaEntity();
+ NamedStoredProcedureQuery2_1 procedureQuery = ((QueryContainer2_1) entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next();
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation procedureQueryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+
+ procedureQuery.addResultClass("Employee");
+ procedureQuery.addResultClass("Address");
+ procedureQuery.addResultClass("Project");
+
+ assertEquals(3, procedureQueryAnnotation.getResultClassesSize());
+
+ procedureQuery.removeResultClass(0);
+ assertEquals(2, procedureQueryAnnotation.getResultClassesSize());
+ assertEquals("Address", procedureQueryAnnotation.resultClassAt(0));
+ assertEquals("Project", procedureQueryAnnotation.resultClassAt(1));
+
+ procedureQuery.removeResultClass("Project");
+ assertEquals(1, procedureQueryAnnotation.getResultClassesSize());
+ assertEquals("Address", procedureQueryAnnotation.resultClassAt(0));
+
+ procedureQuery.removeResultClass(0);
+ assertEquals(0, procedureQueryAnnotation.getResultClassesSize());
+ }
+
+ public void testMoveResultClass() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ Entity entity = getJavaEntity();
+ NamedStoredProcedureQuery2_1 procedureQuery = ((QueryContainer2_1) entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next();
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation procedureQueryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+
+ procedureQuery.addResultClass("Employee");
+ procedureQuery.addResultClass("Address");
+ procedureQuery.addResultClass("Project");
+
+ assertEquals(3, procedureQueryAnnotation.getResultClassesSize());
+
+ procedureQuery.moveResultClass(2, 0);
+ ListIterator<String> resultClasses = procedureQuery.getResultClasses().iterator();
+ assertEquals("Address", resultClasses.next());
+ assertEquals("Project", resultClasses.next());
+ assertEquals("Employee", resultClasses.next());
+
+ assertEquals("Address", procedureQueryAnnotation.resultClassAt(0));
+ assertEquals("Project", procedureQueryAnnotation.resultClassAt(1));
+ assertEquals("Employee", procedureQueryAnnotation.resultClassAt(2));
+
+ procedureQuery.moveResultClass(0, 1);
+ resultClasses = procedureQuery.getResultClasses().iterator();
+ assertEquals("Project", resultClasses.next());
+ assertEquals("Address", resultClasses.next());
+ assertEquals("Employee", resultClasses.next());
+
+ assertEquals("Project", procedureQueryAnnotation.resultClassAt(0));
+ assertEquals("Address", procedureQueryAnnotation.resultClassAt(1));
+ assertEquals("Employee", procedureQueryAnnotation.resultClassAt(2));
+ }
+
+ public void testUpdateResultClass() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ Entity entity = getJavaEntity();
+ NamedStoredProcedureQuery2_1 procedureQuery = ((QueryContainer2_1) entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next();
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation procedureQueryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+
+ procedureQuery.addResultClass("Employee");
+ procedureQuery.addResultClass("Address");
+ procedureQuery.addResultClass("Project");
+ getJpaProject().synchronizeContextModel();
+
+ ListIterator<String> resultClasses = procedureQuery.getResultClasses().iterator();
+ assertEquals("Employee", resultClasses.next());
+ assertEquals("Address", resultClasses.next());
+ assertEquals("Project", resultClasses.next());
+ assertFalse(resultClasses.hasNext());
+
+ procedureQueryAnnotation.moveResultClass(2, 0);
+ getJpaProject().synchronizeContextModel();
+ resultClasses = procedureQuery.getResultClasses().iterator();
+ assertEquals("Address", resultClasses.next());
+ assertEquals("Project", resultClasses.next());
+ assertEquals("Employee", resultClasses.next());
+ assertFalse(resultClasses.hasNext());
+
+ procedureQueryAnnotation.moveResultClass(0, 1);
+ getJpaProject().synchronizeContextModel();
+ resultClasses = procedureQuery.getResultClasses().iterator();
+ assertEquals("Project", resultClasses.next());
+ assertEquals("Address", resultClasses.next());
+ assertEquals("Employee", resultClasses.next());
+ assertFalse(resultClasses.hasNext());
+
+ procedureQueryAnnotation.removeResultClass(1);
+ getJpaProject().synchronizeContextModel();
+ resultClasses = procedureQuery.getResultClasses().iterator();
+ assertEquals("Project", resultClasses.next());
+ assertEquals("Employee", resultClasses.next());
+ assertFalse(resultClasses.hasNext());
+
+ procedureQueryAnnotation.removeResultClass(1);
+ getJpaProject().synchronizeContextModel();
+ resultClasses = procedureQuery.getResultClasses().iterator();
+ assertEquals("Project", resultClasses.next());
+ assertFalse(resultClasses.hasNext());
+
+ procedureQueryAnnotation.removeResultClass(0);
+ getJpaProject().synchronizeContextModel();
+ assertFalse(procedureQuery.getResultClasses().iterator().hasNext());
+ }
+
+ public void testResultClassesSize() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ Entity entity = getJavaEntity();
+
+ NamedStoredProcedureQuery2_1 procedureQuery = ((QueryContainer2_1) entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next();
+ assertEquals(0, procedureQuery.getResultClassesSize());
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation procedureQueryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+
+ procedureQueryAnnotation.addResultClass("Employee");
+ getJpaProject().synchronizeContextModel();
+ assertEquals(1, procedureQuery.getResultClassesSize());
+
+ procedureQueryAnnotation.addResultClass(0, "Address");
+ getJpaProject().synchronizeContextModel();
+ assertEquals(2, procedureQuery.getResultClassesSize());
+
+ procedureQueryAnnotation.removeResultClass(0);
+ procedureQueryAnnotation.removeResultClass(0);
+ getJpaProject().synchronizeContextModel();
+ assertEquals(0, procedureQuery.getResultClassesSize());
+ }
+
+ // ********** result set mappings **********
+
+ public void testAddResultSetMapping() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ Entity entity = getJavaEntity();
+ NamedStoredProcedureQuery2_1 procedureQuery = ((QueryContainer2_1) entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next();
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation procedureQueryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+
+ procedureQuery.addResultSetMapping("Employee");
+ assertEquals("Employee", procedureQueryAnnotation.resultSetMappingAt(0));
+
+ procedureQuery.addResultSetMapping("Address");
+ assertEquals("Employee", procedureQueryAnnotation.resultSetMappingAt(0));
+ assertEquals("Address", procedureQueryAnnotation.resultSetMappingAt(1));
+
+ procedureQuery.addResultSetMapping(1, "Project");
+ assertEquals("Employee", procedureQueryAnnotation.resultSetMappingAt(0));
+ assertEquals("Project", procedureQueryAnnotation.resultSetMappingAt(1));
+ assertEquals("Address", procedureQueryAnnotation.resultSetMappingAt(2));
+
+ ListIterator<String> resultSetMapping = procedureQuery.getResultSetMappings().iterator();
+ assertEquals("Employee", resultSetMapping.next());
+ assertEquals("Project", resultSetMapping.next());
+ assertEquals("Address", resultSetMapping.next());
+ }
+
+ public void testRemoveResultSetMapping() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ Entity entity = getJavaEntity();
+ NamedStoredProcedureQuery2_1 procedureQuery = ((QueryContainer2_1) entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next();
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation procedureQueryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+
+ procedureQuery.addResultSetMapping("Employee");
+ procedureQuery.addResultSetMapping("Address");
+ procedureQuery.addResultSetMapping("Project");
+
+ assertEquals(3, procedureQueryAnnotation.getResultSetMappingsSize());
+
+ procedureQuery.removeResultSetMapping(0);
+ assertEquals(2, procedureQueryAnnotation.getResultSetMappingsSize());
+ assertEquals("Address", procedureQueryAnnotation.resultSetMappingAt(0));
+ assertEquals("Project", procedureQueryAnnotation.resultSetMappingAt(1));
+
+ procedureQuery.removeResultSetMapping("Project");
+ assertEquals(1, procedureQueryAnnotation.getResultSetMappingsSize());
+ assertEquals("Address", procedureQueryAnnotation.resultSetMappingAt(0));
+
+ procedureQuery.removeResultSetMapping(0);
+ assertEquals(0, procedureQueryAnnotation.getResultSetMappingsSize());
+ }
+
+ public void testMoveResultSetMapping() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ Entity entity = getJavaEntity();
+ NamedStoredProcedureQuery2_1 procedureQuery = ((QueryContainer2_1) entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next();
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation procedureQueryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+
+ procedureQuery.addResultSetMapping("Employee");
+ procedureQuery.addResultSetMapping("Address");
+ procedureQuery.addResultSetMapping("Project");
+
+ assertEquals(3, procedureQueryAnnotation.getResultSetMappingsSize());
+
+ procedureQuery.moveResultSetMapping(2, 0);
+ ListIterator<String> resultSetMapping = procedureQuery.getResultSetMappings().iterator();
+ assertEquals("Address", resultSetMapping.next());
+ assertEquals("Project", resultSetMapping.next());
+ assertEquals("Employee", resultSetMapping.next());
+
+ assertEquals("Address", procedureQueryAnnotation.resultSetMappingAt(0));
+ assertEquals("Project", procedureQueryAnnotation.resultSetMappingAt(1));
+ assertEquals("Employee", procedureQueryAnnotation.resultSetMappingAt(2));
+
+ procedureQuery.moveResultSetMapping(0, 1);
+ resultSetMapping = procedureQuery.getResultSetMappings().iterator();
+ assertEquals("Project", resultSetMapping.next());
+ assertEquals("Address", resultSetMapping.next());
+ assertEquals("Employee", resultSetMapping.next());
+
+ assertEquals("Project", procedureQueryAnnotation.resultSetMappingAt(0));
+ assertEquals("Address", procedureQueryAnnotation.resultSetMappingAt(1));
+ assertEquals("Employee", procedureQueryAnnotation.resultSetMappingAt(2));
+ }
+
+ public void testUpdateResultSetMapping() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ Entity entity = getJavaEntity();
+ NamedStoredProcedureQuery2_1 procedureQuery = ((QueryContainer2_1) entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next();
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation procedureQueryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+
+ procedureQuery.addResultSetMapping("Employee");
+ procedureQuery.addResultSetMapping("Address");
+ procedureQuery.addResultSetMapping("Project");
+ getJpaProject().synchronizeContextModel();
+
+ ListIterator<String> resultSetMapping = procedureQuery.getResultSetMappings().iterator();
+ assertEquals("Employee", resultSetMapping.next());
+ assertEquals("Address", resultSetMapping.next());
+ assertEquals("Project", resultSetMapping.next());
+ assertFalse(resultSetMapping.hasNext());
+
+ procedureQueryAnnotation.moveResultSetMapping(2, 0);
+ getJpaProject().synchronizeContextModel();
+ resultSetMapping = procedureQuery.getResultSetMappings().iterator();
+ assertEquals("Address", resultSetMapping.next());
+ assertEquals("Project", resultSetMapping.next());
+ assertEquals("Employee", resultSetMapping.next());
+ assertFalse(resultSetMapping.hasNext());
+
+ procedureQueryAnnotation.moveResultSetMapping(0, 1);
+ getJpaProject().synchronizeContextModel();
+ resultSetMapping = procedureQuery.getResultSetMappings().iterator();
+ assertEquals("Project", resultSetMapping.next());
+ assertEquals("Address", resultSetMapping.next());
+ assertEquals("Employee", resultSetMapping.next());
+ assertFalse(resultSetMapping.hasNext());
+
+ procedureQueryAnnotation.removeResultSetMapping(1);
+ getJpaProject().synchronizeContextModel();
+ resultSetMapping = procedureQuery.getResultSetMappings().iterator();
+ assertEquals("Project", resultSetMapping.next());
+ assertEquals("Employee", resultSetMapping.next());
+ assertFalse(resultSetMapping.hasNext());
+
+ procedureQueryAnnotation.removeResultSetMapping(1);
+ getJpaProject().synchronizeContextModel();
+ resultSetMapping = procedureQuery.getResultSetMappings().iterator();
+ assertEquals("Project", resultSetMapping.next());
+ assertFalse(resultSetMapping.hasNext());
+
+ procedureQueryAnnotation.removeResultSetMapping(0);
+ getJpaProject().synchronizeContextModel();
+ assertFalse(procedureQuery.getResultSetMappings().iterator().hasNext());
+ }
+
+ public void testResultSetMappingsSize() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ Entity entity = getJavaEntity();
+
+ NamedStoredProcedureQuery2_1 procedureQuery = ((QueryContainer2_1) entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next();
+ assertEquals(0, procedureQuery.getResultSetMappingsSize());
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation procedureQueryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+
+ procedureQueryAnnotation.addResultSetMapping("Employee");
+ getJpaProject().synchronizeContextModel();
+ assertEquals(1, procedureQuery.getResultSetMappingsSize());
+
+ procedureQueryAnnotation.addResultSetMapping(0, "Address");
+ getJpaProject().synchronizeContextModel();
+ assertEquals(2, procedureQuery.getResultSetMappingsSize());
+
+ procedureQueryAnnotation.removeResultSetMapping(0);
+ procedureQueryAnnotation.removeResultSetMapping(0);
+ getJpaProject().synchronizeContextModel();
+ assertEquals(0, procedureQuery.getResultSetMappingsSize());
+ }
+
+ // ************ hints ************
+
+ public void testAddHint() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ Entity entity = getJavaEntity();
+ NamedStoredProcedureQuery2_1 procedureQuery = ((QueryContainer2_1) entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next();
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation procedureQueryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+
+ QueryHint queryHint = procedureQuery.addHint(0);
+ queryHint.setName("FOO");
+
+ assertEquals("FOO", procedureQueryAnnotation.hintAt(0).getName());
+
+ QueryHint queryHint2 = procedureQuery.addHint(0);
+ queryHint2.setName("BAR");
+
+ assertEquals("BAR", procedureQueryAnnotation.hintAt(0).getName());
+ assertEquals("FOO", procedureQueryAnnotation.hintAt(1).getName());
+
+ QueryHint queryHint3 = procedureQuery.addHint(1);
+ queryHint3.setName("BAZ");
+
+ assertEquals("BAR", procedureQueryAnnotation.hintAt(0).getName());
+ assertEquals("BAZ", procedureQueryAnnotation.hintAt(1).getName());
+ assertEquals("FOO", procedureQueryAnnotation.hintAt(2).getName());
+
+ ListIterator<? extends QueryHint> hints = procedureQuery.getHints().iterator();
+ assertEquals(queryHint2, hints.next());
+ assertEquals(queryHint3, hints.next());
+ assertEquals(queryHint, hints.next());
+
+ hints = procedureQuery.getHints().iterator();
+ assertEquals("BAR", hints.next().getName());
+ assertEquals("BAZ", hints.next().getName());
+ assertEquals("FOO", hints.next().getName());
+ }
+
+ public void testRemoveHint() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ Entity entity = getJavaEntity();
+ NamedStoredProcedureQuery2_1 procedureQuery = ((QueryContainer2_1) entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next();
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation procedureQueryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+
+ procedureQuery.addHint(0).setName("FOO");
+ procedureQuery.addHint(1).setName("BAR");
+ procedureQuery.addHint(2).setName("BAZ");
+
+ assertEquals(3, procedureQueryAnnotation.getHintsSize());
+
+ procedureQuery.removeHint(0);
+ assertEquals(2, procedureQueryAnnotation.getHintsSize());
+ assertEquals("BAR", procedureQueryAnnotation.hintAt(0).getName());
+ assertEquals("BAZ", procedureQueryAnnotation.hintAt(1).getName());
+
+ procedureQuery.removeHint(0);
+ assertEquals(1, procedureQueryAnnotation.getHintsSize());
+ assertEquals("BAZ", procedureQueryAnnotation.hintAt(0).getName());
+
+ procedureQuery.removeHint(0);
+ assertEquals(0, procedureQueryAnnotation.getHintsSize());
+ }
+
+ public void testMoveHint() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ Entity entity = getJavaEntity();
+ NamedStoredProcedureQuery2_1 procedureQuery = ((QueryContainer2_1) entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next();
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation procedureQueryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+
+ procedureQuery.addHint(0).setName("FOO");
+ procedureQuery.addHint(1).setName("BAR");
+ procedureQuery.addHint(2).setName("BAZ");
+
+ assertEquals(3, procedureQueryAnnotation.getHintsSize());
+
+ procedureQuery.moveHint(2, 0);
+ ListIterator<? extends QueryHint> hints = procedureQuery.getHints().iterator();
+ assertEquals("BAR", hints.next().getName());
+ assertEquals("BAZ", hints.next().getName());
+ assertEquals("FOO", hints.next().getName());
+
+ assertEquals("BAR", procedureQueryAnnotation.hintAt(0).getName());
+ assertEquals("BAZ", procedureQueryAnnotation.hintAt(1).getName());
+ assertEquals("FOO", procedureQueryAnnotation.hintAt(2).getName());
+
+
+ procedureQuery.moveHint(0, 1);
+ hints = procedureQuery.getHints().iterator();
+ assertEquals("BAZ", hints.next().getName());
+ assertEquals("BAR", hints.next().getName());
+ assertEquals("FOO", hints.next().getName());
+
+ assertEquals("BAZ", procedureQueryAnnotation.hintAt(0).getName());
+ assertEquals("BAR", procedureQueryAnnotation.hintAt(1).getName());
+ assertEquals("FOO", procedureQueryAnnotation.hintAt(2).getName());
+ }
+
+ public void testUpdateHints() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ Entity entity = getJavaEntity();
+ NamedStoredProcedureQuery2_1 procedureQuery = ((QueryContainer2_1) entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next();
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation procedureQueryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+
+ procedureQueryAnnotation.addHint(0).setName("FOO");
+ procedureQueryAnnotation.addHint(1).setName("BAR");
+ procedureQueryAnnotation.addHint(2).setName("BAZ");
+ getJpaProject().synchronizeContextModel();
+
+ ListIterator<? extends QueryHint> hints = procedureQuery.getHints().iterator();
+ assertEquals("FOO", hints.next().getName());
+ assertEquals("BAR", hints.next().getName());
+ assertEquals("BAZ", hints.next().getName());
+ assertFalse(hints.hasNext());
+
+ procedureQueryAnnotation.moveHint(2, 0);
+ getJpaProject().synchronizeContextModel();
+ hints = procedureQuery.getHints().iterator();
+ assertEquals("BAR", hints.next().getName());
+ assertEquals("BAZ", hints.next().getName());
+ assertEquals("FOO", hints.next().getName());
+ assertFalse(hints.hasNext());
+
+ procedureQueryAnnotation.moveHint(0, 1);
+ getJpaProject().synchronizeContextModel();
+ hints = procedureQuery.getHints().iterator();
+ assertEquals("BAZ", hints.next().getName());
+ assertEquals("BAR", hints.next().getName());
+ assertEquals("FOO", hints.next().getName());
+ assertFalse(hints.hasNext());
+
+ procedureQueryAnnotation.removeHint(1);
+ getJpaProject().synchronizeContextModel();
+ hints = procedureQuery.getHints().iterator();
+ assertEquals("BAZ", hints.next().getName());
+ assertEquals("FOO", hints.next().getName());
+ assertFalse(hints.hasNext());
+
+ procedureQueryAnnotation.removeHint(1);
+ getJpaProject().synchronizeContextModel();
+ hints = procedureQuery.getHints().iterator();
+ assertEquals("BAZ", hints.next().getName());
+ assertFalse(hints.hasNext());
+
+ procedureQueryAnnotation.removeHint(0);
+ getJpaProject().synchronizeContextModel();
+ assertFalse(procedureQuery.getHints().iterator().hasNext());
+ }
+
+ public void testHintsSize() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ Entity entity = getJavaEntity();
+ NamedStoredProcedureQuery2_1 procedureQuery = ((QueryContainer2_1) entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next();
+ assertEquals(0, procedureQuery.getHintsSize());
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation procedureQueryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+
+ procedureQueryAnnotation.addHint(0);
+ getJpaProject().synchronizeContextModel();
+ assertEquals(1, procedureQuery.getHintsSize());
+
+ procedureQueryAnnotation.addHint(0);
+ getJpaProject().synchronizeContextModel();
+ assertEquals(2, procedureQuery.getHintsSize());
+
+ procedureQueryAnnotation.removeHint(0);
+ procedureQueryAnnotation.removeHint(0);
+ getJpaProject().synchronizeContextModel();
+ assertEquals(0, procedureQuery.getHintsSize());
+ }
+
+}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/java/GenericJavaStoredProcedureParameter2_1Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/java/GenericJavaStoredProcedureParameter2_1Tests.java
new file mode 100644
index 0000000..95ce490
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/java/GenericJavaStoredProcedureParameter2_1Tests.java
@@ -0,0 +1,219 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context.java;
+
+import java.util.Iterator;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement.AstNodeType;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.common.utility.internal.iterator.IteratorTools;
+import org.eclipse.jpt.jpa.core.context.Entity;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.StoredProcedureParameter2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.ParameterMode2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.QueryContainer2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.JPA2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.NamedStoredProcedureQuery2_1Annotation;
+import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.ParameterMode_2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.StoredProcedureParameter2_1Annotation;
+import org.eclipse.jpt.jpa.core.resource.java.JPA;
+import org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context.Generic2_1ContextModelTestCase;
+
+@SuppressWarnings("nls")
+public class GenericJavaStoredProcedureParameter2_1Tests
+ extends Generic2_1ContextModelTestCase
+{
+ public GenericJavaStoredProcedureParameter2_1Tests(String name) {
+ super(name);
+ }
+
+
+ private static final String QUERY_NAME = "QUERY_NAME";
+
+ private ICompilationUnit createTestEntityWithNamedStoredProcedureQuery() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return IteratorTools.iterator(JPA.ENTITY, JPA2_1.NAMED_STORED_PROCEDURE_QUERY, JPA2_1.NAMED_STORED_PROCEDURE_PARAMETER);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ sb.append("@NamedStoredProcedureQuery(name=\"" + QUERY_NAME + "\", parameters=@StoredProcedureParameter())");
+ }
+ });
+ }
+
+ // ************ name ***********
+
+ public void testUpdateName() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ Entity entity = getJavaEntity();
+ StoredProcedureParameter2_1 parameter = ((QueryContainer2_1)entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next().getParameters().iterator().next();
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation queryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+ StoredProcedureParameter2_1Annotation parameterAnnotation = queryAnnotation.getParameters().iterator().next();
+
+ assertNull(parameterAnnotation.getName());
+ assertNull(parameter.getName());
+
+ //set name in the resource model, verify context model updated
+ parameterAnnotation.setName("foo");
+ getJpaProject().synchronizeContextModel();
+ assertEquals("foo", parameterAnnotation.getName());
+ assertEquals("foo", parameter.getName());
+
+ //set name to null in the resource model
+ parameterAnnotation.setName(null);
+ getJpaProject().synchronizeContextModel();
+ assertNull(parameter.getName());
+ }
+
+ public void testModifyName() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ Entity entity = getJavaEntity();
+ StoredProcedureParameter2_1 parameter = ((QueryContainer2_1)entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next().getParameters().iterator().next();
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation queryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+ StoredProcedureParameter2_1Annotation parameterAnnotation = queryAnnotation.getParameters().iterator().next();
+
+ assertNull(parameterAnnotation.getName());
+ assertNull(parameter.getName());
+
+ //set name in the context model, verify resource model updated
+ parameter.setName("foo");
+ assertEquals("foo", parameterAnnotation.getName());
+ assertEquals("foo", parameter.getName());
+
+ //set name to null in the context model
+ parameter.setName(null);
+ assertNull(parameterAnnotation.getName());
+ assertNull(parameter.getName());
+ }
+
+ // ************ mode **********
+
+ public void testUpdateMode() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ Entity entity = getJavaEntity();
+ StoredProcedureParameter2_1 parameter = ((QueryContainer2_1)entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next().getParameters().iterator().next();
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation queryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+ StoredProcedureParameter2_1Annotation parameterAnnotation = queryAnnotation.getParameters().iterator().next();
+
+ assertNull(parameterAnnotation.getMode());
+ assertNull(parameter.getSpecifiedMode());
+ assertEquals(ParameterMode2_1.IN, parameter.getMode());
+
+ //set mode in the resource model, verify context model updated
+ parameterAnnotation.setMode(ParameterMode_2_1.IN);
+ getJpaProject().synchronizeContextModel();
+ assertEquals(ParameterMode_2_1.IN, parameterAnnotation.getMode());
+ assertEquals(ParameterMode2_1.IN, parameter.getMode());
+
+ //set name to null in the resource model
+ parameterAnnotation.setMode(null);
+ getJpaProject().synchronizeContextModel();
+ assertNull(parameterAnnotation.getMode());
+ assertNull(parameter.getSpecifiedMode());
+ assertEquals(ParameterMode2_1.IN, parameter.getMode());
+
+ }
+
+ public void testModifyMode() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ Entity entity = getJavaEntity();
+ StoredProcedureParameter2_1 parameter = ((QueryContainer2_1)entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next().getParameters().iterator().next();
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation queryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+ StoredProcedureParameter2_1Annotation parameterAnnotation = queryAnnotation.getParameters().iterator().next();
+
+ assertNull(parameterAnnotation.getMode());
+ assertNull(parameter.getSpecifiedMode());
+ assertEquals(ParameterMode2_1.IN, parameter.getMode());
+
+ //set mode in the context model, verify resource model updated
+ parameter.setSpecifiedMode(ParameterMode2_1.INOUT);
+ assertEquals(ParameterMode_2_1.INOUT, parameterAnnotation.getMode());
+ assertEquals(ParameterMode2_1.INOUT, parameter.getMode());
+
+ //set mode to null in the context model
+ parameter.setSpecifiedMode(null);
+ assertNull(parameterAnnotation.getMode());
+ assertNull(parameter.getSpecifiedMode());
+ assertEquals(ParameterMode2_1.IN, parameter.getMode());
+
+ }
+
+ // ************ type name **********
+
+ public void testUpdateTypeName() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ Entity entity = getJavaEntity();
+ StoredProcedureParameter2_1 parameter = ((QueryContainer2_1)entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next().getParameters().iterator().next();
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation queryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+ StoredProcedureParameter2_1Annotation parameterAnnotation = queryAnnotation.getParameters().iterator().next();
+
+ assertNull(parameterAnnotation.getTypeName());
+ assertNull(parameter.getTypeName());
+
+ //set type in the resource model, verify context model updated
+ parameterAnnotation.setTypeName("Foo");
+ getJpaProject().synchronizeContextModel();
+ assertEquals("Foo", parameterAnnotation.getTypeName());
+ assertEquals("Foo", parameter.getTypeName());
+
+ //set type to null in the resource model
+ parameterAnnotation.setTypeName(null);
+ getJpaProject().synchronizeContextModel();
+ assertNull(parameter.getTypeName());
+ }
+
+ public void testModifyTypeName() throws Exception {
+ createTestEntityWithNamedStoredProcedureQuery();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ Entity entity = getJavaEntity();
+ StoredProcedureParameter2_1 parameter = ((QueryContainer2_1)entity.getQueryContainer()).getNamedStoredProcedureQueries().iterator().next().getParameters().iterator().next();
+
+ JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE);
+ NamedStoredProcedureQuery2_1Annotation queryAnnotation = ((NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, NamedStoredProcedureQuery2_1Annotation.ANNOTATION_NAME));
+ StoredProcedureParameter2_1Annotation parameterAnnotation = queryAnnotation.getParameters().iterator().next();
+
+ assertNull(parameterAnnotation.getTypeName());
+ assertNull(parameter.getTypeName());
+
+ //set type in the context model, verify resource model updated
+ parameter.setTypeName("Foo");
+ assertEquals("Foo", parameterAnnotation.getTypeName());
+ assertEquals("Foo", parameter.getTypeName());
+
+ //set type to null in the context model
+ parameter.setTypeName(null);
+ assertNull(parameterAnnotation.getTypeName());
+ assertNull(parameter.getTypeName());
+ }
+
+}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/orm/Generic2_1OrmContextModelTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/orm/Generic2_1OrmContextModelTests.java
new file mode 100644
index 0000000..15e22bd
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/orm/Generic2_1OrmContextModelTests.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context.orm;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context.persistence.Generic2_1JpaMetadataConversionTests;
+
+public class Generic2_1OrmContextModelTests extends TestCase
+{
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(Generic2_1OrmContextModelTests.class.getPackage().getName());
+
+ suite.addTestSuite(GenericOrmNamedStoredProcedureQuery2_1Tests.class);
+ suite.addTestSuite(GenericOrmStoredProcedureParameter2_1Tests.class);
+ suite.addTestSuite(Generic2_1JpaMetadataConversionTests.class);
+
+ return suite;
+ }
+
+ private Generic2_1OrmContextModelTests() {
+ super();
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/orm/GenericOrmNamedStoredProcedureQuery2_1Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/orm/GenericOrmNamedStoredProcedureQuery2_1Tests.java
new file mode 100644
index 0000000..ca636ae
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/orm/GenericOrmNamedStoredProcedureQuery2_1Tests.java
@@ -0,0 +1,713 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context.orm;
+
+import java.util.ListIterator;
+import org.eclipse.jpt.jpa.core.MappingKeys;
+import org.eclipse.jpt.jpa.core.context.orm.OrmEntity;
+import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
+import org.eclipse.jpt.jpa.core.context.orm.OrmQueryHint;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm.OrmNamedStoredProcedureQuery2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm.OrmQueryContainer2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm.OrmStoredProcedureParameter2_1;
+import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlEntityMappings;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlNamedStoredProcedureQuery;
+import org.eclipse.jpt.jpa.core.resource.persistence.PersistenceFactory;
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlMappingFileRef;
+import org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context.Generic2_1ContextModelTestCase;
+
+@SuppressWarnings("nls")
+public class GenericOrmNamedStoredProcedureQuery2_1Tests
+ extends Generic2_1ContextModelTestCase
+{
+ public GenericOrmNamedStoredProcedureQuery2_1Tests(String name) {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
+ mappingFileRef.setFileName(XmlEntityMappings.DEFAULT_RUNTIME_PATH_NAME);
+ getXmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
+ getPersistenceXmlResource().save(null);
+ }
+
+ // *********** name *********
+
+ public void testUpdateName() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
+ OrmNamedStoredProcedureQuery2_1 ormProcedureQuery = ((OrmQueryContainer2_1) ormEntity.getQueryContainer()).addNamedStoredProcedureQuery(0);
+
+ XmlNamedStoredProcedureQuery procedureQueryResource = getXmlEntityMappings().getEntities().get(0).getNamedStoredProcedureQueries().get(0);
+
+ assertNull(ormProcedureQuery.getName());
+ assertNull(procedureQueryResource.getName());
+
+ //set name in the resource model, verify context model updated
+ procedureQueryResource.setName("foo");
+ assertEquals("foo", ormProcedureQuery.getName());
+ assertEquals("foo", procedureQueryResource.getName());
+
+ //set name to null in the resource model
+ procedureQueryResource.setName(null);
+ assertNull(ormProcedureQuery.getName());
+ assertNull(procedureQueryResource.getName());
+ }
+
+ public void testModifyName() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
+ OrmNamedStoredProcedureQuery2_1 ormProcedureQuery = ((OrmQueryContainer2_1) ormEntity.getQueryContainer()).addNamedStoredProcedureQuery(0);
+
+ XmlNamedStoredProcedureQuery procedureQueryResource = getXmlEntityMappings().getEntities().get(0).getNamedStoredProcedureQueries().get(0);
+
+ assertNull(ormProcedureQuery.getName());
+ assertNull(procedureQueryResource.getName());
+
+ //set name in the context model, verify resource model updated
+ ormProcedureQuery.setName("foo");
+ assertEquals("foo", ormProcedureQuery.getName());
+ assertEquals("foo", procedureQueryResource.getName());
+
+ //set new name in the context model, verify resource model updated
+ ormProcedureQuery.setName("newFoo");
+ assertEquals("newFoo", ormProcedureQuery.getName());
+ assertEquals("newFoo", procedureQueryResource.getName());
+
+ //set name to null in the context model
+ ormProcedureQuery.setName(null);
+ assertNull(ormProcedureQuery.getName());
+ assertNull(procedureQueryResource.getName());
+ }
+
+ // ********** procedure name ***********
+
+ public void testUpdateProcedureName() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
+ OrmNamedStoredProcedureQuery2_1 ormProcedureQuery = ((OrmQueryContainer2_1) ormEntity.getQueryContainer()).addNamedStoredProcedureQuery(0);
+
+ XmlNamedStoredProcedureQuery procedureQueryResource = getXmlEntityMappings().getEntities().get(0).getNamedStoredProcedureQueries().get(0);
+
+ assertNull(ormProcedureQuery.getProcedureName());
+ assertNull(procedureQueryResource.getProcedureName());
+
+ //set procedure name in the resource model, verify context model updated
+ procedureQueryResource.setProcedureName("foo");
+ assertEquals("foo", ormProcedureQuery.getProcedureName());
+ assertEquals("foo", procedureQueryResource.getProcedureName());
+
+ //set procedure name to null in the resource model
+ procedureQueryResource.setProcedureName(null);
+ assertNull(ormProcedureQuery.getProcedureName());
+ assertNull(procedureQueryResource.getProcedureName());
+ }
+
+ public void testModifyProcedureName() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
+ OrmNamedStoredProcedureQuery2_1 ormProcedureQuery = ((OrmQueryContainer2_1) ormEntity.getQueryContainer()).addNamedStoredProcedureQuery(0);
+
+ XmlNamedStoredProcedureQuery procedureQueryResource = getXmlEntityMappings().getEntities().get(0).getNamedStoredProcedureQueries().get(0);
+
+ assertNull(ormProcedureQuery.getProcedureName());
+ assertNull(procedureQueryResource.getName());
+
+ //set procedure name in the context model, verify resource model updated
+ ormProcedureQuery.setProcedureName("foo");
+ assertEquals("foo", ormProcedureQuery.getProcedureName());
+ assertEquals("foo", procedureQueryResource.getProcedureName());
+
+ //set new procedure name in the context model, verify resource model updated
+ ormProcedureQuery.setProcedureName("newFoo");
+ assertEquals("newFoo", ormProcedureQuery.getProcedureName());
+ assertEquals("newFoo", procedureQueryResource.getProcedureName());
+
+ //set procedure name to null in the context model
+ ormProcedureQuery.setProcedureName(null);
+ assertNull(ormProcedureQuery.getProcedureName());
+ assertNull(procedureQueryResource.getProcedureName());
+ }
+
+
+ // ************ parameters ************
+
+ public void testAddParameter() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
+ OrmNamedStoredProcedureQuery2_1 ormProcedureQuery = ((OrmQueryContainer2_1) ormEntity.getQueryContainer()).addNamedStoredProcedureQuery(0);
+
+ XmlNamedStoredProcedureQuery procedureQueryResource = getXmlEntityMappings().getEntities().get(0).getNamedStoredProcedureQueries().get(0);
+
+ OrmStoredProcedureParameter2_1 parameter1 = ormProcedureQuery.addParameter(0);
+ parameter1.setName("FOO");
+
+ assertEquals("FOO", procedureQueryResource.getParameters().get(0).getName());
+
+ OrmStoredProcedureParameter2_1 parameter2 = ormProcedureQuery.addParameter(0);
+ parameter2.setName("BAR");
+
+ assertEquals("BAR", procedureQueryResource.getParameters().get(0).getName());
+ assertEquals("FOO", procedureQueryResource.getParameters().get(1).getName());
+
+ OrmStoredProcedureParameter2_1 parameter3 = ormProcedureQuery.addParameter(1);
+ parameter3.setName("BAZ");
+
+ assertEquals("BAR", procedureQueryResource.getParameters().get(0).getName());
+ assertEquals("BAZ", procedureQueryResource.getParameters().get(1).getName());
+ assertEquals("FOO", procedureQueryResource.getParameters().get(2).getName());
+
+ ListIterator<OrmStoredProcedureParameter2_1> parameters = ormProcedureQuery.getParameters().iterator();
+ assertEquals(parameter2, parameters.next());
+ assertEquals(parameter3, parameters.next());
+ assertEquals(parameter1, parameters.next());
+
+ parameters = ormProcedureQuery.getParameters().iterator();
+ assertEquals("BAR", parameters.next().getName());
+ assertEquals("BAZ", parameters.next().getName());
+ assertEquals("FOO", parameters.next().getName());
+ }
+
+ public void testRemoveParameter() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
+ OrmNamedStoredProcedureQuery2_1 ormProcedureQuery = ((OrmQueryContainer2_1) ormEntity.getQueryContainer()).addNamedStoredProcedureQuery(0);
+
+ XmlNamedStoredProcedureQuery procedureQueryResource = getXmlEntityMappings().getEntities().get(0).getNamedStoredProcedureQueries().get(0);
+
+ ormProcedureQuery.addParameter(0).setName("FOO");
+ ormProcedureQuery.addParameter(1).setName("BAR");
+ ormProcedureQuery.addParameter(2).setName("BAZ");
+
+ assertEquals(3, procedureQueryResource.getParameters().size());
+
+ ormProcedureQuery.removeParameter(0);
+ assertEquals(2, procedureQueryResource.getParameters().size());
+ assertEquals("BAR", procedureQueryResource.getParameters().get(0).getName());
+ assertEquals("BAZ", procedureQueryResource.getParameters().get(1).getName());
+
+ ormProcedureQuery.removeParameter(0);
+ assertEquals(1, procedureQueryResource.getParameters().size());
+ assertEquals("BAZ", procedureQueryResource.getParameters().get(0).getName());
+
+ ormProcedureQuery.removeParameter(0);
+ assertEquals(0, procedureQueryResource.getParameters().size());
+ }
+
+ public void testMoveParameter() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
+ OrmNamedStoredProcedureQuery2_1 ormProcedureQuery = ((OrmQueryContainer2_1) ormEntity.getQueryContainer()).addNamedStoredProcedureQuery(0);
+
+ XmlNamedStoredProcedureQuery procedureQueryResource = getXmlEntityMappings().getEntities().get(0).getNamedStoredProcedureQueries().get(0);
+
+ ormProcedureQuery.addParameter(0).setName("FOO");
+ ormProcedureQuery.addParameter(1).setName("BAR");
+ ormProcedureQuery.addParameter(2).setName("BAZ");
+
+ assertEquals(3, procedureQueryResource.getParameters().size());
+
+ ormProcedureQuery.moveParameter(2, 0);
+ ListIterator<OrmStoredProcedureParameter2_1> parameters = ormProcedureQuery.getParameters().iterator();
+ assertEquals("BAR", parameters.next().getName());
+ assertEquals("BAZ", parameters.next().getName());
+ assertEquals("FOO", parameters.next().getName());
+
+ assertEquals("BAR", procedureQueryResource.getParameters().get(0).getName());
+ assertEquals("BAZ", procedureQueryResource.getParameters().get(1).getName());
+ assertEquals("FOO", procedureQueryResource.getParameters().get(2).getName());
+
+
+ ormProcedureQuery.moveParameter(0, 1);
+ parameters = ormProcedureQuery.getParameters().iterator();
+ assertEquals("BAZ", parameters.next().getName());
+ assertEquals("BAR", parameters.next().getName());
+ assertEquals("FOO", parameters.next().getName());
+
+ assertEquals("BAZ", procedureQueryResource.getParameters().get(0).getName());
+ assertEquals("BAR", procedureQueryResource.getParameters().get(1).getName());
+ assertEquals("FOO", procedureQueryResource.getParameters().get(2).getName());
+ }
+
+ public void testUpdateParameters() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
+ OrmNamedStoredProcedureQuery2_1 ormProcedureQuery = ((OrmQueryContainer2_1) ormEntity.getQueryContainer()).addNamedStoredProcedureQuery(0);
+
+ XmlNamedStoredProcedureQuery procedureQueryResource = getXmlEntityMappings().getEntities().get(0).getNamedStoredProcedureQueries().get(0);
+
+ procedureQueryResource.getParameters().add(OrmFactory.eINSTANCE.createXmlStoredProcedureParameter());
+ procedureQueryResource.getParameters().add(OrmFactory.eINSTANCE.createXmlStoredProcedureParameter());
+ procedureQueryResource.getParameters().add(OrmFactory.eINSTANCE.createXmlStoredProcedureParameter());
+
+ procedureQueryResource.getParameters().get(0).setName("FOO");
+ procedureQueryResource.getParameters().get(1).setName("BAR");
+ procedureQueryResource.getParameters().get(2).setName("BAZ");
+
+ ListIterator<OrmStoredProcedureParameter2_1> parameters = ormProcedureQuery.getParameters().iterator();
+ assertEquals("FOO", parameters.next().getName());
+ assertEquals("BAR", parameters.next().getName());
+ assertEquals("BAZ", parameters.next().getName());
+ assertFalse(parameters.hasNext());
+
+ procedureQueryResource.getParameters().move(2, 0);
+ parameters = ormProcedureQuery.getParameters().iterator();
+ assertEquals("BAR", parameters.next().getName());
+ assertEquals("BAZ", parameters.next().getName());
+ assertEquals("FOO", parameters.next().getName());
+ assertFalse(parameters.hasNext());
+
+ procedureQueryResource.getParameters().move(0, 1);
+ parameters = ormProcedureQuery.getParameters().iterator();
+ assertEquals("BAZ", parameters.next().getName());
+ assertEquals("BAR", parameters.next().getName());
+ assertEquals("FOO", parameters.next().getName());
+ assertFalse(parameters.hasNext());
+
+ procedureQueryResource.getParameters().remove(1);
+ parameters = ormProcedureQuery.getParameters().iterator();
+ assertEquals("BAZ", parameters.next().getName());
+ assertEquals("FOO", parameters.next().getName());
+ assertFalse(parameters.hasNext());
+
+ procedureQueryResource.getParameters().remove(1);
+ parameters = ormProcedureQuery.getParameters().iterator();
+ assertEquals("BAZ", parameters.next().getName());
+ assertFalse(parameters.hasNext());
+
+ procedureQueryResource.getParameters().remove(0);
+ assertFalse(ormProcedureQuery.getParameters().iterator().hasNext());
+ }
+
+
+ // ************ result classes ********
+
+ public void testAddResultClass() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
+ OrmNamedStoredProcedureQuery2_1 ormProcedureQuery = ((OrmQueryContainer2_1) ormEntity.getQueryContainer()).addNamedStoredProcedureQuery(0);
+
+ XmlNamedStoredProcedureQuery procedureQueryResource = getXmlEntityMappings().getEntities().get(0).getNamedStoredProcedureQueries().get(0);
+
+ ormProcedureQuery.addResultClass("Employee");
+ assertEquals("Employee", procedureQueryResource.getResultClasses().get(0));
+
+ ormProcedureQuery.addResultClass("Address");
+ assertEquals("Employee", procedureQueryResource.getResultClasses().get(0));
+ assertEquals("Address", procedureQueryResource.getResultClasses().get(1));
+
+ ormProcedureQuery.addResultClass(1, "Project");
+
+ assertEquals("Employee", procedureQueryResource.getResultClasses().get(0));
+ assertEquals("Project", procedureQueryResource.getResultClasses().get(1));
+ assertEquals("Address", procedureQueryResource.getResultClasses().get(2));
+
+ ListIterator<String> resultSetClasses = ormProcedureQuery.getResultClasses().iterator();
+ assertEquals("Employee", resultSetClasses.next());
+ assertEquals("Project", resultSetClasses.next());
+ assertEquals("Address", resultSetClasses.next());
+ }
+
+ public void testRemoveResultClass() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
+ OrmNamedStoredProcedureQuery2_1 ormProcedureQuery = ((OrmQueryContainer2_1) ormEntity.getQueryContainer()).addNamedStoredProcedureQuery(0);
+
+ XmlNamedStoredProcedureQuery procedureQueryResource = getXmlEntityMappings().getEntities().get(0).getNamedStoredProcedureQueries().get(0);
+
+ ormProcedureQuery.addResultClass("Employee");
+ ormProcedureQuery.addResultClass("Address");
+ ormProcedureQuery.addResultClass("Project");
+
+ assertEquals(3, procedureQueryResource.getResultClasses().size());
+
+ ormProcedureQuery.removeResultClass(0);
+ assertEquals(2, procedureQueryResource.getResultClasses().size());
+ assertEquals("Address", procedureQueryResource.getResultClasses().get(0));
+ assertEquals("Project", procedureQueryResource.getResultClasses().get(1));
+
+ ormProcedureQuery.removeResultClass("Project");
+ assertEquals(1, procedureQueryResource.getResultClasses().size());
+ assertEquals("Address", procedureQueryResource.getResultClasses().get(0));
+
+ ormProcedureQuery.removeResultClass(0);
+ assertEquals(0, procedureQueryResource.getResultClasses().size());
+ }
+
+ public void testMoveResultClass() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
+ OrmNamedStoredProcedureQuery2_1 ormProcedureQuery = ((OrmQueryContainer2_1) ormEntity.getQueryContainer()).addNamedStoredProcedureQuery(0);
+
+ XmlNamedStoredProcedureQuery procedureQueryResource = getXmlEntityMappings().getEntities().get(0).getNamedStoredProcedureQueries().get(0);
+
+ ormProcedureQuery.addResultClass("Employee");
+ ormProcedureQuery.addResultClass("Address");
+ ormProcedureQuery.addResultClass("Project");
+
+ assertEquals(3, procedureQueryResource.getResultClasses().size());
+
+ ormProcedureQuery.moveResultClass(2, 0);
+ ListIterator<String> resultClasses = ormProcedureQuery.getResultClasses().iterator();
+ assertEquals("Address", resultClasses.next());
+ assertEquals("Project", resultClasses.next());
+ assertEquals("Employee", resultClasses.next());
+
+ assertEquals("Address", procedureQueryResource.getResultClasses().get(0));
+ assertEquals("Project", procedureQueryResource.getResultClasses().get(1));
+ assertEquals("Employee", procedureQueryResource.getResultClasses().get(2));
+
+ ormProcedureQuery.moveResultClass(0, 1);
+ resultClasses = ormProcedureQuery.getResultClasses().iterator();
+ assertEquals("Project", resultClasses.next());
+ assertEquals("Address", resultClasses.next());
+ assertEquals("Employee", resultClasses.next());
+
+ assertEquals("Project", procedureQueryResource.getResultClasses().get(0));
+ assertEquals("Address", procedureQueryResource.getResultClasses().get(1));
+ assertEquals("Employee", procedureQueryResource.getResultClasses().get(2));
+ }
+
+ public void testUpdateResultClasses() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
+ OrmNamedStoredProcedureQuery2_1 ormProcedureQuery = ((OrmQueryContainer2_1) ormEntity.getQueryContainer()).addNamedStoredProcedureQuery(0);
+
+ XmlNamedStoredProcedureQuery procedureQueryResource = getXmlEntityMappings().getEntities().get(0).getNamedStoredProcedureQueries().get(0);
+
+ procedureQueryResource.getResultClasses().add("Employee");
+ procedureQueryResource.getResultClasses().add("Address");
+ procedureQueryResource.getResultClasses().add("Project");
+
+ ListIterator<String> resultClasses = ormProcedureQuery.getResultClasses().iterator();
+ assertEquals("Employee", resultClasses.next());
+ assertEquals("Address", resultClasses.next());
+ assertEquals("Project", resultClasses.next());
+ assertFalse(resultClasses.hasNext());
+
+ procedureQueryResource.getResultClasses().move(2, 0);
+ resultClasses = ormProcedureQuery.getResultClasses().iterator();
+ assertEquals("Address", resultClasses.next());
+ assertEquals("Project", resultClasses.next());
+ assertEquals("Employee", resultClasses.next());
+ assertFalse(resultClasses.hasNext());
+
+ procedureQueryResource.getResultClasses().move(0, 1);
+ resultClasses = ormProcedureQuery.getResultClasses().iterator();
+ assertEquals("Project", resultClasses.next());
+ assertEquals("Address", resultClasses.next());
+ assertEquals("Employee", resultClasses.next());
+ assertFalse(resultClasses.hasNext());
+
+ procedureQueryResource.getResultClasses().remove(1);
+ resultClasses = ormProcedureQuery.getResultClasses().iterator();
+ assertEquals("Project", resultClasses.next());
+ assertEquals("Employee", resultClasses.next());
+ assertFalse(resultClasses.hasNext());
+
+ procedureQueryResource.getResultClasses().remove(1);
+ resultClasses = ormProcedureQuery.getResultClasses().iterator();
+ assertEquals("Project", resultClasses.next());
+ assertFalse(resultClasses.hasNext());
+
+ procedureQueryResource.getResultClasses().remove(0);
+ assertFalse(ormProcedureQuery.getResultClasses().iterator().hasNext());
+ }
+
+
+ // ************ result set mappings ********
+
+ public void testAddResultSetMapping() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
+ OrmNamedStoredProcedureQuery2_1 ormProcedureQuery = ((OrmQueryContainer2_1) ormEntity.getQueryContainer()).addNamedStoredProcedureQuery(0);
+
+ XmlNamedStoredProcedureQuery procedureQueryResource = getXmlEntityMappings().getEntities().get(0).getNamedStoredProcedureQueries().get(0);
+
+ ormProcedureQuery.addResultSetMapping("Employee");
+ assertEquals("Employee", procedureQueryResource.getResultSetMappings().get(0));
+
+ ormProcedureQuery.addResultSetMapping("Address");
+ assertEquals("Employee", procedureQueryResource.getResultSetMappings().get(0));
+ assertEquals("Address", procedureQueryResource.getResultSetMappings().get(1));
+
+ ormProcedureQuery.addResultSetMapping(1, "Project");
+
+ assertEquals("Employee", procedureQueryResource.getResultSetMappings().get(0));
+ assertEquals("Project", procedureQueryResource.getResultSetMappings().get(1));
+ assertEquals("Address", procedureQueryResource.getResultSetMappings().get(2));
+
+ ListIterator<String> resultSetMappings = ormProcedureQuery.getResultSetMappings().iterator();
+ assertEquals("Employee", resultSetMappings.next());
+ assertEquals("Project", resultSetMappings.next());
+ assertEquals("Address", resultSetMappings.next());
+ }
+
+ public void testRemoveResultSetMapping() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
+ OrmNamedStoredProcedureQuery2_1 ormProcedureQuery = ((OrmQueryContainer2_1) ormEntity.getQueryContainer()).addNamedStoredProcedureQuery(0);
+
+ XmlNamedStoredProcedureQuery procedureQueryResource = getXmlEntityMappings().getEntities().get(0).getNamedStoredProcedureQueries().get(0);
+
+ ormProcedureQuery.addResultSetMapping("Employee");
+ ormProcedureQuery.addResultSetMapping("Address");
+ ormProcedureQuery.addResultSetMapping("Project");
+
+ assertEquals(3, procedureQueryResource.getResultSetMappings().size());
+
+ ormProcedureQuery.removeResultSetMapping(0);
+ assertEquals(2, procedureQueryResource.getResultSetMappings().size());
+ assertEquals("Address", procedureQueryResource.getResultSetMappings().get(0));
+ assertEquals("Project", procedureQueryResource.getResultSetMappings().get(1));
+
+ ormProcedureQuery.removeResultSetMapping("Project");
+ assertEquals(1, procedureQueryResource.getResultSetMappings().size());
+ assertEquals("Address", procedureQueryResource.getResultSetMappings().get(0));
+
+ ormProcedureQuery.removeResultSetMapping(0);
+ assertEquals(0, procedureQueryResource.getResultSetMappings().size());
+ }
+
+ public void testMoveResultSetMapping() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
+ OrmNamedStoredProcedureQuery2_1 ormProcedureQuery = ((OrmQueryContainer2_1) ormEntity.getQueryContainer()).addNamedStoredProcedureQuery(0);
+
+ XmlNamedStoredProcedureQuery procedureQueryResource = getXmlEntityMappings().getEntities().get(0).getNamedStoredProcedureQueries().get(0);
+
+ ormProcedureQuery.addResultSetMapping("Employee");
+ ormProcedureQuery.addResultSetMapping("Address");
+ ormProcedureQuery.addResultSetMapping("Project");
+
+ assertEquals(3, procedureQueryResource.getResultSetMappings().size());
+
+ ormProcedureQuery.moveResultSetMapping(2, 0);
+ ListIterator<String> resultSetMappings = ormProcedureQuery.getResultSetMappings().iterator();
+ assertEquals("Address", resultSetMappings.next());
+ assertEquals("Project", resultSetMappings.next());
+ assertEquals("Employee", resultSetMappings.next());
+
+ assertEquals("Address", procedureQueryResource.getResultSetMappings().get(0));
+ assertEquals("Project", procedureQueryResource.getResultSetMappings().get(1));
+ assertEquals("Employee", procedureQueryResource.getResultSetMappings().get(2));
+
+ ormProcedureQuery.moveResultSetMapping(0, 1);
+ resultSetMappings = ormProcedureQuery.getResultSetMappings().iterator();
+ assertEquals("Project", resultSetMappings.next());
+ assertEquals("Address", resultSetMappings.next());
+ assertEquals("Employee", resultSetMappings.next());
+
+ assertEquals("Project", procedureQueryResource.getResultSetMappings().get(0));
+ assertEquals("Address", procedureQueryResource.getResultSetMappings().get(1));
+ assertEquals("Employee", procedureQueryResource.getResultSetMappings().get(2));
+ }
+
+ public void testUpdateResultSetMappings() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
+ OrmNamedStoredProcedureQuery2_1 ormProcedureQuery = ((OrmQueryContainer2_1) ormEntity.getQueryContainer()).addNamedStoredProcedureQuery(0);
+
+ XmlNamedStoredProcedureQuery procedureQueryResource = getXmlEntityMappings().getEntities().get(0).getNamedStoredProcedureQueries().get(0);
+
+ procedureQueryResource.getResultSetMappings().add("Employee");
+ procedureQueryResource.getResultSetMappings().add("Address");
+ procedureQueryResource.getResultSetMappings().add("Project");
+
+ ListIterator<String> resultSetMappings = ormProcedureQuery.getResultSetMappings().iterator();
+ assertEquals("Employee", resultSetMappings.next());
+ assertEquals("Address", resultSetMappings.next());
+ assertEquals("Project", resultSetMappings.next());
+ assertFalse(resultSetMappings.hasNext());
+
+ procedureQueryResource.getResultSetMappings().move(2, 0);
+ resultSetMappings = ormProcedureQuery.getResultSetMappings().iterator();
+ assertEquals("Address", resultSetMappings.next());
+ assertEquals("Project", resultSetMappings.next());
+ assertEquals("Employee", resultSetMappings.next());
+ assertFalse(resultSetMappings.hasNext());
+
+ procedureQueryResource.getResultSetMappings().move(0, 1);
+ resultSetMappings = ormProcedureQuery.getResultSetMappings().iterator();
+ assertEquals("Project", resultSetMappings.next());
+ assertEquals("Address", resultSetMappings.next());
+ assertEquals("Employee", resultSetMappings.next());
+ assertFalse(resultSetMappings.hasNext());
+
+ procedureQueryResource.getResultSetMappings().remove(1);
+ resultSetMappings = ormProcedureQuery.getResultSetMappings().iterator();
+ assertEquals("Project", resultSetMappings.next());
+ assertEquals("Employee", resultSetMappings.next());
+ assertFalse(resultSetMappings.hasNext());
+
+ procedureQueryResource.getResultSetMappings().remove(1);
+ resultSetMappings= ormProcedureQuery.getResultSetMappings().iterator();
+ assertEquals("Project", resultSetMappings.next());
+ assertFalse(resultSetMappings.hasNext());
+
+ procedureQueryResource.getResultSetMappings().remove(0);
+ assertFalse(ormProcedureQuery.getResultSetMappings().iterator().hasNext());
+ }
+
+
+ // ************ hints **********
+
+ public void testAddHint() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
+ OrmNamedStoredProcedureQuery2_1 ormProcedureQuery = ((OrmQueryContainer2_1) ormEntity.getQueryContainer()).addNamedStoredProcedureQuery(0);
+
+ XmlNamedStoredProcedureQuery procedureQueryResource = getXmlEntityMappings().getEntities().get(0).getNamedStoredProcedureQueries().get(0);
+
+ OrmQueryHint queryHint = ormProcedureQuery.addHint(0);
+ queryHint.setName("FOO");
+
+ assertEquals("FOO", procedureQueryResource.getHints().get(0).getName());
+
+ OrmQueryHint queryHint2 = ormProcedureQuery.addHint(0);
+ queryHint2.setName("BAR");
+
+ assertEquals("BAR", procedureQueryResource.getHints().get(0).getName());
+ assertEquals("FOO", procedureQueryResource.getHints().get(1).getName());
+
+ OrmQueryHint queryHint3 = ormProcedureQuery.addHint(1);
+ queryHint3.setName("BAZ");
+
+ assertEquals("BAR", procedureQueryResource.getHints().get(0).getName());
+ assertEquals("BAZ", procedureQueryResource.getHints().get(1).getName());
+ assertEquals("FOO", procedureQueryResource.getHints().get(2).getName());
+
+ ListIterator<OrmQueryHint> queryHints = ormProcedureQuery.getHints().iterator();
+ assertEquals(queryHint2, queryHints.next());
+ assertEquals(queryHint3, queryHints.next());
+ assertEquals(queryHint, queryHints.next());
+
+ queryHints = ormProcedureQuery.getHints().iterator();
+ assertEquals("BAR", queryHints.next().getName());
+ assertEquals("BAZ", queryHints.next().getName());
+ assertEquals("FOO", queryHints.next().getName());
+ }
+
+ public void testRemoveHint() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
+ OrmNamedStoredProcedureQuery2_1 ormProcedureQuery = ((OrmQueryContainer2_1) ormEntity.getQueryContainer()).addNamedStoredProcedureQuery(0);
+
+ XmlNamedStoredProcedureQuery procedureQueryResource = getXmlEntityMappings().getEntities().get(0).getNamedStoredProcedureQueries().get(0);
+
+ ormProcedureQuery.addHint(0).setName("FOO");
+ ormProcedureQuery.addHint(1).setName("BAR");
+ ormProcedureQuery.addHint(2).setName("BAZ");
+
+ assertEquals(3, procedureQueryResource.getHints().size());
+
+ ormProcedureQuery.removeHint(0);
+ assertEquals(2, procedureQueryResource.getHints().size());
+ assertEquals("BAR", procedureQueryResource.getHints().get(0).getName());
+ assertEquals("BAZ", procedureQueryResource.getHints().get(1).getName());
+
+ ormProcedureQuery.removeHint(0);
+ assertEquals(1, procedureQueryResource.getHints().size());
+ assertEquals("BAZ", procedureQueryResource.getHints().get(0).getName());
+
+ ormProcedureQuery.removeHint(0);
+ assertEquals(0, procedureQueryResource.getHints().size());
+ }
+
+ public void testMoveHint() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
+ OrmNamedStoredProcedureQuery2_1 ormProcedureQuery = ((OrmQueryContainer2_1) ormEntity.getQueryContainer()).addNamedStoredProcedureQuery(0);
+
+ XmlNamedStoredProcedureQuery procedureQueryResource = getXmlEntityMappings().getEntities().get(0).getNamedStoredProcedureQueries().get(0);
+
+ ormProcedureQuery.addHint(0).setName("FOO");
+ ormProcedureQuery.addHint(1).setName("BAR");
+ ormProcedureQuery.addHint(2).setName("BAZ");
+
+ assertEquals(3, procedureQueryResource.getHints().size());
+
+
+ ormProcedureQuery.moveHint(2, 0);
+ ListIterator<OrmQueryHint> hints = ormProcedureQuery.getHints().iterator();
+ assertEquals("BAR", hints.next().getName());
+ assertEquals("BAZ", hints.next().getName());
+ assertEquals("FOO", hints.next().getName());
+
+ assertEquals("BAR", procedureQueryResource.getHints().get(0).getName());
+ assertEquals("BAZ", procedureQueryResource.getHints().get(1).getName());
+ assertEquals("FOO", procedureQueryResource.getHints().get(2).getName());
+
+
+ ormProcedureQuery.moveHint(0, 1);
+ hints = ormProcedureQuery.getHints().iterator();
+ assertEquals("BAZ", hints.next().getName());
+ assertEquals("BAR", hints.next().getName());
+ assertEquals("FOO", hints.next().getName());
+
+ assertEquals("BAZ", procedureQueryResource.getHints().get(0).getName());
+ assertEquals("BAR", procedureQueryResource.getHints().get(1).getName());
+ assertEquals("FOO", procedureQueryResource.getHints().get(2).getName());
+ }
+
+ public void testUpdateHints() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
+ OrmNamedStoredProcedureQuery2_1 ormProcedureQuery = ((OrmQueryContainer2_1) ormEntity.getQueryContainer()).addNamedStoredProcedureQuery(0);
+
+ XmlNamedStoredProcedureQuery procedureQueryResource = getXmlEntityMappings().getEntities().get(0).getNamedStoredProcedureQueries().get(0);
+
+ procedureQueryResource.getHints().add(OrmFactory.eINSTANCE.createXmlQueryHint());
+ procedureQueryResource.getHints().add(OrmFactory.eINSTANCE.createXmlQueryHint());
+ procedureQueryResource.getHints().add(OrmFactory.eINSTANCE.createXmlQueryHint());
+
+ procedureQueryResource.getHints().get(0).setName("FOO");
+ procedureQueryResource.getHints().get(1).setName("BAR");
+ procedureQueryResource.getHints().get(2).setName("BAZ");
+
+ ListIterator<OrmQueryHint> hints = ormProcedureQuery.getHints().iterator();
+ assertEquals("FOO", hints.next().getName());
+ assertEquals("BAR", hints.next().getName());
+ assertEquals("BAZ", hints.next().getName());
+ assertFalse(hints.hasNext());
+
+ procedureQueryResource.getHints().move(2, 0);
+ hints = ormProcedureQuery.getHints().iterator();
+ assertEquals("BAR", hints.next().getName());
+ assertEquals("BAZ", hints.next().getName());
+ assertEquals("FOO", hints.next().getName());
+ assertFalse(hints.hasNext());
+
+ procedureQueryResource.getHints().move(0, 1);
+ hints = ormProcedureQuery.getHints().iterator();
+ assertEquals("BAZ", hints.next().getName());
+ assertEquals("BAR", hints.next().getName());
+ assertEquals("FOO", hints.next().getName());
+ assertFalse(hints.hasNext());
+
+ procedureQueryResource.getHints().remove(1);
+ hints = ormProcedureQuery.getHints().iterator();
+ assertEquals("BAZ", hints.next().getName());
+ assertEquals("FOO", hints.next().getName());
+ assertFalse(hints.hasNext());
+
+ procedureQueryResource.getHints().remove(1);
+ hints = ormProcedureQuery.getHints().iterator();
+ assertEquals("BAZ", hints.next().getName());
+ assertFalse(hints.hasNext());
+
+ procedureQueryResource.getHints().remove(0);
+ assertFalse(ormProcedureQuery.getHints().iterator().hasNext());
+ }
+
+}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/orm/GenericOrmStoredProcedureParameter2_1Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/orm/GenericOrmStoredProcedureParameter2_1Tests.java
new file mode 100644
index 0000000..93897ae
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/orm/GenericOrmStoredProcedureParameter2_1Tests.java
@@ -0,0 +1,198 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context.orm;
+
+import org.eclipse.jpt.jpa.core.MappingKeys;
+import org.eclipse.jpt.jpa.core.context.orm.OrmEntity;
+import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm.OrmQueryContainer2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm.OrmStoredProcedureParameter2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.ParameterMode2_1;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlEntityMappings;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlStoredProcedureParameter;
+import org.eclipse.jpt.jpa.core.resource.orm.v2_1.ParameterMode_2_1;
+import org.eclipse.jpt.jpa.core.resource.persistence.PersistenceFactory;
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlMappingFileRef;
+import org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context.Generic2_1ContextModelTestCase;
+
+@SuppressWarnings("nls")
+public class GenericOrmStoredProcedureParameter2_1Tests
+ extends Generic2_1ContextModelTestCase
+{
+ public GenericOrmStoredProcedureParameter2_1Tests(String name) {
+ super(name);
+ }
+
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
+ mappingFileRef.setFileName(XmlEntityMappings.DEFAULT_RUNTIME_PATH_NAME);
+ getXmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
+ getPersistenceXmlResource().save(null);
+ }
+
+ // ******* name ***********
+
+ public void testUpdateName() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
+ OrmStoredProcedureParameter2_1 ormParameter = ((OrmQueryContainer2_1) ormEntity.getQueryContainer()).addNamedStoredProcedureQuery(0).addParameter(0);
+
+ XmlStoredProcedureParameter parameterResource = getXmlEntityMappings().getEntities().get(0).getNamedStoredProcedureQueries().get(0).getParameters().get(0);
+
+ assertNull(ormParameter.getName());
+ assertNull(parameterResource.getName());
+
+ //set name in the resource model, verify context model updated
+ parameterResource.setName("foo");
+ assertEquals("foo", ormParameter.getName());
+ assertEquals("foo", parameterResource.getName());
+
+ //set name to null in the resource model
+ parameterResource.setName(null);
+ assertNull(ormParameter.getName());
+ assertNull(parameterResource.getName());
+ }
+
+ public void testModifyName() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
+ OrmStoredProcedureParameter2_1 ormParameter = ((OrmQueryContainer2_1) ormEntity.getQueryContainer()).addNamedStoredProcedureQuery(0).addParameter(0);
+
+ XmlStoredProcedureParameter parameterResource = getXmlEntityMappings().getEntities().get(0).getNamedStoredProcedureQueries().get(0).getParameters().get(0);
+
+ assertNull(ormParameter.getName());
+ assertNull(parameterResource.getName());
+
+ //set name in the context model, verify resource model updated
+ ormParameter.setName("foo");
+ assertEquals("foo", ormParameter.getName());
+ assertEquals("foo", parameterResource.getName());
+
+ //set new name in the context model, verify resource model updated
+ ormParameter.setName("newFoo");
+ assertEquals("newFoo", ormParameter.getName());
+ assertEquals("newFoo", parameterResource.getName());
+
+ //set name to null in the context model
+ ormParameter.setName(null);
+ assertNull(ormParameter.getName());
+ assertNull(parameterResource.getName());
+ }
+
+ // ********* mode *********
+
+ public void testUpdateMode() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
+ OrmStoredProcedureParameter2_1 ormParameter = ((OrmQueryContainer2_1) ormEntity.getQueryContainer()).addNamedStoredProcedureQuery(0).addParameter(0);
+
+ XmlStoredProcedureParameter parameterResource = getXmlEntityMappings().getEntities().get(0).getNamedStoredProcedureQueries().get(0).getParameters().get(0);
+
+ assertNull(ormParameter.getSpecifiedMode());
+ // test default mode
+ assertEquals(ParameterMode2_1.IN, ormParameter.getMode());
+ assertNull(parameterResource.getMode());
+
+ //set mode in the resource model, verify context model updated
+ parameterResource.setMode(ParameterMode_2_1.INOUT);
+ assertEquals(ParameterMode2_1.INOUT, ormParameter.getMode());
+ assertEquals(ParameterMode_2_1.INOUT, parameterResource.getMode());
+
+ //set mode to null in the resource model
+ parameterResource.setMode(null);
+ assertNull(ormParameter.getSpecifiedMode());
+ // test default mode
+ assertEquals(ParameterMode2_1.IN, ormParameter.getMode());
+ assertNull(parameterResource.getMode());
+ }
+
+ public void testModifyMode() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
+ OrmStoredProcedureParameter2_1 ormParameter = ((OrmQueryContainer2_1) ormEntity.getQueryContainer()).addNamedStoredProcedureQuery(0).addParameter(0);
+
+ XmlStoredProcedureParameter parameterResource = getXmlEntityMappings().getEntities().get(0).getNamedStoredProcedureQueries().get(0).getParameters().get(0);
+
+ assertNull(ormParameter.getSpecifiedMode());
+ // test default mode
+ assertEquals(ParameterMode2_1.IN, ormParameter.getMode());
+ assertNull(parameterResource.getMode());
+
+ //set mode in the context model, verify resource model updated
+ ormParameter.setSpecifiedMode(ParameterMode2_1.INOUT);
+ assertEquals(ParameterMode2_1.INOUT, ormParameter.getMode());
+ assertEquals(ParameterMode_2_1.INOUT, parameterResource.getMode());
+
+ //set new mode in the context model, verify resource model updated
+ ormParameter.setSpecifiedMode(ParameterMode2_1.OUT);
+ assertEquals(ParameterMode2_1.OUT, ormParameter.getMode());
+ assertEquals(ParameterMode_2_1.OUT, parameterResource.getMode());
+
+
+ //set mode to null in the context model
+ ormParameter.setSpecifiedMode(null);
+ assertNull(ormParameter.getSpecifiedMode());
+ // test default mode
+ assertEquals(ParameterMode2_1.IN, ormParameter.getMode());
+ assertNull(parameterResource.getMode());
+ }
+
+ // *********** type name *********
+
+ public void testUpdateTypeName() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
+ OrmStoredProcedureParameter2_1 ormParameter = ((OrmQueryContainer2_1) ormEntity.getQueryContainer()).addNamedStoredProcedureQuery(0).addParameter(0);
+
+ XmlStoredProcedureParameter parameterResource = getXmlEntityMappings().getEntities().get(0).getNamedStoredProcedureQueries().get(0).getParameters().get(0);
+
+ assertNull(ormParameter.getTypeName());
+ assertNull(parameterResource.getClassName());
+
+ //set type name in the resource model, verify context model updated
+ parameterResource.setClassName("MyType");
+ assertEquals("MyType", ormParameter.getTypeName());
+ assertEquals("MyType", parameterResource.getClassName());
+
+ //set type name to null in the resource model
+ parameterResource.setClassName(null);
+ assertNull(ormParameter.getTypeName());
+ assertNull(parameterResource.getClassName());
+ }
+
+ public void testModifyTypeName() throws Exception {
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
+ OrmStoredProcedureParameter2_1 ormParameter = ((OrmQueryContainer2_1) ormEntity.getQueryContainer()).addNamedStoredProcedureQuery(0).addParameter(0);
+
+ XmlStoredProcedureParameter parameterResource = getXmlEntityMappings().getEntities().get(0).getNamedStoredProcedureQueries().get(0).getParameters().get(0);
+
+ assertNull(ormParameter.getTypeName());
+ assertNull(parameterResource.getClassName());
+
+ //set type name in the resource model, verify context model updated
+ parameterResource.setClassName("MyType");
+ assertEquals("MyType", ormParameter.getTypeName());
+ assertEquals("MyType", parameterResource.getClassName());
+
+ //set type name in the resource model, verify context model updated
+ parameterResource.setClassName("MyNewType");
+ assertEquals("MyNewType", ormParameter.getTypeName());
+ assertEquals("MyNewType", parameterResource.getClassName());
+
+ //set type name to null in the resource model
+ parameterResource.setClassName(null);
+ assertNull(ormParameter.getTypeName());
+ assertNull(parameterResource.getClassName());
+ }
+}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/persistence/Generic2_1JpaMetadataConversionTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/persistence/Generic2_1JpaMetadataConversionTests.java
new file mode 100644
index 0000000..7f2629c
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/persistence/Generic2_1JpaMetadataConversionTests.java
@@ -0,0 +1,388 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context.persistence;
+
+import java.util.Iterator;
+import java.util.ListIterator;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jpt.common.utility.internal.iterator.IteratorTools;
+import org.eclipse.jpt.jpa.core.context.java.JavaEntity;
+import org.eclipse.jpt.jpa.core.context.java.JavaMappedSuperclass;
+import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
+import org.eclipse.jpt.jpa.core.context.orm.OrmNamedNativeQuery;
+import org.eclipse.jpt.jpa.core.context.orm.OrmNamedQuery;
+import org.eclipse.jpt.jpa.core.context.orm.OrmQueryHint;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm.OrmNamedStoredProcedureQuery2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm.OrmQueryContainer2_1;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm.OrmStoredProcedureParameter2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.ParameterMode2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.QueryContainer2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.JPA2_1;
+import org.eclipse.jpt.jpa.core.resource.java.JPA;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlEntityMappings;
+import org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context.Generic2_1ContextModelTestCase;
+
+@SuppressWarnings("nls")
+public class Generic2_1JpaMetadataConversionTests
+ extends Generic2_1ContextModelTestCase
+{
+ private IProgressMonitor progressMonitor;
+
+ public Generic2_1JpaMetadataConversionTests(String name) {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ this.progressMonitor = new IProgressMonitor() {
+ public void worked(int work) {}
+ public void subTask(String name) {}
+ public void setTaskName(String name) {}
+ public void setCanceled(boolean value) {}
+ public boolean isCanceled() {return false;}
+ public void internalWorked(double work) {}
+ public void done() {}
+ public void beginTask(String name, int totalWork) {}
+ } ;
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ this.progressMonitor = null;
+ super.tearDown();
+ }
+
+ // ************ entity with queries*************
+
+ private ICompilationUnit createTestEntityWithNamedStoredProcedureQueries() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return IteratorTools.iterator(JPA.ENTITY, JPA2_1.NAMED_STORED_PROCEDURE_QUERIES, JPA2_1.NAMED_STORED_PROCEDURE_QUERY,
+ JPA2_1.NAMED_STORED_PROCEDURE_PARAMETER, JPA2_1.PARAMETER_MODE, JPA.QUERY_HINT);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ sb.append("@NamedStoredProcedureQueries({" +
+ "@NamedStoredProcedureQuery(" +
+ "name=\"nq1\", procedureName=\"abcd\", " +
+ "parameters={@StoredProcedureParameter(name=\"nq1parameter1\", mode=ParameterMode.INOUT, type=String.class), " +
+ "@StoredProcedureParameter(name=\"nq1parameter2\", mode=ParameterMode.OUT, type=Integer.class)}, " +
+ "resultClasses={Employee.class, Address.class}, " +
+ "resultSetMappings={\"EmployeeRSM\", \"AddressRSM\"}, " +
+ "hints={@QueryHint(name=\"nq1hint1\", value = \"aaa\"), @QueryHint(name=\"nq1hint2\", value=\"bbb\")}), " +
+ "@NamedStoredProcedureQuery(" +
+ "name=\"nq2\", procedureName=\"efgh\"," +
+ "parameters=@StoredProcedureParameter(name=\"nq2parameter1\", mode=ParameterMode.INOUT, type=Boolean.class)," +
+ "resultClasses=Project.class," +
+ "resultSetMappings=\"ProjectRSM\"," +
+ "hints=@QueryHint(name=\"nq2hint1\", value=\"ccc\"))})");
+ }
+ });
+ }
+
+ private ICompilationUnit createTestEntityWithQueries() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return IteratorTools.iterator(JPA.ENTITY, JPA.ID, JPA2_1.NAMED_STORED_PROCEDURE_QUERIES, JPA2_1.NAMED_STORED_PROCEDURE_QUERY, JPA.NAMED_NATIVE_QUERY);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ sb.append("@NamedStoredProcedureQueries({@NamedStoredProcedureQuery(name=\"nq\"), @NamedStoredProcedureQuery(name=\"query\")})").append(CR);
+ sb.append("@NamedNativeQuery(name=\"nnq\")");
+ }
+ });
+ }
+
+ private ICompilationUnit createTestEntityWithDuplicateQueries() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return IteratorTools.iterator(JPA.ENTITY, JPA.ID, JPA2_1.NAMED_STORED_PROCEDURE_QUERIES, JPA2_1.NAMED_STORED_PROCEDURE_QUERY, JPA.NAMED_NATIVE_QUERIES, JPA.NAMED_NATIVE_QUERY);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ sb.append("@NamedStoredProcedureQueries({@NamedStoredProcedureQuery(name=\"query\"), @NamedStoredProcedureQuery(name=\"nspq\")})");
+ sb.append("@NamedNativeQueries({@NamedNativeQuery(name=\"query\"), @NamedNativeQuery(name=\"nnq\")})");
+ }
+ });
+ }
+
+ private ICompilationUnit createTestMappedSuperWithNamedStoredProcedureQueries() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return IteratorTools.iterator(JPA.MAPPED_SUPERCLASS, JPA2_1.NAMED_STORED_PROCEDURE_QUERIES, JPA2_1.NAMED_STORED_PROCEDURE_QUERY,
+ JPA2_1.NAMED_STORED_PROCEDURE_PARAMETER, JPA2_1.PARAMETER_MODE, JPA.QUERY_HINT);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@MappedSuperclass").append(CR);
+ sb.append("@NamedStoredProcedureQueries({" +
+ "@NamedStoredProcedureQuery(" +
+ "name=\"nq1\", procedureName=\"abcd\", " +
+ "parameters={@StoredProcedureParameter(name=\"nq1parameter1\", mode=ParameterMode.INOUT, type=String.class), " +
+ "@StoredProcedureParameter(name=\"nq1parameter2\", mode=ParameterMode.OUT, type=Integer.class)}, " +
+ "resultClasses={Employee.class, Address.class}, " +
+ "resultSetMappings={\"EmployeeRSM\", \"AddressRSM\"}, " +
+ "hints={@QueryHint(name=\"nq1hint1\", value = \"aaa\"), @QueryHint(name=\"nq1hint2\", value=\"bbb\")}), " +
+ "@NamedStoredProcedureQuery(" +
+ "name=\"nq2\", procedureName=\"efgh\"," +
+ "parameters=@StoredProcedureParameter(name=\"nq2parameter1\", mode=ParameterMode.INOUT, type=Boolean.class)," +
+ "resultClasses=Project.class," +
+ "resultSetMappings=\"ProjectRSM\"," +
+ "hints=@QueryHint(name=\"nq2hint1\", value=\"ccc\"))})");
+ }
+ });
+ }
+
+
+ public void testConvertNamedStoredProceduerQueriesOnEntity() throws Exception {
+ createTestEntityWithNamedStoredProcedureQueries();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ JavaEntity entity = getJavaEntity();
+ addXmlMappingFileRef(XmlEntityMappings.DEFAULT_RUNTIME_PATH_NAME);
+ EntityMappings entityMappings = getEntityMappings();
+
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+ persistenceUnit.convertJavaQueries(entityMappings, progressMonitor);
+
+ // test Java queries are converted to orm.xml and removed from the Java entity
+ assertEquals(2, ((QueryContainer2_1) entityMappings.getQueryContainer()).getNamedStoredProcedureQueriesSize());
+ assertEquals(0, ((QueryContainer2_1) entity.getQueryContainer()).getNamedStoredProcedureQueriesSize());
+
+ // test the mapping file queries have correct values
+ ListIterator<OrmNamedStoredProcedureQuery2_1> procedureQueries= ((OrmQueryContainer2_1) entityMappings.getQueryContainer()).getNamedStoredProcedureQueries().iterator();
+ OrmNamedStoredProcedureQuery2_1 procedureQuery1 = procedureQueries.next();
+
+ // ----- the first mapping file query -----
+
+ assertEquals("nq1", (procedureQuery1.getName()));
+ assertEquals("abcd", (procedureQuery1.getProcedureName()));
+ assertEquals(2, procedureQuery1.getParametersSize());
+ assertEquals(2, procedureQuery1.getResultClassesSize());
+ assertEquals(2, procedureQuery1.getResultSetMappingsSize());
+ assertEquals(2, (procedureQuery1.getHintsSize()));
+
+ // test the parameters of the first mapping file query have the correct value
+ ListIterator<OrmStoredProcedureParameter2_1> nq1prameters = procedureQuery1.getParameters().iterator();
+
+ // test the first parameter of the first mapping file query
+ OrmStoredProcedureParameter2_1 nq1parameter1 = nq1prameters.next();
+ assertEquals("nq1parameter1", nq1parameter1.getName());
+ assertEquals(ParameterMode2_1.INOUT, nq1parameter1.getMode());
+ assertEquals("String", nq1parameter1.getTypeName());
+
+ // test the second parameter hint of the first mapping file query
+ OrmStoredProcedureParameter2_1 nq1parameter2 = nq1prameters.next();
+ assertEquals("nq1parameter2", nq1parameter2.getName());
+ assertEquals(ParameterMode2_1.OUT, nq1parameter2.getMode());
+ assertEquals("Integer", nq1parameter2.getTypeName());
+
+ // test the result classes of the first mapping file query have the correct value
+ ListIterator<String> nq1ResultClasses = procedureQuery1.getResultClasses().iterator();
+ assertEquals("Employee", nq1ResultClasses.next());
+ assertEquals("Address", nq1ResultClasses.next());
+
+ // test the result classes of the first mapping file query have the correct value
+ ListIterator<String> nq1ResultSetMappings = procedureQuery1.getResultSetMappings().iterator();
+ assertEquals("EmployeeRSM", nq1ResultSetMappings.next());
+ assertEquals("AddressRSM", nq1ResultSetMappings.next());
+
+ // test the query hints of the first mapping file query have the correct value
+ ListIterator<OrmQueryHint> nq1hints = procedureQuery1.getHints().iterator();
+
+ // test the first query hint of the first mapping file query
+ OrmQueryHint nq1hint1 = nq1hints.next();
+ assertEquals("nq1hint1", nq1hint1.getName());
+ assertEquals("aaa", nq1hint1.getValue());
+
+ // test the second query hint of the first mapping file query
+ OrmQueryHint nq1hint2 = nq1hints.next();
+ assertEquals("nq1hint2", nq1hint2.getName());
+ assertEquals("bbb", nq1hint2.getValue());
+
+ // ----- the second mapping file query -----
+ OrmNamedStoredProcedureQuery2_1 procedureQuery2 = procedureQueries.next();
+ assertEquals("nq2", (procedureQuery2.getName()));
+ assertEquals("efgh", (procedureQuery2.getProcedureName()));
+ assertEquals(1, procedureQuery2.getParametersSize());
+ assertEquals(1, procedureQuery2.getResultClassesSize());
+ assertEquals(1, procedureQuery2.getResultSetMappingsSize());
+ assertEquals(1, (procedureQuery2.getHintsSize()));
+
+ // test the parameter of the second mapping file query have the correct value
+ OrmStoredProcedureParameter2_1 nq2parameter = procedureQuery2.getParameters().iterator().next();
+ assertEquals("nq2parameter1", nq2parameter.getName());
+ assertEquals(ParameterMode2_1.INOUT, nq2parameter.getMode());
+ assertEquals("Boolean", nq2parameter.getTypeName());
+
+ // test the result class of the second mapping file query have the correct value
+ String nq2ResultClass = procedureQuery2.getResultClasses().iterator().next();
+ assertEquals("Project", nq2ResultClass);
+
+ // test the result set mapping of the second mapping file query have the correct value
+ String nq2ResultSetMapping = procedureQuery2.getResultSetMappings().iterator().next();
+ assertEquals("ProjectRSM", nq2ResultSetMapping);
+
+ // test the query hint of the second mapping file query have the correct value
+ OrmQueryHint nq2hint1 = procedureQuery2.getHints().iterator().next();
+ assertEquals("nq2hint1", nq2hint1.getName());
+ assertEquals("ccc", nq2hint1.getValue());
+ }
+
+ public void testConvertOverriddenQueries() throws Exception {
+ createTestEntityWithQueries();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ addXmlMappingFileRef(XmlEntityMappings.DEFAULT_RUNTIME_PATH_NAME);
+ EntityMappings entityMappings = getEntityMappings();
+ OrmNamedNativeQuery nnq = entityMappings.getQueryContainer().addNamedNativeQuery();
+ nnq.setName("nq");
+ OrmNamedQuery nq = entityMappings.getQueryContainer().addNamedQuery();
+ nq.setName("nnq");
+
+ JavaEntity entity = getJavaEntity();
+ persistenceUnit.convertJavaQueries(entityMappings, progressMonitor);
+
+ // test overridden Java queries are not converted to orm.xml and not
+ // removed from the Java entity, but unique query is
+ assertEquals(1, ((QueryContainer2_1) entity.getQueryContainer()).getNamedStoredProcedureQueriesSize());
+ assertEquals(1, entity.getQueryContainer().getNamedNativeQueriesSize());
+ assertEquals(1, ((QueryContainer2_1) entityMappings.getQueryContainer()).getNamedStoredProcedureQueriesSize());
+ assertEquals(1, entityMappings.getQueryContainer().getNamedNativeQueriesSize());
+ assertEquals(1, entityMappings.getQueryContainer().getNamedQueriesSize());
+ }
+
+ public void testConvertDuplicateQueries() throws Exception {
+ createTestEntityWithDuplicateQueries();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ addXmlMappingFileRef(XmlEntityMappings.DEFAULT_RUNTIME_PATH_NAME);
+ EntityMappings entityMappings = getEntityMappings();
+ persistenceUnit.convertJavaQueries(entityMappings, progressMonitor);
+
+ JavaEntity entity = getJavaEntity();
+
+ // test duplicate Java queries are not converted to orm.xml and
+ // not removed from the Java entity, but unique query is
+ assertEquals(1, ((QueryContainer2_1) entity.getQueryContainer()).getNamedStoredProcedureQueriesSize());
+ assertEquals(1, entity.getQueryContainer().getNamedNativeQueriesSize());
+ assertEquals(1, ((QueryContainer2_1) entityMappings.getQueryContainer()).getNamedStoredProcedureQueriesSize());
+ assertEquals(1, entityMappings.getQueryContainer().getNamedNativeQueriesSize());
+ }
+
+ public void testConvertNamedStoredProcedureQueriesOnMappedSuperclass() throws Exception {
+ createTestMappedSuperWithNamedStoredProcedureQueries();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ JavaMappedSuperclass mappedSuperclass = (JavaMappedSuperclass) getJavaPersistentType().getMapping();
+ addXmlMappingFileRef(XmlEntityMappings.DEFAULT_RUNTIME_PATH_NAME);
+ EntityMappings entityMappings = getEntityMappings();
+
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+ persistenceUnit.convertJavaQueries(entityMappings, progressMonitor);
+
+ // test Java queries are converted to orm.xml and removed from the Java entity
+ assertEquals(2, ((QueryContainer2_1) entityMappings.getQueryContainer()).getNamedStoredProcedureQueriesSize());
+ assertEquals(0, ((QueryContainer2_1) mappedSuperclass.getQueryContainer()).getNamedStoredProcedureQueriesSize());
+
+ // test the mapping file queries have correct values
+ ListIterator<OrmNamedStoredProcedureQuery2_1> procedureQueries= ((OrmQueryContainer2_1) entityMappings.getQueryContainer()).getNamedStoredProcedureQueries().iterator();
+ OrmNamedStoredProcedureQuery2_1 procedureQuery1 = procedureQueries.next();
+
+ // ----- the first mapping file query -----
+
+ assertEquals("nq1", (procedureQuery1.getName()));
+ assertEquals("abcd", (procedureQuery1.getProcedureName()));
+ assertEquals(2, procedureQuery1.getParametersSize());
+ assertEquals(2, procedureQuery1.getResultClassesSize());
+ assertEquals(2, procedureQuery1.getResultSetMappingsSize());
+ assertEquals(2, (procedureQuery1.getHintsSize()));
+
+ // test the parameters of the first mapping file query have the correct value
+ ListIterator<OrmStoredProcedureParameter2_1> nq1prameters = procedureQuery1.getParameters().iterator();
+
+ // test the first parameter of the first mapping file query
+ OrmStoredProcedureParameter2_1 nq1parameter1 = nq1prameters.next();
+ assertEquals("nq1parameter1", nq1parameter1.getName());
+ assertEquals(ParameterMode2_1.INOUT, nq1parameter1.getMode());
+ assertEquals("String", nq1parameter1.getTypeName());
+
+ // test the second parameter hint of the first mapping file query
+ OrmStoredProcedureParameter2_1 nq1parameter2 = nq1prameters.next();
+ assertEquals("nq1parameter2", nq1parameter2.getName());
+ assertEquals(ParameterMode2_1.OUT, nq1parameter2.getMode());
+ assertEquals("Integer", nq1parameter2.getTypeName());
+
+ // test the result classes of the first mapping file query have the correct value
+ ListIterator<String> nq1ResultClasses = procedureQuery1.getResultClasses().iterator();
+ assertEquals("Employee", nq1ResultClasses.next());
+ assertEquals("Address", nq1ResultClasses.next());
+
+ // test the result classes of the first mapping file query have the correct value
+ ListIterator<String> nq1ResultSetMappings = procedureQuery1.getResultSetMappings().iterator();
+ assertEquals("EmployeeRSM", nq1ResultSetMappings.next());
+ assertEquals("AddressRSM", nq1ResultSetMappings.next());
+
+ // test the query hints of the first mapping file query have the correct value
+ ListIterator<OrmQueryHint> nq1hints = procedureQuery1.getHints().iterator();
+
+ // test the first query hint of the first mapping file query
+ OrmQueryHint nq1hint1 = nq1hints.next();
+ assertEquals("nq1hint1", nq1hint1.getName());
+ assertEquals("aaa", nq1hint1.getValue());
+
+ // test the second query hint of the first mapping file query
+ OrmQueryHint nq1hint2 = nq1hints.next();
+ assertEquals("nq1hint2", nq1hint2.getName());
+ assertEquals("bbb", nq1hint2.getValue());
+
+ // ----- the second mapping file query -----
+ OrmNamedStoredProcedureQuery2_1 procedureQuery2 = procedureQueries.next();
+ assertEquals("nq2", (procedureQuery2.getName()));
+ assertEquals("efgh", (procedureQuery2.getProcedureName()));
+ assertEquals(1, procedureQuery2.getParametersSize());
+ assertEquals(1, procedureQuery2.getResultClassesSize());
+ assertEquals(1, procedureQuery2.getResultSetMappingsSize());
+ assertEquals(1, (procedureQuery2.getHintsSize()));
+
+ // test the parameter of the second mapping file query have the correct value
+ OrmStoredProcedureParameter2_1 nq2parameter = procedureQuery2.getParameters().iterator().next();
+ assertEquals("nq2parameter1", nq2parameter.getName());
+ assertEquals(ParameterMode2_1.INOUT, nq2parameter.getMode());
+ assertEquals("Boolean", nq2parameter.getTypeName());
+
+ // test the result class of the second mapping file query have the correct value
+ String nq2ResultClass = procedureQuery2.getResultClasses().iterator().next();
+ assertEquals("Project", nq2ResultClass);
+
+ // test the result set mapping of the second mapping file query have the correct value
+ String nq2ResultSetMapping = procedureQuery2.getResultSetMappings().iterator().next();
+ assertEquals("ProjectRSM", nq2ResultSetMapping);
+
+ // test the query hint of the second mapping file query have the correct value
+ OrmQueryHint nq2hint1 = procedureQuery2.getHints().iterator().next();
+ assertEquals("nq2hint1", nq2hint1.getName());
+ assertEquals("ccc", nq2hint1.getValue());
+ }
+}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/resource/java/StoredProcedureParameter2_1AnnotationTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/resource/java/StoredProcedureParameter2_1AnnotationTests.java
index 33bb3ca..1600a90 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/resource/java/StoredProcedureParameter2_1AnnotationTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/resource/java/StoredProcedureParameter2_1AnnotationTests.java
@@ -15,7 +15,7 @@ import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.common.utility.internal.iterator.IteratorTools;
import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.JPA2_1;
import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.NamedStoredProcedureQuery2_1Annotation;
-import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.ParameterMode2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.ParameterMode_2_1;
import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.StoredProcedureParameter2_1Annotation;
@SuppressWarnings("nls")
@@ -85,7 +85,7 @@ public class StoredProcedureParameter2_1AnnotationTests
NamedStoredProcedureQuery2_1Annotation namedQuery = (NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, JPA2_1.NAMED_STORED_PROCEDURE_QUERY);
StoredProcedureParameter2_1Annotation parameter = namedQuery.parameterAt(0);
- assertEquals(ParameterMode2_1.IN, parameter.getMode());
+ assertEquals(ParameterMode_2_1.IN, parameter.getMode());
}
public void testSetMode() throws Exception {
@@ -94,10 +94,10 @@ public class StoredProcedureParameter2_1AnnotationTests
NamedStoredProcedureQuery2_1Annotation namedQuery = (NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, JPA2_1.NAMED_STORED_PROCEDURE_QUERY);
StoredProcedureParameter2_1Annotation parameter = namedQuery.parameterAt(0);
- assertEquals(ParameterMode2_1.IN, parameter.getMode());
+ assertEquals(ParameterMode_2_1.IN, parameter.getMode());
- parameter.setMode(ParameterMode2_1.INOUT);
- assertEquals(ParameterMode2_1.INOUT, parameter.getMode());
+ parameter.setMode(ParameterMode_2_1.INOUT);
+ assertEquals(ParameterMode_2_1.INOUT, parameter.getMode());
assertSourceContains("@StoredProcedureParameter(name = \"MyParameter\", mode = INOUT, type = MyType.class)", cu);
parameter.setMode(null);
@@ -114,7 +114,7 @@ public class StoredProcedureParameter2_1AnnotationTests
NamedStoredProcedureQuery2_1Annotation namedQuery = (NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, JPA2_1.NAMED_STORED_PROCEDURE_QUERY);
StoredProcedureParameter2_1Annotation parameter = namedQuery.parameterAt(0);
- assertEquals("MyType", parameter.getType());
+ assertEquals("MyType", parameter.getTypeName());
}
public void testSetType() throws Exception {
@@ -124,14 +124,14 @@ public class StoredProcedureParameter2_1AnnotationTests
NamedStoredProcedureQuery2_1Annotation namedQuery = (NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, JPA2_1.NAMED_STORED_PROCEDURE_QUERY);
StoredProcedureParameter2_1Annotation parameter = namedQuery.parameterAt(0);
- assertEquals("MyType", parameter.getType());
+ assertEquals("MyType", parameter.getTypeName());
- parameter.setType("Foo");
- assertEquals("Foo", parameter.getType());
+ parameter.setTypeName("Foo");
+ assertEquals("Foo", parameter.getTypeName());
assertSourceContains("@StoredProcedureParameter(name = \"MyParameter\", mode = ParameterMode.IN, type = Foo.class", cu);
- parameter.setType(null);
- assertNull(parameter.getType());
+ parameter.setTypeName(null);
+ assertNull(parameter.getTypeName());
assertSourceDoesNotContain("type", cu);
assertSourceContains("@StoredProcedureParameter(name = \"MyParameter\", mode = ParameterMode.IN", cu);
}
@@ -143,10 +143,10 @@ public class StoredProcedureParameter2_1AnnotationTests
NamedStoredProcedureQuery2_1Annotation namedQuery = (NamedStoredProcedureQuery2_1Annotation) resourceType.getAnnotation(0, JPA2_1.NAMED_STORED_PROCEDURE_QUERY);
StoredProcedureParameter2_1Annotation parameter = namedQuery.parameterAt(0);
- assertNotNull(parameter.getType());
+ assertNotNull(parameter.getTypeName());
assertEquals("MyType", parameter.getFullyQualifiedTypeName());
- parameter.setType(TYPE_NAME);
+ parameter.setTypeName(TYPE_NAME);
assertEquals(FULLY_QUALIFIED_TYPE_NAME, parameter.getFullyQualifiedTypeName());
assertSourceContains("@StoredProcedureParameter(name = \"MyParameter\", mode = ParameterMode.IN, type = " + TYPE_NAME + ".class)", cu);