Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2011-08-24 14:19:03 +0000
committerkmoore2011-08-24 14:19:03 +0000
commitb28d95828f5bd4f47eb413047ff516cc2adfff31 (patch)
tree702d3490ea02faab731482e92a14ec0adca54902
parent91fd652afe238ecc188ac3e94ed2c260c14a5b43 (diff)
downloadwebtools.dali-b28d95828f5bd4f47eb413047ff516cc2adfff31.tar.gz
webtools.dali-b28d95828f5bd4f47eb413047ff516cc2adfff31.tar.xz
webtools.dali-b28d95828f5bd4f47eb413047ff516cc2adfff31.zip
Bug 354444 - Invalid ORM ElementCollection target-class validation with package element
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/AbstractOrmElementCollectionMapping2_0.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/AbstractOrmElementCollectionMapping2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/AbstractOrmElementCollectionMapping2_0.java
index ad0f72049e..398d46138e 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/AbstractOrmElementCollectionMapping2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/AbstractOrmElementCollectionMapping2_0.java
@@ -1196,8 +1196,7 @@ public abstract class AbstractOrmElementCollectionMapping2_0<X extends XmlElemen
return;
}
- IJavaProject javaProject = this.getJpaProject().getJavaProject();
- if (JDTTools.findType(javaProject, targetClass) == null) {
+ if (! this.targetClassExists()) {
messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
@@ -1210,6 +1209,7 @@ public abstract class AbstractOrmElementCollectionMapping2_0<X extends XmlElemen
return;
}
+ IJavaProject javaProject = this.getJpaProject().getJavaProject();
if ( ! JDTTools.typeIsBasic(javaProject, targetClass) && (this.getResolvedTargetEmbeddable() == null)) {
messages.add(
DefaultJpaValidationMessages.buildMessage(
@@ -1223,6 +1223,20 @@ public abstract class AbstractOrmElementCollectionMapping2_0<X extends XmlElemen
}
}
+ protected boolean targetClassExists() {
+ IJavaProject javaProject = getJpaProject().getJavaProject();
+ boolean targetClassExists = JDTTools.findType(javaProject, this.getTargetClass()) != null;
+ if (targetClassExists) {
+ return true;
+ }
+ // ...then try to resolve by prepending the global package name
+ if (this.getEntityMappings().getPackage() != null) {
+ String fullyQualifiedIdClassName = this.getEntityMappings().getPackage() + '.' + this.getTargetClass();
+ targetClassExists = JDTTools.findType(javaProject, fullyQualifiedIdClassName) != null;
+ }
+ return targetClassExists;
+ }
+
protected TextRange getTargetClassTextRange() {
return this.getValidationTextRange(this.xmlAttributeMapping.getTargetClassTextRange());
}

Back to the top