bug 346535 - fixed isVirtual calc and removed converter construction for virtual attributes
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentAttribute.java
index 5505335..7665525 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentAttribute.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentAttribute.java
@@ -14,6 +14,7 @@
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.Modifier;
+import org.eclipse.jpt.common.core.JptCommonCorePlugin;
import org.eclipse.jpt.common.core.internal.utility.JDTTools;
import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.common.utility.Filter;
@@ -23,7 +24,6 @@
import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
import org.eclipse.jpt.jpa.core.JpaStructureNode;
-import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
import org.eclipse.jpt.jpa.core.context.AccessType;
import org.eclipse.jpt.jpa.core.context.CollectionMapping;
import org.eclipse.jpt.jpa.core.context.Embeddable;
@@ -610,11 +610,9 @@
* as its own.)
*/
public boolean isVirtual() {
- return this.declaringPersistentTypeIs(JptJpaCorePlugin.ORM_XML_CONTENT_TYPE);
- }
-
- protected boolean declaringPersistentTypeIs(IContentType contentType) {
- return this.getOwningPersistentType().getResourceType().getContentType().equals(contentType);
+ IContentType persistentTypeContentType = this.getOwningPersistentType().getResourceType().getContentType();
+ return ! persistentTypeContentType.isKindOf(JptCommonCorePlugin.JAVA_SOURCE_CONTENT_TYPE)
+ && ! persistentTypeContentType.isKindOf(JptCommonCorePlugin.JAR_CONTENT_TYPE);
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkConvert.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkConvert.java
index dffb14d..d7bb143 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkConvert.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkConvert.java
@@ -135,9 +135,9 @@
}
} else {
if ((this.converter == null) || (this.converter.getType() != converterType)) {
- JavaEclipseLinkConverter.Adapter converterAdapter = this.getConverterAdapter(converterType);
- this.retainConverterAnnotation(converterAdapter);
- this.setConverter_(converterAdapter.buildNewConverter(this.getResourcePersistentAttribute(), this));
+ JavaEclipseLinkConverter.Adapter adapter = this.getConverterAdapter(converterType);
+ this.retainConverterAnnotation(adapter);
+ this.setConverter_(buildConverter(adapter));
}
}
}
@@ -149,6 +149,12 @@
}
protected JavaEclipseLinkConverter<?> buildConverter() {
+
+ // do not build a converter for a "virtual" attribute
+ if (getAttributeMapping().getPersistentAttribute().isVirtual()) {
+ return null;
+ }
+
JavaResourcePersistentAttribute resourceAttribute = this.getResourcePersistentAttribute();
for (JavaEclipseLinkConverter.Adapter adapter : this.getConverterAdapters()) {
JavaEclipseLinkConverter<?> javaConverter = adapter.buildConverter(resourceAttribute, this);
@@ -158,7 +164,28 @@
}
return null;
}
-
+
+ protected JavaEclipseLinkConverter<?> buildConverter(JavaEclipseLinkConverter.Adapter adapter) {
+
+ // do not build a converter for a "virtual" attribute
+ if (getAttributeMapping().getPersistentAttribute().isVirtual()) {
+ return null;
+ }
+
+ return adapter.buildNewConverter(this.getResourcePersistentAttribute(), this);
+ }
+
+ protected JavaEclipseLinkConverter<?> buildConverter(
+ JavaEclipseLinkConverter.Adapter adapter, EclipseLinkNamedConverterAnnotation annotation) {
+
+ // do not build a converter for a "virtual" attribute
+ if (getAttributeMapping().getPersistentAttribute().isVirtual()) {
+ return null;
+ }
+
+ return adapter.buildConverter(annotation, this);
+ }
+
/**
* Clear all the converter annotations <em>except</em> for the annotation
* corresponding to the specified adapter. If the specified adapter is
@@ -187,7 +214,7 @@
(this.converter.getConverterAnnotation() == annotation)) {
this.converter.synchronizeWithResourceModel();
} else {
- this.setConverter_(adapter.buildConverter(annotation, this));
+ this.setConverter_(buildConverter(adapter, annotation));
}
}
}