Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaIdMapping.java20
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmIdMapping.java29
3 files changed, 43 insertions, 8 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties b/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties
index ff3d351cd9..9e4e16b54b 100644
--- a/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties
+++ b/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties
@@ -70,7 +70,7 @@ MAPPING_UNRESOLVED_MAPPED_BY=In {0}, the "mapped by" value ''{1}'' cannot be res
MAPPING_INVALID_MAPPED_BY=In {0}, the "mapped by" attribute ''{1}'' has an invalid mapping type for this relationship.
MAPPING_MAPPED_BY_ON_BOTH_SIDES=In {0}, the "mapped by" attribute ''{1}'' also maps this attribute. Every relationship must have an owner.
ID_MAPPING_UNRESOLVED_GENERATOR_NAME=Unresolved generator name \"{0}\"
-ID_MAPPING_MAPPED_BY_RELATIONSHIP_AND_COLUMN_SPECIFIED=IDs that are mapped by a relationship should not specify a column.
+ID_MAPPING_MAPPED_BY_RELATIONSHIP_AND_COLUMN_SPECIFIED=In {0}, a column is specified, but it is mapped by a relationship. IDs that are mapped by a relationship should not specify a column.
EMBEDDED_ID_MAPPING_MAPPED_BY_RELATIONSHIP_AND_ATTRIBUTE_OVERRIDES_SPECIFIED=Embedded IDs that are mapped by a relationship should not specify any attribute overrides.
ATTRIBUTE_OVERRIDE_MAPPED_BY_RELATIONSHIP_AND_SPECIFIED=Attributes (or subattributes of an attribute) that are mapped by a relationship should not be overridden.
TABLE_UNRESOLVED_CATALOG=Catalog \"{0}\" cannot be resolved for table \"{1}\"
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaIdMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaIdMapping.java
index ed19e6a5c8..68f52fe35e 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaIdMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaIdMapping.java
@@ -18,6 +18,7 @@ import org.eclipse.jpt.core.context.AttributeMapping;
import org.eclipse.jpt.core.context.BaseColumn;
import org.eclipse.jpt.core.context.Converter;
import org.eclipse.jpt.core.context.NamedColumn;
+import org.eclipse.jpt.core.context.PersistentAttribute;
import org.eclipse.jpt.core.context.java.JavaColumn;
import org.eclipse.jpt.core.context.java.JavaConverter;
import org.eclipse.jpt.core.context.java.JavaGeneratedValue;
@@ -38,6 +39,7 @@ import org.eclipse.jpt.core.resource.java.TableGeneratorAnnotation;
import org.eclipse.jpt.core.resource.java.TemporalAnnotation;
import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.jpt.utility.Filter;
+import org.eclipse.jpt.utility.internal.ArrayTools;
import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.StringTools;
import org.eclipse.jpt.utility.internal.iterables.CompositeIterable;
@@ -45,6 +47,7 @@ import org.eclipse.jpt.utility.internal.iterables.FilteringIterable;
import org.eclipse.jpt.utility.internal.iterables.SubIterableWrapper;
import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
@@ -418,11 +421,9 @@ public abstract class AbstractJavaIdMapping
// (In JPA 1.0, this will never be the case, since the id is never mapped by a relationship)
if (isColumnSpecified() && isMappedByRelationship()) {
messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
+ buildMessage(
JpaValidationMessages.ID_MAPPING_MAPPED_BY_RELATIONSHIP_AND_COLUMN_SPECIFIED,
new String[] {},
- getColumn(),
getColumn().getValidationTextRange(astRoot)));
}
@@ -455,4 +456,17 @@ public abstract class AbstractJavaIdMapping
textRange
);
}
+
+ /* TODO - move to AbstractOrmAttributeMapping? */
+ protected IMessage buildMessage(String msgID, String[] params, TextRange textRange) {
+ PersistentAttribute attribute = getPersistentAttribute();
+ String attributeDesc = NLS.bind(JpaValidationDescriptionMessages.ATTRIBUTE_DESC, attribute.getName());
+
+ return DefaultJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ msgID,
+ ArrayTools.add(params, 0, attributeDesc),
+ this,
+ textRange);
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmIdMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmIdMapping.java
index 7597709e53..6dc07edd24 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmIdMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmIdMapping.java
@@ -16,6 +16,7 @@ import org.eclipse.jpt.core.context.AttributeMapping;
import org.eclipse.jpt.core.context.BaseColumn;
import org.eclipse.jpt.core.context.Converter;
import org.eclipse.jpt.core.context.NamedColumn;
+import org.eclipse.jpt.core.context.PersistentAttribute;
import org.eclipse.jpt.core.context.orm.OrmAttributeMapping;
import org.eclipse.jpt.core.context.orm.OrmColumn;
import org.eclipse.jpt.core.context.orm.OrmColumnMapping;
@@ -29,6 +30,7 @@ import org.eclipse.jpt.core.internal.validation.JpaValidationDescriptionMessages
import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.core.jpa2.context.IdMapping2_0;
import org.eclipse.jpt.core.jpa2.context.SingleRelationshipMapping2_0;
+import org.eclipse.jpt.core.resource.java.JPA;
import org.eclipse.jpt.core.resource.orm.Attributes;
import org.eclipse.jpt.core.resource.orm.OrmFactory;
import org.eclipse.jpt.core.resource.orm.XmlColumn;
@@ -36,9 +38,11 @@ import org.eclipse.jpt.core.resource.orm.XmlGeneratedValue;
import org.eclipse.jpt.core.resource.orm.XmlId;
import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.jpt.db.Table;
+import org.eclipse.jpt.utility.internal.ArrayTools;
import org.eclipse.jpt.utility.internal.iterables.CompositeIterable;
import org.eclipse.jpt.utility.internal.iterables.FilteringIterable;
import org.eclipse.jpt.utility.internal.iterables.SubIterableWrapper;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
@@ -190,7 +194,12 @@ public abstract class AbstractOrmIdMapping<T extends XmlId>
}
protected boolean isColumnSpecified() {
- return ! isVirtual() && getResourceColumn() != null;
+ if (! isVirtual()) {
+ return getResourceColumn() != null;
+ }
+ else {
+ return getJavaResourcePersistentAttribute().getAnnotation(JPA.COLUMN) != null;
+ }
}
public void addResourceColumn() {
@@ -341,11 +350,9 @@ public abstract class AbstractOrmIdMapping<T extends XmlId>
// (In JPA 1.0, this will never be the case, since the id is never mapped by a relationship)
if (isColumnSpecified() && isMappedByRelationship()) {
messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
+ buildMessage(
JpaValidationMessages.ID_MAPPING_MAPPED_BY_RELATIONSHIP_AND_COLUMN_SPECIFIED,
new String[] {},
- getColumn(),
getColumn().getValidationTextRange()));
}
@@ -407,4 +414,18 @@ public abstract class AbstractOrmIdMapping<T extends XmlId>
textRange
);
}
+
+ /* TODO - move to AbstractOrmAttributeMapping? */
+ protected IMessage buildMessage(String msgID, String[] params, TextRange textRange) {
+ String attributeDescString;
+ PersistentAttribute attribute = getPersistentAttribute();
+ if (attribute.isVirtual()) {
+ attributeDescString = NLS.bind(JpaValidationDescriptionMessages.VIRTUAL_ATTRIBUTE_DESC, attribute.getName());
+ }
+ else {
+ attributeDescString = NLS.bind(JpaValidationDescriptionMessages.ATTRIBUTE_DESC, attribute.getName());
+ }
+ return DefaultJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY, msgID, ArrayTools.add(params, 0, attributeDescString), this, textRange);
+ }
}

Back to the top