diff options
author | Karen Butzke | 2012-10-10 17:31:57 +0000 |
---|---|---|
committer | Karen Butzke | 2012-10-10 17:31:57 +0000 |
commit | 7c93ea23f97a2883a6c49feece20119165285c25 (patch) | |
tree | c4e819e3fe36aa32250d6b20b0566c7dd16b1898 /jpa | |
parent | 977427af766a26fad9b0d0328142603b679fb908 (diff) | |
download | webtools.dali-7c93ea23f97a2883a6c49feece20119165285c25.tar.gz webtools.dali-7c93ea23f97a2883a6c49feece20119165285c25.tar.xz webtools.dali-7c93ea23f97a2883a6c49feece20119165285c25.zip |
Bug 391017 - orm.xml implied attribute validation errors appearing in the wrong location
Diffstat (limited to 'jpa')
25 files changed, 244 insertions, 133 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaAttributeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaAttributeMapping.java index 73fe4b3911..b67fe399af 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaAttributeMapping.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaAttributeMapping.java @@ -302,15 +302,28 @@ public abstract class AbstractJavaAttributeMapping<A extends Annotation> protected void validateMappingType(List<IMessage> messages) { if ( ! this.getTypeMapping().attributeMappingKeyAllowed(this.getKey())) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.PERSISTENT_ATTRIBUTE_INVALID_MAPPING, - new String[] {this.getName()}, - this, - this.getValidationTextRange() - ) - ); + if (this.getPersistentAttribute().isVirtual()) { + messages.add( + DefaultJpaValidationMessages.buildMessage( + IMessage.HIGH_SEVERITY, + JpaValidationMessages.PERSISTENT_ATTRIBUTE_INVALID_MAPPING, //TODO KFB - different message for virtual attribute + new String[] {this.getName()}, + this, + this.getVirtualPersistentAttributeTextRange() + ) + ); + } + else { + messages.add( + DefaultJpaValidationMessages.buildMessage( + IMessage.HIGH_SEVERITY, + JpaValidationMessages.PERSISTENT_ATTRIBUTE_INVALID_MAPPING, + new String[] {this.getName()}, + this, + this.getValidationTextRange() + ) + ); + } } } @@ -319,6 +332,10 @@ public abstract class AbstractJavaAttributeMapping<A extends Annotation> return (textRange != null) ? textRange : this.getPersistentAttribute().getValidationTextRange(); } + protected TextRange getVirtualPersistentAttributeTextRange() { + return this.getPersistentAttribute().getValidationTextRange(); + } + protected TextRange getMappingAnnotationTextRange() { A annotation = this.getMappingAnnotation(); return (annotation == null) ? null : annotation.getTextRange(); diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaBaseEmbeddedMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaBaseEmbeddedMapping.java index 4468022cdd..f8690c64bc 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaBaseEmbeddedMapping.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaBaseEmbeddedMapping.java @@ -223,7 +223,7 @@ public abstract class AbstractJavaBaseEmbeddedMapping<A extends Annotation> JpaValidationMessages.VIRTUAL_ATTRIBUTE_TARGET_NOT_AN_EMBEDDABLE, new String[] {this.getName(), targetEmbeddableTypeName}, this, - this.getValidationTextRange() + this.getVirtualPersistentAttributeTextRange() ) ); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEmbeddedIdMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEmbeddedIdMapping.java index 7822d98eab..1f1463eaa8 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEmbeddedIdMapping.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEmbeddedIdMapping.java @@ -12,7 +12,6 @@ package org.eclipse.jpt.jpa.core.internal.context.java; import java.io.Serializable; import java.util.List; -import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jpt.common.core.internal.utility.JDTTools; import org.eclipse.jpt.common.core.resource.java.JavaResourceType; import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; @@ -118,7 +117,7 @@ public abstract class AbstractJavaEmbeddedIdMapping JpaValidationMessages.VIRTUAL_ATTRIBUTE_EMBEDDED_ID_MAPPING_MAPPED_BY_RELATIONSHIP_AND_ATTRIBUTE_OVERRIDES_SPECIFIED, new String[] {this.getName()}, this.attributeOverrideContainer, - this.attributeOverrideContainer.getValidationTextRange() + this.getVirtualPersistentAttributeTextRange() ) ); } else { @@ -144,8 +143,7 @@ public abstract class AbstractJavaEmbeddedIdMapping protected void validateTargetEmbeddableImplementsZeroArgConstructor(List<IMessage> messages, IReporter reporter) { if (this.getTargetEmbeddable() != null) { String targetEmbeddableClassName = this.getTargetEmbeddable().getPersistentType().getName(); - IJavaProject javaProject = getJpaProject().getJavaProject(); - if (!JDTTools.classHasPublicZeroArgConstructor(javaProject, targetEmbeddableClassName)){ + if (!JDTTools.classHasPublicZeroArgConstructor(this.getJavaProject(), targetEmbeddableClassName)){ if (this.getPersistentAttribute().isVirtual()) { messages.add( DefaultJpaValidationMessages.buildMessage( @@ -153,7 +151,7 @@ public abstract class AbstractJavaEmbeddedIdMapping JpaValidationMessages.VIRTUAL_ATTRIBUTE_EMBEDDED_ID_CLASS_SHOULD_IMPLEMENT_NO_ARG_CONSTRUCTOR, new String[] {this.getName()}, this, - this.getValidationTextRange() + this.getVirtualPersistentAttributeTextRange() ) ); } else { @@ -184,7 +182,7 @@ public abstract class AbstractJavaEmbeddedIdMapping JpaValidationMessages.VIRTUAL_ATTRIBUTE_EMBEDDED_ID_CLASS_SHOULD_IMPLEMENT_EQUALS_HASHCODE, new String[] {this.getName()}, this, - this.getValidationTextRange() + this.getVirtualPersistentAttributeTextRange() ) ); } else { @@ -204,15 +202,15 @@ public abstract class AbstractJavaEmbeddedIdMapping protected void validateTargetEmbeddableIsPublic(List<IMessage> messages, IReporter reporter) { if (this.getTargetEmbeddable() != null) { - if (!getTargetEmbeddable().getJavaResourceType().isPublic()) { - if (getPersistentAttribute().isVirtual()) { + if (!this.getTargetEmbeddable().getJavaResourceType().isPublic()) { + if (this.getPersistentAttribute().isVirtual()) { messages.add( DefaultJpaValidationMessages.buildMessage( IMessage.HIGH_SEVERITY, JpaValidationMessages.VIRTUAL_ATTRIBUTE_EMBEDDED_ID_CLASS_SHOULD_BE_PUBLIC, new String[] {this.getName()}, this, - this.getValidationTextRange() + this.getVirtualPersistentAttributeTextRange() ) ); } else { @@ -233,16 +231,15 @@ public abstract class AbstractJavaEmbeddedIdMapping protected void validateTargetEmbeddableImplementsSerializable(List<IMessage> messages, IReporter reporter) { if (this.getTargetEmbeddable() != null) { String targetEmbeddableClassName = this.getTargetEmbeddable().getPersistentType().getName(); - IJavaProject javaProject = getJpaProject().getJavaProject(); - if (!JDTTools.typeIsSubType(javaProject, targetEmbeddableClassName, Serializable.class.getName())) { - if (getPersistentAttribute().isVirtual()) { + if (!JDTTools.typeIsSubType(this.getJavaProject(), targetEmbeddableClassName, Serializable.class.getName())) { + if (this.getPersistentAttribute().isVirtual()) { messages.add( DefaultJpaValidationMessages.buildMessage( IMessage.HIGH_SEVERITY, JpaValidationMessages.VIRTUAL_ATTRIBUTE_EMBEDDED_ID_CLASS_SHOULD_IMPLEMENT_SERIALIZABLE, new String[] {this.getName()}, this, - this.getValidationTextRange() + this.getVirtualPersistentAttributeTextRange() ) ); } else { @@ -267,16 +264,16 @@ public abstract class AbstractJavaEmbeddedIdMapping || targetEmbeddableTypeMapping.getAllAttributeMappings(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY).iterator().hasNext() || targetEmbeddableTypeMapping.getAllAttributeMappings(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY).iterator().hasNext() || targetEmbeddableTypeMapping.getAllAttributeMappings(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY).iterator().hasNext()) { - if (getPersistentAttribute().isVirtual()) { + if (this.getPersistentAttribute().isVirtual()) { messages.add( DefaultJpaValidationMessages.buildMessage( IMessage.HIGH_SEVERITY, JpaValidationMessages.VIRTUAL_ATTRIBUTE_EMBEDDED_ID_CLASS_SHOULD_NOT_CONTAIN_RELATIONSHIP_MAPPINGS, new String[] {this.getName()}, this, - this.getValidationTextRange() + this.getVirtualPersistentAttributeTextRange() ) - ); + ); } else { messages.add( DefaultJpaValidationMessages.buildMessage( diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaIdMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaIdMapping.java index 406a2a7746..91eb0dfebe 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaIdMapping.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaIdMapping.java @@ -463,18 +463,17 @@ public abstract class AbstractJavaIdMapping protected IMessage buildColumnSpecifiedAndDerivedMessage() { return this.buildMessage( JpaValidationMessages.ID_MAPPING_MAPPED_BY_RELATIONSHIP_AND_COLUMN_SPECIFIED, - EMPTY_STRING_ARRAY, - this.column.getValidationTextRange() + EMPTY_STRING_ARRAY ); } - protected IMessage buildMessage(String msgID, String[] parms, TextRange textRange) { + protected IMessage buildMessage(String msgID, String[] parms) { return DefaultJpaValidationMessages.buildMessage( IMessage.HIGH_SEVERITY, msgID, ArrayTools.add(parms, 0, this.buildAttributeDescription()), this, - textRange + getTextRange() ); } @@ -487,4 +486,10 @@ public abstract class AbstractJavaIdMapping JpaValidationDescriptionMessages.VIRTUAL_ATTRIBUTE_DESC : JpaValidationDescriptionMessages.ATTRIBUTE_DESC; } + + protected TextRange getTextRange() { + return this.getPersistentAttribute().isVirtual() ? + this.getVirtualPersistentAttributeTextRange() : + this.column.getValidationTextRange() ; + } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java index 36e3c02b11..a7cd61dace 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java @@ -975,7 +975,7 @@ public abstract class AbstractJavaMultiRelationshipMapping<A extends Relationshi JpaValidationMessages.VIRTUAL_ATTRIBUTE_ATTRIBUTE_TYPE_IS_NOT_SUPPORTED_COLLECTION_TYPE, new String[] {getName()}, this, - this.getValidationTextRange() + this.getVirtualPersistentAttributeTextRange() ) ); } @@ -1037,7 +1037,7 @@ public abstract class AbstractJavaMultiRelationshipMapping<A extends Relationshi JpaValidationMessages.VIRTUAL_ATTRIBUTE_MAP_KEY_CLASS_NOT_DEFINED, new String[] {this.getName()}, this, - this.getValidationTextRange() + this.getVirtualPersistentAttributeTextRange() ) ); } else { @@ -1066,7 +1066,7 @@ public abstract class AbstractJavaMultiRelationshipMapping<A extends Relationshi JpaValidationMessages.VIRTUAL_ATTRIBUTE_MAP_KEY_CLASS_MUST_BE_ENTITY_EMBEDDABLE_OR_BASIC_TYPE, new String[] {this.getName(), this.getFullyQualifiedMapKeyClass()}, this, - this.getMapKeyClassTextRange() + this.getVirtualPersistentAttributeTextRange() ) ); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaRelationshipMapping.java index d3b85d651f..f2af92e24a 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaRelationshipMapping.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaRelationshipMapping.java @@ -325,18 +325,28 @@ public abstract class AbstractJavaRelationshipMapping<A extends RelationshipMapp protected void validateTargetEntity(List<IMessage> messages) { if (this.getTargetEntity() == null) { - String msg = this.getPersistentAttribute().isVirtual() ? - JpaValidationMessages.VIRTUAL_ATTRIBUTE_TARGET_ENTITY_NOT_DEFINED : - JpaValidationMessages.TARGET_ENTITY_NOT_DEFINED; - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - msg, - new String[] {this.getName()}, - this, - this.getValidationTextRange() - ) - ); + if (this.getPersistentAttribute().isVirtual()) { + messages.add( + DefaultJpaValidationMessages.buildMessage( + IMessage.HIGH_SEVERITY, + JpaValidationMessages.VIRTUAL_ATTRIBUTE_TARGET_ENTITY_NOT_DEFINED, + new String[] {this.getName()}, + this, + this.getVirtualPersistentAttributeTextRange() + ) + ); + } + else { + messages.add( + DefaultJpaValidationMessages.buildMessage( + IMessage.HIGH_SEVERITY, + JpaValidationMessages.TARGET_ENTITY_NOT_DEFINED, + new String[] {this.getName()}, + this, + this.getValidationTextRange() + ) + ); + } return; } @@ -353,7 +363,7 @@ public abstract class AbstractJavaRelationshipMapping<A extends RelationshipMapp JpaValidationMessages.VIRTUAL_ATTRIBUTE_TARGET_ENTITY_IS_NOT_AN_ENTITY, new String[] {this.getName(), this.getFullyQualifiedTargetEntity()}, this, - this.getValidationTextRange() + this.getVirtualPersistentAttributeTextRange() ) ); } else { diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVersionMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVersionMapping.java index 13a6bc2315..bcbcbba082 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVersionMapping.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVersionMapping.java @@ -280,15 +280,28 @@ public abstract class AbstractJavaVersionMapping protected void validateAttributeType(List<IMessage> messages) { if (!ArrayTools.contains(SUPPORTED_TYPE_NAMES, this.getPersistentAttribute().getTypeName())) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.NORMAL_SEVERITY, - JpaValidationMessages.PERSISTENT_ATTRIBUTE_INVALID_VERSION_MAPPING_TYPE, - new String[] {this.getName()}, - this, - this.getValidationTextRange() - ) - ); + if (this.getPersistentAttribute().isVirtual()) { + messages.add( + DefaultJpaValidationMessages.buildMessage( + IMessage.NORMAL_SEVERITY, + JpaValidationMessages.PERSISTENT_ATTRIBUTE_INVALID_VERSION_MAPPING_TYPE, //TODO KFB - different message for virtual attribute + new String[] {this.getName()}, + this, + this.getVirtualPersistentAttributeTextRange() + ) + ); + } + else { + messages.add( + DefaultJpaValidationMessages.buildMessage( + IMessage.NORMAL_SEVERITY, + JpaValidationMessages.PERSISTENT_ATTRIBUTE_INVALID_VERSION_MAPPING_TYPE, + new String[] {this.getName()}, + this, + this.getValidationTextRange() + ) + ); + } } } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaMappedByRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaMappedByRelationshipStrategy.java index 2b3b40dc8f..3d5aaf77e4 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaMappedByRelationshipStrategy.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaMappedByRelationshipStrategy.java @@ -242,6 +242,9 @@ public class GenericJavaMappedByRelationshipStrategy String attributeDescription = attribute.isVirtual() ? JpaValidationDescriptionMessages.VIRTUAL_ATTRIBUTE_DESC : JpaValidationDescriptionMessages.ATTRIBUTE_DESC; + TextRange textRange = attribute.isVirtual() ? + attribute.getValidationTextRange() : + this.getValidationTextRange(); attributeDescription = NLS.bind(attributeDescription, attribute.getName()); parms = ArrayTools.add(parms, 0, attributeDescription); return DefaultJpaValidationMessages.buildMessage( @@ -249,7 +252,7 @@ public class GenericJavaMappedByRelationshipStrategy msgID, parms, this, - this.getValidationTextRange() + textRange ); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/VirtualOrmPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/VirtualOrmPersistentAttribute.java index ee08808708..a253357c4c 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/VirtualOrmPersistentAttribute.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/VirtualOrmPersistentAttribute.java @@ -327,7 +327,6 @@ public class VirtualOrmPersistentAttribute @Override public void validate(List<IMessage> messages, IReporter reporter) { super.validate(messages, reporter); - // the Java attribute should not need an AST for validation from here this.getJavaPersistentAttribute().validate(messages, reporter); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractEntityPrimaryKeyValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractEntityPrimaryKeyValidator.java index 2f87bde464..6904432928 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractEntityPrimaryKeyValidator.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractEntityPrimaryKeyValidator.java @@ -94,7 +94,7 @@ public abstract class AbstractEntityPrimaryKeyValidator extends JpaValidationMessages.ENTITY_NON_ROOT_ID_ATTRIBUTE_SPECIFIED, EMPTY_STRING_ARRAY, each, - getAttributeMappingTextRange(each.getName()))); + getAttributeMappingTextRange(each))); } } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractNamedColumnValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractNamedColumnValidator.java index 8198b71376..cbf4eca9d2 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractNamedColumnValidator.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractNamedColumnValidator.java @@ -10,6 +10,8 @@ package org.eclipse.jpt.jpa.core.internal.jpa1.context; import java.util.List; + +import org.eclipse.jpt.common.core.utility.TextRange; import org.eclipse.jpt.common.utility.internal.StringTools; import org.eclipse.jpt.jpa.core.context.ReadOnlyNamedColumn; import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; @@ -111,7 +113,7 @@ public abstract class AbstractNamedColumnValidator<C extends ReadOnlyNamedColumn this.column.getDbTable().getName() }, this.column, - this.column.getNameTextRange() + this.getVirtualAttributeTextRange() ); } @@ -122,6 +124,9 @@ public abstract class AbstractNamedColumnValidator<C extends ReadOnlyNamedColumn this.persistentAttribute.isVirtual(); } + protected TextRange getVirtualAttributeTextRange() { + return this.persistentAttribute.getValidationTextRange(); + } // ********** table description provider ********** @@ -222,7 +227,7 @@ public abstract class AbstractNamedColumnValidator<C extends ReadOnlyNamedColumn this.getColumnTableDescriptionMessage() }, this.getColumn(), - this.getColumn().getTableTextRange() + AbstractNamedColumnValidator.this.getVirtualAttributeTextRange() ); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractPrimaryKeyValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractPrimaryKeyValidator.java index 5d92c9e19a..e4e34ea23f 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractPrimaryKeyValidator.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractPrimaryKeyValidator.java @@ -65,9 +65,12 @@ public abstract class AbstractPrimaryKeyValidator } - protected TextRange getAttributeMappingTextRange(String attributeName) { - return this.typeMapping().getPersistentType(). - getAttributeNamed(attributeName).getMapping().getValidationTextRange(); + protected TextRange getAttributeMappingTextRange(AttributeMapping attributeMapping) { + ReadOnlyPersistentAttribute attribute = attributeMapping.getPersistentAttribute(); + if (attribute.isVirtual()) { + return attribute.getValidationTextRange(); + } + return attributeMapping.getValidationTextRange(); } // for JPA portability, a hierarchy must define its primary key on one class @@ -90,7 +93,7 @@ public abstract class AbstractPrimaryKeyValidator JpaValidationMessages.TYPE_MAPPING_PK_REDEFINED_ID_ATTRIBUTE, EMPTY_STRING_ARRAY, each, - getAttributeMappingTextRange(each.getName()))); + getAttributeMappingTextRange(each))); } return; } @@ -158,7 +161,7 @@ public abstract class AbstractPrimaryKeyValidator JpaValidationMessages.TYPE_MAPPING_ID_CLASS_WITH_MAPS_ID, new String[] {mapsIdRelationshipMapping.getName()}, mapsIdRelationshipMapping, - getAttributeMappingTextRange(mapsIdRelationshipMapping.getName()))); + getAttributeMappingTextRange(mapsIdRelationshipMapping))); } AttributeMapping resolvedAttributeMapping = @@ -172,7 +175,7 @@ public abstract class AbstractPrimaryKeyValidator JpaValidationMessages.TYPE_MAPPING_MAPS_ID_ATTRIBUTE_TYPE_DOES_NOT_AGREE, new String[] {mapsIdRelationshipMapping.getName()}, mapsIdRelationshipMapping, - getAttributeMappingTextRange(mapsIdRelationshipMapping.getName()))); + getAttributeMappingTextRange(mapsIdRelationshipMapping))); } } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractTableValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractTableValidator.java index b1926fa628..31f24a982f 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractTableValidator.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractTableValidator.java @@ -10,6 +10,8 @@ package org.eclipse.jpt.jpa.core.internal.jpa1.context; import java.util.List; + +import org.eclipse.jpt.common.core.utility.TextRange; import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; import org.eclipse.jpt.jpa.core.context.ReadOnlyTable; import org.eclipse.jpt.jpa.core.internal.context.JptValidator; @@ -98,10 +100,14 @@ public abstract class AbstractTableValidator this.table.getName() }, this.table, - this.table.getCatalogTextRange() + this.getVirtualAttributeValidationTextRange() ); } + protected TextRange getVirtualAttributeValidationTextRange() { + return this.persistentAttribute.getValidationTextRange(); + } + protected abstract String getVirtualAttributeUnresolvedCatalogMessage(); protected IMessage buildUnresolvedSchemaMessage() { @@ -135,7 +141,7 @@ public abstract class AbstractTableValidator this.table.getName() }, this.table, - this.table.getSchemaTextRange() + this.getVirtualAttributeValidationTextRange() ); } @@ -168,7 +174,7 @@ public abstract class AbstractTableValidator this.table.getName() }, this.table, - this.table.getNameTextRange() + this.getVirtualAttributeValidationTextRange() ); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractTemporalConverterValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractTemporalConverterValidator.java index 7f1491f88e..c6101149a0 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractTemporalConverterValidator.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractTemporalConverterValidator.java @@ -81,7 +81,7 @@ public abstract class AbstractTemporalConverterValidator this.getVirtualAttributeInvalidTemporalMappingType(), new String[] {this.getPersistentAttribute().getName()}, this.converter, - this.converter.getValidationTextRange() + this.getPersistentAttribute().getValidationTextRange() ); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AssociationOverrideInverseJoinColumnValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AssociationOverrideInverseJoinColumnValidator.java index a07e31550c..4d7a55b1c7 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AssociationOverrideInverseJoinColumnValidator.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AssociationOverrideInverseJoinColumnValidator.java @@ -79,7 +79,7 @@ public class AssociationOverrideInverseJoinColumnValidator this.column.getDbTable().getName() }, this.column, - this.column.getNameTextRange() + this.persistentAttribute.getValidationTextRange() ); } @@ -121,7 +121,7 @@ public class AssociationOverrideInverseJoinColumnValidator this.column.getReferencedColumnDbTable().getName() }, this.column, - this.column.getReferencedColumnNameTextRange() + this.persistentAttribute.getValidationTextRange() ); } @@ -157,7 +157,7 @@ public class AssociationOverrideInverseJoinColumnValidator this.override.getName() }, this.column, - this.column.getNameTextRange() + this.persistentAttribute.getValidationTextRange() ); } @@ -193,7 +193,7 @@ public class AssociationOverrideInverseJoinColumnValidator this.override.getName() }, this.column, - this.column.getReferencedColumnNameTextRange() + this.persistentAttribute.getValidationTextRange() ); } @@ -251,7 +251,7 @@ public class AssociationOverrideInverseJoinColumnValidator this.getColumnTableDescriptionMessage() }, this.getColumn(), - this.getColumn().getTableTextRange() + AssociationOverrideInverseJoinColumnValidator.this.persistentAttribute.getValidationTextRange() ); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AssociationOverrideJoinColumnValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AssociationOverrideJoinColumnValidator.java index b2af74f775..d02b6e8605 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AssociationOverrideJoinColumnValidator.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AssociationOverrideJoinColumnValidator.java @@ -80,7 +80,7 @@ public class AssociationOverrideJoinColumnValidator this.column.getDbTable().getName() }, this.column, - this.column.getNameTextRange() + this.persistentAttribute.getValidationTextRange() ); } @@ -122,7 +122,7 @@ public class AssociationOverrideJoinColumnValidator this.column.getReferencedColumnDbTable().getName() }, this.column, - this.column.getReferencedColumnNameTextRange() + this.persistentAttribute.getValidationTextRange() ); } @@ -158,7 +158,7 @@ public class AssociationOverrideJoinColumnValidator this.override.getName() }, this.column, - this.column.getNameTextRange() + this.persistentAttribute.getValidationTextRange() ); } @@ -194,7 +194,7 @@ public class AssociationOverrideJoinColumnValidator this.override.getName() }, this.column, - this.column.getReferencedColumnNameTextRange() + this.persistentAttribute.getValidationTextRange() ); } @@ -252,7 +252,7 @@ public class AssociationOverrideJoinColumnValidator this.getColumnTableDescriptionMessage() }, this.getColumn(), - this.getColumn().getTableTextRange() + AssociationOverrideJoinColumnValidator.this.persistentAttribute.getValidationTextRange() ); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AttributeOverrideColumnValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AttributeOverrideColumnValidator.java index cbcfec0d98..0f8e8001e1 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AttributeOverrideColumnValidator.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AttributeOverrideColumnValidator.java @@ -81,7 +81,7 @@ public class AttributeOverrideColumnValidator this.column.getDbTable().getName() }, this.column, - this.column.getNameTextRange() + this.getVirtualAttributeTextRange() ); } @@ -139,7 +139,7 @@ public class AttributeOverrideColumnValidator this.getColumnTableDescriptionMessage() }, this.getColumn(), - this.getColumn().getTableTextRange() + AttributeOverrideColumnValidator.this.persistentAttribute.getValidationTextRange() ); } 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 967c3525ab..4f67149760 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 @@ -105,7 +105,7 @@ public abstract class BaseJoinColumnValidator<C extends ReadOnlyBaseJoinColumn> this.column.getReferencedColumnDbTable().getName() }, this.column, - this.column.getReferencedColumnNameTextRange() + this.getVirtualAttributeTextRange() ); } @@ -135,7 +135,7 @@ public abstract class BaseJoinColumnValidator<C extends ReadOnlyBaseJoinColumn> this.getVirtualAttributeUnspecifiedNameMultipleJoinColumnsMessage(), new String[] {this.persistentAttribute.getName()}, this.column, - this.column.getNameTextRange() + this.getVirtualAttributeTextRange() ); } @@ -165,7 +165,7 @@ public abstract class BaseJoinColumnValidator<C extends ReadOnlyBaseJoinColumn> this.getVirtualAttributeUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage(), new String[] {this.persistentAttribute.getName()}, this.column, - this.column.getReferencedColumnNameTextRange() + this.getVirtualAttributeTextRange() ); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/OverrideValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/OverrideValidator.java index 2c9dee4b08..a169f4f32d 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/OverrideValidator.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/OverrideValidator.java @@ -150,7 +150,7 @@ public abstract class OverrideValidator this.container.getOverridableTypeMapping().getName() }, this.override, - this.override.getNameTextRange() + this.persistentAttribute.getValidationTextRange() ); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaGeneratedValue.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaGeneratedValue.java index b80d5c20d5..89aa1bad88 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaGeneratedValue.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaGeneratedValue.java @@ -200,15 +200,28 @@ public class GenericJavaGeneratedValue } } - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.ID_MAPPING_UNRESOLVED_GENERATOR_NAME, - new String[] {generator}, - this.getIdMapping(), - this.getGeneratorTextRange() - ) - ); + if (getIdMapping().getPersistentAttribute().isVirtual()) { + messages.add( + DefaultJpaValidationMessages.buildMessage( + IMessage.HIGH_SEVERITY, + JpaValidationMessages.ID_MAPPING_UNRESOLVED_GENERATOR_NAME, //TODO KFB need a different message for virtual + new String[] {generator}, + this.getIdMapping(), + this.getIdMapping().getPersistentAttribute().getValidationTextRange() + ) + ); + } + else { + messages.add( + DefaultJpaValidationMessages.buildMessage( + IMessage.HIGH_SEVERITY, + JpaValidationMessages.ID_MAPPING_UNRESOLVED_GENERATOR_NAME, + new String[] {generator}, + this.getIdMapping(), + this.getGeneratorTextRange() + ) + ); + } } public TextRange getValidationTextRange() { diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaOrderable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaOrderable.java index bc684da49d..2f85aca19b 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaOrderable.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaOrderable.java @@ -440,15 +440,28 @@ public class GenericJavaOrderable public void validate(List<IMessage> messages, IReporter reporter) { super.validate(messages, reporter); if (this.orderColumnAnnotationIsPresent() && (this.getOrderByAnnotation() != null)) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.ORDER_COLUMN_AND_ORDER_BY_BOTH_SPECIFIED, - new String[] {this.getPersistentAttribute().getName()}, - this.getAttributeMapping(), - this.getOrderByAnnotationTextRange() - ) - ); + if (this.getPersistentAttribute().isVirtual()) { + messages.add( + DefaultJpaValidationMessages.buildMessage( + IMessage.HIGH_SEVERITY, + JpaValidationMessages.ORDER_COLUMN_AND_ORDER_BY_BOTH_SPECIFIED, + new String[] {this.getPersistentAttribute().getName()}, + this.getAttributeMapping(), + this.getPersistentAttribute().getValidationTextRange() + ) + ); + } + else { + messages.add( + DefaultJpaValidationMessages.buildMessage( + IMessage.HIGH_SEVERITY, + JpaValidationMessages.ORDER_COLUMN_AND_ORDER_BY_BOTH_SPECIFIED, + new String[] {this.getPersistentAttribute().getName()}, + this.getAttributeMapping(), + this.getOrderByAnnotationTextRange() + ) + ); + } } if (this.orderColumnOrdering) { //TODO validation message if type is not List diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/AbstractJavaElementCollectionMapping2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/AbstractJavaElementCollectionMapping2_0.java index 69201aff12..7c120f37e0 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/AbstractJavaElementCollectionMapping2_0.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/AbstractJavaElementCollectionMapping2_0.java @@ -1530,7 +1530,7 @@ public abstract class AbstractJavaElementCollectionMapping2_0 } } if (prohibitedMappingFound) { - if (getPersistentAttribute().isVirtual()) { + if (this.getPersistentAttribute().isVirtual()) { messages.add( DefaultJpaValidationMessages.buildMessage( IMessage.HIGH_SEVERITY, @@ -1538,19 +1538,19 @@ public abstract class AbstractJavaElementCollectionMapping2_0 new String[] {this.getName(), embeddable.getName(), relationshipMapping.getName()}, this, - this.getValidationTextRange() + this.getVirtualPersistentAttributeTextRange() ) ); } else { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.ELEMENT_COLLECTION_CONTAINS_EMBEDDABLE_WITH_PROHIBITED_RELATIONSHIP_MAPPING, - new String[] {embeddable.getName(), relationshipMapping.getName()}, - this, - this.getValidationTextRange() - ) - ); + messages.add( + DefaultJpaValidationMessages.buildMessage( + IMessage.HIGH_SEVERITY, + JpaValidationMessages.ELEMENT_COLLECTION_CONTAINS_EMBEDDABLE_WITH_PROHIBITED_RELATIONSHIP_MAPPING, + new String[] {embeddable.getName(), relationshipMapping.getName()}, + this, + this.getValidationTextRange() + ) + ); } } } @@ -1558,14 +1558,14 @@ public abstract class AbstractJavaElementCollectionMapping2_0 private void embeddableContainsElementCollection(List<IMessage> messages, Embeddable embeddable) { Iterable<AttributeMapping> elementCollectionMappings = embeddable.getAllAttributeMappings(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); if (elementCollectionMappings.iterator().hasNext()) { - if (getPersistentAttribute().isVirtual()) { + if (this.getPersistentAttribute().isVirtual()) { messages.add( DefaultJpaValidationMessages.buildMessage( IMessage.HIGH_SEVERITY, JpaValidationMessages.VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_CONTAINS_EMBEDDABLE_WITH_ELEMENT_COLLECTION_MAPPING, new String[] {this.getName(), embeddable.getName(), elementCollectionMappings.iterator().next().getName()}, this, - this.getValidationTextRange() + this.getVirtualPersistentAttributeTextRange() ) ); } else { @@ -1592,7 +1592,7 @@ public abstract class AbstractJavaElementCollectionMapping2_0 JpaValidationMessages.VIRTUAL_ATTRIBUTE_ATTRIBUTE_TYPE_IS_NOT_SUPPORTED_COLLECTION_TYPE, new String[] {this.getName()}, this, - this.getValidationTextRange() + this.getVirtualPersistentAttributeTextRange() ) ); } @@ -1620,7 +1620,7 @@ public abstract class AbstractJavaElementCollectionMapping2_0 JpaValidationMessages.VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_TARGET_CLASS_NOT_DEFINED, new String[] {this.getName()}, this, - this.getValidationTextRange() + this.getVirtualPersistentAttributeTextRange() ) ); } else { @@ -1648,7 +1648,7 @@ public abstract class AbstractJavaElementCollectionMapping2_0 JpaValidationMessages.VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_TARGET_CLASS_MUST_BE_EMBEDDABLE_OR_BASIC_TYPE, new String[] {this.getName(), targetClass}, this, - this.getTargetClassTextRange() + this.getVirtualPersistentAttributeTextRange() ) ); } else { @@ -1694,7 +1694,7 @@ public abstract class AbstractJavaElementCollectionMapping2_0 JpaValidationMessages.VIRTUAL_ATTRIBUTE_MAP_KEY_CLASS_NOT_DEFINED, new String[] {this.getName()}, this, - this.getValidationTextRange() + this.getVirtualPersistentAttributeTextRange() ) ); } else { @@ -1722,7 +1722,7 @@ public abstract class AbstractJavaElementCollectionMapping2_0 JpaValidationMessages.VIRTUAL_ATTRIBUTE_MAP_KEY_CLASS_MUST_BE_ENTITY_EMBEDDABLE_OR_BASIC_TYPE, new String[] {this.getName(), this.getFullyQualifiedMapKeyClass()}, this, - this.getValidationTextRange() + this.getVirtualPersistentAttributeTextRange() ) ); } else { diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaMapsIdDerivedIdentityStrategy2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaMapsIdDerivedIdentityStrategy2_0.java index 7911ec65ba..34bc4abf30 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaMapsIdDerivedIdentityStrategy2_0.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaMapsIdDerivedIdentityStrategy2_0.java @@ -348,12 +348,15 @@ public class GenericJavaMapsIdDerivedIdentityStrategy2_0 JpaValidationDescriptionMessages.ATTRIBUTE_DESC; attributeDescription = NLS.bind(attributeDescription, attribute.getName()); parms = ArrayTools.add(parms, 0, attributeDescription); + TextRange textRange = attribute.isVirtual() ? + attribute.getValidationTextRange() : + this.getValidationTextRange(); return DefaultJpaValidationMessages.buildMessage( IMessage.HIGH_SEVERITY, msgID, parms, this, - this.getValidationTextRange() + textRange ); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/EclipseLinkConvertValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/EclipseLinkConvertValidator.java index 45a51c9632..e5eec0dac1 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/EclipseLinkConvertValidator.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/EclipseLinkConvertValidator.java @@ -10,6 +10,8 @@ package org.eclipse.jpt.jpa.eclipselink.core.internal.context; import java.util.List; + +import org.eclipse.jpt.common.core.utility.TextRange; import org.eclipse.jpt.common.utility.internal.ArrayTools; import org.eclipse.jpt.common.utility.internal.CollectionTools; import org.eclipse.jpt.jpa.core.context.AttributeMapping; @@ -73,11 +75,20 @@ public class EclipseLinkConvertValidator this.getAttributeMapping().getName() }, this.getAttributeMapping(), - this.convert.getValidationTextRange() + this.getValidationTextRange() ) ); return false; } + protected TextRange getValidationTextRange() { + return this.getAttributeMapping().getPersistentAttribute().isVirtual() ? + this.getVirtualValidationTextRange() : + this.convert.getValidationTextRange(); + } + + protected TextRange getVirtualValidationTextRange() { + return getAttributeMapping().getPersistentAttribute().getValidationTextRange(); + } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkVersionMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkVersionMapping.java index e07f7aaf30..3f93f1a56c 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkVersionMapping.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkVersionMapping.java @@ -112,15 +112,28 @@ public class JavaEclipseLinkVersionMapping @Override protected void validateAttributeType(List<IMessage> messages) { if (!ArrayTools.contains(SUPPORTED_TYPE_NAMES, this.getPersistentAttribute().getTypeName())) { - messages.add( - DefaultEclipseLinkJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - EclipseLinkJpaValidationMessages.PERSISTENT_ATTRIBUTE_INVALID_VERSION_MAPPING_TYPE, - new String[] {this.getName()}, - this, - this.getValidationTextRange() - ) - ); + if (this.getPersistentAttribute().isVirtual()) { + messages.add( + DefaultEclipseLinkJpaValidationMessages.buildMessage( + IMessage.HIGH_SEVERITY, + EclipseLinkJpaValidationMessages.PERSISTENT_ATTRIBUTE_INVALID_VERSION_MAPPING_TYPE, + new String[] {this.getName()}, + this, + this.getVirtualPersistentAttributeTextRange() + ) + ); + } + else { + messages.add( + DefaultEclipseLinkJpaValidationMessages.buildMessage( + IMessage.HIGH_SEVERITY, + EclipseLinkJpaValidationMessages.PERSISTENT_ATTRIBUTE_INVALID_VERSION_MAPPING_TYPE, + new String[] {this.getName()}, + this, + this.getValidationTextRange() + ) + ); + } } } } |