Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2009-11-19 17:08:45 -0500
committerkmoore2009-11-19 17:08:45 -0500
commitda59995953ad834aeed44aba97adc34898866fd8 (patch)
treefb8be9659877e6533ab8a4117fcfcdb622d8776a
parent4b53de5731fa3bd136c539c99831e5de7672e345 (diff)
downloadwebtools.dali-da59995953ad834aeed44aba97adc34898866fd8.tar.gz
webtools.dali-da59995953ad834aeed44aba97adc34898866fd8.tar.xz
webtools.dali-da59995953ad834aeed44aba97adc34898866fd8.zip
258515 - OrderColumn annotation resource model support
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/Generic2_0JpaAnnotationDefinitionProvider.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/OrderColumn2_0AnnotationDefinition.java60
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryOrderColumn2_0Annotation.java144
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceOrderColumn2_0Annotation.java189
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryColumnAnnotation.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryDiscriminatorColumnAnnotation.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinColumnAnnotation.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedColumnAnnotation.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPrimaryKeyJoinColumnAnnotation.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceColumnAnnotation.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorColumnAnnotation.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinColumnAnnotation.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedColumnAnnotation.java12
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnAnnotation.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/resource/java/JPA2_0.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/resource/java/OrderColumn2_0Annotation.java94
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/resource/java/JavaResource2_0Tests.java1
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/resource/java/OrderColumn2_0AnnotationTests.java242
18 files changed, 760 insertions, 26 deletions
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 d65d551bca..7c9e549a09 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
@@ -21,6 +21,7 @@ import org.eclipse.jpt.core.internal.jpa2.resource.java.ElementCollection2_0Anno
import org.eclipse.jpt.core.internal.jpa2.resource.java.MapsId2_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;
import org.eclipse.jpt.core.internal.jpa2.resource.java.SequenceGenerator2_0AnnotationDefinition;
import org.eclipse.jpt.core.internal.resource.java.AttributeOverrideAnnotationDefinition;
import org.eclipse.jpt.core.internal.resource.java.AttributeOverridesAnnotationDefinition;
@@ -150,6 +151,7 @@ public class Generic2_0JpaAnnotationDefinitionProvider
definitions.add(OneToMany2_0AnnotationDefinition.instance());
definitions.add(OneToOne2_0AnnotationDefinition.instance());
definitions.add(OrderByAnnotationDefinition.instance());
+ definitions.add(OrderColumn2_0AnnotationDefinition.instance());
definitions.add(PrimaryKeyJoinColumnAnnotationDefinition.instance());
definitions.add(PrimaryKeyJoinColumnsAnnotationDefinition.instance());
definitions.add(SequenceGenerator2_0AnnotationDefinition.instance());
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/OrderColumn2_0AnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/OrderColumn2_0AnnotationDefinition.java
new file mode 100644
index 0000000000..0b1f977a11
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/OrderColumn2_0AnnotationDefinition.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * 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.BinaryOrderColumn2_0Annotation;
+import org.eclipse.jpt.core.internal.jpa2.resource.java.source.SourceOrderColumn2_0Annotation;
+import org.eclipse.jpt.core.jpa2.resource.java.OrderColumn2_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.utility.jdt.Member;
+
+/**
+ * javax.persistence.OrderColumn
+ */
+public final class OrderColumn2_0AnnotationDefinition
+ implements AnnotationDefinition
+{
+ // singleton
+ private static final AnnotationDefinition INSTANCE = new OrderColumn2_0AnnotationDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static AnnotationDefinition instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Ensure single instance.
+ */
+ private OrderColumn2_0AnnotationDefinition() {
+ super();
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) {
+ return new SourceOrderColumn2_0Annotation(parent, member);
+ }
+
+ public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) {
+ return null;// new NullOrderColumn2_0Annotation(parent);
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) {
+ return new BinaryOrderColumn2_0Annotation(parent, jdtAnnotation);
+ }
+
+ public String getAnnotationName() {
+ return OrderColumn2_0Annotation.ANNOTATION_NAME;
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryOrderColumn2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryOrderColumn2_0Annotation.java
new file mode 100644
index 0000000000..e83939294f
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryOrderColumn2_0Annotation.java
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * 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.BinaryNamedColumnAnnotation;
+import org.eclipse.jpt.core.jpa2.resource.java.OrderColumn2_0Annotation;
+import org.eclipse.jpt.core.resource.java.JPA;
+import org.eclipse.jpt.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.core.utility.TextRange;
+
+/**
+ * javax.persistence.OrderColumn
+ */
+public class BinaryOrderColumn2_0Annotation
+ extends BinaryNamedColumnAnnotation
+ implements OrderColumn2_0Annotation
+{
+ private Boolean nullable;
+ private Boolean insertable;
+ private Boolean updatable;
+
+
+ public BinaryOrderColumn2_0Annotation(JavaResourceNode parent, IAnnotation jdtAnnotation) {
+ super(parent, jdtAnnotation);
+ this.nullable = this.buildNullable();
+ this.insertable = this.buildInsertable();
+ this.updatable = this.buildUpdatable();
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ this.setNullable_(this.buildNullable());
+ this.setInsertable_(this.buildInsertable());
+ this.setUpdatable_(this.buildUpdatable());
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ @Override
+ protected String getColumnDefinitionElementName() {
+ return JPA.COLUMN__COLUMN_DEFINITION;
+ }
+
+ @Override
+ protected String getNameElementName() {
+ return JPA.COLUMN__NAME;
+ }
+
+ //************* OrderColumn2_0Annotation implementation *************
+
+ // ***** nullable
+ public Boolean getNullable() {
+ return this.nullable;
+ }
+
+ public void setNullable(Boolean nullable) {
+ throw new UnsupportedOperationException();
+ }
+
+ private void setNullable_(Boolean nullable) {
+ Boolean old = this.nullable;
+ this.nullable = nullable;
+ this.firePropertyChanged(NULLABLE_PROPERTY, old, nullable);
+ }
+
+ private Boolean buildNullable() {
+ return (Boolean) this.getJdtMemberValue(getNullableElementName());
+ }
+
+ String getNullableElementName() {
+ return JPA.COLUMN__NULLABLE;
+ }
+
+ public TextRange getNullableTextRange(CompilationUnit astRoot) {
+ throw new UnsupportedOperationException();
+ }
+
+ // ***** insertable
+ public Boolean getInsertable() {
+ return this.insertable;
+ }
+
+ public void setInsertable(Boolean insertable) {
+ throw new UnsupportedOperationException();
+ }
+
+ private void setInsertable_(Boolean insertable) {
+ Boolean old = this.insertable;
+ this.insertable = insertable;
+ this.firePropertyChanged(INSERTABLE_PROPERTY, old, insertable);
+ }
+
+ private Boolean buildInsertable() {
+ return (Boolean) this.getJdtMemberValue(this.getInsertableElementName());
+ }
+
+ String getInsertableElementName() {
+ return JPA.COLUMN__INSERTABLE;
+ }
+
+ public TextRange getInsertableTextRange(CompilationUnit astRoot) {
+ throw new UnsupportedOperationException();
+ }
+
+ // ***** updatable
+ public Boolean getUpdatable() {
+ return this.updatable;
+ }
+
+ public void setUpdatable(Boolean updatable) {
+ throw new UnsupportedOperationException();
+ }
+
+ private void setUpdatable_(Boolean updatable) {
+ Boolean old = this.updatable;
+ this.updatable = updatable;
+ this.firePropertyChanged(UPDATABLE_PROPERTY, old, updatable);
+ }
+
+ private Boolean buildUpdatable() {
+ return (Boolean) this.getJdtMemberValue(this.getUpdatableElementName());
+ }
+
+ String getUpdatableElementName() {
+ return JPA.COLUMN__UPDATABLE;
+ }
+
+ public TextRange getUpdatableTextRange(CompilationUnit astRoot) {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceOrderColumn2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceOrderColumn2_0Annotation.java
new file mode 100644
index 0000000000..ef5a9cd4b3
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceOrderColumn2_0Annotation.java
@@ -0,0 +1,189 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 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.SourceNamedColumnAnnotation;
+import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.jpa2.resource.java.OrderColumn2_0Annotation;
+import org.eclipse.jpt.core.resource.java.BaseColumnAnnotation;
+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.Member;
+
+/**
+ * javax.persistence.OrderColumn
+ */
+public class SourceOrderColumn2_0Annotation
+ extends SourceNamedColumnAnnotation
+ implements OrderColumn2_0Annotation
+{
+
+ final DeclarationAnnotationElementAdapter<Boolean> nullableDeclarationAdapter;
+ final AnnotationElementAdapter<Boolean> nullableAdapter;
+ Boolean nullable;
+
+ final DeclarationAnnotationElementAdapter<Boolean> insertableDeclarationAdapter;
+ final AnnotationElementAdapter<Boolean> insertableAdapter;
+ Boolean insertable;
+
+ final DeclarationAnnotationElementAdapter<Boolean> updatableDeclarationAdapter;
+ final AnnotationElementAdapter<Boolean> updatableAdapter;
+ Boolean updatable;
+
+ public SourceOrderColumn2_0Annotation(JavaResourceNode parent, Member member) {
+ this(parent, member, new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME));
+ }
+
+ SourceOrderColumn2_0Annotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa) {
+ this(parent, member, daa, new MemberAnnotationAdapter(member, daa));
+ }
+
+ SourceOrderColumn2_0Annotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
+ super(parent, member, daa, annotationAdapter);
+ this.nullableDeclarationAdapter = this.buildBooleanElementAdapter(this.getNullableElementName());
+ this.nullableAdapter = this.buildShortCircuitBooleanElementAdapter(this.nullableDeclarationAdapter);
+ this.insertableDeclarationAdapter = this.buildBooleanElementAdapter(this.getInsertableElementName());
+ this.insertableAdapter = this.buildShortCircuitBooleanElementAdapter(this.insertableDeclarationAdapter);
+ this.updatableDeclarationAdapter = this.buildBooleanElementAdapter(this.getUpdatableElementName());
+ this.updatableAdapter = this.buildShortCircuitBooleanElementAdapter(this.updatableDeclarationAdapter);
+ }
+
+ @Override
+ public void initialize(CompilationUnit astRoot) {
+ super.initialize(astRoot);
+ this.nullable = this.buildNullable(astRoot);
+ this.insertable = this.buildInsertable(astRoot);
+ this.updatable = this.buildUpdatable(astRoot);
+ }
+
+ @Override
+ public void update(CompilationUnit astRoot) {
+ super.update(astRoot);
+ this.setNullable(this.buildNullable(astRoot));
+ this.setInsertable(this.buildInsertable(astRoot));
+ this.setUpdatable(this.buildUpdatable(astRoot));
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ @Override
+ protected String getNameElementName() {
+ return JPA.COLUMN__NAME;
+ }
+
+ @Override
+ protected String getColumnDefinitionElementName() {
+ return JPA.COLUMN__COLUMN_DEFINITION;
+ }
+ //************* OrderColumn2_0Annotation implementation *************
+
+ // ***** nullable
+ public Boolean getNullable() {
+ return this.nullable;
+ }
+
+ public void setNullable(Boolean nullable) {
+ if (this.attributeValueHasNotChanged(this.nullable, nullable)) {
+ return;
+ }
+ Boolean old = this.nullable;
+ this.nullable = nullable;
+ this.nullableAdapter.setValue(nullable);
+ this.firePropertyChanged(NULLABLE_PROPERTY, old, nullable);
+ }
+
+ private Boolean buildNullable(CompilationUnit astRoot) {
+ return this.nullableAdapter.getValue(astRoot);
+ }
+
+ public TextRange getNullableTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.nullableDeclarationAdapter, astRoot);
+ }
+
+ String getNullableElementName() {
+ return JPA.COLUMN__NULLABLE;
+ }
+
+ // ***** insertable
+ public Boolean getInsertable() {
+ return this.insertable;
+ }
+
+ public void setInsertable(Boolean insertable) {
+ if (this.attributeValueHasNotChanged(this.insertable, insertable)) {
+ return;
+ }
+ Boolean old = this.insertable;
+ this.insertable = insertable;
+ this.insertableAdapter.setValue(insertable);
+ this.firePropertyChanged(INSERTABLE_PROPERTY, old, insertable);
+ }
+
+ private Boolean buildInsertable(CompilationUnit astRoot) {
+ return this.insertableAdapter.getValue(astRoot);
+ }
+
+ public TextRange getInsertableTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.insertableDeclarationAdapter, astRoot);
+ }
+
+ String getInsertableElementName() {
+ return JPA.COLUMN__INSERTABLE;
+ }
+
+ // ***** updatable
+ public Boolean getUpdatable() {
+ return this.updatable;
+ }
+
+ public void setUpdatable(Boolean updatable) {
+ if (this.attributeValueHasNotChanged(this.updatable, updatable)) {
+ return;
+ }
+ Boolean old = this.updatable;
+ this.updatable = updatable;
+ this.updatableAdapter.setValue(updatable);
+ this.firePropertyChanged(UPDATABLE_PROPERTY, old, updatable);
+ }
+
+ private Boolean buildUpdatable(CompilationUnit astRoot) {
+ return this.updatableAdapter.getValue(astRoot);
+ }
+
+ public TextRange getUpdatableTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.updatableDeclarationAdapter, astRoot);
+ }
+
+ String getUpdatableElementName() {
+ return JPA.COLUMN__UPDATABLE;
+ }
+
+
+ //************* NestableAnnotation implementation *************
+
+ @Override
+ public void initializeFrom(NestableAnnotation oldAnnotation) {
+ super.initializeFrom(oldAnnotation);
+ BaseColumnAnnotation oldColumn = (BaseColumnAnnotation) oldAnnotation;
+ this.setNullable(oldColumn.getNullable());
+ this.setInsertable(oldColumn.getInsertable());
+ this.setUpdatable(oldColumn.getUpdatable());
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryColumnAnnotation.java
index 3290815860..9251f9d9e0 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryColumnAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryColumnAnnotation.java
@@ -51,12 +51,12 @@ public final class BinaryColumnAnnotation
// ********** JavaSourceNamedColumnAnnotation implementation **********
@Override
- String getNameElementName() {
+ protected String getNameElementName() {
return JPA.COLUMN__NAME;
}
@Override
- String getColumnDefinitionElementName() {
+ protected String getColumnDefinitionElementName() {
return JPA.COLUMN__COLUMN_DEFINITION;
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryDiscriminatorColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryDiscriminatorColumnAnnotation.java
index 779578ff56..3215bc8100 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryDiscriminatorColumnAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryDiscriminatorColumnAnnotation.java
@@ -47,12 +47,12 @@ public final class BinaryDiscriminatorColumnAnnotation
// ********** AbstractNamedColumn implementation **********
@Override
- String getNameElementName() {
+ protected String getNameElementName() {
return JPA.DISCRIMINATOR_COLUMN__NAME;
}
@Override
- String getColumnDefinitionElementName() {
+ protected String getColumnDefinitionElementName() {
return JPA.DISCRIMINATOR_COLUMN__COLUMN_DEFINITION;
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinColumnAnnotation.java
index 5c15fcefac..d9f681de35 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinColumnAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinColumnAnnotation.java
@@ -45,12 +45,12 @@ public final class BinaryJoinColumnAnnotation
// ********** JavaSourceNamedColumnAnnotation implementation **********
@Override
- String getNameElementName() {
+ protected String getNameElementName() {
return JPA.JOIN_COLUMN__NAME;
}
@Override
- String getColumnDefinitionElementName() {
+ protected String getColumnDefinitionElementName() {
return JPA.JOIN_COLUMN__COLUMN_DEFINITION;
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedColumnAnnotation.java
index fb9168e6e5..2230a57bca 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedColumnAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedColumnAnnotation.java
@@ -21,7 +21,7 @@ import org.eclipse.jpt.core.utility.TextRange;
* javax.persistence.DiscriminatorColumn
* javax.persistence.PrimaryKeyJoinColumn.
*/
-abstract class BinaryNamedColumnAnnotation
+public abstract class BinaryNamedColumnAnnotation
extends BinaryAnnotation
implements NamedColumnAnnotation
{
@@ -29,7 +29,7 @@ abstract class BinaryNamedColumnAnnotation
private String columnDefinition;
- BinaryNamedColumnAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) {
+ protected BinaryNamedColumnAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) {
super(parent, jdtAnnotation);
this.name = this.buildName();
this.columnDefinition = this.buildColumnDefinition();
@@ -73,7 +73,7 @@ abstract class BinaryNamedColumnAnnotation
return (String) this.getJdtMemberValue(this.getNameElementName());
}
- abstract String getNameElementName();
+ protected abstract String getNameElementName();
public TextRange getNameTextRange(CompilationUnit astRoot) {
throw new UnsupportedOperationException();
@@ -102,7 +102,7 @@ abstract class BinaryNamedColumnAnnotation
return (String) this.getJdtMemberValue(this.getColumnDefinitionElementName());
}
- abstract String getColumnDefinitionElementName();
+ protected abstract String getColumnDefinitionElementName();
public TextRange getColumnDefinitionTextRange(CompilationUnit astRoot) {
throw new UnsupportedOperationException();
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPrimaryKeyJoinColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPrimaryKeyJoinColumnAnnotation.java
index 35a6401ce0..ba9b01d58c 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPrimaryKeyJoinColumnAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPrimaryKeyJoinColumnAnnotation.java
@@ -45,12 +45,12 @@ public final class BinaryPrimaryKeyJoinColumnAnnotation
// ********** AbstractNamedColumn implementation **********
@Override
- String getNameElementName() {
+ protected String getNameElementName() {
return JPA.PRIMARY_KEY_JOIN_COLUMN__NAME;
}
@Override
- String getColumnDefinitionElementName() {
+ protected String getColumnDefinitionElementName() {
return JPA.PRIMARY_KEY_JOIN_COLUMN__COLUMN_DEFINITION;
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceColumnAnnotation.java
index d04fb8b97c..e9179ab0b6 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceColumnAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceColumnAnnotation.java
@@ -80,12 +80,12 @@ public final class SourceColumnAnnotation
// ********** JavaSourceNamedColumnAnnotation implementation **********
@Override
- String getNameElementName() {
+ protected String getNameElementName() {
return JPA.COLUMN__NAME;
}
@Override
- String getColumnDefinitionElementName() {
+ protected String getColumnDefinitionElementName() {
return JPA.COLUMN__COLUMN_DEFINITION;
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorColumnAnnotation.java
index 0239d3f048..048986b6d9 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorColumnAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorColumnAnnotation.java
@@ -70,12 +70,12 @@ public final class SourceDiscriminatorColumnAnnotation
// ********** JavaSourceNamedColumnAnnotation implementation **********
@Override
- String getNameElementName() {
+ protected String getNameElementName() {
return JPA.DISCRIMINATOR_COLUMN__NAME;
}
@Override
- String getColumnDefinitionElementName() {
+ protected String getColumnDefinitionElementName() {
return JPA.DISCRIMINATOR_COLUMN__COLUMN_DEFINITION;
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinColumnAnnotation.java
index cf9f24a3a6..03fc7a6b8a 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinColumnAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinColumnAnnotation.java
@@ -76,12 +76,12 @@ public final class SourceJoinColumnAnnotation
// ********** JavaSourceNamedColumnAnnotation implementation **********
@Override
- String getNameElementName() {
+ protected String getNameElementName() {
return JPA.JOIN_COLUMN__NAME;
}
@Override
- String getColumnDefinitionElementName() {
+ protected String getColumnDefinitionElementName() {
return JPA.JOIN_COLUMN__COLUMN_DEFINITION;
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedColumnAnnotation.java
index 3f6048f7e3..639b03f8ca 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedColumnAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedColumnAnnotation.java
@@ -31,7 +31,7 @@ import org.eclipse.jpt.core.utility.jdt.Member;
* javax.persistence.DiscriminatorColumn
* javax.persistence.PrimaryKeyJoinColumn.
*/
-abstract class SourceNamedColumnAnnotation
+public abstract class SourceNamedColumnAnnotation
extends SourceAnnotation<Member>
implements NamedColumnAnnotation
{
@@ -48,7 +48,7 @@ abstract class SourceNamedColumnAnnotation
this(parent, member, daa, new MemberAnnotationAdapter(member, daa));
}
- SourceNamedColumnAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
+ protected SourceNamedColumnAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
super(parent, member, daa, annotationAdapter);
this.nameDeclarationAdapter = this.buildStringElementAdapter(this.getNameElementName());
this.nameAdapter = this.buildShortCircuitElementAdapter(this.nameDeclarationAdapter);
@@ -60,7 +60,7 @@ abstract class SourceNamedColumnAnnotation
return ConversionDeclarationAnnotationElementAdapter.forStrings(this.daa, elementName);
}
- DeclarationAnnotationElementAdapter<Boolean> buildBooleanElementAdapter(String elementName) {
+ protected DeclarationAnnotationElementAdapter<Boolean> buildBooleanElementAdapter(String elementName) {
return new ConversionDeclarationAnnotationElementAdapter<Boolean>(this.daa, elementName, BooleanExpressionConverter.instance());
}
@@ -72,7 +72,7 @@ abstract class SourceNamedColumnAnnotation
return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea);
}
- AnnotationElementAdapter<Boolean> buildShortCircuitBooleanElementAdapter(DeclarationAnnotationElementAdapter<Boolean> daea) {
+ protected AnnotationElementAdapter<Boolean> buildShortCircuitBooleanElementAdapter(DeclarationAnnotationElementAdapter<Boolean> daea) {
return new ShortCircuitAnnotationElementAdapter<Boolean>(this.member, daea);
}
@@ -133,7 +133,7 @@ abstract class SourceNamedColumnAnnotation
return this.elementTouches(this.nameDeclarationAdapter, pos, astRoot);
}
- abstract String getNameElementName();
+ protected abstract String getNameElementName();
// ***** column definition
public String getColumnDefinition() {
@@ -158,7 +158,7 @@ abstract class SourceNamedColumnAnnotation
return this.getElementTextRange(this.columnDefinitionDeclarationAdapter, astRoot);
}
- abstract String getColumnDefinitionElementName();
+ protected abstract String getColumnDefinitionElementName();
// ********** NestableAnnotation implementation **********
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnAnnotation.java
index 7e7a3a2e21..1b190855fd 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnAnnotation.java
@@ -76,12 +76,12 @@ public final class SourcePrimaryKeyJoinColumnAnnotation
// ********** JavaSourceNamedColumnAnnotation implementation **********
@Override
- String getNameElementName() {
+ protected String getNameElementName() {
return JPA.PRIMARY_KEY_JOIN_COLUMN__NAME;
}
@Override
- String getColumnDefinitionElementName() {
+ protected String getColumnDefinitionElementName() {
return JPA.PRIMARY_KEY_JOIN_COLUMN__COLUMN_DEFINITION;
}
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 781829d519..69ae561b65 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
@@ -48,6 +48,8 @@ public interface JPA2_0
String ONE_TO_ONE__ORPHAN_REMOVAL = "orphanRemoval";
+ String ORDER_COLUMN = PACKAGE_ + "OrderColumn";
+
String SEQUENCE_GENERATOR__CATALOG = "catalog";
String SEQUENCE_GENERATOR__SCHEMA = "schema";
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/resource/java/OrderColumn2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/resource/java/OrderColumn2_0Annotation.java
new file mode 100644
index 0000000000..2c4a6ddf56
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/resource/java/OrderColumn2_0Annotation.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * 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.NamedColumnAnnotation;
+import org.eclipse.jpt.core.utility.TextRange;
+
+/**
+ * Corresponds to the JPA 2.0 annotation
+ * javax.persistence.OrderColumn
+ *
+ * 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 OrderColumn2_0Annotation
+ extends NamedColumnAnnotation
+{
+
+ String ANNOTATION_NAME = JPA2_0.ORDER_COLUMN;
+
+ /**
+ * Corresponds to the 'nullable' element of the OrderColumn annotation.
+ * Return null if the element does not exist in Java.
+ */
+ Boolean getNullable();
+ String NULLABLE_PROPERTY = "nullable"; //$NON-NLS-1$
+
+ /**
+ * Corresponds to the 'nullable' element of the OrderColumn annotation.
+ * Set to null to remove the element.
+ */
+ void setNullable(Boolean nullable);
+
+ /**
+ * Return the {@link TextRange} for the 'nullable' element. If the element
+ * does not exist return the {@link TextRange} for the OrderColumn annotation.
+ */
+ TextRange getNullableTextRange(CompilationUnit astRoot);
+
+
+ /**
+ * Corresponds to the 'insertable' element of the OrderColumn annotation.
+ * Return null if the element does not exist in Java.
+ */
+ Boolean getInsertable();
+ String INSERTABLE_PROPERTY = "insertable"; //$NON-NLS-1$
+
+ /**
+ * Corresponds to the 'insertable' element of the OrderColumn annotation.
+ * Set to null to remove the element.
+ */
+ void setInsertable(Boolean insertable);
+
+ /**
+ * Return the {@link TextRange} for the 'insertable' element. If the element
+ * does not exist return the {@link TextRange} for the OrderColumn annotation.
+ */
+ TextRange getInsertableTextRange(CompilationUnit astRoot);
+
+
+ /**
+ * Corresponds to the 'updatable' element of the OrderColumn annotation.
+ * Return null if the element does not exist in Java.
+ */
+ Boolean getUpdatable();
+ String UPDATABLE_PROPERTY = "updatable"; //$NON-NLS-1$
+
+ /**
+ * Corresponds to the 'updatable' element of the OrderColumn annotation.
+ * Set to null to remove the element.
+ */
+ void setUpdatable(Boolean updatable);
+
+ /**
+ * Return the {@link TextRange} for the 'updatable' element. If the element
+ * does not exist return the {@link TextRange} for the OrderColumn annotation.
+ */
+ TextRange getUpdatableTextRange(CompilationUnit astRoot);
+
+}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/resource/java/JavaResource2_0Tests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/resource/java/JavaResource2_0Tests.java
index 9a6e0e74eb..0444c88a1b 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/resource/java/JavaResource2_0Tests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/resource/java/JavaResource2_0Tests.java
@@ -23,6 +23,7 @@ public class JavaResource2_0Tests {
suite.addTestSuite(Cacheable2_0AnnotationTests.class);
suite.addTestSuite(ElementCollection2_0AnnotationTests.class);
suite.addTestSuite(MapsId2_0AnnotationTests.class);
+ suite.addTestSuite(OrderColumn2_0AnnotationTests.class);
suite.addTestSuite(SequenceGenerator2_0Tests.class);
return suite;
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/resource/java/OrderColumn2_0AnnotationTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/resource/java/OrderColumn2_0AnnotationTests.java
new file mode 100644
index 0000000000..676a2829aa
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/resource/java/OrderColumn2_0AnnotationTests.java
@@ -0,0 +1,242 @@
+/*******************************************************************************
+ * 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.tests.internal.jpa2.resource.java;
+
+import java.util.Iterator;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0;
+import org.eclipse.jpt.core.jpa2.resource.java.OrderColumn2_0Annotation;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
+import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
+
+@SuppressWarnings("nls")
+public class OrderColumn2_0AnnotationTests extends JavaResourceModel2_0TestCase {
+
+ private static final String COLUMN_NAME = "MY_COLUMN";
+ private static final String COLUMN_TABLE = "MY_TABLE";
+ private static final String COLUMN_COLUMN_DEFINITION = "COLUMN_DEFINITION";
+
+ public OrderColumn2_0AnnotationTests(String name) {
+ super(name);
+ }
+
+ private ICompilationUnit createTestOrderColumn() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA2_0.ORDER_COLUMN);
+ }
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append("@OrderColumn");
+ }
+ });
+ }
+
+ private ICompilationUnit createTestOrderColumnWithName() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA2_0.ORDER_COLUMN);
+ }
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append("@OrderColumn(name = \"" + COLUMN_NAME + "\")");
+ }
+ });
+ }
+
+ private ICompilationUnit createTestOrderColumnWithColumnDefinition() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA2_0.ORDER_COLUMN);
+ }
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append("@OrderColumn(columnDefinition = \"" + COLUMN_COLUMN_DEFINITION + "\")");
+ }
+ });
+ }
+
+ private ICompilationUnit createTestOrderColumnWithBooleanElement(final String booleanElement) throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA2_0.ORDER_COLUMN);
+ }
+ @Override
+ public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ sb.append("@OrderColumn(" + booleanElement + " = true)");
+ }
+ });
+ }
+
+ public void testGetName() throws Exception {
+ ICompilationUnit cu = this.createTestOrderColumnWithName();
+ JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
+ JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
+ OrderColumn2_0Annotation column = (OrderColumn2_0Annotation) attributeResource.getAnnotation(JPA2_0.ORDER_COLUMN);
+ assertNotNull(column);
+ assertEquals(COLUMN_NAME, column.getName());
+ }
+
+ public void testGetNull() throws Exception {
+ ICompilationUnit cu = this.createTestOrderColumn();
+ JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
+ JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
+ OrderColumn2_0Annotation column = (OrderColumn2_0Annotation) attributeResource.getAnnotation(JPA2_0.ORDER_COLUMN);
+ assertNotNull(column);
+ assertNull(column.getName());
+ assertNull(column.getNullable());
+ assertNull(column.getInsertable());
+ assertNull(column.getUpdatable());
+ assertNull(column.getColumnDefinition());
+ }
+
+ public void testSetName() throws Exception {
+ ICompilationUnit cu = this.createTestOrderColumn();
+ JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
+ JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
+ OrderColumn2_0Annotation column = (OrderColumn2_0Annotation) attributeResource.getAnnotation(JPA2_0.ORDER_COLUMN);
+
+ assertNotNull(column);
+ assertNull(column.getName());
+
+ column.setName("Foo");
+ assertEquals("Foo", column.getName());
+
+ assertSourceContains("@OrderColumn(name = \"Foo\")", cu);
+ }
+
+ public void testSetNameNull() throws Exception {
+ ICompilationUnit cu = this.createTestOrderColumnWithName();
+ JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
+ JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
+ OrderColumn2_0Annotation column = (OrderColumn2_0Annotation) attributeResource.getAnnotation(JPA2_0.ORDER_COLUMN);
+
+ assertEquals(COLUMN_NAME, column.getName());
+
+ column.setName(null);
+ assertNull(column.getName());
+
+ assertSourceDoesNotContain("@OrderColumn", cu);
+ }
+
+ public void testGetColumnDefinition() throws Exception {
+ ICompilationUnit cu = this.createTestOrderColumnWithColumnDefinition();
+ JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
+ JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
+ OrderColumn2_0Annotation column = (OrderColumn2_0Annotation) attributeResource.getAnnotation(JPA2_0.ORDER_COLUMN);
+ assertEquals(COLUMN_COLUMN_DEFINITION, column.getColumnDefinition());
+ }
+
+ public void testSetColumnDefinition() throws Exception {
+ ICompilationUnit cu = this.createTestOrderColumn();
+ JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
+ JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
+ OrderColumn2_0Annotation column = (OrderColumn2_0Annotation) attributeResource.getAnnotation(JPA2_0.ORDER_COLUMN);
+
+ assertNotNull(column);
+ assertNull(column.getColumnDefinition());
+
+ column.setColumnDefinition("Foo");
+ assertEquals("Foo", column.getColumnDefinition());
+
+ assertSourceContains("@OrderColumn(columnDefinition = \"Foo\")", cu);
+
+
+ column.setColumnDefinition(null);
+ assertSourceDoesNotContain("@OrderColumn", cu);
+ }
+
+ public void testGetNullable() throws Exception {
+ ICompilationUnit cu = this.createTestOrderColumnWithBooleanElement("nullable");
+ JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
+ JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
+ OrderColumn2_0Annotation column = (OrderColumn2_0Annotation) attributeResource.getAnnotation(JPA2_0.ORDER_COLUMN);
+
+ assertEquals(Boolean.TRUE, column.getNullable());
+ }
+
+ public void testSetNullable() throws Exception {
+ ICompilationUnit cu = this.createTestOrderColumn();
+ JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
+ JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
+ OrderColumn2_0Annotation column = (OrderColumn2_0Annotation) attributeResource.getAnnotation(JPA2_0.ORDER_COLUMN);
+
+ assertNotNull(column);
+ assertNull(column.getNullable());
+
+ column.setNullable(Boolean.FALSE);
+ assertEquals(Boolean.FALSE, column.getNullable());
+
+ assertSourceContains("@OrderColumn(nullable = false)", cu);
+
+ column.setNullable(null);
+ assertSourceDoesNotContain("@OrderColumn", cu);
+ }
+
+ public void testGetInsertable() throws Exception {
+ ICompilationUnit cu = this.createTestOrderColumnWithBooleanElement("insertable");
+ JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
+ JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
+ OrderColumn2_0Annotation column = (OrderColumn2_0Annotation) attributeResource.getAnnotation(JPA2_0.ORDER_COLUMN);
+
+ assertEquals(Boolean.TRUE, column.getInsertable());
+ }
+
+ public void testSetInsertable() throws Exception {
+ ICompilationUnit cu = this.createTestOrderColumn();
+ JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
+ JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
+ OrderColumn2_0Annotation column = (OrderColumn2_0Annotation) attributeResource.getAnnotation(JPA2_0.ORDER_COLUMN);
+
+ assertNotNull(column);
+ assertNull(column.getInsertable());
+
+ column.setInsertable(Boolean.FALSE);
+ assertEquals(Boolean.FALSE, column.getInsertable());
+
+ assertSourceContains("@OrderColumn(insertable = false)", cu);
+
+ column.setInsertable(null);
+ assertSourceDoesNotContain("@OrderColumn", cu);
+ }
+
+ public void testGetUpdatable() throws Exception {
+ ICompilationUnit cu = this.createTestOrderColumnWithBooleanElement("updatable");
+ JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
+ JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
+ OrderColumn2_0Annotation column = (OrderColumn2_0Annotation) attributeResource.getAnnotation(JPA2_0.ORDER_COLUMN);
+
+ assertEquals(Boolean.TRUE, column.getUpdatable());
+ }
+
+ public void testSetUpdatable() throws Exception {
+ ICompilationUnit cu = this.createTestOrderColumn();
+ JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
+ JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
+ OrderColumn2_0Annotation column = (OrderColumn2_0Annotation) attributeResource.getAnnotation(JPA2_0.ORDER_COLUMN);
+
+ assertNotNull(column);
+ assertNull(column.getUpdatable());
+
+ column.setUpdatable(Boolean.FALSE);
+ assertEquals(Boolean.FALSE, column.getUpdatable());
+
+ assertSourceContains("@OrderColumn(updatable = false)", cu);
+
+ column.setUpdatable(null);
+ assertSourceDoesNotContain("@OrderColumn", cu);
+ }
+
+}

Back to the top