summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNan Li2013-04-26 16:03:23 (EDT)
committerBrian Vosburgh2013-04-26 16:03:23 (EDT)
commit66e5158236bb3e6db1d0e382abe854e2c5e9daec (patch)
tree99c2f55b9a29533aeeb49e5429474bf68aef69c5
parentad154083b8ff07f56797ac68cf8935eee732a654 (diff)
downloadwebtools.dali-66e5158236bb3e6db1d0e382abe854e2c5e9daec.zip
webtools.dali-66e5158236bb3e6db1d0e382abe854e2c5e9daec.tar.gz
webtools.dali-66e5158236bb3e6db1d0e382abe854e2c5e9daec.tar.bz2
[380021] fix entity default primary key join column validation (patch
from Nan)
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEntity.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/BaseJoinColumnValidator.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/JavaEntityPrimaryKeyJoinColumnValidator.java40
3 files changed, 44 insertions, 4 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEntity.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEntity.java
index b782831..8bbcdd8 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEntity.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEntity.java
@@ -80,13 +80,13 @@ import org.eclipse.jpt.jpa.core.internal.jpa1.context.AssociationOverrideValidat
import org.eclipse.jpt.jpa.core.internal.jpa1.context.AttributeOverrideColumnValidator;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.AttributeOverrideValidator;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.DiscriminatorColumnValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.EntityPrimaryKeyJoinColumnValidator;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.EntityTableDescriptionProvider;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.GenericEntityPrimaryKeyValidator;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.JoinTableTableDescriptionProvider;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.MappedSuperclassOverrideDescriptionProvider;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.SecondaryTableValidator;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.TableValidator;
+import org.eclipse.jpt.jpa.core.internal.jpa1.context.java.JavaEntityPrimaryKeyJoinColumnValidator;
import org.eclipse.jpt.jpa.core.internal.resource.java.NullPrimaryKeyJoinColumnAnnotation;
import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaAssociationOverrideContainer2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaAttributeOverrideContainer2_0;
@@ -1155,7 +1155,7 @@ public abstract class AbstractJavaEntity
* Return whether the entity is the top of an inheritance hierarchy
* and has no descendants and no specified inheritance strategy has been defined.
*/
- protected boolean isRootNoDescendantsNoStrategyDefined() {
+ public boolean isRootNoDescendantsNoStrategyDefined() {
return this.isRootEntity() &&
this.descendants.isEmpty() &&
(this.specifiedInheritanceStrategy == null);
@@ -1637,7 +1637,7 @@ public abstract class AbstractJavaEntity
}
public JpaValidator buildColumnValidator(NamedColumn column) {
- return new EntityPrimaryKeyJoinColumnValidator((BaseJoinColumn) column, this);
+ return new JavaEntityPrimaryKeyJoinColumnValidator((BaseJoinColumn) column, this, AbstractJavaEntity.this);
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/BaseJoinColumnValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/BaseJoinColumnValidator.java
index d8ac2c6..25bd053 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/BaseJoinColumnValidator.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/BaseJoinColumnValidator.java
@@ -19,7 +19,7 @@ import org.eclipse.wst.validation.internal.provisional.core.IMessage;
public abstract class BaseJoinColumnValidator<C extends BaseJoinColumn>
extends AbstractNamedColumnValidator<C>
{
- private final BaseJoinColumn.ParentAdapter joinColumnParentAdapter;
+ protected final BaseJoinColumn.ParentAdapter joinColumnParentAdapter;
protected BaseJoinColumnValidator(
C column,
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/JavaEntityPrimaryKeyJoinColumnValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/JavaEntityPrimaryKeyJoinColumnValidator.java
new file mode 100644
index 0000000..787a7f6
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/JavaEntityPrimaryKeyJoinColumnValidator.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.jpa1.context.java;
+
+import java.util.List;
+import org.eclipse.jpt.jpa.core.context.BaseJoinColumn;
+import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaEntity;
+import org.eclipse.jpt.jpa.core.internal.jpa1.context.EntityPrimaryKeyJoinColumnValidator;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+
+public class JavaEntityPrimaryKeyJoinColumnValidator
+ extends EntityPrimaryKeyJoinColumnValidator
+{
+ protected final AbstractJavaEntity entity;
+
+ public JavaEntityPrimaryKeyJoinColumnValidator(
+ BaseJoinColumn column,
+ BaseJoinColumn.ParentAdapter parentAdapter,
+ AbstractJavaEntity entity) {
+ super(column, parentAdapter);
+ this.entity = entity;
+ }
+
+ @Override
+ protected void validateJoinColumnName(List<IMessage> messages) {
+ if ( ! this.entity.isRootNoDescendantsNoStrategyDefined()) {
+ messages.add(this.buildUnresolvedNameMessage(this.getVirtualPKJoinColumnUnresolvedNameMessage()));
+ }
+ else if (this.entity.getSpecifiedPrimaryKeyJoinColumnsSize() > 0) {
+ super.validateJoinColumnName(messages);
+ }
+ }
+} \ No newline at end of file