diff options
author | pfullbright | 2011-05-25 00:32:56 +0000 |
---|---|---|
committer | pfullbright | 2011-05-25 00:32:56 +0000 |
commit | 2360c8b58c410f7c802b69565f35284fb2ecaa51 (patch) | |
tree | 41d6b4c962d0dabfbc320ba0b87c5dd0eab021d7 | |
parent | a44b1c28d5946bb44b749cf9679cf91a56ba7537 (diff) | |
download | webtools.dali-2360c8b58c410f7c802b69565f35284fb2ecaa51.tar.gz webtools.dali-2360c8b58c410f7c802b69565f35284fb2ecaa51.tar.xz webtools.dali-2360c8b58c410f7c802b69565f35284fb2ecaa51.zip |
bug 346535 - fixed isVirtual calc and removed converter construction for virtual attributes
2 files changed, 36 insertions, 11 deletions
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 55053350af..7665525524 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 java.util.List; 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.Tools; 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 @@ public abstract class AbstractJavaPersistentAttribute * 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 dffb14d720..d7bb143ff2 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 @@ public class JavaEclipseLinkConvert } } 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 @@ public class JavaEclipseLinkConvert } 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 @@ public class JavaEclipseLinkConvert } 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 @@ public class JavaEclipseLinkConvert (this.converter.getConverterAnnotation() == annotation)) { this.converter.synchronizeWithResourceModel(); } else { - this.setConverter_(adapter.buildConverter(annotation, this)); + this.setConverter_(buildConverter(adapter, annotation)); } } } |