summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNan Li2012-09-10 20:57:06 (EDT)
committerKaren Butzke2012-09-10 20:57:06 (EDT)
commitf763ba8e486f0ffef17e029ed48b5861221fa7f0 (patch)
tree51145fef89cb61798953e867c1c04998a6d0e0a0
parent2895790d41082cae2d316c5a45ee06dd4241c9d9 (diff)
downloadwebtools.dali-f763ba8e486f0ffef17e029ed48b5861221fa7f0.zip
webtools.dali-f763ba8e486f0ffef17e029ed48b5861221fa7f0.tar.gz
webtools.dali-f763ba8e486f0ffef17e029ed48b5861221fa7f0.tar.bz2
Bug 372069 - NPE when trying to override an association mapping with
mapped-by strategy
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaOverrideRelationship.java10
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmOverrideRelationship.java13
2 files changed, 14 insertions, 9 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaOverrideRelationship.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaOverrideRelationship.java
index 6504083..f9deb2a 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaOverrideRelationship.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaOverrideRelationship.java
@@ -15,13 +15,13 @@ import org.eclipse.jpt.jpa.core.context.Entity;
import org.eclipse.jpt.jpa.core.context.MappedByRelationship;
import org.eclipse.jpt.jpa.core.context.OverrideRelationship;
import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseColumn;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyTableColumn.Owner;
import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn;
import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumnRelationship;
import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTable;
import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTableRelationship;
import org.eclipse.jpt.jpa.core.context.ReadOnlyOverrideRelationship;
import org.eclipse.jpt.jpa.core.context.ReadOnlyRelationship;
+import org.eclipse.jpt.jpa.core.context.ReadOnlyTableColumn.Owner;
import org.eclipse.jpt.jpa.core.context.Relationship;
import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
import org.eclipse.jpt.jpa.core.context.RelationshipStrategy;
@@ -285,7 +285,7 @@ public class GenericJavaOverrideRelationship
return result;
}
- return this.strategy.getCompletionProposals(pos);
+ return (this.strategy == null) ? null : this.strategy.getCompletionProposals(pos);
}
@@ -298,7 +298,11 @@ public class GenericJavaOverrideRelationship
@Override
public void validate(List<IMessage> messages, IReporter reporter) {
super.validate(messages, reporter);
- this.strategy.validate(messages, reporter);
+ // prevent NPE on JPA 2_0 platforms
+ // this.strategy == null when the mapping relationship strategy, e.g. mappedBy, cannot be overridden
+ if (this.strategy != null) {
+ this.strategy.validate(messages, reporter);
+ }
}
public JptValidator buildJoinTableValidator(ReadOnlyJoinTable table) {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmOverrideRelationship.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmOverrideRelationship.java
index c893406..4087478 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmOverrideRelationship.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmOverrideRelationship.java
@@ -288,7 +288,11 @@ public class GenericOrmOverrideRelationship
@Override
public void validate(List<IMessage> messages, IReporter reporter) {
super.validate(messages, reporter);
- this.strategy.validate(messages, reporter);
+ // prevent NPE on JPA 2_0 platforms
+ // this.strategy == null when the mapping relationship strategy, e.g. mapped-by, cannot be overridden
+ if (this.strategy != null) {
+ this.strategy.validate(messages, reporter);
+ }
}
public JptValidator buildJoinTableValidator(ReadOnlyJoinTable table) {
@@ -311,10 +315,7 @@ public class GenericOrmOverrideRelationship
if (result != null) {
return result;
}
- result = this.strategy.getCompletionProposals(pos);
- if (result != null) {
- return result;
- }
- return null;
+
+ return this.strategy == null ? null : this.strategy.getCompletionProposals(pos);
}
}