Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortle2009-11-30 21:47:48 -0500
committertle2009-11-30 21:47:48 -0500
commit7f30f7b8ad5ff45efb1b0ec62ace1e7d0c528e63 (patch)
treec29f90d8dc93114d58573b36005a0893100b32d0
parent5c3cc4a22df3c7bbbed0ec72e383557a3277b571 (diff)
downloadwebtools.dali-7f30f7b8ad5ff45efb1b0ec62ace1e7d0c528e63.tar.gz
webtools.dali-7f30f7b8ad5ff45efb1b0ec62ace1e7d0c528e63.tar.xz
webtools.dali-7f30f7b8ad5ff45efb1b0ec62ace1e7d0c528e63.zip
258535 - [JPA 2.0] NamedQuery lockModeType support
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/resource/java/binary/BinaryNamedQueries1_0Annotation.java32
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/resource/java/binary/BinaryNamedQuery1_0Annotation.java27
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/resource/java/source/SourceNamedQuery1_0Annotation.java33
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/Generic2_0JpaAnnotationDefinitionProvider.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/GenericJpaFactory2_0.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaNamedQuery2_0.java87
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmNamedQuery2_0.java85
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmXml2_0ContextNodeFactory.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NamedQueries2_0AnnotationDefinition.java61
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NamedQuery2_0AnnotationDefinition.java61
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryNamedQueries2_0Annotation.java32
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryNamedQuery2_0Annotation.java69
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceNamedQueries2_0Annotation.java29
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceNamedQuery2_0Annotation.java132
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedQueriesAnnotationDefinition.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedQueryAnnotationDefinition.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueriesAnnotation.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueryAnnotation.java5
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseNamedQueryAnnotation.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueriesAnnotation.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueryAnnotation.java18
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/LockModeType_2_0.java117
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/NamedQuery2_0.java37
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/java/JavaNamedQuery2_0.java24
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/orm/OrmNamedQuery2_0.java26
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/resource/java/JPA2_0.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/resource/java/LockModeType_2_0.java72
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/resource/java/NamedQuery2_0Annotation.java49
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/NamedQueryAnnotation.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/NestableNamedQueryAnnotation.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/EclipseLink2_0JpaFactory.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/context/orm/EclipseLinkOrmXml2_0ContextNodeFactory.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/orm/AbstractEclipseLinkEntityMappingsDetailsPage.java5
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/v2_0/details/java/JavaEclipseLinkEntity2_0Composite.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/v2_0/details/orm/EclipseLinkEntityMappings2_0DetailsPage.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/v2_0/details/orm/OrmEclipseLinkEntity2_0Composite.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_details2_0.properties11
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/NamedQueryPropertyComposite.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/QueriesComposite.java36
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/AbstractEntityMappingsDetailsPage.java9
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmQueriesComposite.java12
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/JptUiDetailsMessages2_0.java12
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/LockModeComposite.java89
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/NamedQueryProperty2_0Composite.java67
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/Queries2_0Composite.java55
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/java/JavaEntity2_0Composite.java9
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/orm/EntityMappings2_0DetailsPage.java5
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/orm/OrmEntity2_0Composite.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/orm/OrmQueries2_0Composite.java43
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaEntity2_0Tests.java236
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/orm/GenericOrmEntity2_0Tests.java200
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedQueriesTests.java24
52 files changed, 1851 insertions, 70 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/resource/java/binary/BinaryNamedQueries1_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/resource/java/binary/BinaryNamedQueries1_0Annotation.java
new file mode 100644
index 0000000000..5d6435121f
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/resource/java/binary/BinaryNamedQueries1_0Annotation.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+* Copyright (c) 2009 Oracle. All rights reserved.
+* This program and the accompanying materials are made available under the
+* terms of the Eclipse Public License v1.0, which accompanies this distribution
+* and is available at http://www.eclipse.org/legal/epl-v10.html.
+*
+* Contributors:
+* Oracle - initial API and implementation
+*******************************************************************************/
+package org.eclipse.jpt.core.internal.jpa1.resource.java.binary;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jpt.core.internal.resource.java.binary.BinaryNamedQueriesAnnotation;
+import org.eclipse.jpt.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation;
+
+/**
+ * javax.persistence.NamedQueries
+ */
+public final class BinaryNamedQueries1_0Annotation
+ extends BinaryNamedQueriesAnnotation
+{
+ public BinaryNamedQueries1_0Annotation(JavaResourceNode parent, IAnnotation jdtAnnotation) {
+ super(parent, jdtAnnotation);
+ }
+
+ @Override
+ protected NamedQueryAnnotation buildNamedQuery(Object jdtQuery) {
+ return new BinaryNamedQuery1_0Annotation(this, (IAnnotation) jdtQuery);
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/resource/java/binary/BinaryNamedQuery1_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/resource/java/binary/BinaryNamedQuery1_0Annotation.java
new file mode 100644
index 0000000000..3ddb0353c1
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/resource/java/binary/BinaryNamedQuery1_0Annotation.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+* Copyright (c) 2009 Oracle. All rights reserved.
+* This program and the accompanying materials are made available under the
+* terms of the Eclipse Public License v1.0, which accompanies this distribution
+* and is available at http://www.eclipse.org/legal/epl-v10.html.
+*
+* Contributors:
+* Oracle - initial API and implementation
+*******************************************************************************/
+package org.eclipse.jpt.core.internal.jpa1.resource.java.binary;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jpt.core.internal.resource.java.binary.BinaryNamedQueryAnnotation;
+import org.eclipse.jpt.core.resource.java.JavaResourceNode;
+
+/**
+ * javax.persistence.NamedQuery
+ */
+public final class BinaryNamedQuery1_0Annotation
+ extends BinaryNamedQueryAnnotation
+{
+
+ public BinaryNamedQuery1_0Annotation(JavaResourceNode parent, IAnnotation jdtAnnotation) {
+ super(parent, jdtAnnotation);
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/resource/java/source/SourceNamedQuery1_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/resource/java/source/SourceNamedQuery1_0Annotation.java
new file mode 100644
index 0000000000..8aa0a58141
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/resource/java/source/SourceNamedQuery1_0Annotation.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+* Copyright (c) 2009 Oracle. All rights reserved.
+* This program and the accompanying materials are made available under the
+* terms of the Eclipse Public License v1.0, which accompanies this distribution
+* and is available at http://www.eclipse.org/legal/epl-v10.html.
+*
+* Contributors:
+* Oracle - initial API and implementation
+*******************************************************************************/
+package org.eclipse.jpt.core.internal.jpa1.resource.java.source;
+
+import org.eclipse.jpt.core.internal.resource.java.source.SourceNamedQueryAnnotation;
+import org.eclipse.jpt.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.Type;
+
+/**
+ * SourceNamedQuery1_0Annotation
+ */
+public final class SourceNamedQuery1_0Annotation
+ extends SourceNamedQueryAnnotation
+{
+
+ // ********** constructors **********
+ public SourceNamedQuery1_0Annotation(JavaResourceNode parent, Type type) {
+ super(parent, type);
+ }
+
+ public SourceNamedQuery1_0Annotation(JavaResourceNode parent, Type type, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
+ super(parent, type, daa, annotationAdapter);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/Generic2_0JpaAnnotationDefinitionProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/Generic2_0JpaAnnotationDefinitionProvider.java
index 7c9e549a09..b422f45d7e 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/Generic2_0JpaAnnotationDefinitionProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/Generic2_0JpaAnnotationDefinitionProvider.java
@@ -19,6 +19,8 @@ import org.eclipse.jpt.core.internal.jpa2.resource.java.AssociationOverrides2_0A
import org.eclipse.jpt.core.internal.jpa2.resource.java.Cacheable2_0AnnotationDefinition;
import org.eclipse.jpt.core.internal.jpa2.resource.java.ElementCollection2_0AnnotationDefinition;
import org.eclipse.jpt.core.internal.jpa2.resource.java.MapsId2_0AnnotationDefinition;
+import org.eclipse.jpt.core.internal.jpa2.resource.java.NamedQueries2_0AnnotationDefinition;
+import org.eclipse.jpt.core.internal.jpa2.resource.java.NamedQuery2_0AnnotationDefinition;
import org.eclipse.jpt.core.internal.jpa2.resource.java.OneToMany2_0AnnotationDefinition;
import org.eclipse.jpt.core.internal.jpa2.resource.java.OneToOne2_0AnnotationDefinition;
import org.eclipse.jpt.core.internal.jpa2.resource.java.OrderColumn2_0AnnotationDefinition;
@@ -48,8 +50,6 @@ import org.eclipse.jpt.core.internal.resource.java.MapKeyAnnotationDefinition;
import org.eclipse.jpt.core.internal.resource.java.MappedSuperclassAnnotationDefinition;
import org.eclipse.jpt.core.internal.resource.java.NamedNativeQueriesAnnotationDefinition;
import org.eclipse.jpt.core.internal.resource.java.NamedNativeQueryAnnotationDefinition;
-import org.eclipse.jpt.core.internal.resource.java.NamedQueriesAnnotationDefinition;
-import org.eclipse.jpt.core.internal.resource.java.NamedQueryAnnotationDefinition;
import org.eclipse.jpt.core.internal.resource.java.OrderByAnnotationDefinition;
import org.eclipse.jpt.core.internal.resource.java.PrimaryKeyJoinColumnAnnotationDefinition;
import org.eclipse.jpt.core.internal.resource.java.PrimaryKeyJoinColumnsAnnotationDefinition;
@@ -105,8 +105,8 @@ public class Generic2_0JpaAnnotationDefinitionProvider
definitions.add(IdClassAnnotationDefinition.instance());
definitions.add(InheritanceAnnotationDefinition.instance());
definitions.add(MappedSuperclassAnnotationDefinition.instance());
- definitions.add(NamedQueryAnnotationDefinition.instance());
- definitions.add(NamedQueriesAnnotationDefinition.instance());
+ definitions.add(NamedQuery2_0AnnotationDefinition.instance());
+ definitions.add(NamedQueries2_0AnnotationDefinition.instance());
definitions.add(NamedNativeQueryAnnotationDefinition.instance());
definitions.add(NamedNativeQueriesAnnotationDefinition.instance());
definitions.add(PrimaryKeyJoinColumnAnnotationDefinition.instance());
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/GenericJpaFactory2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/GenericJpaFactory2_0.java
index 6ee2dcdcf7..874eb7f1fb 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/GenericJpaFactory2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/GenericJpaFactory2_0.java
@@ -17,6 +17,7 @@ import org.eclipse.jpt.core.context.java.JavaAssociationOverrideContainer;
import org.eclipse.jpt.core.context.java.JavaAssociationOverrideRelationshipReference;
import org.eclipse.jpt.core.context.java.JavaEmbeddable;
import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
+import org.eclipse.jpt.core.context.java.JavaNamedQuery;
import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.core.context.java.JavaPersistentType;
import org.eclipse.jpt.core.context.java.JavaSequenceGenerator;
@@ -28,6 +29,7 @@ import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaDerivedId2_0;
import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaElementCollectionMapping2_0;
import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaEmbeddable2_0;
import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaMapsId2_0;
+import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaNamedQuery2_0;
import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaOrphanRemoval2_0;
import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaPersistentAttribute2_0;
import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaPersistentType2_0;
@@ -138,4 +140,9 @@ public class GenericJpaFactory2_0
public JavaOrphanRemovable2_0 buildJavaOrphanRemoval(JavaOrphanRemovalHolder2_0 parent) {
return new GenericJavaOrphanRemoval2_0(parent);
}
+
+ @Override
+ public JavaNamedQuery buildJavaNamedQuery(JavaJpaContextNode parent) {
+ return new GenericJavaNamedQuery2_0(parent);
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaNamedQuery2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaNamedQuery2_0.java
new file mode 100644
index 0000000000..73178a2130
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaNamedQuery2_0.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+* Copyright (c) 2009 Oracle. All rights reserved.
+* This program and the accompanying materials are made available under the
+* terms of the Eclipse Public License v1.0, which accompanies this distribution
+* and is available at http://www.eclipse.org/legal/epl-v10.html.
+*
+* Contributors:
+* Oracle - initial API and implementation
+*******************************************************************************/
+package org.eclipse.jpt.core.internal.jpa2.context.java;
+
+import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
+import org.eclipse.jpt.core.internal.context.java.AbstractJavaQuery;
+import org.eclipse.jpt.core.jpa2.context.LockModeType_2_0;
+import org.eclipse.jpt.core.jpa2.context.java.JavaNamedQuery2_0;
+import org.eclipse.jpt.core.jpa2.resource.java.NamedQuery2_0Annotation;
+import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation;
+
+/**
+ * GenericJavaNamedQuery2_0
+ */
+public class GenericJavaNamedQuery2_0 extends AbstractJavaQuery
+ implements JavaNamedQuery2_0
+{
+ private LockModeType_2_0 specifiedLockMode;
+ private LockModeType_2_0 defaultLockMode;
+
+ public GenericJavaNamedQuery2_0(JavaJpaContextNode parent) {
+ super(parent);
+ }
+
+ // ********** NamedQuery2_0 implementation **********
+
+ public LockModeType_2_0 getLockMode() {
+ return (this.specifiedLockMode != null) ? this.specifiedLockMode : this.defaultLockMode;
+ }
+
+ public LockModeType_2_0 getSpecifiedLockMode() {
+ return this.specifiedLockMode;
+ }
+
+ public void setSpecifiedLockMode(LockModeType_2_0 lockMode) {
+ LockModeType_2_0 old = this.specifiedLockMode;
+ this.specifiedLockMode = lockMode;
+ this.getResourceQuery().setLockMode(LockModeType_2_0.toJavaResourceModel(lockMode));
+ this.firePropertyChanged(SPECIFIED_LOCK_MODE_PROPERTY, old, lockMode);
+ }
+
+ protected void setSpecifiedLockMode_(LockModeType_2_0 lockMode) {
+ LockModeType_2_0 old = this.specifiedLockMode;
+ this.specifiedLockMode = lockMode;
+ this.firePropertyChanged(SPECIFIED_LOCK_MODE_PROPERTY, old, lockMode);
+ }
+
+ public LockModeType_2_0 getDefaultLockMode() {
+ return this.defaultLockMode;
+ }
+
+ protected void setDefaultLockMode(LockModeType_2_0 lockMode) {
+ LockModeType_2_0 old = this.defaultLockMode;
+ this.defaultLockMode = lockMode;
+ firePropertyChanged(DEFAULT_LOCK_MODE_PROPERTY, old, lockMode);
+ }
+
+ // ********** resource => context **********
+
+ public void initialize(NamedQueryAnnotation resourceQuery) {
+ super.initialize(resourceQuery);
+ this.specifiedLockMode = this.getResourceQueryLockMode(resourceQuery);
+ }
+
+ public void update(NamedQueryAnnotation resourceQuery) {
+ super.update(resourceQuery);
+ this.setSpecifiedLockMode_(this.getResourceQueryLockMode(resourceQuery));
+ }
+
+ @Override
+ protected NamedQuery2_0Annotation getResourceQuery() {
+ return (NamedQuery2_0Annotation) super.getResourceQuery();
+ }
+
+ protected LockModeType_2_0 getResourceQueryLockMode(NamedQueryAnnotation resourceQuery) {
+ return LockModeType_2_0.fromJavaResourceModel(
+ ((NamedQuery2_0Annotation)resourceQuery).getLockMode());
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmNamedQuery2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmNamedQuery2_0.java
new file mode 100644
index 0000000000..922adcbe75
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmNamedQuery2_0.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+* Copyright (c) 2009 Oracle. All rights reserved.
+* This program and the accompanying materials are made available under the
+* terms of the Eclipse Public License v1.0, which accompanies this distribution
+* and is available at http://www.eclipse.org/legal/epl-v10.html.
+*
+* Contributors:
+* Oracle - initial API and implementation
+*******************************************************************************/
+package org.eclipse.jpt.core.internal.jpa2.context.orm;
+
+import org.eclipse.jpt.core.context.XmlContextNode;
+import org.eclipse.jpt.core.internal.context.orm.AbstractOrmQuery;
+import org.eclipse.jpt.core.jpa2.context.LockModeType_2_0;
+import org.eclipse.jpt.core.jpa2.context.orm.OrmNamedQuery2_0;
+import org.eclipse.jpt.core.resource.orm.XmlNamedQuery;
+
+/**
+ * GenericOrmNamedQuery2_0
+ */
+public class GenericOrmNamedQuery2_0 extends AbstractOrmQuery<XmlNamedQuery>
+ implements OrmNamedQuery2_0
+{
+ private LockModeType_2_0 specifiedLockMode;
+ private LockModeType_2_0 defaultLockMode;
+
+ // ********** constructor **********
+ public GenericOrmNamedQuery2_0(XmlContextNode parent, XmlNamedQuery resourceNamedQuery) {
+ super(parent, resourceNamedQuery);
+ }
+
+ // ********** NamedQuery2_0 implementation **********
+
+ public LockModeType_2_0 getLockMode() {
+ return (this.specifiedLockMode != null) ? this.specifiedLockMode : this.defaultLockMode;
+ }
+
+ public LockModeType_2_0 getSpecifiedLockMode() {
+ return this.specifiedLockMode;
+ }
+
+ public void setSpecifiedLockMode(LockModeType_2_0 lockMode) {
+ LockModeType_2_0 old = this.specifiedLockMode;
+ this.specifiedLockMode = lockMode;
+ this.getResourceQuery().setLockMode(LockModeType_2_0.toOrmResourceModel(lockMode));
+ this.firePropertyChanged(SPECIFIED_LOCK_MODE_PROPERTY, old, lockMode);
+ }
+
+ public void setSpecifiedLockMode_(LockModeType_2_0 lockMode) {
+ LockModeType_2_0 old = this.specifiedLockMode;
+ this.specifiedLockMode = lockMode;
+ this.firePropertyChanged(SPECIFIED_LOCK_MODE_PROPERTY, old, lockMode);
+ }
+
+ public LockModeType_2_0 getDefaultLockMode() {
+ return this.defaultLockMode;
+ }
+
+ protected void setDefaultLockMode(LockModeType_2_0 lockMode) {
+ LockModeType_2_0 old = this.defaultLockMode;
+ this.defaultLockMode = lockMode;
+ this.firePropertyChanged(DEFAULT_LOCK_MODE_PROPERTY, old, lockMode);
+ }
+
+ // ********** resource => context **********
+
+ @Override
+ protected void initialize(XmlNamedQuery xmlQuery) {
+ super.initialize(xmlQuery);
+
+ this.specifiedLockMode = this.getResourceLockModeOf(xmlQuery);
+ }
+
+ @Override
+ public void update(XmlNamedQuery xmlQuery) {
+ super.update(xmlQuery);
+
+ this.setSpecifiedLockMode_(this.getResourceLockModeOf(xmlQuery));
+ }
+
+ private LockModeType_2_0 getResourceLockModeOf(XmlNamedQuery xmlQuery) {
+ return LockModeType_2_0.fromOrmResourceModel(xmlQuery.getLockMode());
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmXml2_0ContextNodeFactory.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmXml2_0ContextNodeFactory.java
index 611795c0ae..fc9b028744 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmXml2_0ContextNodeFactory.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmXml2_0ContextNodeFactory.java
@@ -26,6 +26,7 @@ import org.eclipse.jpt.core.context.orm.OrmAssociationOverride;
import org.eclipse.jpt.core.context.orm.OrmAssociationOverrideContainer;
import org.eclipse.jpt.core.context.orm.OrmAssociationOverrideRelationshipReference;
import org.eclipse.jpt.core.context.orm.OrmEmbeddable;
+import org.eclipse.jpt.core.context.orm.OrmNamedQuery;
import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
import org.eclipse.jpt.core.context.orm.OrmPersistentType;
import org.eclipse.jpt.core.context.orm.OrmSequenceGenerator;
@@ -55,6 +56,7 @@ import org.eclipse.jpt.core.resource.orm.XmlEmbeddedId;
import org.eclipse.jpt.core.resource.orm.XmlId;
import org.eclipse.jpt.core.resource.orm.XmlManyToMany;
import org.eclipse.jpt.core.resource.orm.XmlManyToOne;
+import org.eclipse.jpt.core.resource.orm.XmlNamedQuery;
import org.eclipse.jpt.core.resource.orm.XmlNullAttributeMapping;
import org.eclipse.jpt.core.resource.orm.XmlOneToMany;
import org.eclipse.jpt.core.resource.orm.XmlOneToOne;
@@ -128,6 +130,11 @@ public class GenericOrmXml2_0ContextNodeFactory extends AbstractOrmXmlContextNod
return new GenericOrmOrphanRemoval2_0(parent, resource);
}
+ @Override
+ public OrmNamedQuery buildOrmNamedQuery(XmlContextNode parent, XmlNamedQuery resourceNamedQuery) {
+ return new GenericOrmNamedQuery2_0(parent, resourceNamedQuery);
+ }
+
// ********** ORM Virtual Resource Model **********
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NamedQueries2_0AnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NamedQueries2_0AnnotationDefinition.java
new file mode 100644
index 0000000000..2c17accad0
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NamedQueries2_0AnnotationDefinition.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+* Copyright (c) 2009 Oracle. All rights reserved.
+* This program and the accompanying materials are made available under the
+* terms of the Eclipse Public License v1.0, which accompanies this distribution
+* and is available at http://www.eclipse.org/legal/epl-v10.html.
+*
+* Contributors:
+* Oracle - initial API and implementation
+*******************************************************************************/
+package org.eclipse.jpt.core.internal.jpa2.resource.java;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jpt.core.internal.jpa2.resource.java.binary.BinaryNamedQueries2_0Annotation;
+import org.eclipse.jpt.core.internal.jpa2.resource.java.source.SourceNamedQueries2_0Annotation;
+import org.eclipse.jpt.core.resource.java.Annotation;
+import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
+import org.eclipse.jpt.core.resource.java.NamedQueriesAnnotation;
+import org.eclipse.jpt.core.utility.jdt.Member;
+import org.eclipse.jpt.core.utility.jdt.Type;
+
+/**
+ * javax.persistence.NamedQueries
+ */
+public class NamedQueries2_0AnnotationDefinition
+ implements AnnotationDefinition
+{
+ // singleton
+ private static final AnnotationDefinition INSTANCE = new NamedQueries2_0AnnotationDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static AnnotationDefinition instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Ensure single instance.
+ */
+ private NamedQueries2_0AnnotationDefinition() {
+ super();
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) {
+ return new SourceNamedQueries2_0Annotation(parent, (Type) member);
+ }
+
+ public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) {
+ return new BinaryNamedQueries2_0Annotation(parent, jdtAnnotation);
+ }
+
+ public String getAnnotationName() {
+ return NamedQueriesAnnotation.ANNOTATION_NAME;
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NamedQuery2_0AnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NamedQuery2_0AnnotationDefinition.java
new file mode 100644
index 0000000000..5c09d18be5
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NamedQuery2_0AnnotationDefinition.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+* Copyright (c) 2009 Oracle. All rights reserved.
+* This program and the accompanying materials are made available under the
+* terms of the Eclipse Public License v1.0, which accompanies this distribution
+* and is available at http://www.eclipse.org/legal/epl-v10.html.
+*
+* Contributors:
+* Oracle - initial API and implementation
+*******************************************************************************/
+package org.eclipse.jpt.core.internal.jpa2.resource.java;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jpt.core.internal.jpa2.resource.java.binary.BinaryNamedQuery2_0Annotation;
+import org.eclipse.jpt.core.internal.jpa2.resource.java.source.SourceNamedQuery2_0Annotation;
+import org.eclipse.jpt.core.resource.java.Annotation;
+import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
+import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation;
+import org.eclipse.jpt.core.utility.jdt.Member;
+import org.eclipse.jpt.core.utility.jdt.Type;
+
+/**
+ * javax.persistence.NamedQuery
+ */
+public class NamedQuery2_0AnnotationDefinition
+ implements AnnotationDefinition
+{
+ // singleton
+ private static final AnnotationDefinition INSTANCE = new NamedQuery2_0AnnotationDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static AnnotationDefinition instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Ensure single instance.
+ */
+ private NamedQuery2_0AnnotationDefinition() {
+ super();
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) {
+ return new SourceNamedQuery2_0Annotation(parent, (Type) member);
+ }
+
+ public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) {
+ return new BinaryNamedQuery2_0Annotation(parent, jdtAnnotation);
+ }
+
+ public String getAnnotationName() {
+ return NamedQueryAnnotation.ANNOTATION_NAME;
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryNamedQueries2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryNamedQueries2_0Annotation.java
new file mode 100644
index 0000000000..23c5499dff
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryNamedQueries2_0Annotation.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+* Copyright (c) 2009 Oracle. All rights reserved.
+* This program and the accompanying materials are made available under the
+* terms of the Eclipse Public License v1.0, which accompanies this distribution
+* and is available at http://www.eclipse.org/legal/epl-v10.html.
+*
+* Contributors:
+* Oracle - initial API and implementation
+*******************************************************************************/
+package org.eclipse.jpt.core.internal.jpa2.resource.java.binary;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jpt.core.internal.resource.java.binary.BinaryNamedQueriesAnnotation;
+import org.eclipse.jpt.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation;
+
+/**
+ * javax.persistence.NamedQueries
+ */
+public final class BinaryNamedQueries2_0Annotation
+ extends BinaryNamedQueriesAnnotation
+{
+ public BinaryNamedQueries2_0Annotation(JavaResourceNode parent, IAnnotation jdtAnnotation) {
+ super(parent, jdtAnnotation);
+ }
+
+ @Override
+ protected NamedQueryAnnotation buildNamedQuery(Object jdtQuery) {
+ return new BinaryNamedQuery2_0Annotation(this, (IAnnotation) jdtQuery);
+ }
+
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryNamedQuery2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryNamedQuery2_0Annotation.java
new file mode 100644
index 0000000000..c42b1289dd
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryNamedQuery2_0Annotation.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+* Copyright (c) 2009 Oracle. All rights reserved.
+* This program and the accompanying materials are made available under the
+* terms of the Eclipse Public License v1.0, which accompanies this distribution
+* and is available at http://www.eclipse.org/legal/epl-v10.html.
+*
+* Contributors:
+* Oracle - initial API and implementation
+*******************************************************************************/
+package org.eclipse.jpt.core.internal.jpa2.resource.java.binary;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.resource.java.binary.BinaryNamedQueryAnnotation;
+import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0;
+import org.eclipse.jpt.core.jpa2.resource.java.LockModeType_2_0;
+import org.eclipse.jpt.core.jpa2.resource.java.NamedQuery2_0Annotation;
+import org.eclipse.jpt.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.core.utility.TextRange;
+
+/**
+ * BinaryNamedQuery2_0Annotation
+ */
+public final class BinaryNamedQuery2_0Annotation
+ extends BinaryNamedQueryAnnotation
+ implements NamedQuery2_0Annotation
+{
+ private LockModeType_2_0 lockMode;
+
+ public BinaryNamedQuery2_0Annotation(JavaResourceNode parent, IAnnotation jdtAnnotation) {
+ super(parent, jdtAnnotation);
+ this.lockMode = this.buildLockMode();
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ this.setLockMode_(this.buildLockMode());
+ }
+
+ // ********** NamedQuery2_0Annotation implementation **********
+
+ public LockModeType_2_0 getLockMode() {
+ return this.lockMode;
+ }
+
+ public void setLockMode(LockModeType_2_0 lockMode) {
+ throw new UnsupportedOperationException();
+ }
+
+ private void setLockMode_(LockModeType_2_0 lockMode) {
+ LockModeType_2_0 old = this.lockMode;
+ this.lockMode = lockMode;
+ this.firePropertyChanged(LOCK_MODE_PROPERTY, old, lockMode);
+ }
+
+ public TextRange getLockModeTextRange(CompilationUnit astRoot) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean lockModeTouches(int pos, CompilationUnit astRoot) {
+ throw new UnsupportedOperationException();
+ }
+
+ private LockModeType_2_0 buildLockMode() {
+ return LockModeType_2_0.fromJavaAnnotationValue(this.getJdtMemberValue(JPA2_0.NAMED_QUERY__LOCK_MODE));
+ }
+
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceNamedQueries2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceNamedQueries2_0Annotation.java
new file mode 100644
index 0000000000..82f15d31a9
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceNamedQueries2_0Annotation.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+* Copyright (c) 2009 Oracle. All rights reserved.
+* This program and the accompanying materials are made available under the
+* terms of the Eclipse Public License v1.0, which accompanies this distribution
+* and is available at http://www.eclipse.org/legal/epl-v10.html.
+*
+* Contributors:
+* Oracle - initial API and implementation
+*******************************************************************************/
+package org.eclipse.jpt.core.internal.jpa2.resource.java.source;
+
+import org.eclipse.jpt.core.internal.resource.java.source.SourceNamedQueriesAnnotation;
+import org.eclipse.jpt.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.core.resource.java.NestableNamedQueryAnnotation;
+import org.eclipse.jpt.core.utility.jdt.Type;
+
+/**
+ * SourceNamedQueries2_0Annotation
+ */
+public class SourceNamedQueries2_0Annotation extends SourceNamedQueriesAnnotation
+{
+ public SourceNamedQueries2_0Annotation(JavaResourceNode parent, Type type) {
+ super(parent, type);
+ }
+
+ protected NestableNamedQueryAnnotation buildNamedQuery(int index) {
+ return SourceNamedQuery2_0Annotation.createNestedNamedQuery(this, member, index, this.daa);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceNamedQuery2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceNamedQuery2_0Annotation.java
new file mode 100644
index 0000000000..e554df0082
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceNamedQuery2_0Annotation.java
@@ -0,0 +1,132 @@
+/*******************************************************************************
+* Copyright (c) 2009 Oracle. All rights reserved.
+* This program and the accompanying materials are made available under the
+* terms of the Eclipse Public License v1.0, which accompanies this distribution
+* and is available at http://www.eclipse.org/legal/epl-v10.html.
+*
+* Contributors:
+* Oracle - initial API and implementation
+*******************************************************************************/
+package org.eclipse.jpt.core.internal.jpa2.resource.java.source;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.resource.java.source.SourceNamedQueryAnnotation;
+import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter;
+import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0;
+import org.eclipse.jpt.core.jpa2.resource.java.LockModeType_2_0;
+import org.eclipse.jpt.core.jpa2.resource.java.NamedQuery2_0Annotation;
+import org.eclipse.jpt.core.resource.java.JPA;
+import org.eclipse.jpt.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.core.resource.java.NestableAnnotation;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.Type;
+
+/**
+ * SourceNamedQuery2_0Annotation
+ */
+public final class SourceNamedQuery2_0Annotation
+ extends SourceNamedQueryAnnotation
+ implements NamedQuery2_0Annotation
+{
+ private final DeclarationAnnotationElementAdapter<String> lockModeDeclarationAdapter;
+ private final AnnotationElementAdapter<String> lockModeAdapter;
+ private LockModeType_2_0 lockMode;
+
+ // ********** constructors **********
+ public SourceNamedQuery2_0Annotation(JavaResourceNode parent, Type type, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
+ super(parent, type, daa, annotationAdapter);
+ this.lockModeDeclarationAdapter = this.buildLockModeTypeAdapter(daa);
+ this.lockModeAdapter = new ShortCircuitAnnotationElementAdapter<String>(type, this.lockModeDeclarationAdapter);
+ }
+
+ public SourceNamedQuery2_0Annotation(JavaResourceNode parent, Type type) {
+ this(parent, type, DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(type, DECLARATION_ANNOTATION_ADAPTER));
+ }
+
+ private DeclarationAnnotationElementAdapter<String> buildLockModeTypeAdapter(DeclarationAnnotationAdapter daa) {
+ return new EnumDeclarationAnnotationElementAdapter(daa, this.getLockModeElementName());
+ }
+
+ private String getLockModeElementName() {
+ return JPA2_0.NAMED_QUERY__LOCK_MODE;
+ }
+
+ // ********** initialize/update **********
+ @Override
+ public void initialize(CompilationUnit astRoot) {
+ super.initialize(astRoot);
+ this.lockMode = this.buildLockMode(astRoot);
+ }
+
+ @Override
+ public void initializeFrom(NestableAnnotation oldAnnotation) {
+ super.initializeFrom(oldAnnotation);
+
+ NamedQuery2_0Annotation old = (NamedQuery2_0Annotation) oldAnnotation;
+ this.setLockMode(old.getLockMode());
+ }
+
+ @Override
+ public void update(CompilationUnit astRoot) {
+ super.update(astRoot);
+ this.setLockMode(this.buildLockMode(astRoot));
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.lockMode);
+ }
+
+ // ********** NamedQuery2_0Annotation implementation **********
+
+ public LockModeType_2_0 getLockMode() {
+ return this.lockMode;
+ }
+
+ public void setLockMode(LockModeType_2_0 lockMode) {
+ if (this.attributeValueHasNotChanged(this.lockMode, lockMode)) {
+ return;
+ }
+ LockModeType_2_0 old = this.lockMode;
+ this.lockMode = lockMode;
+ this.lockModeAdapter.setValue(LockModeType_2_0.toJavaAnnotationValue(lockMode));
+ this.firePropertyChanged(LOCK_MODE_PROPERTY, old, lockMode);
+ }
+
+ private LockModeType_2_0 buildLockMode(CompilationUnit astRoot) {
+ return LockModeType_2_0.fromJavaAnnotationValue(this.lockModeAdapter.getValue(astRoot));
+ }
+
+ public TextRange getLockModeTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.lockModeDeclarationAdapter, astRoot);
+ }
+
+ public boolean lockModeTouches(int pos, CompilationUnit astRoot) {
+ return this.elementTouches(this.lockModeDeclarationAdapter, pos, astRoot);
+ }
+
+
+ // ********** static methods **********
+
+ static SourceNamedQuery2_0Annotation createNestedNamedQuery(JavaResourceNode parent, Type type, int index, DeclarationAnnotationAdapter attributeOverridesAdapter) {
+ IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, attributeOverridesAdapter);
+ IndexedAnnotationAdapter annotationAdapter = new MemberIndexedAnnotationAdapter(type, idaa);
+
+ return new SourceNamedQuery2_0Annotation(parent, type, idaa, annotationAdapter);
+ }
+
+ private static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter namedQueriesAdapter) {
+ return new NestedIndexedDeclarationAnnotationAdapter(namedQueriesAdapter, index, JPA.NAMED_QUERY);
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedQueriesAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedQueriesAnnotationDefinition.java
index 6220ca19d7..e560b3e62d 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedQueriesAnnotationDefinition.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedQueriesAnnotationDefinition.java
@@ -10,7 +10,7 @@
package org.eclipse.jpt.core.internal.resource.java;
import org.eclipse.jdt.core.IAnnotation;
-import org.eclipse.jpt.core.internal.resource.java.binary.BinaryNamedQueriesAnnotation;
+import org.eclipse.jpt.core.internal.jpa1.resource.java.binary.BinaryNamedQueries1_0Annotation;
import org.eclipse.jpt.core.internal.resource.java.source.SourceNamedQueriesAnnotation;
import org.eclipse.jpt.core.resource.java.Annotation;
import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
@@ -51,7 +51,7 @@ public final class NamedQueriesAnnotationDefinition
}
public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) {
- return new BinaryNamedQueriesAnnotation(parent, jdtAnnotation);
+ return new BinaryNamedQueries1_0Annotation(parent, jdtAnnotation);
}
public String getAnnotationName() {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedQueryAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedQueryAnnotationDefinition.java
index 2b40783b96..9685560628 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedQueryAnnotationDefinition.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedQueryAnnotationDefinition.java
@@ -10,8 +10,8 @@
package org.eclipse.jpt.core.internal.resource.java;
import org.eclipse.jdt.core.IAnnotation;
-import org.eclipse.jpt.core.internal.resource.java.binary.BinaryNamedQueryAnnotation;
-import org.eclipse.jpt.core.internal.resource.java.source.SourceNamedQueryAnnotation;
+import org.eclipse.jpt.core.internal.jpa1.resource.java.binary.BinaryNamedQuery1_0Annotation;
+import org.eclipse.jpt.core.internal.jpa1.resource.java.source.SourceNamedQuery1_0Annotation;
import org.eclipse.jpt.core.resource.java.Annotation;
import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
@@ -43,7 +43,7 @@ public final class NamedQueryAnnotationDefinition
}
public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) {
- return SourceNamedQueryAnnotation.createNamedQuery(parent, (Type) member);
+ return new SourceNamedQuery1_0Annotation(parent, (Type) member);
}
public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) {
@@ -51,7 +51,7 @@ public final class NamedQueryAnnotationDefinition
}
public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) {
- return new BinaryNamedQueryAnnotation(parent, jdtAnnotation);
+ return new BinaryNamedQuery1_0Annotation(parent, jdtAnnotation);
}
public String getAnnotationName() {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueriesAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueriesAnnotation.java
index f671570332..4a069ab1c7 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueriesAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueriesAnnotation.java
@@ -16,13 +16,14 @@ import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jpt.core.resource.java.JPA;
import org.eclipse.jpt.core.resource.java.JavaResourceNode;
import org.eclipse.jpt.core.resource.java.NamedQueriesAnnotation;
+import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation;
import org.eclipse.jpt.core.resource.java.NestableNamedQueryAnnotation;
import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
/**
* javax.persistence.NamedQueries
*/
-public final class BinaryNamedQueriesAnnotation
+public abstract class BinaryNamedQueriesAnnotation
extends BinaryContainerAnnotation<NestableNamedQueryAnnotation>
implements NamedQueriesAnnotation
{
@@ -50,11 +51,13 @@ public final class BinaryNamedQueriesAnnotation
Object[] jdtQueries = this.getJdtMemberValues(JPA.NAMED_QUERIES__VALUE);
Vector<NestableNamedQueryAnnotation> result = new Vector<NestableNamedQueryAnnotation>(jdtQueries.length);
for (Object jdtQuery : jdtQueries) {
- result.add(new BinaryNamedQueryAnnotation(this, (IAnnotation) jdtQuery));
+ result.add(this.buildNamedQuery(jdtQuery));
}
return result;
}
+ protected abstract NamedQueryAnnotation buildNamedQuery(Object jdtQuery);
+
@Override
public void update() {
super.update();
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueryAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueryAnnotation.java
index 95b7b0e2a0..158384ddb8 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueryAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueryAnnotation.java
@@ -12,14 +12,15 @@ package org.eclipse.jpt.core.internal.resource.java.binary;
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jpt.core.resource.java.JPA;
import org.eclipse.jpt.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation;
import org.eclipse.jpt.core.resource.java.NestableNamedQueryAnnotation;
/**
* javax.persistence.NamedQuery
*/
-public final class BinaryNamedQueryAnnotation
+public abstract class BinaryNamedQueryAnnotation
extends BinaryBaseNamedQueryAnnotation
- implements NestableNamedQueryAnnotation
+ implements NestableNamedQueryAnnotation, NamedQueryAnnotation
{
public BinaryNamedQueryAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) {
super(parent, jdtAnnotation);
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseNamedQueryAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseNamedQueryAnnotation.java
index 20e69a94f7..530bcbcfe6 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseNamedQueryAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseNamedQueryAnnotation.java
@@ -76,7 +76,7 @@ abstract class SourceBaseNamedQueryAnnotation
/**
* convenience method
*/
- AnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationElementAdapter<String> daea) {
+ protected AnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationElementAdapter<String> daea) {
return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea);
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueriesAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueriesAnnotation.java
index 25734c6cc4..334e628a28 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueriesAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueriesAnnotation.java
@@ -27,7 +27,7 @@ import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
/**
* javax.persistence.NamedQueries
*/
-public final class SourceNamedQueriesAnnotation
+public class SourceNamedQueriesAnnotation
extends SourceAnnotation<Type>
implements NamedQueriesAnnotation
{
@@ -90,7 +90,7 @@ public final class SourceNamedQueriesAnnotation
return namedQuery;
}
- private NestableNamedQueryAnnotation buildNamedQuery(int index) {
+ protected NestableNamedQueryAnnotation buildNamedQuery(int index) {
return SourceNamedQueryAnnotation.createNestedNamedQuery(this, member, index, this.daa);
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueryAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueryAnnotation.java
index 3408082826..a1cab17e6f 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueryAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueryAnnotation.java
@@ -9,13 +9,14 @@
******************************************************************************/
package org.eclipse.jpt.core.internal.resource.java.source;
+import org.eclipse.jpt.core.internal.jpa1.resource.java.source.SourceNamedQuery1_0Annotation;
import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter;
import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter;
import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter;
import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
import org.eclipse.jpt.core.resource.java.JPA;
import org.eclipse.jpt.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.core.resource.java.NestableNamedQueryAnnotation;
+import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation;
import org.eclipse.jpt.core.resource.java.NestableQueryHintAnnotation;
import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
@@ -26,12 +27,16 @@ import org.eclipse.jpt.core.utility.jdt.Type;
/**
* javax.persistence.NamedQuery
*/
-public final class SourceNamedQueryAnnotation
+public abstract class SourceNamedQueryAnnotation
extends SourceBaseNamedQueryAnnotation
- implements NestableNamedQueryAnnotation
+ implements NamedQueryAnnotation
{
public static final SimpleDeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
+ // ********** constructors **********
+ public SourceNamedQueryAnnotation(JavaResourceNode parent, Type type) {
+ super(parent, type, DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(type, DECLARATION_ANNOTATION_ADAPTER));
+ }
public SourceNamedQueryAnnotation(JavaResourceNode parent, Type type, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
super(parent, type, daa, annotationAdapter);
@@ -67,14 +72,11 @@ public final class SourceNamedQueryAnnotation
// ********** static methods **********
- public static SourceNamedQueryAnnotation createNamedQuery(JavaResourceNode parent, Type type) {
- return new SourceNamedQueryAnnotation(parent, type, DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(type, DECLARATION_ANNOTATION_ADAPTER));
- }
-
static SourceNamedQueryAnnotation createNestedNamedQuery(JavaResourceNode parent, Type type, int index, DeclarationAnnotationAdapter attributeOverridesAdapter) {
IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, attributeOverridesAdapter);
IndexedAnnotationAdapter annotationAdapter = new MemberIndexedAnnotationAdapter(type, idaa);
- return new SourceNamedQueryAnnotation(parent, type, idaa, annotationAdapter);
+
+ return new SourceNamedQuery1_0Annotation(parent, type, idaa, annotationAdapter);
}
private static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter namedQueriesAdapter) {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/LockModeType_2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/LockModeType_2_0.java
new file mode 100644
index 0000000000..d366108a58
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/LockModeType_2_0.java
@@ -0,0 +1,117 @@
+/*******************************************************************************
+* Copyright (c) 2009 Oracle. All rights reserved.
+* This program and the accompanying materials are made available under the
+* terms of the Eclipse Public License v1.0, which accompanies this distribution
+* and is available at http://www.eclipse.org/legal/epl-v10.html.
+*
+* Contributors:
+* Oracle - initial API and implementation
+*******************************************************************************/
+package org.eclipse.jpt.core.jpa2.context;
+
+/**
+ * LockMode Type
+ *
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ */
+public enum LockModeType_2_0 {
+
+ READ(
+ org.eclipse.jpt.core.jpa2.resource.java.LockModeType_2_0.READ,
+ org.eclipse.jpt.core.resource.orm.v2_0.LockModeType_2_0.READ
+ ),
+ WRITE(
+ org.eclipse.jpt.core.jpa2.resource.java.LockModeType_2_0.WRITE,
+ org.eclipse.jpt.core.resource.orm.v2_0.LockModeType_2_0.WRITE
+ ),
+ OPTIMISTIC(
+ org.eclipse.jpt.core.jpa2.resource.java.LockModeType_2_0.OPTIMISTIC,
+ org.eclipse.jpt.core.resource.orm.v2_0.LockModeType_2_0.OPTIMISTIC
+ ),
+ OPTIMISTIC_FORCE_INCREMENT(
+ org.eclipse.jpt.core.jpa2.resource.java.LockModeType_2_0.OPTIMISTIC_FORCE_INCREMENT,
+ org.eclipse.jpt.core.resource.orm.v2_0.LockModeType_2_0.OPTIMISTIC_FORCE_INCREMENT
+ ),
+ PESSIMISTIC_READ(
+ org.eclipse.jpt.core.jpa2.resource.java.LockModeType_2_0.PESSIMISTIC_READ,
+ org.eclipse.jpt.core.resource.orm.v2_0.LockModeType_2_0.PESSIMISTIC_READ
+ ),
+ PESSIMISTIC_WRITE(
+ org.eclipse.jpt.core.jpa2.resource.java.LockModeType_2_0.PESSIMISTIC_WRITE,
+ org.eclipse.jpt.core.resource.orm.v2_0.LockModeType_2_0.PESSIMISTIC_WRITE
+ ),
+ PESSIMISTIC_FORCE_INCREMENT(
+ org.eclipse.jpt.core.jpa2.resource.java.LockModeType_2_0.PESSIMISTIC_FORCE_INCREMENT,
+ org.eclipse.jpt.core.resource.orm.v2_0.LockModeType_2_0.PESSIMISTIC_FORCE_INCREMENT
+ ),
+ NONE(
+ org.eclipse.jpt.core.jpa2.resource.java.LockModeType_2_0.NONE,
+ org.eclipse.jpt.core.resource.orm.v2_0.LockModeType_2_0.NONE
+ );
+
+
+ private org.eclipse.jpt.core.jpa2.resource.java.LockModeType_2_0 javaLockModeType;
+ private org.eclipse.jpt.core.resource.orm.v2_0.LockModeType_2_0 ormLockModeType;
+
+ LockModeType_2_0(org.eclipse.jpt.core.jpa2.resource.java.LockModeType_2_0 javaLockModeType, org.eclipse.jpt.core.resource.orm.v2_0.LockModeType_2_0 ormLockModeType) {
+ if (javaLockModeType == null) {
+ throw new NullPointerException();
+ }
+ if (ormLockModeType == null) {
+ throw new NullPointerException();
+ }
+ this.javaLockModeType = javaLockModeType;
+ this.ormLockModeType = ormLockModeType;
+ }
+
+ public org.eclipse.jpt.core.jpa2.resource.java.LockModeType_2_0 getJavaLockModeType() {
+ return this.javaLockModeType;
+ }
+
+ public org.eclipse.jpt.core.resource.orm.v2_0.LockModeType_2_0 getOrmLockModeType() {
+ return this.ormLockModeType;
+ }
+
+
+ // ********** static methods **********
+
+ public static LockModeType_2_0 fromJavaResourceModel(org.eclipse.jpt.core.jpa2.resource.java.LockModeType_2_0 javaLockModeType) {
+ return (javaLockModeType == null) ? null : fromJavaResourceModel_(javaLockModeType);
+ }
+
+ private static LockModeType_2_0 fromJavaResourceModel_(org.eclipse.jpt.core.jpa2.resource.java.LockModeType_2_0 javaLockModeType) {
+ for (LockModeType_2_0 lockModeType : LockModeType_2_0.values()) {
+ if (lockModeType.getJavaLockModeType() == javaLockModeType) {
+ return lockModeType;
+ }
+ }
+ return null;
+ }
+
+ public static org.eclipse.jpt.core.jpa2.resource.java.LockModeType_2_0 toJavaResourceModel(LockModeType_2_0 lockModeType) {
+ return (lockModeType == null) ? null : lockModeType.getJavaLockModeType();
+ }
+
+
+ public static LockModeType_2_0 fromOrmResourceModel(org.eclipse.jpt.core.resource.orm.v2_0.LockModeType_2_0 ormLockModeType) {
+ return (ormLockModeType == null) ? null : fromOrmResourceModel_(ormLockModeType);
+ }
+
+ private static LockModeType_2_0 fromOrmResourceModel_(org.eclipse.jpt.core.resource.orm.v2_0.LockModeType_2_0 ormLockModeType) {
+ for (LockModeType_2_0 lockModeType : LockModeType_2_0.values()) {
+ if (lockModeType.getOrmLockModeType() == ormLockModeType) {
+ return lockModeType;
+ }
+ }
+ return null;
+ }
+
+ public static org.eclipse.jpt.core.resource.orm.v2_0.LockModeType_2_0 toOrmResourceModel(LockModeType_2_0 lockModeType) {
+ return (lockModeType == null) ? null : lockModeType.getOrmLockModeType();
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/NamedQuery2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/NamedQuery2_0.java
new file mode 100644
index 0000000000..90375525ad
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/NamedQuery2_0.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+* Copyright (c) 2009 Oracle. All rights reserved.
+* This program and the accompanying materials are made available under the
+* terms of the Eclipse Public License v1.0, which accompanies this distribution
+* and is available at http://www.eclipse.org/legal/epl-v10.html.
+*
+* Contributors:
+* Oracle - initial API and implementation
+*******************************************************************************/
+package org.eclipse.jpt.core.jpa2.context;
+
+import org.eclipse.jpt.core.context.NamedQuery;
+
+/**
+ * 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.0
+ * @since 3.0
+ */
+public interface NamedQuery2_0 extends NamedQuery
+{
+ /**
+ * Return the specified lockMode if present, otherwise return the default
+ * lockMode.
+ */
+ LockModeType_2_0 getLockMode();
+ LockModeType_2_0 getSpecifiedLockMode();
+ void setSpecifiedLockMode(LockModeType_2_0 lockMode);
+ String SPECIFIED_LOCK_MODE_PROPERTY = "specifiedLockMode"; //$NON-NLS-1$
+ LockModeType_2_0 getDefaultLockMode();
+ String DEFAULT_LOCK_MODE_PROPERTY = "defaultLockMode"; //$NON-NLS-1$
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/java/JavaNamedQuery2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/java/JavaNamedQuery2_0.java
new file mode 100644
index 0000000000..b3180cd52e
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/java/JavaNamedQuery2_0.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+* Copyright (c) 2009 Oracle. All rights reserved.
+* This program and the accompanying materials are made available under the
+* terms of the Eclipse Public License v1.0, which accompanies this distribution
+* and is available at http://www.eclipse.org/legal/epl-v10.html.
+*
+* Contributors:
+* Oracle - initial API and implementation
+*******************************************************************************/
+package org.eclipse.jpt.core.jpa2.context.java;
+
+import org.eclipse.jpt.core.context.java.JavaNamedQuery;
+import org.eclipse.jpt.core.jpa2.context.NamedQuery2_0;
+
+/**
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ */
+public interface JavaNamedQuery2_0
+extends NamedQuery2_0, JavaNamedQuery
+{}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/orm/OrmNamedQuery2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/orm/OrmNamedQuery2_0.java
new file mode 100644
index 0000000000..cc29d62479
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/context/orm/OrmNamedQuery2_0.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+* Copyright (c) 2009 Oracle. All rights reserved.
+* This program and the accompanying materials are made available under the
+* terms of the Eclipse Public License v1.0, which accompanies this distribution
+* and is available at http://www.eclipse.org/legal/epl-v10.html.
+*
+* Contributors:
+* Oracle - initial API and implementation
+*******************************************************************************/
+package org.eclipse.jpt.core.jpa2.context.orm;
+
+import org.eclipse.jpt.core.context.orm.OrmNamedQuery;
+import org.eclipse.jpt.core.jpa2.context.NamedQuery2_0;
+
+/**
+ * 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.0
+ * @since 3.0
+ */
+public interface OrmNamedQuery2_0 extends OrmNamedQuery, NamedQuery2_0
+{}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/resource/java/JPA2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/resource/java/JPA2_0.java
index 69ae561b65..5f3f3d72b0 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/resource/java/JPA2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/resource/java/JPA2_0.java
@@ -44,6 +44,8 @@ public interface JPA2_0
String MAPS_ID = PACKAGE_ + "MapsId";
String MAPS_ID__VALUE = "value";
+ String NAMED_QUERY__LOCK_MODE = "lockMode";
+
String ONE_TO_MANY__ORPHAN_REMOVAL = "orphanRemoval";
String ONE_TO_ONE__ORPHAN_REMOVAL = "orphanRemoval";
@@ -60,6 +62,17 @@ public interface JPA2_0
String ACCESS_TYPE__FIELD = ACCESS_TYPE_ + "FIELD";
String ACCESS_TYPE__PROPERTY = ACCESS_TYPE_ + "PROPERTY";
+ String LOCK_MODE_TYPE = PACKAGE_ + "LockModeType";
+ String LOCK_MODE_TYPE_ = LOCK_MODE_TYPE + '.';
+ String LOCK_MODE_TYPE__READ = LOCK_MODE_TYPE_ + "READ";
+ String LOCK_MODE_TYPE__WRITE = LOCK_MODE_TYPE_ + "WRITE";
+ String LOCK_MODE_TYPE__OPTIMISTIC = LOCK_MODE_TYPE_ + "OPTIMISTIC";
+ String LOCK_MODE_TYPE__OPTIMISTIC_FORCE_INCREMENT = LOCK_MODE_TYPE_ + "OPTIMISTIC_FORCE_INCREMENT";
+ String LOCK_MODE_TYPE__PESSIMISTIC_READ = LOCK_MODE_TYPE_ + "PESSIMISTIC_READ";
+ String LOCK_MODE_TYPE__PESSIMISTIC_WRITE = LOCK_MODE_TYPE_ + "PESSIMISTIC_WRITE";
+ String LOCK_MODE_TYPE__PESSIMISTIC_FORCE_INCREMENT = LOCK_MODE_TYPE_ + "PESSIMISTIC_FORCE_INCREMENT";
+ String LOCK_MODE_TYPE__NONE = LOCK_MODE_TYPE_ + "NONE";
+
// JPA 2.0 metamodel
String METAMODEL_PACKAGE = PACKAGE_ + "metamodel";
String METAMODEL_PACKAGE_ = METAMODEL_PACKAGE + '.';
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/resource/java/LockModeType_2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/resource/java/LockModeType_2_0.java
new file mode 100644
index 0000000000..91b7545cf1
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/resource/java/LockModeType_2_0.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+* Copyright (c) 2009 Oracle. All rights reserved.
+* This program and the accompanying materials are made available under the
+* terms of the Eclipse Public License v1.0, which accompanies this distribution
+* and is available at http://www.eclipse.org/legal/epl-v10.html.
+*
+* Contributors:
+* Oracle - initial API and implementation
+*******************************************************************************/
+package org.eclipse.jpt.core.jpa2.resource.java;
+
+import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0;
+
+/**
+ * Corresponds to the JPA 2.0 enum
+ * javax.persistence.LockModeType
+ * <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.0
+ * @since 3.0
+ */
+public enum LockModeType_2_0 {
+
+ READ(JPA2_0.LOCK_MODE_TYPE__READ),
+ WRITE(JPA2_0.LOCK_MODE_TYPE__WRITE),
+ OPTIMISTIC(JPA2_0.LOCK_MODE_TYPE__OPTIMISTIC),
+ OPTIMISTIC_FORCE_INCREMENT(JPA2_0.LOCK_MODE_TYPE__OPTIMISTIC_FORCE_INCREMENT),
+ PESSIMISTIC_READ(JPA2_0.LOCK_MODE_TYPE__PESSIMISTIC_READ),
+ PESSIMISTIC_WRITE(JPA2_0.LOCK_MODE_TYPE__PESSIMISTIC_WRITE),
+ PESSIMISTIC_FORCE_INCREMENT(JPA2_0.LOCK_MODE_TYPE__PESSIMISTIC_FORCE_INCREMENT),
+ NONE(JPA2_0.LOCK_MODE_TYPE__NONE);
+
+
+ private String javaAnnotationValue;
+
+ LockModeType_2_0(String javaAnnotationValue) {
+ if (javaAnnotationValue == null) {
+ throw new NullPointerException();
+ }
+ this.javaAnnotationValue = javaAnnotationValue;
+ }
+
+ public String getJavaAnnotationValue() {
+ return this.javaAnnotationValue;
+ }
+
+
+ // ********** static methods **********
+
+ public static LockModeType_2_0 fromJavaAnnotationValue(Object javaAnnotationValue) {
+ return (javaAnnotationValue == null) ? null : fromJavaAnnotationValue_(javaAnnotationValue);
+ }
+
+ private static LockModeType_2_0 fromJavaAnnotationValue_(Object javaAnnotationValue) {
+ for (LockModeType_2_0 lockModeType : LockModeType_2_0.values()) {
+ if (lockModeType.getJavaAnnotationValue().equals(javaAnnotationValue)) {
+ return lockModeType;
+ }
+ }
+ return null;
+ }
+
+ public static String toJavaAnnotationValue(LockModeType_2_0 lockModeType) {
+ return (lockModeType == null) ? null : lockModeType.getJavaAnnotationValue();
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/resource/java/NamedQuery2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/resource/java/NamedQuery2_0Annotation.java
new file mode 100644
index 0000000000..8265f21aeb
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/resource/java/NamedQuery2_0Annotation.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+* Copyright (c) 2009 Oracle. All rights reserved.
+* This program and the accompanying materials are made available under the
+* terms of the Eclipse Public License v1.0, which accompanies this distribution
+* and is available at http://www.eclipse.org/legal/epl-v10.html.
+*
+* Contributors:
+* Oracle - initial API and implementation
+*******************************************************************************/
+package org.eclipse.jpt.core.jpa2.resource.java;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation;
+import org.eclipse.jpt.core.utility.TextRange;
+
+/**
+ * NamedQuery2_0Annotation
+ */
+public interface NamedQuery2_0Annotation
+ extends NamedQueryAnnotation
+{
+ // ********** lockMode **********
+ /**
+ * Corresponds to the 'lockMode' element of the NamedQuery annotation.
+ * Return null if the element does not exist in Java.
+ */
+ LockModeType_2_0 getLockMode();
+ String LOCK_MODE_PROPERTY = "lockMode"; //$NON-NLS-1$
+
+ /**
+ * Corresponds to the 'lockMode' element of the NamedQuery annotation.
+ * Set to null to remove the element. If no other elements exist
+ * the NamedQuery annotation will be removed as well.
+ */
+ void setLockMode(LockModeType_2_0 lockMode);
+
+ /**
+ * Return the {@link TextRange} for the 'lockMode' element. If the element
+ * does not exist return the {@link TextRange} for the NamedQuery annotation.
+ */
+ TextRange getLockModeTextRange(CompilationUnit astRoot);
+
+ /**
+ * Return whether the specified position touches the 'lockMode' element.
+ * Return false if the element does not exist.
+ */
+ boolean lockModeTouches(int pos, CompilationUnit astRoot);
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/NamedQueryAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/NamedQueryAnnotation.java
index 4b458e9787..7e8e9f428c 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/NamedQueryAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/NamedQueryAnnotation.java
@@ -20,7 +20,7 @@ package org.eclipse.jpt.core.resource.java;
* will almost certainly be broken (repeatedly) as the API evolves.
*/
public interface NamedQueryAnnotation
- extends BaseNamedQueryAnnotation
+ extends NestableNamedQueryAnnotation
{
String ANNOTATION_NAME = JPA.NAMED_QUERY;
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/NestableNamedQueryAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/NestableNamedQueryAnnotation.java
index b903d4b438..06ffd10e16 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/NestableNamedQueryAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/NestableNamedQueryAnnotation.java
@@ -20,7 +20,7 @@ package org.eclipse.jpt.core.resource.java;
* will almost certainly be broken (repeatedly) as the API evolves.
*/
public interface NestableNamedQueryAnnotation
- extends NamedQueryAnnotation, NestableAnnotation
+ extends BaseNamedQueryAnnotation, NestableAnnotation
{
// combines two annotation
}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/EclipseLink2_0JpaFactory.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/EclipseLink2_0JpaFactory.java
index 93d296b724..64f7e3da20 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/EclipseLink2_0JpaFactory.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/EclipseLink2_0JpaFactory.java
@@ -16,6 +16,7 @@ import org.eclipse.jpt.core.context.java.JavaAssociationOverride;
import org.eclipse.jpt.core.context.java.JavaAssociationOverrideContainer;
import org.eclipse.jpt.core.context.java.JavaAssociationOverrideRelationshipReference;
import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
+import org.eclipse.jpt.core.context.java.JavaNamedQuery;
import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.core.context.java.JavaPersistentType;
import org.eclipse.jpt.core.context.java.JavaSequenceGenerator;
@@ -27,6 +28,7 @@ import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaCacheable2_0;
import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaDerivedId2_0;
import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaElementCollectionMapping2_0;
import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaMapsId2_0;
+import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaNamedQuery2_0;
import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaOrphanRemoval2_0;
import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaPersistentType2_0;
import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaSequenceGenerator2_0;
@@ -121,4 +123,9 @@ public class EclipseLink2_0JpaFactory
public JavaOrphanRemovable2_0 buildJavaOrphanRemoval(JavaOrphanRemovalHolder2_0 parent) {
return new GenericJavaOrphanRemoval2_0(parent);
}
+
+ @Override
+ public JavaNamedQuery buildJavaNamedQuery(JavaJpaContextNode parent) {
+ return new GenericJavaNamedQuery2_0(parent);
+ }
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/context/orm/EclipseLinkOrmXml2_0ContextNodeFactory.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/context/orm/EclipseLinkOrmXml2_0ContextNodeFactory.java
index 5dd3ef0bc3..72b0641e2f 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/context/orm/EclipseLinkOrmXml2_0ContextNodeFactory.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/context/orm/EclipseLinkOrmXml2_0ContextNodeFactory.java
@@ -23,6 +23,7 @@ import org.eclipse.jpt.core.context.java.JavaVersionMapping;
import org.eclipse.jpt.core.context.orm.OrmAssociationOverride;
import org.eclipse.jpt.core.context.orm.OrmAssociationOverrideContainer;
import org.eclipse.jpt.core.context.orm.OrmAssociationOverrideRelationshipReference;
+import org.eclipse.jpt.core.context.orm.OrmNamedQuery;
import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
import org.eclipse.jpt.core.context.orm.OrmPersistentType;
import org.eclipse.jpt.core.context.orm.OrmSequenceGenerator;
@@ -34,6 +35,7 @@ import org.eclipse.jpt.core.internal.jpa2.context.orm.GenericOrmCacheable2_0;
import org.eclipse.jpt.core.internal.jpa2.context.orm.GenericOrmDerivedId2_0;
import org.eclipse.jpt.core.internal.jpa2.context.orm.GenericOrmElementCollectionMapping2_0;
import org.eclipse.jpt.core.internal.jpa2.context.orm.GenericOrmMapsId2_0;
+import org.eclipse.jpt.core.internal.jpa2.context.orm.GenericOrmNamedQuery2_0;
import org.eclipse.jpt.core.internal.jpa2.context.orm.GenericOrmOrphanRemoval2_0;
import org.eclipse.jpt.core.internal.jpa2.context.orm.GenericOrmSequenceGenerator2_0;
import org.eclipse.jpt.core.internal.jpa2.context.orm.VirtualXmlAssociationOverride2_0;
@@ -50,6 +52,7 @@ import org.eclipse.jpt.core.jpa2.context.orm.OrmSingleRelationshipMapping2_0;
import org.eclipse.jpt.core.resource.orm.XmlAssociationOverride;
import org.eclipse.jpt.core.resource.orm.XmlAssociationOverrideContainer;
import org.eclipse.jpt.core.resource.orm.XmlElementCollection;
+import org.eclipse.jpt.core.resource.orm.XmlNamedQuery;
import org.eclipse.jpt.core.resource.orm.XmlNullAttributeMapping;
import org.eclipse.jpt.core.resource.orm.v2_0.XmlCacheable_2_0;
import org.eclipse.jpt.core.resource.orm.v2_0.XmlDerivedId_2_0;
@@ -134,6 +137,11 @@ public class EclipseLinkOrmXml2_0ContextNodeFactory extends EclipseLinkOrmXmlCon
public OrmOrphanRemovable2_0 buildOrmOrphanRemoval(OrmOrphanRemovalHolder2_0 parent, XmlOrphanRemovable_2_0 resource) {
return new GenericOrmOrphanRemoval2_0(parent, resource);
}
+
+ @Override
+ public OrmNamedQuery buildOrmNamedQuery(XmlContextNode parent, XmlNamedQuery resourceNamedQuery) {
+ return new GenericOrmNamedQuery2_0(parent, resourceNamedQuery);
+ }
// ********** ORM Virtual Resource Model **********
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/orm/AbstractEclipseLinkEntityMappingsDetailsPage.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/orm/AbstractEclipseLinkEntityMappingsDetailsPage.java
index df6e5a0345..9a0693af6d 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/orm/AbstractEclipseLinkEntityMappingsDetailsPage.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/orm/AbstractEclipseLinkEntityMappingsDetailsPage.java
@@ -137,10 +137,7 @@ public abstract class AbstractEclipseLinkEntityMappingsDetailsPage extends Abstr
this.buildEntityMappingsGeneratorsComposite(container);
// Queries pane
- new OrmQueriesComposite(
- this,
- container
- );
+ this.buildOrmQueriesComposite(container);
// Converters section
container = addCollapsableSection(
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/v2_0/details/java/JavaEclipseLinkEntity2_0Composite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/v2_0/details/java/JavaEclipseLinkEntity2_0Composite.java
index b2ca11b351..991a522355 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/v2_0/details/java/JavaEclipseLinkEntity2_0Composite.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/v2_0/details/java/JavaEclipseLinkEntity2_0Composite.java
@@ -11,6 +11,7 @@ package org.eclipse.jpt.eclipselink.ui.internal.v2_0.details.java;
import org.eclipse.jpt.core.context.AccessHolder;
import org.eclipse.jpt.core.context.GeneratorContainer;
+import org.eclipse.jpt.core.context.QueryContainer;
import org.eclipse.jpt.core.context.java.JavaEntity;
import org.eclipse.jpt.eclipselink.core.context.java.JavaEclipseLinkCaching;
import org.eclipse.jpt.eclipselink.core.context.java.JavaEclipseLinkEntity;
@@ -22,6 +23,7 @@ import org.eclipse.jpt.ui.internal.details.IdClassComposite;
import org.eclipse.jpt.ui.internal.details.TableComposite;
import org.eclipse.jpt.ui.internal.jpa2.details.Entity2_0OverridesComposite;
import org.eclipse.jpt.ui.internal.jpa2.details.Generation2_0Composite;
+import org.eclipse.jpt.ui.internal.jpa2.details.Queries2_0Composite;
import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.swt.widgets.Composite;
@@ -87,4 +89,9 @@ public class JavaEclipseLinkEntity2_0Composite extends AbstractJavaEclipseLinkEn
new JavaEclipseLinkCaching2_0Composite(this, cachingHolder, container);
}
+ @Override
+ protected void addQueriesComposite(Composite container, PropertyValueModel<QueryContainer> queryContainerHolder) {
+ new Queries2_0Composite(this, queryContainerHolder, container);
+ }
+
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/v2_0/details/orm/EclipseLinkEntityMappings2_0DetailsPage.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/v2_0/details/orm/EclipseLinkEntityMappings2_0DetailsPage.java
index 108d9bfe5a..881c486178 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/v2_0/details/orm/EclipseLinkEntityMappings2_0DetailsPage.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/v2_0/details/orm/EclipseLinkEntityMappings2_0DetailsPage.java
@@ -19,6 +19,7 @@ import org.eclipse.jpt.ui.internal.details.orm.OrmPackageChooser;
import org.eclipse.jpt.ui.internal.details.orm.OrmQueriesComposite;
import org.eclipse.jpt.ui.internal.details.orm.PersistenceUnitMetadataComposite;
import org.eclipse.jpt.ui.internal.jpa2.details.orm.EntityMappingsGenerators2_0Composite;
+import org.eclipse.jpt.ui.internal.jpa2.details.orm.OrmQueries2_0Composite;
import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer;
import org.eclipse.swt.widgets.Composite;
@@ -98,4 +99,9 @@ public class EclipseLinkEntityMappings2_0DetailsPage extends AbstractEclipseLink
);
}
+ @Override
+ protected void buildOrmQueriesComposite(Composite container) {
+ new OrmQueries2_0Composite(this, container);
+ }
+
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/v2_0/details/orm/OrmEclipseLinkEntity2_0Composite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/v2_0/details/orm/OrmEclipseLinkEntity2_0Composite.java
index 0f99e18a2a..fad681ca3e 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/v2_0/details/orm/OrmEclipseLinkEntity2_0Composite.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/v2_0/details/orm/OrmEclipseLinkEntity2_0Composite.java
@@ -11,12 +11,14 @@
package org.eclipse.jpt.eclipselink.ui.internal.v2_0.details.orm;
import org.eclipse.jpt.core.context.GeneratorContainer;
+import org.eclipse.jpt.core.context.QueryContainer;
import org.eclipse.jpt.core.context.orm.OrmEntity;
import org.eclipse.jpt.eclipselink.core.context.orm.OrmEclipseLinkCaching;
import org.eclipse.jpt.eclipselink.ui.internal.details.orm.AbstractOrmEclipseLinkEntityComposite;
import org.eclipse.jpt.ui.WidgetFactory;
import org.eclipse.jpt.ui.internal.jpa2.details.Entity2_0OverridesComposite;
import org.eclipse.jpt.ui.internal.jpa2.details.Generation2_0Composite;
+import org.eclipse.jpt.ui.internal.jpa2.details.Queries2_0Composite;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.swt.widgets.Composite;
@@ -43,4 +45,9 @@ public class OrmEclipseLinkEntity2_0Composite extends AbstractOrmEclipseLinkEnti
new OrmEclipseLinkCaching2_0Composite(this, cachingHolder, container);
}
+ @Override
+ protected void addQueriesComposite(Composite container, PropertyValueModel<QueryContainer> queryContainerHolder) {
+ new Queries2_0Composite(this, queryContainerHolder, container);
+ }
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_details2_0.properties b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_details2_0.properties
index d6e442e6d2..90b1bdc284 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_details2_0.properties
+++ b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_details2_0.properties
@@ -21,3 +21,14 @@ OrderingComposite_orderColumn=Order column
OrphanRemoval2_0Composite_orphanRemovalLabel=Orphan removal
OrphanRemoval2_0Composite_orphanRemovalLabelDefault=Orphan removal ({0})
+
+LockModeComposite_lockModeLabel = Lock mode:
+
+LockModeComposite_read = Read
+LockModeComposite_write = Write
+LockModeComposite_optimistic = Optimistic
+LockModeComposite_optimistic_force_increment = Optimistic Force Increment
+LockModeComposite_pessimistic_read = Pessimistic Read
+LockModeComposite_pessimistic_write = Pessimistic Write
+LockModeComposite_pessimistic_force_increment = Pessimistic Force Increment
+LockModeComposite_none = None
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/NamedQueryPropertyComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/NamedQueryPropertyComposite.java
index c27a26ab3a..bef74fcc9c 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/NamedQueryPropertyComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/NamedQueryPropertyComposite.java
@@ -43,7 +43,7 @@ import org.eclipse.swt.widgets.Composite;
* @version 2.0
* @since 2.0
*/
-public class NamedQueryPropertyComposite extends Pane<NamedQuery>
+public class NamedQueryPropertyComposite<T extends NamedQuery> extends Pane<T>
{
/**
* Creates a new <code>NamedQueryPropertyComposite</code>.
@@ -53,13 +53,13 @@ public class NamedQueryPropertyComposite extends Pane<NamedQuery>
* @param parent The parent container
*/
public NamedQueryPropertyComposite(Pane<?> parentPane,
- PropertyValueModel<? extends NamedQuery> subjectHolder,
+ PropertyValueModel<T> subjectHolder,
Composite parent) {
super(parentPane, subjectHolder, parent);
}
- private WritablePropertyValueModel<String> buildQueryHolder() {
+ protected WritablePropertyValueModel<String> buildQueryHolder() {
return new PropertyAspectAdapter<NamedQuery, String>(getSubjectHolder(), Query.QUERY_PROPERTY) {
@Override
protected String buildValue_() {
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/QueriesComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/QueriesComposite.java
index 4a361b0e36..e741243831 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/QueriesComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/QueriesComposite.java
@@ -75,10 +75,10 @@ public class QueriesComposite extends Pane<QueryContainer>
{
private AddRemoveListPane<QueryContainer> listPane;
private NamedNativeQueryPropertyComposite namedNativeQueryPane;
- private NamedQueryPropertyComposite namedQueryPane;
+ private NamedQueryPropertyComposite<? extends NamedQuery> namedQueryPane;
private WritablePropertyValueModel<Query> queryHolder;
-
+
public QueriesComposite(
Pane<?> parentPane,
PropertyValueModel<? extends QueryContainer> subjectHolder,
@@ -111,7 +111,7 @@ public class QueriesComposite extends Pane<QueryContainer>
throw new IllegalArgumentException();
}
query.setName(dialog.getName());
- this.queryHolder.setValue(query);//so that it gets selected in the List for the user to edit
+ this.getQueryHolder().setValue(query);//so that it gets selected in the List for the user to edit
}
private ListValueModel<Query> buildDisplayableQueriesListHolder() {
@@ -128,7 +128,7 @@ public class QueriesComposite extends Pane<QueryContainer>
container,
buildQueriesAdapter(),
buildDisplayableQueriesListHolder(),
- this.queryHolder,
+ this.getQueryHolder(),
buildQueriesListLabelProvider(),
JpaHelpContextIds.MAPPING_NAMED_QUERIES
);
@@ -152,7 +152,7 @@ public class QueriesComposite extends Pane<QueryContainer>
}
private PropertyValueModel<NamedNativeQuery> buildNamedNativeQueryHolder() {
- return new TransformationPropertyValueModel<Query, NamedNativeQuery>(this.queryHolder) {
+ return new TransformationPropertyValueModel<Query, NamedNativeQuery>(this.getQueryHolder()) {
@Override
protected NamedNativeQuery transform_(Query value) {
return (value instanceof NamedNativeQuery) ? (NamedNativeQuery) value : null;
@@ -178,7 +178,7 @@ public class QueriesComposite extends Pane<QueryContainer>
}
private PropertyValueModel<NamedQuery> buildNamedQueryHolder() {
- return new TransformationPropertyValueModel<Query, NamedQuery>(this.queryHolder) {
+ return new TransformationPropertyValueModel<Query, NamedQuery>(this.getQueryHolder()) {
@Override
protected NamedQuery transform_(Query value) {
return (value instanceof NamedQuery) ? (NamedQuery) value : null;
@@ -276,30 +276,38 @@ public class QueriesComposite extends Pane<QueryContainer>
protected void initializeLayout(Composite container) {
// List pane
- this.listPane = addListPane(container);
+ this.listPane = this.addListPane(container);
// Property pane
PageBook pageBook = new PageBook(container, SWT.NULL);
pageBook.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// Named Query property pane
- this.namedQueryPane = new NamedQueryPropertyComposite(
- this,
- buildNamedQueryHolder(),
- pageBook
- );
+ this.namedQueryPane = this.buildNamedQueryPropertyComposite(pageBook);
// Named Native Query property pane
this.namedNativeQueryPane = new NamedNativeQueryPropertyComposite(
this,
- buildNamedNativeQueryHolder(),
+ this.buildNamedNativeQueryHolder(),
pageBook
);
installPaneSwitcher(pageBook);
}
+
+ protected NamedQueryPropertyComposite<? extends NamedQuery> buildNamedQueryPropertyComposite(PageBook pageBook) {
+ return new NamedQueryPropertyComposite<NamedQuery>(
+ this,
+ this.buildNamedQueryHolder(),
+ pageBook
+ );
+ }
private void installPaneSwitcher(PageBook pageBook) {
- new ControlSwitcher(this.queryHolder, buildPaneTransformer(), pageBook);
+ new ControlSwitcher(this.getQueryHolder(), this.buildPaneTransformer(), pageBook);
+ }
+
+ protected WritablePropertyValueModel<Query> getQueryHolder() {
+ return queryHolder;
}
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/AbstractEntityMappingsDetailsPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/AbstractEntityMappingsDetailsPage.java
index 1cf7acf0c8..f5bd890953 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/AbstractEntityMappingsDetailsPage.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/AbstractEntityMappingsDetailsPage.java
@@ -243,10 +243,7 @@ public abstract class AbstractEntityMappingsDetailsPage extends AbstractJpaDetai
this.buildEntityMappingsGeneratorsComposite(container);
// Queries pane
- new OrmQueriesComposite(
- this,
- container
- );
+ this.buildOrmQueriesComposite(container);
}
protected void buildEntityMappingsGeneratorsComposite(Composite container) {
@@ -255,4 +252,8 @@ public abstract class AbstractEntityMappingsDetailsPage extends AbstractJpaDetai
container
);
}
+
+ protected void buildOrmQueriesComposite(Composite container) {
+ new OrmQueriesComposite(this, container);
+ }
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmQueriesComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmQueriesComposite.java
index b76bb074d9..a9cd33d78f 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmQueriesComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/OrmQueriesComposite.java
@@ -63,17 +63,21 @@ public class OrmQueriesComposite extends Pane<EntityMappings> {
@Override
protected void initializeLayout(Composite container) {
- container = addCollapsableSection(
+ container = this.addCollapsableSection(
container,
JptUiDetailsOrmMessages.OrmQueriesComposite_groupBox
);
- QueriesComposite queriesComposite = new QueriesComposite(this, buildQueryContainer(), container);
+ QueriesComposite queriesComposite = this.buildQueriesComposite(container, this.buildQueryContainerHolder());
- installPaneEnabler(queriesComposite);
+ this.installPaneEnabler(queriesComposite);
}
- private PropertyValueModel<QueryContainer> buildQueryContainer() {
+ protected QueriesComposite buildQueriesComposite(Composite container, PropertyValueModel<QueryContainer> queryContainerHolder) {
+ return new QueriesComposite(this, queryContainerHolder, container);
+ }
+
+ private PropertyValueModel<QueryContainer> buildQueryContainerHolder() {
return new PropertyAspectAdapter<EntityMappings, QueryContainer>(getSubjectHolder()) {
@Override
protected QueryContainer buildValue_() {
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/JptUiDetailsMessages2_0.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/JptUiDetailsMessages2_0.java
index 90fb68b2ca..dd1a17bc66 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/JptUiDetailsMessages2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/JptUiDetailsMessages2_0.java
@@ -31,6 +31,18 @@ public class JptUiDetailsMessages2_0 {
public static String OrphanRemoval2_0Composite_orphanRemovalLabel;
public static String OrphanRemoval2_0Composite_orphanRemovalLabelDefault;
+ public static String LockModeComposite_lockModeLabel;
+
+ public static String LockModeComposite_read;
+ public static String LockModeComposite_write;
+ public static String LockModeComposite_optimistic;
+ public static String LockModeComposite_optimistic_force_increment;
+ public static String LockModeComposite_pessimistic_read;
+ public static String LockModeComposite_pessimistic_write;
+ public static String LockModeComposite_pessimistic_force_increment;
+ public static String LockModeComposite_none;
+
+
private static final String BUNDLE_NAME = "jpt_ui_details2_0"; //$NON-NLS-1$
private static final Class<?> BUNDLE_CLASS = JptUiDetailsMessages2_0.class;
static {
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/LockModeComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/LockModeComposite.java
new file mode 100644
index 0000000000..d0bc9ee716
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/LockModeComposite.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+* Copyright (c) 2009 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.ui.internal.jpa2.details;
+
+import java.util.Collection;
+
+import org.eclipse.jpt.core.jpa2.context.LockModeType_2_0;
+import org.eclipse.jpt.core.jpa2.context.NamedQuery2_0;
+import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer;
+import org.eclipse.jpt.ui.internal.widgets.Pane;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * LockModeComposite
+ */
+public class LockModeComposite extends Pane<NamedQuery2_0>
+{
+ /**
+ * Creates a new <code>LockModeComposite</code>.
+ *
+ * @param parentPane The parent container of this one
+ * @param parent The parent container
+ */
+ public LockModeComposite(Pane<? extends NamedQuery2_0> parentPane,
+ Composite parent) {
+
+ super(parentPane, parent);
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+
+ this.addLabeledComposite(
+ container,
+ JptUiDetailsMessages2_0.LockModeComposite_lockModeLabel,
+ this.addLockModeTypeCombo(container),
+ null // TODO
+ );
+ }
+
+ private EnumFormComboViewer<NamedQuery2_0, LockModeType_2_0> addLockModeTypeCombo(Composite container) {
+
+ return new EnumFormComboViewer<NamedQuery2_0, LockModeType_2_0>(this, container) {
+
+ @Override
+ protected void addPropertyNames(Collection<String> propertyNames) {
+ super.addPropertyNames(propertyNames);
+ propertyNames.add(NamedQuery2_0.DEFAULT_LOCK_MODE_PROPERTY);
+ propertyNames.add(NamedQuery2_0.SPECIFIED_LOCK_MODE_PROPERTY);
+ }
+
+ @Override
+ protected LockModeType_2_0[] getChoices() {
+ return LockModeType_2_0.values();
+ }
+
+ @Override
+ protected LockModeType_2_0 getDefaultValue() {
+ return this.getSubject().getDefaultLockMode();
+ }
+
+ @Override
+ protected String displayString(LockModeType_2_0 value) {
+ return this.buildDisplayString(
+ JptUiDetailsMessages2_0.class,
+ LockModeComposite.this,
+ value
+ );
+ }
+
+ @Override
+ protected LockModeType_2_0 getValue() {
+ return this.getSubject().getSpecifiedLockMode();
+ }
+
+ @Override
+ protected void setValue(LockModeType_2_0 value) {
+ this.getSubject().setSpecifiedLockMode(value);
+ }
+ };
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/NamedQueryProperty2_0Composite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/NamedQueryProperty2_0Composite.java
new file mode 100644
index 0000000000..a673a5b00e
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/NamedQueryProperty2_0Composite.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+* Copyright (c) 2009 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.ui.internal.jpa2.details;
+
+import org.eclipse.jpt.core.jpa2.context.NamedQuery2_0;
+import org.eclipse.jpt.ui.internal.details.JptUiDetailsMessages;
+import org.eclipse.jpt.ui.internal.details.NamedQueryPropertyComposite;
+import org.eclipse.jpt.ui.internal.details.QueryHintsComposite;
+import org.eclipse.jpt.ui.internal.widgets.Pane;
+import org.eclipse.jpt.utility.model.value.PropertyValueModel;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * NamedQueryProperty2_0Composite
+ */
+public class NamedQueryProperty2_0Composite extends NamedQueryPropertyComposite<NamedQuery2_0>
+{
+ /**
+ * Creates a new <code>NamedQueryProperty2_0Composite</code>.
+ *
+ * @param parentPane The parent container of this one
+ * @param subjectHolder The holder of this pane's subject
+ * @param parent The parent container
+ */
+ public NamedQueryProperty2_0Composite(Pane<?> parentPane,
+ PropertyValueModel<NamedQuery2_0> subjectHolder,
+ Composite parent) {
+
+ super(parentPane, subjectHolder, parent);
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+
+ this.addLabeledText(
+ container,
+ JptUiDetailsMessages.NamedQueryComposite_nameTextLabel,
+ this.buildNameTextHolder());
+
+ // Query text area
+ this.addLabeledMultiLineText(
+ container,
+ JptUiDetailsMessages.NamedQueryPropertyComposite_query,
+ this.buildQueryHolder(),
+ 4,
+ null
+ );
+
+ new LockModeComposite(this, container);
+
+ // Query Hints pane
+ container = this.addTitledGroup(
+ this.addSubPane(container, 5),
+ JptUiDetailsMessages.NamedQueryPropertyComposite_queryHintsGroupBox
+ );
+
+ new QueryHintsComposite(this, container);
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/Queries2_0Composite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/Queries2_0Composite.java
new file mode 100644
index 0000000000..d4fab4b9be
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/Queries2_0Composite.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+* Copyright (c) 2009 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.ui.internal.jpa2.details;
+
+import org.eclipse.jpt.core.context.NamedQuery;
+import org.eclipse.jpt.core.context.Query;
+import org.eclipse.jpt.core.context.QueryContainer;
+import org.eclipse.jpt.core.jpa2.context.NamedQuery2_0;
+import org.eclipse.jpt.ui.internal.details.NamedQueryPropertyComposite;
+import org.eclipse.jpt.ui.internal.details.QueriesComposite;
+import org.eclipse.jpt.ui.internal.widgets.Pane;
+import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
+import org.eclipse.jpt.utility.model.value.PropertyValueModel;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.part.PageBook;
+
+/**
+ * Queries2_0Composite
+ */
+public class Queries2_0Composite extends QueriesComposite
+{
+
+ public Queries2_0Composite(
+ Pane<?> parentPane,
+ PropertyValueModel<? extends QueryContainer> subjectHolder,
+ Composite parent) {
+
+ super(parentPane, subjectHolder, parent);
+ }
+
+ protected NamedQueryPropertyComposite<NamedQuery2_0> buildNamedQueryPropertyComposite(PageBook pageBook) {
+ return new NamedQueryProperty2_0Composite(
+ this,
+ this.buildNamedQuery2_0Holder(),
+ pageBook
+ );
+ }
+
+ protected PropertyValueModel<NamedQuery2_0> buildNamedQuery2_0Holder() {
+ return new TransformationPropertyValueModel<Query, NamedQuery2_0>(this.getQueryHolder()) {
+ @Override
+ protected NamedQuery2_0 transform_(Query value) {
+ return (value instanceof NamedQuery) ? (NamedQuery2_0) value : null;
+ }
+ };
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/java/JavaEntity2_0Composite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/java/JavaEntity2_0Composite.java
index b7c9a531ab..3c7df52b76 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/java/JavaEntity2_0Composite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/java/JavaEntity2_0Composite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2006, 2009 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -10,6 +10,7 @@
package org.eclipse.jpt.ui.internal.jpa2.details.java;
import org.eclipse.jpt.core.context.AccessHolder;
+import org.eclipse.jpt.core.context.QueryContainer;
import org.eclipse.jpt.core.context.java.JavaEntity;
import org.eclipse.jpt.core.jpa2.context.Cacheable2_0;
import org.eclipse.jpt.core.jpa2.context.CacheableHolder2_0;
@@ -23,6 +24,7 @@ import org.eclipse.jpt.ui.internal.details.java.JavaInheritanceComposite;
import org.eclipse.jpt.ui.internal.details.java.JavaSecondaryTablesComposite;
import org.eclipse.jpt.ui.internal.jpa2.details.Cacheable2_0Pane;
import org.eclipse.jpt.ui.internal.jpa2.details.Entity2_0OverridesComposite;
+import org.eclipse.jpt.ui.internal.jpa2.details.Queries2_0Composite;
import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.swt.widgets.Composite;
@@ -97,4 +99,9 @@ public class JavaEntity2_0Composite extends AbstractEntityComposite<JavaEntity>
protected void addAttributeOverridesComposite(Composite container) {
new Entity2_0OverridesComposite(this, container);
}
+
+ @Override
+ protected void addQueriesComposite(Composite container, PropertyValueModel<QueryContainer> queryContainerHolder) {
+ new Queries2_0Composite(this, queryContainerHolder, container);
+ }
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/orm/EntityMappings2_0DetailsPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/orm/EntityMappings2_0DetailsPage.java
index 47e2578734..647e66236b 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/orm/EntityMappings2_0DetailsPage.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/orm/EntityMappings2_0DetailsPage.java
@@ -38,4 +38,9 @@ public class EntityMappings2_0DetailsPage extends AbstractEntityMappingsDetailsP
);
}
+ @Override
+ protected void buildOrmQueriesComposite(Composite container) {
+ new OrmQueries2_0Composite(this, container);
+ }
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/orm/OrmEntity2_0Composite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/orm/OrmEntity2_0Composite.java
index 3f7088e763..fb6e5c5f80 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/orm/OrmEntity2_0Composite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/orm/OrmEntity2_0Composite.java
@@ -10,6 +10,7 @@
package org.eclipse.jpt.ui.internal.jpa2.details.orm;
import org.eclipse.jpt.core.context.GeneratorContainer;
+import org.eclipse.jpt.core.context.QueryContainer;
import org.eclipse.jpt.core.context.orm.OrmEntity;
import org.eclipse.jpt.core.jpa2.context.Cacheable2_0;
import org.eclipse.jpt.core.jpa2.context.CacheableHolder2_0;
@@ -24,6 +25,7 @@ import org.eclipse.jpt.ui.internal.details.orm.OrmJavaClassChooser;
import org.eclipse.jpt.ui.internal.jpa2.details.Cacheable2_0Pane;
import org.eclipse.jpt.ui.internal.jpa2.details.Generation2_0Composite;
import org.eclipse.jpt.ui.internal.jpa2.details.Entity2_0OverridesComposite;
+import org.eclipse.jpt.ui.internal.jpa2.details.Queries2_0Composite;
import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.swt.widgets.Composite;
@@ -81,4 +83,9 @@ public class OrmEntity2_0Composite extends AbstractOrmEntityComposite
new Generation2_0Composite(this, generatorContainerHolder, container);
}
+ @Override
+ protected void addQueriesComposite(Composite container, PropertyValueModel<QueryContainer> queryContainerHolder) {
+ new Queries2_0Composite(this, queryContainerHolder, container);
+ }
+
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/orm/OrmQueries2_0Composite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/orm/OrmQueries2_0Composite.java
new file mode 100644
index 0000000000..7fce6a0086
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/jpa2/details/orm/OrmQueries2_0Composite.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+* Copyright (c) 2009 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.ui.internal.jpa2.details.orm;
+
+import org.eclipse.jpt.core.context.QueryContainer;
+import org.eclipse.jpt.core.context.orm.EntityMappings;
+import org.eclipse.jpt.ui.internal.details.QueriesComposite;
+import org.eclipse.jpt.ui.internal.details.orm.OrmQueriesComposite;
+import org.eclipse.jpt.ui.internal.jpa2.details.Queries2_0Composite;
+import org.eclipse.jpt.ui.internal.widgets.Pane;
+import org.eclipse.jpt.utility.model.value.PropertyValueModel;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * OrmQueries2_0Composite
+ */
+public class OrmQueries2_0Composite extends OrmQueriesComposite {
+
+ /**
+ * Creates a new <code>OrmQueries2_0Composite</code>.
+ *
+ * @param parentPane The parent container of this one
+ * @param parent The parent container
+ */
+ public OrmQueries2_0Composite(Pane<? extends EntityMappings> parentPane,
+ Composite parent) {
+
+ super(parentPane, parent);
+ }
+
+ @Override
+ protected QueriesComposite buildQueriesComposite(Composite container, PropertyValueModel<QueryContainer> queryContainerHolder) {
+ return new Queries2_0Composite(this, queryContainerHolder, container);
+ }
+
+}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaEntity2_0Tests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaEntity2_0Tests.java
index 8e32cd010f..5d813c758e 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaEntity2_0Tests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaEntity2_0Tests.java
@@ -11,6 +11,7 @@ package org.eclipse.jpt.core.tests.internal.jpa2.context.java;
import java.util.Iterator;
import java.util.ListIterator;
+
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.core.MappingKeys;
import org.eclipse.jpt.core.context.AssociationOverride;
@@ -26,20 +27,26 @@ import org.eclipse.jpt.core.context.PersistentType;
import org.eclipse.jpt.core.context.java.JavaAssociationOverride;
import org.eclipse.jpt.core.context.java.JavaAttributeOverride;
import org.eclipse.jpt.core.context.java.JavaEntity;
+import org.eclipse.jpt.core.context.java.JavaNamedQuery;
import org.eclipse.jpt.core.context.persistence.ClassRef;
import org.eclipse.jpt.core.jpa2.MappingKeys2_0;
import org.eclipse.jpt.core.jpa2.context.Cacheable2_0;
import org.eclipse.jpt.core.jpa2.context.CacheableHolder2_0;
+import org.eclipse.jpt.core.jpa2.context.LockModeType_2_0;
+import org.eclipse.jpt.core.jpa2.context.NamedQuery2_0;
import org.eclipse.jpt.core.jpa2.context.persistence.PersistenceUnit2_0;
import org.eclipse.jpt.core.jpa2.context.persistence.options.SharedCacheMode;
import org.eclipse.jpt.core.jpa2.resource.java.Cacheable2_0Annotation;
import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0;
+import org.eclipse.jpt.core.jpa2.resource.java.NamedQuery2_0Annotation;
import org.eclipse.jpt.core.resource.java.AssociationOverrideAnnotation;
import org.eclipse.jpt.core.resource.java.AssociationOverridesAnnotation;
import org.eclipse.jpt.core.resource.java.AttributeOverrideAnnotation;
import org.eclipse.jpt.core.resource.java.AttributeOverridesAnnotation;
import org.eclipse.jpt.core.resource.java.JPA;
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
+import org.eclipse.jpt.core.resource.java.NamedQueriesAnnotation;
+import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation;
import org.eclipse.jpt.core.resource.java.NestableAnnotation;
import org.eclipse.jpt.core.tests.internal.jpa2.context.Generic2_0ContextModelTestCase;
import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
@@ -254,7 +261,7 @@ public class GenericJavaEntity2_0Tests extends Generic2_0ContextModelTestCase
};
this.javaProject.createCompilationUnit(PACKAGE_NAME, "Address.java", sourceWriter);
}
-
+
private void createTestEmbeddableZipCode() throws Exception {
SourceWriter sourceWriter = new SourceWriter() {
public void appendSourceTo(StringBuilder sb) {
@@ -278,6 +285,233 @@ public class GenericJavaEntity2_0Tests extends Generic2_0ContextModelTestCase
this.javaProject.createCompilationUnit(PACKAGE_NAME, "ZipCode.java", sourceWriter);
}
+
+ private LockModeType_2_0 lockModeOf(NamedQuery2_0Annotation resourceQuery) {
+ return resourceQuery == null ? null : LockModeType_2_0.fromJavaResourceModel(resourceQuery.getLockMode());
+ }
+
+ public void testAddNamedQuery2_0() throws Exception {
+ this.createTestEntity();
+ this.addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ JavaEntity entity = this.getJavaEntity();
+ JavaResourcePersistentType typeResource = this.getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+
+ NamedQuery2_0 namedQuery1 = (NamedQuery2_0) entity.getQueryContainer().addNamedQuery(0);
+ namedQuery1.setName("FOO");
+ namedQuery1.setSpecifiedLockMode(LockModeType_2_0.OPTIMISTIC);
+
+ Iterator<NestableAnnotation> javaNamedQueries = typeResource.annotations(
+ NamedQueryAnnotation.ANNOTATION_NAME,
+ NamedQueriesAnnotation.ANNOTATION_NAME);
+ NamedQuery2_0Annotation queryAnnotation = (NamedQuery2_0Annotation) javaNamedQueries.next();
+ assertEquals("FOO", queryAnnotation.getName());
+ assertEquals(LockModeType_2_0.OPTIMISTIC, this.lockModeOf(queryAnnotation));
+
+ NamedQuery2_0 namedQuery2 = (NamedQuery2_0) entity.getQueryContainer().addNamedQuery(0);
+ namedQuery2.setName("BAR");
+ namedQuery2.setSpecifiedLockMode(LockModeType_2_0.READ);
+
+ javaNamedQueries = typeResource.annotations(NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
+ queryAnnotation = (NamedQuery2_0Annotation) javaNamedQueries.next();
+ assertEquals("BAR", queryAnnotation.getName());
+ assertEquals(LockModeType_2_0.READ, this.lockModeOf(queryAnnotation));
+ assertEquals("FOO", ((NamedQuery2_0Annotation) javaNamedQueries.next()).getName());
+
+ NamedQuery2_0 namedQuery3 = (NamedQuery2_0) entity.getQueryContainer().addNamedQuery(1);
+ namedQuery3.setName("BAZ");
+ namedQuery3.setSpecifiedLockMode(LockModeType_2_0.WRITE);
+
+ javaNamedQueries = typeResource.annotations(NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
+ assertEquals("BAR", ((NamedQuery2_0Annotation) javaNamedQueries.next()).getName());
+ queryAnnotation = (NamedQuery2_0Annotation) javaNamedQueries.next();
+ assertEquals("BAZ", queryAnnotation.getName());
+ assertEquals(LockModeType_2_0.WRITE, this.lockModeOf(queryAnnotation));
+ assertEquals("FOO", ((NamedQuery2_0Annotation) javaNamedQueries.next()).getName());
+
+ ListIterator<JavaNamedQuery> namedQueries = entity.getQueryContainer().namedQueries();
+ assertEquals(namedQuery2, namedQueries.next());
+ assertEquals(namedQuery3, namedQueries.next());
+ assertEquals(namedQuery1, namedQueries.next());
+
+ namedQueries = entity.getQueryContainer().namedQueries();
+ assertEquals("BAR", namedQueries.next().getName());
+ assertEquals("BAZ", namedQueries.next().getName());
+ assertEquals("FOO", namedQueries.next().getName());
+
+ entity.getQueryContainer().addNamedNativeQuery(0).setName("foo");
+ }
+
+ public void testRemoveNamedQuery2_0() throws Exception {
+ createTestEntity();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ JavaEntity entity = getJavaEntity();
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+
+ entity.getQueryContainer().addNamedQuery(0).setName("FOO");
+ NamedQuery2_0 namedQuery1 = (NamedQuery2_0) entity.getQueryContainer().addNamedQuery(1);
+ namedQuery1.setName("BAR");
+ namedQuery1.setSpecifiedLockMode(LockModeType_2_0.READ);
+
+ NamedQuery2_0 namedQuery2 = (NamedQuery2_0) entity.getQueryContainer().addNamedQuery(2);
+ namedQuery2.setName("BAZ");
+ namedQuery2.setSpecifiedLockMode(LockModeType_2_0.OPTIMISTIC);
+
+ Iterator<NestableAnnotation> javaNamedQueries = typeResource.annotations(NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
+ assertEquals(3, CollectionTools.size(javaNamedQueries));
+
+ entity.getQueryContainer().removeNamedQuery(0);
+ javaNamedQueries = typeResource.annotations(NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
+ assertEquals(2, CollectionTools.size(javaNamedQueries));
+ javaNamedQueries = typeResource.annotations(NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
+ NamedQuery2_0Annotation annotation1 = (NamedQuery2_0Annotation) javaNamedQueries.next();
+ assertEquals("BAR", annotation1.getName());
+ assertEquals(LockModeType_2_0.READ, this.lockModeOf(annotation1));
+
+ NamedQuery2_0Annotation annotation2 = (NamedQuery2_0Annotation) javaNamedQueries.next();
+ assertEquals("BAZ", annotation2.getName());
+ assertEquals(LockModeType_2_0.OPTIMISTIC, this.lockModeOf(annotation2));
+
+ entity.getQueryContainer().removeNamedQuery(0);
+ javaNamedQueries = typeResource.annotations(NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
+ assertEquals(1, CollectionTools.size(javaNamedQueries));
+ javaNamedQueries = typeResource.annotations(NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
+ annotation2 = (NamedQuery2_0Annotation) javaNamedQueries.next();
+ assertEquals("BAZ", annotation2.getName());
+ assertEquals(LockModeType_2_0.OPTIMISTIC, this.lockModeOf(annotation2));
+
+ entity.getQueryContainer().removeNamedQuery(0);
+ javaNamedQueries = typeResource.annotations(NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
+ assertEquals(0, CollectionTools.size(javaNamedQueries));
+ }
+
+ public void testMoveNamedQuery2_0() throws Exception {
+ createTestEntity();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ JavaEntity entity = getJavaEntity();
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+
+ entity.getQueryContainer().addNamedQuery(0).setName("FOO");
+ NamedQuery2_0 namedQuery1 = (NamedQuery2_0) entity.getQueryContainer().addNamedQuery(1);
+ namedQuery1.setName("BAR");
+ namedQuery1.setSpecifiedLockMode(LockModeType_2_0.OPTIMISTIC);
+ entity.getQueryContainer().addNamedQuery(2).setName("BAZ");
+
+ Iterator<NestableAnnotation> javaNamedQueries = typeResource.annotations(NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
+ assertEquals(3, CollectionTools.size(javaNamedQueries));
+
+
+ entity.getQueryContainer().moveNamedQuery(2, 0);
+ ListIterator<JavaNamedQuery> namedQueries = entity.getQueryContainer().namedQueries();
+ namedQuery1 = (NamedQuery2_0) namedQueries.next();
+ assertEquals("BAR", namedQuery1.getName());
+ assertEquals(LockModeType_2_0.OPTIMISTIC, namedQuery1.getLockMode());
+ assertEquals("BAZ", namedQueries.next().getName());
+ assertEquals("FOO", namedQueries.next().getName());
+
+ javaNamedQueries = typeResource.annotations(NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
+ NamedQuery2_0Annotation annotation1 = (NamedQuery2_0Annotation) javaNamedQueries.next();
+ assertEquals("BAR", annotation1.getName());
+ assertEquals(LockModeType_2_0.OPTIMISTIC, this.lockModeOf(annotation1));
+ assertEquals("BAZ", ((NamedQuery2_0Annotation) javaNamedQueries.next()).getName());
+ assertEquals("FOO", ((NamedQuery2_0Annotation) javaNamedQueries.next()).getName());
+
+
+ entity.getQueryContainer().moveNamedQuery(0, 1);
+ namedQueries = entity.getQueryContainer().namedQueries();
+ assertEquals("BAZ", namedQueries.next().getName());
+ namedQuery1 = (NamedQuery2_0) namedQueries.next();
+ assertEquals("BAR", namedQuery1.getName());
+ assertEquals(LockModeType_2_0.OPTIMISTIC, namedQuery1.getLockMode());
+ assertEquals("FOO", namedQueries.next().getName());
+
+ javaNamedQueries = typeResource.annotations(NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
+ assertEquals("BAZ", ((NamedQuery2_0Annotation) javaNamedQueries.next()).getName());
+ annotation1 = (NamedQuery2_0Annotation) javaNamedQueries.next();
+ assertEquals("BAR", annotation1.getName());
+ assertEquals(LockModeType_2_0.OPTIMISTIC, this.lockModeOf(annotation1));
+ assertEquals("FOO", ((NamedQuery2_0Annotation) javaNamedQueries.next()).getName());
+ }
+
+ public void testUpdateNamedQueries2_0() throws Exception {
+ createTestEntity();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ JavaEntity entity = getJavaEntity();
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+
+ assertEquals(0, entity.getPersistenceUnit().queriesSize());
+
+ ((NamedQuery2_0Annotation) typeResource.addAnnotation(0, NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME)).setName("FOO");
+ ((NamedQuery2_0Annotation) typeResource.addAnnotation(1, NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME)).setName("BAR");
+ NamedQuery2_0Annotation annotation1 = (NamedQuery2_0Annotation) typeResource.addAnnotation(1, NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
+ annotation1.setName("BAZ");
+ annotation1.setLockMode(org.eclipse.jpt.core.jpa2.resource.java.LockModeType_2_0.OPTIMISTIC);
+
+ ListIterator<JavaNamedQuery> namedQueries = entity.getQueryContainer().namedQueries();
+ assertEquals("FOO", namedQueries.next().getName());
+ NamedQuery2_0 namedQuery1 = (NamedQuery2_0) namedQueries.next();
+ assertEquals("BAZ", namedQuery1.getName());
+ assertEquals(LockModeType_2_0.OPTIMISTIC, namedQuery1.getLockMode());
+ assertEquals("BAR", namedQueries.next().getName());
+ assertFalse(namedQueries.hasNext());
+ assertEquals(3, entity.getPersistenceUnit().queriesSize());
+
+ typeResource.moveAnnotation(2, 0, NamedQueriesAnnotation.ANNOTATION_NAME);
+ namedQueries = entity.getQueryContainer().namedQueries();
+ namedQuery1 = (NamedQuery2_0) namedQueries.next();
+ assertEquals("BAZ", namedQuery1.getName());
+ assertEquals(LockModeType_2_0.OPTIMISTIC, namedQuery1.getLockMode());
+ assertEquals("BAR", namedQueries.next().getName());
+ assertEquals("FOO", namedQueries.next().getName());
+ assertFalse(namedQueries.hasNext());
+
+ typeResource.moveAnnotation(0, 1, NamedQueriesAnnotation.ANNOTATION_NAME);
+ namedQueries = entity.getQueryContainer().namedQueries();
+ assertEquals("BAR", namedQueries.next().getName());
+ namedQuery1 = (NamedQuery2_0) namedQueries.next();
+ assertEquals("BAZ", namedQuery1.getName());
+ assertEquals(LockModeType_2_0.OPTIMISTIC, namedQuery1.getLockMode());
+ assertEquals("FOO", namedQueries.next().getName());
+ assertFalse(namedQueries.hasNext());
+
+ typeResource.removeAnnotation(1, NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
+ namedQueries = entity.getQueryContainer().namedQueries();
+ assertEquals("BAR", namedQueries.next().getName());
+ assertEquals("FOO", namedQueries.next().getName());
+ assertFalse(namedQueries.hasNext());
+ assertEquals(2, entity.getPersistenceUnit().queriesSize());
+
+ typeResource.removeAnnotation(1, NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
+ namedQueries = entity.getQueryContainer().namedQueries();
+ assertEquals("BAR", namedQueries.next().getName());
+ assertFalse(namedQueries.hasNext());
+ assertEquals(1, entity.getPersistenceUnit().queriesSize());
+
+ typeResource.removeAnnotation(0, NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
+ namedQueries = entity.getQueryContainer().namedQueries();
+ assertFalse(namedQueries.hasNext());
+ assertEquals(0, entity.getPersistenceUnit().queriesSize());
+ }
+
+ public void testNamedQueries2_0Size() throws Exception {
+ createTestEntity();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ JavaEntity entity = getJavaEntity();
+ JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
+
+ assertEquals(0, entity.getQueryContainer().namedQueriesSize());
+
+ ((NamedQuery2_0Annotation) typeResource.addAnnotation(0, NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME)).setName("FOO");
+ ((NamedQuery2_0Annotation) typeResource.addAnnotation(1, NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME)).setName("BAR");
+ ((NamedQuery2_0Annotation) typeResource.addAnnotation(2, NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME)).setName("BAZ");
+
+ assertEquals(3, entity.getQueryContainer().namedQueriesSize());
+ }
+
public void testAttributeMappingKeyAllowed() throws Exception {
createTestEntity();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/orm/GenericOrmEntity2_0Tests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/orm/GenericOrmEntity2_0Tests.java
index 4f7c379e3d..128d81d9cf 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/orm/GenericOrmEntity2_0Tests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/orm/GenericOrmEntity2_0Tests.java
@@ -11,6 +11,7 @@ package org.eclipse.jpt.core.tests.internal.jpa2.context.orm;
import java.util.Iterator;
import java.util.ListIterator;
+
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.core.MappingKeys;
import org.eclipse.jpt.core.context.AssociationOverride;
@@ -25,15 +26,19 @@ import org.eclipse.jpt.core.context.orm.OrmAssociationOverride;
import org.eclipse.jpt.core.context.orm.OrmAttributeOverride;
import org.eclipse.jpt.core.context.orm.OrmEntity;
import org.eclipse.jpt.core.context.orm.OrmMappedSuperclass;
+import org.eclipse.jpt.core.context.orm.OrmNamedQuery;
import org.eclipse.jpt.core.context.orm.OrmPersistentType;
import org.eclipse.jpt.core.jpa2.context.Cacheable2_0;
import org.eclipse.jpt.core.jpa2.context.CacheableHolder2_0;
+import org.eclipse.jpt.core.jpa2.context.LockModeType_2_0;
+import org.eclipse.jpt.core.jpa2.context.orm.OrmNamedQuery2_0;
import org.eclipse.jpt.core.jpa2.context.persistence.PersistenceUnit2_0;
import org.eclipse.jpt.core.jpa2.context.persistence.options.SharedCacheMode;
import org.eclipse.jpt.core.resource.java.JPA;
import org.eclipse.jpt.core.resource.orm.OrmFactory;
import org.eclipse.jpt.core.resource.orm.XmlAssociationOverride;
import org.eclipse.jpt.core.resource.orm.XmlEntity;
+import org.eclipse.jpt.core.resource.orm.XmlNamedQuery;
import org.eclipse.jpt.core.tests.internal.jpa2.context.Generic2_0ContextModelTestCase;
import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
@@ -270,6 +275,201 @@ public class GenericOrmEntity2_0Tests extends Generic2_0ContextModelTestCase
this.javaProject.createCompilationUnit(PACKAGE_NAME, "ZipCode.java", sourceWriter);
}
+
+ private LockModeType_2_0 lockModeOf(XmlNamedQuery resourceQuery) {
+ return resourceQuery == null ? null : LockModeType_2_0.fromOrmResourceModel(resourceQuery.getLockMode());
+ }
+
+ public void testAddNamedQuery() throws Exception {
+ OrmPersistentType persistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
+ XmlEntity entityResource = getXmlEntityMappings().getEntities().get(0);
+
+ OrmNamedQuery2_0 namedQuery = (OrmNamedQuery2_0) ormEntity.getQueryContainer().addNamedQuery(0);
+ namedQuery.setName("FOO");
+ namedQuery.setSpecifiedLockMode(LockModeType_2_0.OPTIMISTIC);
+
+ XmlNamedQuery resourceQuery = entityResource.getNamedQueries().get(0);
+ assertEquals("FOO", resourceQuery.getName());
+ assertEquals(LockModeType_2_0.OPTIMISTIC, this.lockModeOf(resourceQuery));
+
+ OrmNamedQuery2_0 namedQuery2 = (OrmNamedQuery2_0) ormEntity.getQueryContainer().addNamedQuery(0);
+ namedQuery2.setName("BAR");
+ namedQuery2.setSpecifiedLockMode(LockModeType_2_0.READ);
+
+ resourceQuery = entityResource.getNamedQueries().get(0);
+ assertEquals("BAR", resourceQuery.getName());
+ assertEquals(LockModeType_2_0.READ, this.lockModeOf(resourceQuery));
+ assertEquals("FOO", entityResource.getNamedQueries().get(1).getName());
+
+ OrmNamedQuery2_0 namedQuery3 = (OrmNamedQuery2_0) ormEntity.getQueryContainer().addNamedQuery(1);
+ namedQuery3.setName("BAZ");
+ namedQuery3.setSpecifiedLockMode(LockModeType_2_0.WRITE);
+
+ assertEquals("BAR", entityResource.getNamedQueries().get(0).getName());
+ resourceQuery = entityResource.getNamedQueries().get(1);
+ assertEquals("BAZ", resourceQuery.getName());
+ assertEquals(LockModeType_2_0.WRITE, this.lockModeOf(resourceQuery));
+ assertEquals("FOO", entityResource.getNamedQueries().get(2).getName());
+
+ ListIterator<OrmNamedQuery> namedQueries = ormEntity.getQueryContainer().namedQueries();
+ assertEquals(namedQuery2, namedQueries.next());
+ assertEquals(namedQuery3, namedQueries.next());
+ assertEquals(namedQuery, namedQueries.next());
+
+ namedQueries = ormEntity.getQueryContainer().namedQueries();
+ assertEquals("BAR", namedQueries.next().getName());
+ assertEquals("BAZ", namedQueries.next().getName());
+ assertEquals("FOO", namedQueries.next().getName());
+ }
+
+ public void testRemoveNamedQuery() throws Exception {
+ OrmPersistentType persistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
+
+ ormEntity.getQueryContainer().addNamedQuery(0).setName("FOO");
+ OrmNamedQuery2_0 namedQuery1 = (OrmNamedQuery2_0) ormEntity.getQueryContainer().addNamedQuery(1);
+ namedQuery1.setName("BAR");
+ namedQuery1.setSpecifiedLockMode(LockModeType_2_0.READ);
+
+ OrmNamedQuery2_0 namedQuery2 = (OrmNamedQuery2_0) ormEntity.getQueryContainer().addNamedQuery(2);
+ namedQuery2.setName("BAZ");
+ namedQuery2.setSpecifiedLockMode(LockModeType_2_0.OPTIMISTIC);
+
+ XmlEntity entityResource = getXmlEntityMappings().getEntities().get(0);
+ assertEquals(3, entityResource.getNamedQueries().size());
+
+ ormEntity.getQueryContainer().removeNamedQuery(0);
+ assertEquals(2, entityResource.getNamedQueries().size());
+ XmlNamedQuery xmlQuery0 = entityResource.getNamedQueries().get(0);
+ assertEquals("BAR", xmlQuery0.getName());
+ assertEquals(LockModeType_2_0.READ, this.lockModeOf(xmlQuery0));
+
+ XmlNamedQuery xmlQuery1 = entityResource.getNamedQueries().get(1);
+ assertEquals("BAZ", xmlQuery1.getName());
+ assertEquals(LockModeType_2_0.OPTIMISTIC, this.lockModeOf(xmlQuery1));
+
+ ormEntity.getQueryContainer().removeNamedQuery(0);
+ assertEquals(1, entityResource.getNamedQueries().size());
+ assertEquals("BAZ", entityResource.getNamedQueries().get(0).getName());
+ xmlQuery0 = entityResource.getNamedQueries().get(0);
+ assertEquals("BAZ", xmlQuery0.getName());
+ assertEquals(LockModeType_2_0.OPTIMISTIC, this.lockModeOf(xmlQuery0));
+
+ ormEntity.getQueryContainer().removeNamedQuery(0);
+ assertEquals(0, entityResource.getNamedQueries().size());
+ }
+
+ public void testMoveNamedQuery() throws Exception {
+ OrmPersistentType persistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
+
+ ormEntity.getQueryContainer().addNamedQuery(0).setName("FOO");
+ OrmNamedQuery2_0 namedQuery1 = (OrmNamedQuery2_0) ormEntity.getQueryContainer().addNamedQuery(1);
+ namedQuery1.setName("BAR");
+ namedQuery1.setSpecifiedLockMode(LockModeType_2_0.OPTIMISTIC);
+ ormEntity.getQueryContainer().addNamedQuery(2).setName("BAZ");
+
+ XmlEntity entityResource = getXmlEntityMappings().getEntities().get(0);
+ assertEquals(3, entityResource.getNamedQueries().size());
+
+
+ ormEntity.getQueryContainer().moveNamedQuery(2, 0);
+ ListIterator<OrmNamedQuery> namedQueries = ormEntity.getQueryContainer().namedQueries();
+ namedQuery1 = (OrmNamedQuery2_0) namedQueries.next();
+ assertEquals("BAR", namedQuery1.getName());
+ assertEquals(LockModeType_2_0.OPTIMISTIC, namedQuery1.getLockMode());
+ assertEquals("BAZ", namedQueries.next().getName());
+ assertEquals("FOO", namedQueries.next().getName());
+
+ XmlNamedQuery xmlQuery0 = entityResource.getNamedQueries().get(0);
+ assertEquals("BAR", xmlQuery0.getName());
+ assertEquals(LockModeType_2_0.OPTIMISTIC, this.lockModeOf(xmlQuery0));
+ assertEquals("BAZ", entityResource.getNamedQueries().get(1).getName());
+ assertEquals("FOO", entityResource.getNamedQueries().get(2).getName());
+
+
+ ormEntity.getQueryContainer().moveNamedQuery(0, 1);
+ namedQueries = ormEntity.getQueryContainer().namedQueries();
+ assertEquals("BAZ", namedQueries.next().getName());
+ namedQuery1 = (OrmNamedQuery2_0) namedQueries.next();
+ assertEquals("BAR", namedQuery1.getName());
+ assertEquals(LockModeType_2_0.OPTIMISTIC, namedQuery1.getLockMode());
+ assertEquals("FOO", namedQueries.next().getName());
+
+ assertEquals("BAZ", entityResource.getNamedQueries().get(0).getName());
+ XmlNamedQuery xmlQuery1 = entityResource.getNamedQueries().get(1);
+ assertEquals("BAR", xmlQuery1.getName());
+ assertEquals(LockModeType_2_0.OPTIMISTIC, this.lockModeOf(xmlQuery1));
+ assertEquals("FOO", entityResource.getNamedQueries().get(2).getName());
+ }
+
+ public void testUpdateNamedQueries() throws Exception {
+ OrmPersistentType persistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ OrmEntity ormEntity = (OrmEntity) persistentType.getMapping();
+
+ assertEquals(0, ormEntity.getPersistenceUnit().queriesSize());
+
+ XmlEntity entityResource = getXmlEntityMappings().getEntities().get(0);
+ entityResource.getNamedQueries().add(OrmFactory.eINSTANCE.createXmlNamedQuery());
+ entityResource.getNamedQueries().add(OrmFactory.eINSTANCE.createXmlNamedQuery());
+ entityResource.getNamedQueries().add(OrmFactory.eINSTANCE.createXmlNamedQuery());
+ entityResource.getNamedQueries().get(0).setName("FOO");
+ entityResource.getNamedQueries().get(1).setName("BAR");
+ XmlNamedQuery xmlQuery = entityResource.getNamedQueries().get(2);
+ xmlQuery.setName("BAZ");
+ xmlQuery.setLockMode(org.eclipse.jpt.core.resource.orm.v2_0.LockModeType_2_0.OPTIMISTIC);
+
+ ListIterator<OrmNamedQuery> namedQueries = ormEntity.getQueryContainer().namedQueries();
+ assertEquals("FOO", namedQueries.next().getName());
+ assertEquals("BAR", namedQueries.next().getName());
+ OrmNamedQuery2_0 namedQuery1 = (OrmNamedQuery2_0) namedQueries.next();
+ assertEquals("BAZ", namedQuery1.getName());
+ assertEquals(LockModeType_2_0.OPTIMISTIC, namedQuery1.getLockMode());
+ assertFalse(namedQueries.hasNext());
+ assertEquals(3, ormEntity.getPersistenceUnit().queriesSize());
+
+ entityResource.getNamedQueries().move(2, 0);
+ namedQueries = ormEntity.getQueryContainer().namedQueries();
+ assertEquals("BAR", namedQueries.next().getName());
+ namedQuery1 = (OrmNamedQuery2_0) namedQueries.next();
+ assertEquals("BAZ", namedQuery1.getName());
+ assertEquals(LockModeType_2_0.OPTIMISTIC, namedQuery1.getLockMode());
+ assertEquals("FOO", namedQueries.next().getName());
+ assertFalse(namedQueries.hasNext());
+
+ entityResource.getNamedQueries().move(0, 1);
+ namedQueries = ormEntity.getQueryContainer().namedQueries();
+ namedQuery1 = (OrmNamedQuery2_0) namedQueries.next();
+ assertEquals("BAZ", namedQuery1.getName());
+ assertEquals(LockModeType_2_0.OPTIMISTIC, namedQuery1.getLockMode());
+ assertEquals("BAR", namedQueries.next().getName());
+ assertEquals("FOO", namedQueries.next().getName());
+ assertFalse(namedQueries.hasNext());
+
+ entityResource.getNamedQueries().remove(1);
+ namedQueries = ormEntity.getQueryContainer().namedQueries();
+ namedQuery1 = (OrmNamedQuery2_0) namedQueries.next();
+ assertEquals("BAZ", namedQuery1.getName());
+ assertEquals(LockModeType_2_0.OPTIMISTIC, namedQuery1.getLockMode());
+ assertEquals("FOO", namedQueries.next().getName());
+ assertFalse(namedQueries.hasNext());
+ assertEquals(2, ormEntity.getPersistenceUnit().queriesSize());
+
+ entityResource.getNamedQueries().remove(1);
+ namedQueries = ormEntity.getQueryContainer().namedQueries();
+ namedQuery1 = (OrmNamedQuery2_0) namedQueries.next();
+ assertEquals("BAZ", namedQuery1.getName());
+ assertEquals(LockModeType_2_0.OPTIMISTIC, namedQuery1.getLockMode());
+ assertFalse(namedQueries.hasNext());
+ assertEquals(1, ormEntity.getPersistenceUnit().queriesSize());
+
+ entityResource.getNamedQueries().remove(0);
+ assertFalse(ormEntity.getQueryContainer().namedQueries().hasNext());
+ assertEquals(0, ormEntity.getPersistenceUnit().queriesSize());
+ }
+
+
public void testAttributeMappingKeyAllowed() throws Exception {
createTestEntity();
OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.AnnotationTestTypeChild");
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedQueriesTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedQueriesTests.java
index 103cbe30d4..6cdbdc802f 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedQueriesTests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedQueriesTests.java
@@ -96,7 +96,7 @@ public class NamedQueriesTests extends JavaResourceModelTestCase {
JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES);
- NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
+ NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) namedQueries.nestedAnnotations().next();
assertNotNull(namedQuery);
}
@@ -105,7 +105,7 @@ public class NamedQueriesTests extends JavaResourceModelTestCase {
JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES);
- NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
+ NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) namedQueries.nestedAnnotations().next();
assertEquals(QUERY_NAME, namedQuery.getName());
}
@@ -114,7 +114,7 @@ public class NamedQueriesTests extends JavaResourceModelTestCase {
JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES);
- NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
+ NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) namedQueries.nestedAnnotations().next();
assertEquals(QUERY_NAME, namedQuery.getName());
namedQuery.setName("foo");
@@ -133,7 +133,7 @@ public class NamedQueriesTests extends JavaResourceModelTestCase {
JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES);
- NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
+ NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) namedQueries.nestedAnnotations().next();
assertEquals(QUERY_QUERY, namedQuery.getQuery());
}
@@ -142,7 +142,7 @@ public class NamedQueriesTests extends JavaResourceModelTestCase {
JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES);
- NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
+ NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) namedQueries.nestedAnnotations().next();
assertEquals(QUERY_QUERY, namedQuery.getQuery());
namedQuery.setQuery("foo");
@@ -161,7 +161,7 @@ public class NamedQueriesTests extends JavaResourceModelTestCase {
JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES);
- NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
+ NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) namedQueries.nestedAnnotations().next();
assertEquals(0, namedQuery.hintsSize());
}
@@ -171,7 +171,7 @@ public class NamedQueriesTests extends JavaResourceModelTestCase {
JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES);
- NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
+ NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) namedQueries.nestedAnnotations().next();
namedQuery.addHint(0);
namedQuery.addHint(1);
@@ -184,7 +184,7 @@ public class NamedQueriesTests extends JavaResourceModelTestCase {
JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES);
- NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
+ NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) namedQueries.nestedAnnotations().next();
assertEquals(2, namedQuery.hintsSize());
}
@@ -194,7 +194,7 @@ public class NamedQueriesTests extends JavaResourceModelTestCase {
JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES);
- NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
+ NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) namedQueries.nestedAnnotations().next();
namedQuery.addHint(0).setName("FOO");
namedQuery.addHint(1);
@@ -212,7 +212,7 @@ public class NamedQueriesTests extends JavaResourceModelTestCase {
JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES);
- NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
+ NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) namedQueries.nestedAnnotations().next();
namedQuery.addHint(0).setName("BAZ");
assertEquals("BAZ", namedQuery.hintAt(0).getName());
@@ -241,7 +241,7 @@ public class NamedQueriesTests extends JavaResourceModelTestCase {
JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES);
- NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
+ NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) namedQueries.nestedAnnotations().next();
namedQuery.addHint(0).setName("BAZ");
assertEquals("BAZ", namedQuery.hintAt(0).getName());
@@ -263,7 +263,7 @@ public class NamedQueriesTests extends JavaResourceModelTestCase {
JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES);
- NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next();
+ NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) namedQueries.nestedAnnotations().next();
namedQuery.addHint(0).setName("BAZ");
assertEquals("BAZ", namedQuery.hintAt(0).getName());

Back to the top