summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaren Butzke2012-12-04 14:47:56 (EST)
committerKaren Butzke2012-12-04 14:47:56 (EST)
commit7d7659ab9d05c534091103aea097d10f94c6fcc0 (patch)
tree6de12bac8bb8e396a581a2c370176df11d7d69f7
parent1211d885029bbc9540f125a0f2806001b3cf0790 (diff)
downloadwebtools.dali-7d7659ab9d05c534091103aea097d10f94c6fcc0.zip
webtools.dali-7d7659ab9d05c534091103aea097d10f94c6fcc0.tar.gz
webtools.dali-7d7659ab9d05c534091103aea097d10f94c6fcc0.tar.bz2
Bug 316034 - Interface listed in persistence.xml leads to "Class cannot be resolved" validation error. Also change specified class refs to be built with the coresponding JavaResourceAbstractType instead of the class name
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/property_files/jpa_validation.properties2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaProject.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/ClassRef.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/PersistenceXmlContextNodeFactory.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaProject.java17
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java60
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceXmlContextNodeFactory.java5
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericClassRef.java74
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/validation/JpaValidationMessages.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui_validation_preferences.properties2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiValidationPreferenceMessages.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/prefs/JpaProblemSeveritiesPage.java2
12 files changed, 114 insertions, 67 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/property_files/jpa_validation.properties b/jpa/plugins/org.eclipse.jpt.jpa.core/property_files/jpa_validation.properties
index 3d25621..0e56ed9 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/property_files/jpa_validation.properties
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/property_files/jpa_validation.properties
@@ -34,6 +34,8 @@ PERSISTENCE_UNIT_DUPLICATE_CLASS=Duplicate class \"{0}\"
PERSISTENCE_UNIT_DUPLICATE_JAR_FILE=Duplicate JAR file \"{0}\"
PERSISTENCE_UNIT_DUPLICATE_MAPPING_FILE=Duplicate mapping file \"{0}\"
PERSISTENCE_UNIT_NONEXISTENT_CLASS=Class \"{0}\" cannot be resolved
+PERSISTENCE_UNIT_LISTED_CLASS_IS_AN_INTERFACE=Listed class \"{0}\" must not be an interface
+PERSISTENCE_UNIT_LISTED_CLASS_IS_AN_ENUM=Listed class \"{0}\" must not be an enum
PERSISTENCE_UNIT_NONEXISTENT_MAPPING_FILE=Mapping file \"{0}\" cannot be resolved.
PERSISTENCE_UNIT_NONEXISTENT_JAR_FILE=JAR file \"{0}\" cannot be resolved
PERSISTENCE_UNIT_INVALID_CLASS=Class \"{0}\" is included in a persistence unit, but is not mapped
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaProject.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaProject.java
index 30b4a4f..d3b9a15 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaProject.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaProject.java
@@ -228,12 +228,12 @@ public interface JpaProject
Iterable<String> getAnnotatedJavaSourceClassNames();
/**
- * Return only the names of those valid <em>mapped</em> (i.e. annotated with
+ * Return only the types of those valid <em>mapped</em> (i.e. annotated with
* <code>@Entity</code>, <code>@Embeddable</code>, etc.) Java resource
- * persistent types that are directly part of the JPA project, ignoring
+ * types that are directly part of the JPA project, ignoring
* those in JARs referenced in <code>persistence.xml</code>.
*/
- Iterable<String> getMappedJavaSourceClassNames();
+ Iterable<JavaResourceAbstractType> getMappedJavaSourceTypes();
Iterable<String> getTypeMappingAnnotationNames();
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/ClassRef.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/ClassRef.java
index 965b906..556db26 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/ClassRef.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/ClassRef.java
@@ -11,6 +11,7 @@ package org.eclipse.jpt.jpa.core.context.persistence;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
import org.eclipse.jpt.common.utility.internal.transformer.AbstractTransformer;
import org.eclipse.jpt.common.utility.transformer.Transformer;
import org.eclipse.jpt.jpa.core.JpaStructureNode;
@@ -81,6 +82,11 @@ public interface ClassRef
*/
void setClassName(String className);
+ /**
+ * Return the corresponding JavaResourceAbstractType, null if the name does not resolve to a class.
+ */
+ JavaResourceAbstractType getJavaResourceType();
+
// ********** java persistent type **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/PersistenceXmlContextNodeFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/PersistenceXmlContextNodeFactory.java
index 06111ff..14e8525 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/PersistenceXmlContextNodeFactory.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/PersistenceXmlContextNodeFactory.java
@@ -9,6 +9,7 @@
******************************************************************************/
package org.eclipse.jpt.jpa.core.context.persistence;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
import org.eclipse.jpt.common.core.resource.java.JavaResourcePackageFragmentRoot;
import org.eclipse.jpt.jpa.core.context.java.JarFile;
import org.eclipse.jpt.jpa.core.resource.persistence.XmlJarFileRef;
@@ -54,7 +55,7 @@ public interface PersistenceXmlContextNodeFactory
/**
* Build a "virtual" class ref.
*/
- ClassRef buildClassRef(PersistenceUnit parent, String className);
+ ClassRef buildClassRef(PersistenceUnit parent, JavaResourceAbstractType jrat);
JarFileRef buildJarFileRef(PersistenceUnit parent, XmlJarFileRef xmlJarFileRef);
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaProject.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaProject.java
index 5e854ad..d20a111 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaProject.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaProject.java
@@ -827,7 +827,7 @@ public abstract class AbstractJpaProject
}
/**
- * Return only those valid annotated Java resource persistent types that are
+ * Return only those valid annotated Java resource types that are
* directly part of the JPA project, ignoring those in JARs referenced in
* <code>persistence.xml</code>.
* @see JavaResourceAbstractType#isAnnotated()
@@ -836,24 +836,19 @@ public abstract class AbstractJpaProject
return new FilteringIterable<JavaResourceAbstractType>(this.getInternalSourceJavaResourceTypes()) {
@Override
protected boolean accept(JavaResourceAbstractType jraType) {
- return jraType.isAnnotated(); // i.e. the type has a valid type annotation
+ return jraType.isAnnotated(); // i.e. the type has a valid JPA type annotation
}
};
}
/**
- * Return only the names of those valid <em>mapped</em> (i.e. annotated with
+ * Return only the types of those valid <em>mapped</em> (i.e. annotated with
* <code>@Entity</code>, <code>@Embeddable</code>, etc.) Java resource
- * persistent types that are directly part of the JPA project, ignoring
+ * types that are directly part of the JPA project, ignoring
* those in JARs referenced in <code>persistence.xml</code>.
*/
- public Iterable<String> getMappedJavaSourceClassNames() {
- return new TransformationIterable<JavaResourceAbstractType, String>(this.getInternalMappedSourceJavaResourceTypes()) {
- @Override
- protected String transform(JavaResourceAbstractType jraType) {
- return jraType.getTypeBinding().getQualifiedName();
- }
- };
+ public Iterable<JavaResourceAbstractType> getMappedJavaSourceTypes() {
+ return getInternalAnnotatedSourceJavaResourceTypes();
}
/**
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java
index bade179..6fc88f8 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java
@@ -165,7 +165,7 @@ public abstract class AbstractPersistenceUnit
protected final ContextListContainer<ClassRef, XmlJavaClassRef> specifiedClassRefContainer;
- protected final ContextCollectionContainer<ClassRef, String> impliedClassRefContainer;
+ protected final ContextCollectionContainer<ClassRef, JavaResourceAbstractType> impliedClassRefContainer;
protected final ContextListContainer<Property, XmlProperty> propertyContainer;
@@ -805,14 +805,14 @@ public abstract class AbstractPersistenceUnit
return classRef;
}
- protected Iterable<ClassRef> addSpecifiedClassRefs(Iterable<String> classNames) {
+ protected Iterable<ClassRef> addSpecifiedClassRefs(Iterable<JavaResourceAbstractType> classNames) {
return this.addSpecifiedClassRefs(this.getSpecifiedClassRefsSize(), classNames);
}
- protected Iterable<ClassRef> addSpecifiedClassRefs(int index, Iterable<String> classNames) {
+ protected Iterable<ClassRef> addSpecifiedClassRefs(int index, Iterable<JavaResourceAbstractType> jrats) {
ArrayList<XmlJavaClassRef> xmlClassRefs = new ArrayList<XmlJavaClassRef>();
- for (String className : classNames) {
- xmlClassRefs.add(this.buildXmlJavaClassRef(className));
+ for (JavaResourceAbstractType jrat : jrats) {
+ xmlClassRefs.add(this.buildXmlJavaClassRef(jrat.getTypeBinding().getQualifiedName()));
}
Iterable<ClassRef> classRefs = this.specifiedClassRefContainer.addContextElements(index, xmlClassRefs);
this.xmlPersistenceUnit.getClasses().addAll(index, xmlClassRefs);
@@ -905,22 +905,18 @@ public abstract class AbstractPersistenceUnit
return this.impliedClassRefContainer.getContextElementsSize();
}
- protected ClassRef addImpliedClassRef(String className) {
- return this.impliedClassRefContainer.addContextElement(getImpliedClassRefsSize(), className);
- }
-
- protected ClassRef buildClassRef(String className) {
- return this.getContextNodeFactory().buildClassRef(this, className);
+ protected ClassRef buildClassRef(JavaResourceAbstractType jrat) {
+ return this.getContextNodeFactory().buildClassRef(this, jrat);
}
protected void updateImpliedClassRefs() {
this.impliedClassRefContainer.update();
}
- protected Iterable<String> getImpliedClassNames() {
+ protected Iterable<JavaResourceAbstractType> getImpliedClassResourceTypes() {
return this.excludesUnlistedClasses() ?
- EmptyIterable.<String>instance() :
- this.getImpliedClassNames_();
+ EmptyIterable.<JavaResourceAbstractType>instance() :
+ this.getImpliedClassResourceTypes_();
}
/**
@@ -928,24 +924,23 @@ public abstract class AbstractPersistenceUnit
* mapped (i.e. have the appropriate annotation etc.) but not specified
* in the persistence unit or any of its mapping files.
*/
- protected Iterable<String> getImpliedClassNames_() {
- return new FilteringIterable<String>(this.getJpaProject().getMappedJavaSourceClassNames()) {
+ protected Iterable<JavaResourceAbstractType> getImpliedClassResourceTypes_() {
+ return new FilteringIterable<JavaResourceAbstractType>(this.getJpaProject().getMappedJavaSourceTypes()) {
@Override
- protected boolean accept(String mappedClassName) {
- return ! AbstractPersistenceUnit.this.specifiesPersistentType(mappedClassName);
+ protected boolean accept(JavaResourceAbstractType jrat) {
+ return ! AbstractPersistenceUnit.this.specifiesPersistentType(jrat.getTypeBinding().getQualifiedName());
}
};
}
- protected ContextCollectionContainer<ClassRef, String> buildImpliedClassRefContainer() {
+ protected ContextCollectionContainer<ClassRef, JavaResourceAbstractType> buildImpliedClassRefContainer() {
return new ImpliedClassRefContainer();
}
/**
* Virtual class ref container adapter.
* <p>
- * <strong>NB:</strong> The context class ref is matched with a resource
- * class by name.
+ * <strong>NB:</strong> The context class ref is matched with a java resource type.
* <p>
* This is used during <strong>both</strong> <em>sync</em> and
* <em>update</em> because the list of implied class refs can be modified
@@ -966,23 +961,23 @@ public abstract class AbstractPersistenceUnit
* collection must also be synchronized during <em>update</em>.
*/
protected class ImpliedClassRefContainer
- extends ContextCollectionContainer<ClassRef, String>
+ extends ContextCollectionContainer<ClassRef, JavaResourceAbstractType>
{
@Override
protected String getContextElementsPropertyName() {
return IMPLIED_CLASS_REFS_COLLECTION;
}
@Override
- protected ClassRef buildContextElement(String resourceElement) {
+ protected ClassRef buildContextElement(JavaResourceAbstractType resourceElement) {
return AbstractPersistenceUnit.this.buildClassRef(resourceElement);
}
@Override
- protected Iterable<String> getResourceElements() {
- return AbstractPersistenceUnit.this.getImpliedClassNames();
+ protected Iterable<JavaResourceAbstractType> getResourceElements() {
+ return AbstractPersistenceUnit.this.getImpliedClassResourceTypes();
}
@Override
- protected String getResourceElement(ClassRef contextElement) {
- return contextElement.getClassName();
+ protected JavaResourceAbstractType getResourceElement(ClassRef contextElement) {
+ return contextElement.getJavaResourceType();
}
@Override
protected void disposeElement(ClassRef contextElement) {
@@ -2036,7 +2031,7 @@ public abstract class AbstractPersistenceUnit
SubMonitor sm = SubMonitor.convert(monitor, 3);
// calculate the refs to remove and add
- HashSet<String> newTypeNames = CollectionTools.set(this.getJpaProject().getMappedJavaSourceClassNames());
+ HashSet<JavaResourceAbstractType> newTypes = CollectionTools.set(this.getJpaProject().getMappedJavaSourceTypes());
ArrayList<ClassRef> deadClassRefs = new ArrayList<ClassRef>();
HashSet<String> mappingFileTypeNames = this.getMappingFileTypeNames();
@@ -2046,11 +2041,11 @@ public abstract class AbstractPersistenceUnit
// Java type cannot be resolved
deadClassRefs.add(classRef);
} else {
- String specifiedName = specifiedJPT.getName();
- if ( ! newTypeNames.remove(specifiedName)) {
+ JavaResourceType specifiedType = specifiedJPT.getJavaResourceType();
+ if ( ! newTypes.remove(specifiedType)) {
// Java type is not annotated
deadClassRefs.add(classRef);
- } else if (mappingFileTypeNames.contains(specifiedName)) {
+ } else if (mappingFileTypeNames.contains(specifiedType.getTypeBinding().getQualifiedName())) {
// type is also listed in a mapping file
deadClassRefs.add(classRef);
}
@@ -2067,7 +2062,7 @@ public abstract class AbstractPersistenceUnit
}
sm.worked(1);
- this.addSpecifiedClassRefs(newTypeNames);
+ this.addSpecifiedClassRefs(newTypes);
sm.worked(1);
}
@@ -2147,6 +2142,7 @@ public abstract class AbstractPersistenceUnit
this.xmlPersistenceUnit.getClasses().addAll(addedXmlClassRefs);
sm.worked(5);
}
+
protected JavaTypeMappingDefinition getJavaTypeMappingDefinition(String key) {
for (JavaTypeMappingDefinition definition : this.getJpaPlatform().getJavaTypeMappingDefinitions()) {
if (ObjectTools.equals(definition.getKey(), key)) {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceXmlContextNodeFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceXmlContextNodeFactory.java
index 7d64437..d64145e 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceXmlContextNodeFactory.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceXmlContextNodeFactory.java
@@ -9,6 +9,7 @@
******************************************************************************/
package org.eclipse.jpt.jpa.core.internal.context.persistence;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
import org.eclipse.jpt.common.core.resource.java.JavaResourcePackageFragmentRoot;
import org.eclipse.jpt.jpa.core.context.java.JarFile;
import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
@@ -57,8 +58,8 @@ public abstract class AbstractPersistenceXmlContextNodeFactory
return new GenericClassRef(parent, classRef);
}
- public ClassRef buildClassRef(PersistenceUnit parent, String className) {
- return new GenericClassRef(parent, className);
+ public ClassRef buildClassRef(PersistenceUnit parent, JavaResourceAbstractType jrat) {
+ return new GenericClassRef(parent, jrat);
}
public JarFileRef buildJarFileRef(PersistenceUnit parent, XmlJarFileRef xmlJarFileRef) {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericClassRef.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericClassRef.java
index 64d246a..ab08133 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericClassRef.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericClassRef.java
@@ -13,8 +13,9 @@ import java.util.Collection;
import java.util.List;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement.Kind;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement.Kind;
import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.jpt.common.utility.internal.ObjectTools;
@@ -60,6 +61,10 @@ public class GenericClassRef
*/
protected JavaPersistentType javaPersistentType;
+ /**
+ * Hold on to this for validation if the resourceType is not of type {@link AstNodeType#TYPE}
+ */
+ protected JavaResourceAbstractType resourceType;
// ********** constructors **********
@@ -68,25 +73,27 @@ public class GenericClassRef
* an explicit entry in the <code>persistence.xml</code>.
*/
public GenericClassRef(PersistenceUnit parent, XmlJavaClassRef xmlJavaClassRef) {
- this(parent, xmlJavaClassRef, xmlJavaClassRef.getJavaClass());
+ this(parent, null, xmlJavaClassRef, xmlJavaClassRef.getJavaClass());
}
/**
* Construct an <em>virtual</em> class ref; i.e. a class ref without
* an explicit entry in the <code>persistence.xml</code>.
*/
- public GenericClassRef(PersistenceUnit parent, String className) {
- this(parent, null, className);
+ public GenericClassRef(PersistenceUnit parent, JavaResourceAbstractType jrat) {
+ this(parent, jrat, null, jrat.getTypeBinding().getQualifiedName());
}
- protected GenericClassRef(PersistenceUnit parent, XmlJavaClassRef xmlJavaClassRef, String className) {
+ protected GenericClassRef(PersistenceUnit parent, JavaResourceAbstractType jrat, XmlJavaClassRef xmlJavaClassRef, String className) {
super(parent);
this.xmlJavaClassRef = xmlJavaClassRef;
this.className = className;
// build 'javaPersistentType' here, but also resolve in the update
- JavaResourceType resourceType = this.resolveJavaResourceType();
- if (resourceType != null) {
- this.javaPersistentType = this.buildJavaPersistentType(resourceType);
+ if (jrat != null) {
+ this.resourceType = jrat;
+ if (jrat.getKind() == Kind.TYPE) {
+ this.javaPersistentType = this.buildJavaPersistentType((JavaResourceType) jrat);
+ }
}
}
@@ -148,6 +155,10 @@ public class GenericClassRef
return StringTools.isBlank(this.className) ? null : this.className.replace('$', '.');
}
+ public JavaResourceAbstractType getJavaResourceType() {
+ return this.resourceType;
+ }
+
// ********** java persistent type **********
@@ -162,33 +173,34 @@ public class GenericClassRef
}
protected void updateJavaPersistentType() {
- JavaResourceType resourceType = this.resolveJavaResourceType();
- if (resourceType == null) {
+ this.resourceType = this.resolveJavaResourceType();
+ if (this.resourceType == null || this.resourceType.getKind() != Kind.TYPE) {
if (this.javaPersistentType != null) {
this.javaPersistentType.dispose();
this.setJavaPersistentType(null);
}
} else {
+ JavaResourceType jrt = (JavaResourceType) this.resourceType;
if (this.javaPersistentType == null) {
- this.setJavaPersistentType(this.buildJavaPersistentType(resourceType));
+ this.setJavaPersistentType(this.buildJavaPersistentType(jrt));
} else {
- if (this.javaPersistentType.getJavaResourceType() == resourceType) {
+ if (this.javaPersistentType.getJavaResourceType() == jrt) {
this.javaPersistentType.update();
} else {
this.javaPersistentType.dispose();
- this.setJavaPersistentType(this.buildJavaPersistentType(resourceType));
+ this.setJavaPersistentType(this.buildJavaPersistentType(jrt));
}
}
}
}
- protected JavaResourceType resolveJavaResourceType() {
+ protected JavaResourceAbstractType resolveJavaResourceType() {
String javaClassName = this.getJavaClassName();
- return (javaClassName == null) ? null : (JavaResourceType) this.getJpaProject().getJavaResourceType(javaClassName, Kind.TYPE);
+ return (javaClassName == null) ? null : this.getJpaProject().getJavaResourceType(javaClassName);
}
- protected JavaPersistentType buildJavaPersistentType(JavaResourceType jrpt) {
- return this.getJpaFactory().buildJavaPersistentType(this, jrpt);
+ protected JavaPersistentType buildJavaPersistentType(JavaResourceType jrt) {
+ return this.getJpaFactory().buildJavaPersistentType(this, jrt);
}
@@ -344,7 +356,7 @@ public class GenericClassRef
return;
}
- if (this.javaPersistentType == null) {
+ if (this.resourceType == null) {
messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
@@ -357,6 +369,32 @@ public class GenericClassRef
return;
}
+ if (this.resourceType.getKind() == Kind.ENUM) {
+ messages.add(
+ DefaultJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JpaValidationMessages.PERSISTENCE_UNIT_LISTED_CLASS_IS_AN_ENUM,
+ new String[] {this.getJavaClassName()},
+ this,
+ this.getValidationTextRange()
+ )
+ );
+ return;
+ }
+
+ if (this.resourceType.getKind() == Kind.TYPE && this.resourceType.getTypeBinding().isInterface()) {
+ messages.add(
+ DefaultJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JpaValidationMessages.PERSISTENCE_UNIT_LISTED_CLASS_IS_AN_INTERFACE,
+ new String[] {this.getJavaClassName()},
+ this,
+ this.getValidationTextRange()
+ )
+ );
+ return;
+ }
+
// 190062 validate Java class only if this is the only reference to it
// i.e. the persistence.xml ref is the only ref - none of the mapping
// files reference the same class
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/validation/JpaValidationMessages.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/validation/JpaValidationMessages.java
index eaf456a..7d639e6 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/validation/JpaValidationMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/validation/JpaValidationMessages.java
@@ -42,6 +42,8 @@ public interface JpaValidationMessages {
public static final String PERSISTENCE_UNIT_INVALID_MAPPING_FILE = "PERSISTENCE_UNIT_INVALID_MAPPING_FILE";
public static final String PERSISTENCE_UNIT_JAR_FILE_DEPLOYMENT_PATH_WARNING = "PERSISTENCE_UNIT_JAR_FILE_DEPLOYMENT_PATH_WARNING";
public static final String PERSISTENCE_UNIT_NONEXISTENT_CLASS = "PERSISTENCE_UNIT_NONEXISTENT_CLASS";
+ public static final String PERSISTENCE_UNIT_LISTED_CLASS_IS_AN_INTERFACE = "PERSISTENCE_UNIT_LISTED_CLASS_IS_AN_INTERFACE";
+ public static final String PERSISTENCE_UNIT_LISTED_CLASS_IS_AN_ENUM = "PERSISTENCE_UNIT_LISTED_CLASS_IS_AN_ENUM";
public static final String PERSISTENCE_UNIT_NONEXISTENT_JAR_FILE = "PERSISTENCE_UNIT_NONEXISTENT_JAR_FILE";
public static final String PERSISTENCE_UNIT_NONEXISTENT_MAPPING_FILE = "PERSISTENCE_UNIT_NONEXISTENT_MAPPING_FILE";
public static final String PERSISTENCE_UNIT_REDUNDANT_CLASS = "PERSISTENCE_UNIT_REDUNDANT_CLASS";
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui_validation_preferences.properties b/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui_validation_preferences.properties
index bc615ac..cf30ee8 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui_validation_preferences.properties
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui_validation_preferences.properties
@@ -38,6 +38,8 @@ PERSISTENCE_UNIT_INVALID_CLASS=Class is included in a persistence unit but is no
PERSISTENCE_UNIT_INVALID_MAPPING_FILE=Mapping file does not have ORM content:
PERSISTENCE_UNIT_JAR_FILE_DEPLOYMENT_PATH_WARNING=The path to the JAR file will vary:
PERSISTENCE_UNIT_NONEXISTENT_CLASS=Class cannot be resolved:
+PERSISTENCE_UNIT_LISTED_CLASS_IS_AN_INTERFACE=Listed class must not be an interface:
+PERSISTENCE_UNIT_LISTED_CLASS_IS_AN_ENUM=Listed class must not be an enum:
PERSISTENCE_UNIT_NONEXISTENT_JAR_FILE=JAR file cannot be resolved:
PERSISTENCE_UNIT_NONEXISTENT_MAPPING_FILE=Mapping file cannot be resolved:
PERSISTENCE_UNIT_REDUNDANT_CLASS=Class is already specified in mapping file:
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiValidationPreferenceMessages.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiValidationPreferenceMessages.java
index ba46079..1d4e7c3 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiValidationPreferenceMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiValidationPreferenceMessages.java
@@ -44,6 +44,8 @@ public class JptUiValidationPreferenceMessages {
public static String PERSISTENCE_UNIT_INVALID_MAPPING_FILE;
public static String PERSISTENCE_UNIT_JAR_FILE_DEPLOYMENT_PATH_WARNING;
public static String PERSISTENCE_UNIT_NONEXISTENT_CLASS;
+ public static String PERSISTENCE_UNIT_LISTED_CLASS_IS_AN_INTERFACE;
+ public static String PERSISTENCE_UNIT_LISTED_CLASS_IS_AN_ENUM;
public static String PERSISTENCE_UNIT_NONEXISTENT_JAR_FILE;
public static String PERSISTENCE_UNIT_NONEXISTENT_MAPPING_FILE;
public static String PERSISTENCE_UNIT_REDUNDANT_CLASS;
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/prefs/JpaProblemSeveritiesPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/prefs/JpaProblemSeveritiesPage.java
index ba23b39..8e02f91 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/prefs/JpaProblemSeveritiesPage.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/prefs/JpaProblemSeveritiesPage.java
@@ -295,6 +295,8 @@ public class JpaProblemSeveritiesPage extends PropertyAndPreferencePage {
addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_INVALID_MAPPING_FILE, JpaValidationMessages.PERSISTENCE_UNIT_INVALID_MAPPING_FILE);
addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_JAR_FILE_DEPLOYMENT_PATH_WARNING, JpaValidationMessages.PERSISTENCE_UNIT_JAR_FILE_DEPLOYMENT_PATH_WARNING);
addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_NONEXISTENT_CLASS, JpaValidationMessages.PERSISTENCE_UNIT_NONEXISTENT_CLASS);
+ addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_LISTED_CLASS_IS_AN_INTERFACE, JpaValidationMessages.PERSISTENCE_UNIT_LISTED_CLASS_IS_AN_INTERFACE);
+ addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_LISTED_CLASS_IS_AN_ENUM, JpaValidationMessages.PERSISTENCE_UNIT_LISTED_CLASS_IS_AN_ENUM);
addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_NONEXISTENT_JAR_FILE, JpaValidationMessages.PERSISTENCE_UNIT_NONEXISTENT_JAR_FILE);
addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_NONEXISTENT_MAPPING_FILE, JpaValidationMessages.PERSISTENCE_UNIT_NONEXISTENT_MAPPING_FILE);
addLabeledCombo(parent, JptUiValidationPreferenceMessages.PERSISTENCE_UNIT_REDUNDANT_CLASS, JpaValidationMessages.PERSISTENCE_UNIT_REDUNDANT_CLASS);