diff options
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core')
8 files changed, 59 insertions, 124 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/EclipseLinkNonEmbeddableTypeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/EclipseLinkNonEmbeddableTypeMapping.java index 2eb269b1a3..6e01a5f77d 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/EclipseLinkNonEmbeddableTypeMapping.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/EclipseLinkNonEmbeddableTypeMapping.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2012 Oracle. All rights reserved. + * Copyright (c) 2010, 2013 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -10,6 +10,7 @@ package org.eclipse.jpt.jpa.eclipselink.core.context; import org.eclipse.jpt.jpa.core.context.GeneratorContainer; +import org.eclipse.jpt.jpa.core.context.IdTypeMapping; /** @@ -20,10 +21,13 @@ import org.eclipse.jpt.jpa.core.context.GeneratorContainer; * stability. It is available at this early stage to solicit feedback from * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. + * + * @version 3.6 + * @since 3.3 */ public interface EclipseLinkNonEmbeddableTypeMapping - extends EclipseLinkTypeMapping -{ + extends IdTypeMapping, EclipseLinkTypeMapping { + EclipseLinkCaching getCaching(); EclipseLinkReadOnly getReadOnly(); diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/EclipseLinkEntityPrimaryKeyValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/EclipseLinkEntityPrimaryKeyValidator.java index 894478b6d7..2ca8b04b9c 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/EclipseLinkEntityPrimaryKeyValidator.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/EclipseLinkEntityPrimaryKeyValidator.java @@ -10,10 +10,10 @@ package org.eclipse.jpt.jpa.eclipselink.core.internal.context; import java.util.List; -import org.eclipse.jpt.jpa.core.context.TypeMapping; +import org.eclipse.jpt.common.core.internal.utility.ValidationMessageTools; +import org.eclipse.jpt.jpa.core.context.IdTypeMapping; import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; import org.eclipse.jpt.jpa.core.internal.jpa1.context.AbstractEntityPrimaryKeyValidator; -import org.eclipse.jpt.common.core.internal.utility.ValidationMessageTools; import org.eclipse.jpt.jpa.core.validation.JptJpaCoreValidationMessages; import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkEntity; import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkTypeMapping; @@ -52,7 +52,7 @@ public class EclipseLinkEntityPrimaryKeyValidator } @Override - protected boolean definesPrimaryKey(TypeMapping typeMapping) { + protected boolean definesPrimaryKey(IdTypeMapping typeMapping) { return super.definesPrimaryKey(typeMapping) || ((EclipseLinkTypeMapping) typeMapping).usesPrimaryKeyColumns() || ((EclipseLinkTypeMapping) typeMapping).usesPrimaryKeyTenantDiscriminatorColumns(); diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/EclipseLinkMappedSuperclassPrimaryKeyValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/EclipseLinkMappedSuperclassPrimaryKeyValidator.java index fe5b1e966b..371882b950 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/EclipseLinkMappedSuperclassPrimaryKeyValidator.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/EclipseLinkMappedSuperclassPrimaryKeyValidator.java @@ -10,10 +10,10 @@ package org.eclipse.jpt.jpa.eclipselink.core.internal.context; import java.util.List; -import org.eclipse.jpt.jpa.core.context.TypeMapping; +import org.eclipse.jpt.common.core.internal.utility.ValidationMessageTools; +import org.eclipse.jpt.jpa.core.context.IdTypeMapping; import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; import org.eclipse.jpt.jpa.core.internal.jpa1.context.AbstractMappedSuperclassPrimaryKeyValidator; -import org.eclipse.jpt.common.core.internal.utility.ValidationMessageTools; import org.eclipse.jpt.jpa.core.validation.JptJpaCoreValidationMessages; import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkMappedSuperclass; import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkTypeMapping; @@ -64,7 +64,7 @@ public class EclipseLinkMappedSuperclassPrimaryKeyValidator } @Override - protected boolean definesPrimaryKey(TypeMapping typeMapping) { + protected boolean definesPrimaryKey(IdTypeMapping typeMapping) { return super.definesPrimaryKey(typeMapping) || ((EclipseLinkTypeMapping) typeMapping).usesPrimaryKeyColumns(); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaMappedSuperclassImpl.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaMappedSuperclassImpl.java index 94901598fa..eda7685112 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaMappedSuperclassImpl.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaMappedSuperclassImpl.java @@ -43,27 +43,27 @@ import org.eclipse.wst.validation.internal.provisional.core.IReporter; * Java mapped superclass */ public class EclipseLinkJavaMappedSuperclassImpl - extends AbstractJavaMappedSuperclass - implements - EclipseLinkJavaMappedSuperclass, - JavaCacheableReference2_0, - EclipseLinkJavaConverterContainer.Parent, - JavaGeneratorContainer.Parent -{ + extends AbstractJavaMappedSuperclass + implements + EclipseLinkJavaMappedSuperclass, + JavaCacheableReference2_0, + EclipseLinkJavaConverterContainer.Parent, + JavaGeneratorContainer.Parent { + protected final EclipseLinkJavaCaching caching; - + protected final EclipseLinkJavaReadOnly readOnly; - + protected final EclipseLinkJavaConverterContainer converterContainer; - + protected final EclipseLinkJavaChangeTracking changeTracking; - + protected final EclipseLinkJavaCustomizer customizer; - + protected final EclipseLinkJavaMultitenancy2_3 multitenancy; - + protected final JavaGeneratorContainer generatorContainer; - + public EclipseLinkJavaMappedSuperclassImpl(JavaPersistentType parent, MappedSuperclassAnnotation mappingAnnotation) { super(parent, mappingAnnotation); this.caching = this.buildCaching(); diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaMultitenancyImpl2_3.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaMultitenancyImpl2_3.java index 7ca200ace7..c4b747c8db 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaMultitenancyImpl2_3.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/EclipseLinkJavaMultitenancyImpl2_3.java @@ -607,15 +607,13 @@ public class EclipseLinkJavaMultitenancyImpl2_3 } protected EclipseLinkMappedSuperclass getSuperMappedSuperclass(TypeMapping typeMapping) { - TypeMapping superTypeMapping = typeMapping.getSuperTypeMapping(); - if (superTypeMapping == null) { - return null; - } - //instanceof check in case the mapped superclass is in an orm.xml instead of an eclipselinkorm.xml file. - if (superTypeMapping instanceof EclipseLinkMappedSuperclass) { - return (EclipseLinkMappedSuperclass) superTypeMapping; + for (TypeMapping superTypeMapping : typeMapping.getAncestors()) { + //instanceof check in case the mapped superclass is in an orm.xml instead of an eclipselinkorm.xml file. + if (superTypeMapping instanceof EclipseLinkMappedSuperclass) { + return (EclipseLinkMappedSuperclass) superTypeMapping; + } } - return this.getSuperMappedSuperclass(superTypeMapping); + return null; } public boolean usesPrimaryKeyTenantDiscriminatorColumns() { diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmMultitenancyImpl2_3.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmMultitenancyImpl2_3.java index df4cd3d8ad..0272d03b9d 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmMultitenancyImpl2_3.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmMultitenancyImpl2_3.java @@ -647,15 +647,13 @@ public class EclipseLinkOrmMultitenancyImpl2_3 } protected EclipseLinkMappedSuperclass getSuperMappedSuperclass(TypeMapping typeMapping) { - TypeMapping superTypeMapping = typeMapping.getSuperTypeMapping(); - if (superTypeMapping == null) { - return null; - } - //instanceof check in case the mapped superclass is in an orm.xml instead of an eclipselinkorm.xml file. - if (superTypeMapping instanceof EclipseLinkMappedSuperclass) { - return (EclipseLinkMappedSuperclass) superTypeMapping; + for (TypeMapping superTypeMapping : typeMapping.getAncestors()) { + //instanceof check in case the mapped superclass is in an orm.xml instead of an eclipselinkorm.xml file. + if (superTypeMapping instanceof EclipseLinkMappedSuperclass) { + return (EclipseLinkMappedSuperclass) superTypeMapping; + } } - return this.getSuperMappedSuperclass(superTypeMapping); + return null; } public boolean usesPrimaryKeyTenantDiscriminatorColumns() { 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 049b824fc7..7dd8c71034 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 @@ -13,8 +13,8 @@ import java.util.List; import org.eclipse.jpt.common.core.resource.java.JavaResourceType; import org.eclipse.jpt.common.core.utility.jdt.TypeBinding; import org.eclipse.jpt.common.utility.internal.ObjectTools; -import org.eclipse.jpt.jpa.core.context.PersistentType; import org.eclipse.jpt.jpa.core.context.PersistentAttribute; +import org.eclipse.jpt.jpa.core.context.PersistentType; import org.eclipse.jpt.jpa.core.context.java.JavaManagedType; import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; import org.eclipse.jpt.jpa.core.context.orm.EntityMappings; @@ -27,8 +27,8 @@ import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkAccessType; import org.eclipse.jpt.jpa.eclipselink.core.context.orm.EclipseLinkEntityMappings; import org.eclipse.jpt.jpa.eclipselink.core.context.orm.EclipseLinkOrmPersistentType; import org.eclipse.jpt.jpa.eclipselink.core.context.orm.EclipseLinkOrmTypeMapping; -import org.eclipse.jpt.jpa.eclipselink.core.internal.EclipseLinkJpaPlatformFactory2_1; import org.eclipse.jpt.jpa.eclipselink.core.internal.EclipseLinkJpaPlatformFactory.EclipseLinkJpaPlatformVersion; +import org.eclipse.jpt.jpa.eclipselink.core.internal.EclipseLinkJpaPlatformFactory2_1; import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.EclipseLinkOrmFactory; import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlAccessMethods; import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlAccessMethodsHolder; @@ -172,7 +172,7 @@ public class EclipseLinkOrmPersistentTypeImpl @Override public TypeBinding getAttributeTypeBinding(PersistentAttribute attribute) { if (this.dynamic) { - return (this.superPersistentType == null) ? null : this.superPersistentType.getAttributeTypeBinding(attribute); + return (getSuperPersistentType() == null) ? null : getSuperPersistentType().getAttributeTypeBinding(attribute); } return super.getAttributeTypeBinding(attribute); } 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 b34efe43c1..2321142bce 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 @@ -10,20 +10,16 @@ package org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm; import java.util.Collection; -import java.util.HashSet; import java.util.List; import java.util.Map; import org.eclipse.core.resources.IFile; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement; import org.eclipse.jpt.common.core.resource.java.JavaResourceAttribute; import org.eclipse.jpt.common.core.resource.java.JavaResourceType; import org.eclipse.jpt.common.core.utility.BodySourceWriter; import org.eclipse.jpt.common.core.utility.TextRange; import org.eclipse.jpt.common.core.utility.jdt.TypeBinding; -import org.eclipse.jpt.common.utility.internal.ObjectTools; -import org.eclipse.jpt.common.utility.internal.StringTools; import org.eclipse.jpt.common.utility.internal.iterable.EmptyIterable; import org.eclipse.jpt.common.utility.internal.iterable.EmptyListIterable; import org.eclipse.jpt.common.utility.internal.iterable.IterableTools; @@ -33,6 +29,7 @@ import org.eclipse.jpt.jpa.core.JpaStructureNode; import org.eclipse.jpt.jpa.core.context.AccessType; import org.eclipse.jpt.jpa.core.context.PersistentAttribute; import org.eclipse.jpt.jpa.core.context.PersistentType; +import org.eclipse.jpt.jpa.core.context.TypeMapping; import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute; import org.eclipse.jpt.jpa.core.context.java.JavaTypeMapping; @@ -47,14 +44,13 @@ import org.eclipse.wst.validation.internal.provisional.core.IMessage; import org.eclipse.wst.validation.internal.provisional.core.IReporter; public class EclipseLinkVirtualJavaPersistentType - extends AbstractJavaContextModel<EclipseLinkOrmPersistentType> - implements JavaPersistentType, PersistentType2_0 -{ + extends AbstractJavaContextModel<EclipseLinkOrmPersistentType> + implements JavaPersistentType, PersistentType2_0 { + private final XmlTypeMapping xmlTypeMapping; protected final JavaTypeMapping mapping; - protected PersistentType superPersistentType; - + public EclipseLinkVirtualJavaPersistentType(EclipseLinkOrmPersistentType parent, XmlTypeMapping xmlTypeMapping) { super(parent); @@ -76,7 +72,6 @@ public class EclipseLinkVirtualJavaPersistentType @Override public void update() { super.update(); - this.setSuperPersistentType(this.buildSuperPersistentType()); } public void addRootStructureNodesTo(JpaFile jpaFile, Collection<JpaStructureNode> rootStructureNodes) { @@ -141,64 +136,22 @@ public class EclipseLinkVirtualJavaPersistentType } - // ********** super persistent type ********** - + // ***** super persistent type ***** + public PersistentType getSuperPersistentType() { - return this.superPersistentType; - } - - protected void setSuperPersistentType(PersistentType superPersistentType) { - PersistentType old = this.superPersistentType; - this.superPersistentType = superPersistentType; - this.firePropertyChanged(SUPER_PERSISTENT_TYPE_PROPERTY, old, superPersistentType); - } - - protected PersistentType buildSuperPersistentType() { - HashSet<JavaResourceType> visited = new HashSet<JavaResourceType>(); - PersistentType spt = this.resolveSuperPersistentType(this.xmlTypeMapping.getParentClass(), visited); - if (spt == null) { - return null; - } - if (IterableTools.contains(spt.getInheritanceHierarchy(), this)) { - return null; // short-circuit in this case, we have circular inheritance - } - return spt.isMapped() ? spt : spt.getSuperPersistentType(); - } - - /** - * The JPA spec allows non-persistent types in a persistent type's - * inheritance hierarchy. We check for a persistent type with the - * specified name in the persistence unit (Use the EntityMapping - * API for this because it will append the package name if unqualified). - * If it is not found we use java resource type and look for <em>its</em> super type. - * <p> - * The <code>visited</code> collection is used to detect a cycle in the - * <em>resource</em> type inheritance hierarchy and prevent the resulting - * stack overflow. Any cycles in the <em>context</em> type inheritance - * hierarchy are handled in {@link #buildSuperPersistentType()}. - */ - protected PersistentType resolveSuperPersistentType(String typeName, Collection<JavaResourceType> visited) { - if (StringTools.isBlank(typeName)) { - return null; - } - PersistentType spt = this.resolvePersistentType(typeName); - if (spt != null) { - return spt; - } - JavaResourceType resourceType = this.resolveJavaResourceType(typeName); - visited.add(resourceType); - return (resourceType == null) ? null : this.resolveSuperPersistentType(resourceType.getSuperclassQualifiedName(), visited); // recurse + TypeMapping superTypeMapping = this.mapping.getSuperTypeMapping(); + return (superTypeMapping == null) ? null : superTypeMapping.getPersistentType(); } - - protected PersistentType resolvePersistentType(String typeName) { - return this.getEntityMappings().resolvePersistentType(typeName); + + public Iterable<PersistentType> getAncestors() { + return IterableTools.transform(getMapping().getAncestors(), TypeMapping.PERSISTENT_TYPE_TRANSFORMER); } - - protected JavaResourceType resolveJavaResourceType(String typeName) { - return (JavaResourceType) this.getEntityMappings().resolveJavaResourceType(typeName, JavaResourceAnnotatedElement.AstNodeType.TYPE); + + public Iterable<PersistentType> getInheritanceHierarchy() { + return IterableTools.transform(getMapping().getInheritanceHierarchy(), TypeMapping.PERSISTENT_TYPE_TRANSFORMER); } - - + + // ********** attributes ********** //The VirtualJavaPersistentAttributes are built by the OrmEclipseLinkPersistentAttribute, no attributes here @@ -243,24 +196,6 @@ public class EclipseLinkVirtualJavaPersistentType } - // ********** inheritance ********** - - public Iterable<PersistentType> getInheritanceHierarchy() { - return this.buildInheritanceHierarchy(this); - } - - public Iterable<PersistentType> getAncestors() { - return (this.superPersistentType == null) ? - IterableTools.<PersistentType>emptyIterable() : - this.buildInheritanceHierarchy(this.superPersistentType); - } - - protected Iterable<PersistentType> buildInheritanceHierarchy(PersistentType start) { - // using a chain iterable to traverse up the inheritance tree - return ObjectTools.chain(start, SUPER_PERSISTENT_TYPE_TRANSFORMER); - } - - // ********** JpaStructureNode implementation ********** public ContextType getContextType() { |