diff options
author | Brian Vosburgh | 2013-04-30 20:40:21 +0000 |
---|---|---|
committer | Brian Vosburgh | 2013-04-30 20:53:00 +0000 |
commit | a89bf09664296357cfdfd0cbf473ee1820ce8d2e (patch) | |
tree | 9e26a7c28c072a0255497ffa8daa2d6c6edb5c76 /jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core | |
parent | 9b5ed45204c80b315f0f4807bdc5e2fed68976f0 (diff) | |
download | webtools.dali-a89bf09664296357cfdfd0cbf473ee1820ce8d2e.tar.gz webtools.dali-a89bf09664296357cfdfd0cbf473ee1820ce8d2e.tar.xz webtools.dali-a89bf09664296357cfdfd0cbf473ee1820ce8d2e.zip |
[406731] fix NPE in metamodel generation when target type is null
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core')
6 files changed, 40 insertions, 65 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/EclipseLinkPersistenceUnit.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/EclipseLinkPersistenceUnit.java index df894a2534..3df5223658 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/EclipseLinkPersistenceUnit.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/EclipseLinkPersistenceUnit.java @@ -776,7 +776,7 @@ public class EclipseLinkPersistenceUnit return; } - if (ArrayTools.contains(EclipseLinkCustomization.RESERVED_PROFILER_NAMES, profilerProperty.getValue())) { + if (ArrayTools.contains(org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkCustomization.RESERVED_PROFILER_NAMES, profilerProperty.getValue())) { return; } @@ -807,7 +807,7 @@ public class EclipseLinkPersistenceUnit ) ); } else if (!TypeTools.isSubType( - profilerProperty.getValue(), EclipseLinkCustomization.ECLIPSELINK_SESSION_PROFILER_CLASS_NAME, javaProject) + profilerProperty.getValue(), org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkCustomization.ECLIPSELINK_SESSION_PROFILER_CLASS_NAME, javaProject) ) { messages.add( this.buildValidationMessage( @@ -853,7 +853,7 @@ public class EclipseLinkPersistenceUnit ) ); } else if (!TypeTools.isSubType( - property.getValue(), EclipseLinkCustomization.ECLIPSELINK_SESSION_CUSTOMIZER_CLASS_NAME, javaProject) + property.getValue(), org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkCustomization.ECLIPSELINK_SESSION_CUSTOMIZER_CLASS_NAME, javaProject) ) { messages.add( this.buildValidationMessage( @@ -883,47 +883,47 @@ public class EclipseLinkPersistenceUnit } private Property getCacheTypeDefaultProperty() { - return this.getProperty(EclipseLinkCaching.ECLIPSELINK_CACHE_TYPE_DEFAULT); + return this.getProperty(org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkCaching.ECLIPSELINK_CACHE_TYPE_DEFAULT); } private Property getCacheSizeDefaultProperty() { - return this.getProperty(EclipseLinkCaching.ECLIPSELINK_CACHE_SIZE_DEFAULT); + return this.getProperty(org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkCaching.ECLIPSELINK_CACHE_SIZE_DEFAULT); } private Property getCacheSharedDefaultProperty() { - return this.getProperty(EclipseLinkCaching.ECLIPSELINK_CACHE_SHARED_DEFAULT); + return this.getProperty(org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkCaching.ECLIPSELINK_CACHE_SHARED_DEFAULT); } private Property getFlushClearCacheProperty() { - return this.getProperty(EclipseLinkCaching.ECLIPSELINK_FLUSH_CLEAR_CACHE); + return this.getProperty(org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkCaching.ECLIPSELINK_FLUSH_CLEAR_CACHE); } /** * Returns all Shared Cache Properties, including Entity and default. */ private Iterable<Property> getSharedCacheProperties() { - return this.getPropertiesWithNamePrefix(EclipseLinkCaching.ECLIPSELINK_SHARED_CACHE); + return this.getPropertiesWithNamePrefix(org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkCaching.ECLIPSELINK_SHARED_CACHE); } /** * Returns Entity Cache Size Properties, excluding default. */ private Iterable<Property> getEntityCacheSizeProperties() { - return this.getEntityPropertiesWithPrefix(EclipseLinkCaching.ECLIPSELINK_CACHE_SIZE); + return this.getEntityPropertiesWithPrefix(org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkCaching.ECLIPSELINK_CACHE_SIZE); } /** * Returns Entity Cache Type Properties, excluding default. */ private Iterable<Property> getEntityCacheTypeProperties() { - return this.getEntityPropertiesWithPrefix(EclipseLinkCaching.ECLIPSELINK_CACHE_TYPE); + return this.getEntityPropertiesWithPrefix(org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkCaching.ECLIPSELINK_CACHE_TYPE); } /** * Returns Descriptor Customizer Properties. */ private Iterable<Property> getDescriptorCustomizerProperties() { - return this.getEntityPropertiesWithPrefix(EclipseLinkCustomization.ECLIPSELINK_DESCRIPTOR_CUSTOMIZER); + return this.getEntityPropertiesWithPrefix(org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkCustomization.ECLIPSELINK_DESCRIPTOR_CUSTOMIZER); } /** @@ -955,18 +955,18 @@ public class EclipseLinkPersistenceUnit } private Property getExceptionHandlerProperty() { - return this.getProperty(EclipseLinkCustomization.ECLIPSELINK_EXCEPTION_HANDLER); + return this.getProperty(org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkCustomization.ECLIPSELINK_EXCEPTION_HANDLER); } private Property getPerformanceProfilerProperty() { - return this.getProperty(EclipseLinkCustomization.ECLIPSELINK_PROFILER); + return this.getProperty(org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkCustomization.ECLIPSELINK_PROFILER); } /** * Returns all Session Customizer Properties. */ private Iterable<Property> getSessionCustomizerProperties() { - return this.getPropertiesWithNamePrefix(EclipseLinkCustomization.ECLIPSELINK_SESSION_CUSTOMIZER); + return this.getPropertiesWithNamePrefix(org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkCustomization.ECLIPSELINK_SESSION_CUSTOMIZER); } /** @@ -1344,21 +1344,4 @@ public class EclipseLinkPersistenceUnit return convertibleModels; } - - // ********** metamodel ********** - - @Override - protected HashMap<String, PersistentType> getPersistentTypesToSynchronizeMetamodel() { - HashMap<String, PersistentType> allPersistentTypes = super.getPersistentTypesToSynchronizeMetamodel(); - - this.removeDynamicTypes(allPersistentTypes); - return allPersistentTypes; - } - - private void removeDynamicTypes(HashMap<String, PersistentType> persistentTypes) { - Iterator<String> dynamicTypeNames = this.getEclipseLinkDynamicPersistentTypeNames().iterator(); - while(dynamicTypeNames.hasNext()) { - persistentTypes.remove(dynamicTypeNames.next()); - } - } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkAbstractOrmBasicCollectionMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkAbstractOrmBasicCollectionMapping.java index a0168da556..8215c74ecc 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkAbstractOrmBasicCollectionMapping.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkAbstractOrmBasicCollectionMapping.java @@ -15,7 +15,6 @@ import org.eclipse.jpt.jpa.core.context.orm.OrmSpecifiedPersistentAttribute; import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmAttributeMapping; import org.eclipse.jpt.jpa.core.jpa2.context.MetamodelField2_0; import org.eclipse.jpt.jpa.core.jpa2.context.SpecifiedPersistentAttribute2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.PersistentType2_0; import org.eclipse.jpt.jpa.eclipselink.core.EclipseLinkMappingKeys; import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkBasicCollectionMapping; import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.Attributes; @@ -59,11 +58,8 @@ public abstract class EclipseLinkAbstractOrmBasicCollectionMapping @Override public String getMetamodelTypeName() { String targetTypeName = null; - JavaSpecifiedPersistentAttribute javaPersistentAttribute = getJavaPersistentAttribute(); + JavaSpecifiedPersistentAttribute javaPersistentAttribute = this.getJavaPersistentAttribute(); if (javaPersistentAttribute != null) { - if(((PersistentType2_0)javaPersistentAttribute).getMetamodelType() == null) { // dynamic type - return null; - } targetTypeName = javaPersistentAttribute.getMultiReferenceTargetTypeName(); } return (targetTypeName != null) ? targetTypeName : MetamodelField2_0.DEFAULT_TYPE_NAME; diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkAbstractOrmBasicMapMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkAbstractOrmBasicMapMapping.java index af2b35240e..5ef2620c6d 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkAbstractOrmBasicMapMapping.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkAbstractOrmBasicMapMapping.java @@ -16,7 +16,6 @@ import org.eclipse.jpt.jpa.core.context.orm.OrmSpecifiedPersistentAttribute; import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmAttributeMapping; import org.eclipse.jpt.jpa.core.jpa2.context.MetamodelField2_0; import org.eclipse.jpt.jpa.core.jpa2.context.SpecifiedPersistentAttribute2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.PersistentType2_0; import org.eclipse.jpt.jpa.eclipselink.core.EclipseLinkMappingKeys; import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkBasicMapMapping; import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.Attributes; @@ -63,9 +62,6 @@ public abstract class EclipseLinkAbstractOrmBasicMapMapping String targetTypeName = null; JavaSpecifiedPersistentAttribute javaPersistentAttribute = this.getJavaPersistentAttribute(); if (javaPersistentAttribute != null) { - if(((PersistentType2_0)javaPersistentAttribute).getMetamodelType() == null) { // dynamic type - return null; - } targetTypeName = javaPersistentAttribute.getMultiReferenceTargetTypeName(); } return (targetTypeName != null) ? targetTypeName : MetamodelField2_0.DEFAULT_TYPE_NAME; @@ -83,7 +79,9 @@ public abstract class EclipseLinkAbstractOrmBasicMapMapping if (javaPersistentAttribute != null) { mapKeyTypeName = javaPersistentAttribute.getMultiReferenceMapKeyTypeName(); } - mapKeyTypeName = mapKeyTypeName != null ? mapKeyTypeName : MetamodelField2_0.DEFAULT_TYPE_NAME; + if (mapKeyTypeName == null) { + mapKeyTypeName = MetamodelField2_0.DEFAULT_TYPE_NAME; + } typeArgumentNames.add(mapKeyTypeName); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmManyToManyMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmManyToManyMapping.java index 8013d43787..4973092340 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmManyToManyMapping.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmManyToManyMapping.java @@ -22,8 +22,8 @@ import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmManyToManyMappin import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkAccessType; import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkJoinFetch; import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkManyToManyMapping2_0; -import org.eclipse.jpt.jpa.eclipselink.core.context.orm.EclipseLinkOrmConvertibleMapping; import org.eclipse.jpt.jpa.eclipselink.core.context.orm.EclipseLinkOrmConverterContainer; +import org.eclipse.jpt.jpa.eclipselink.core.context.orm.EclipseLinkOrmConvertibleMapping; import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit; import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlManyToMany; import org.eclipse.jpt.jpa.eclipselink.core.validation.JptJpaEclipseLinkCoreValidationMessages; @@ -205,7 +205,7 @@ public class EclipseLinkOrmManyToManyMapping protected Iterable<String> getCandidateTargetEntityClassNames() { return IterableTools.concatenate( super.getCandidateTargetEntityClassNames(), - ((EclipseLinkPersistenceUnit) this.getPersistenceUnit()).getEclipseLinkDynamicPersistentTypeNames() + IterableTools.sort(((EclipseLinkPersistenceUnit) this.getPersistenceUnit()).getEclipseLinkDynamicPersistentTypeNames()) ); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmPersistentTypeImpl.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmPersistentTypeImpl.java index aaac3d61c7..88ee6cbe02 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmPersistentTypeImpl.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmPersistentTypeImpl.java @@ -46,9 +46,9 @@ import org.eclipse.wst.validation.internal.provisional.core.IMessage; * </ul> */ public class EclipseLinkOrmPersistentTypeImpl - extends SpecifiedOrmPersistentType - implements EclipseLinkOrmPersistentType { - + extends SpecifiedOrmPersistentType + implements EclipseLinkOrmPersistentType +{ protected String specifiedGetMethod; protected String defaultGetMethod; @@ -57,6 +57,7 @@ public class EclipseLinkOrmPersistentTypeImpl protected boolean dynamic; + public EclipseLinkOrmPersistentTypeImpl(EntityMappings parent, XmlTypeMapping xmlTypeMapping) { super(parent, xmlTypeMapping); this.specifiedGetMethod = this.buildSpecifiedGetMethod(); @@ -73,6 +74,7 @@ public class EclipseLinkOrmPersistentTypeImpl return (EclipseLinkOrmTypeMapping) super.getMapping(); } + // ********** synchronize/update ********** @Override @@ -91,7 +93,7 @@ public class EclipseLinkOrmPersistentTypeImpl } - //*************** dynamic ***************** + // ********** dynamic ********** public boolean isDynamic() { return this.dynamic; @@ -128,7 +130,7 @@ public class EclipseLinkOrmPersistentTypeImpl @Override protected JavaManagedType buildJavaManagedType(JavaResourceType jrt) { - return this.isDynamic() ? + return this.dynamic ? this.buildVirtualJavaPersistentType() : super.buildJavaManagedType(jrt); } @@ -140,10 +142,7 @@ public class EclipseLinkOrmPersistentTypeImpl @Override public PersistentType getOverriddenPersistentType() { - if (this.isDynamic()) { - return null; - } - return super.getOverriddenPersistentType(); + return this.dynamic ? null : super.getOverriddenPersistentType(); } public OrmSpecifiedPersistentAttribute addVirtualAttribute(String attributeName, String mappingKey, String attributeType, String targetType) { @@ -171,19 +170,17 @@ public class EclipseLinkOrmPersistentTypeImpl @Override public TypeBinding getAttributeTypeBinding(PersistentAttribute attribute) { - if (isDynamic()) { - PersistentType superPT = getSuperPersistentType(); - return (superPT == null) ? null : superPT.getAttributeTypeBinding(attribute); + if (this.dynamic) { + return (this.superPersistentType == null) ? null : this.superPersistentType.getAttributeTypeBinding(attribute); } return super.getAttributeTypeBinding(attribute); } - //*************** get method ***************** + // ********** get method ********** public String getGetMethod() { - String getMethod = this.getSpecifiedGetMethod(); - return (getMethod != null) ? getMethod : this.defaultGetMethod; + return (this.specifiedGetMethod != null) ? this.specifiedGetMethod : this.defaultGetMethod; } public String getDefaultGetMethod() { @@ -230,11 +227,10 @@ public class EclipseLinkOrmPersistentTypeImpl } - //*************** set method ***************** + // ********** set method ********** public String getSetMethod() { - String setMethod = this.getSpecifiedSetMethod(); - return (setMethod != null) ? setMethod : this.defaultSetMethod; + return (this.specifiedSetMethod != null) ? this.specifiedSetMethod : this.defaultSetMethod; } public String getDefaultSetMethod() { @@ -280,7 +276,8 @@ public class EclipseLinkOrmPersistentTypeImpl return accessMethods != null ? accessMethods.getSetMethod() : null; } - //*************** XML access methods ***************** + + // ********** XML access methods ********** protected XmlAccessMethodsHolder getXmlAccessMethodsHolder() { return this.getXmlTypeMapping(); @@ -324,16 +321,16 @@ public class EclipseLinkOrmPersistentTypeImpl @Override protected void validateClassResolves(List<IMessage> messages) { - if (this.isDynamic() && !this.isVirtualAccess()) { + if (this.dynamic && ! this.isVirtualAccess()) { super.validateClassResolves(messages); } } + // ********** metamodel ********** @Override public PersistentType2_0 getMetamodelType() { - return (this.isDynamic()) ? null : this; + return this.dynamic ? null : this; } - } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkVirtualJavaPersistentType.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkVirtualJavaPersistentType.java index df78b9b362..58184009c2 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkVirtualJavaPersistentType.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkVirtualJavaPersistentType.java @@ -360,6 +360,7 @@ public class EclipseLinkVirtualJavaPersistentType sb.append(this.getName()); } + // ********** metamodel ********** public PersistentType2_0 getMetamodelType() { |