From a5525a943f84a7e0393eeb7e56f613785c9469d7 Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Thu, 8 Dec 2022 17:14:28 +0000 Subject: [PATCH] HHH-15853 Remove the AttributeMetadataAccess interface --- .../ast/internal/LoaderSelectBuilder.java | 3 +- .../metamodel/mapping/AttributeMapping.java | 4 +- .../mapping/AttributeMetadataAccess.java | 20 -------- .../internal/AbstractEmbeddableMapping.java | 19 ++++---- .../AbstractSingularAttributeMapping.java | 10 ++-- .../AbstractStateArrayContributorMapping.java | 17 ++++--- .../internal/BasicAttributeMapping.java | 16 +++---- .../internal/CompoundNaturalIdMapping.java | 9 ++-- ...criminatedAssociationAttributeMapping.java | 6 +-- .../internal/EmbeddableMappingTypeImpl.java | 2 +- .../internal/EmbeddedAttributeMapping.java | 10 ++-- .../internal/GeneratedValuesProcessor.java | 3 +- .../mapping/internal/IdClassEmbeddable.java | 8 ++-- .../internal/MappingModelCreationHelper.java | 47 ++++++++++--------- .../internal/PluralAttributeMappingImpl.java | 12 ++--- ...cess.java => SimpleAttributeMetadata.java} | 15 ++---- .../internal/SimpleNaturalIdMapping.java | 2 +- .../internal/ToOneAttributeMapping.java | 12 ++--- .../VirtualEmbeddedAttributeMapping.java | 10 ++-- .../entity/AbstractEntityPersister.java | 25 ++++------ .../mutation/UpdateCoordinatorStandard.java | 3 +- .../entity/AbstractEntityInitializer.java | 3 +- .../AbstractCompositeIdAndNaturalIdTest.java | 2 +- ...tableManyToOneNaturalIdAnnotationTest.java | 4 +- .../ImmutableManyToOneNaturalIdHbmTest.java | 4 +- .../immutable/ImmutableNaturalIdTest.java | 2 +- .../ImmutableEntityNaturalIdTest.java | 2 +- .../inheritance/InheritedNaturalIdTest.java | 2 +- .../nullable/NullableNaturalIdTest.java | 16 +++---- 29 files changed, 124 insertions(+), 164 deletions(-) delete mode 100644 hibernate-core/src/main/java/org/hibernate/metamodel/mapping/AttributeMetadataAccess.java rename hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/{BasicAttributeMetadataAccess.java => SimpleAttributeMetadata.java} (85%) diff --git a/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderSelectBuilder.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderSelectBuilder.java index 2faa26c4f4..17c4a09679 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderSelectBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderSelectBuilder.java @@ -756,8 +756,7 @@ public class LoaderSelectBuilder { } } else if ( loadQueryInfluencers.getEnabledCascadingFetchProfile() != null ) { - final CascadeStyle cascadeStyle = fetchable.asAttributeMapping().getAttributeMetadataAccess() - .resolveAttributeMetadata( fetchable.findContainingEntityMapping() ) + final CascadeStyle cascadeStyle = fetchable.asAttributeMapping().getAttributeMetadata() .getCascadeStyle(); final CascadingAction cascadingAction = loadQueryInfluencers.getEnabledCascadingFetchProfile() .getCascadingAction(); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/AttributeMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/AttributeMapping.java index 16497073b4..c52d20fb15 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/AttributeMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/AttributeMapping.java @@ -39,7 +39,7 @@ public interface AttributeMapping /** * Access to AttributeMetadata */ - AttributeMetadataAccess getAttributeMetadataAccess(); + AttributeMetadata getAttributeMetadata(); /** * The managed type that declares this attribute @@ -79,7 +79,7 @@ public interface AttributeMapping @Override default MutabilityPlan getExposedMutabilityPlan() { - return getAttributeMetadataAccess().resolveAttributeMetadata( null ).getMutabilityPlan(); + return getAttributeMetadata().getMutabilityPlan(); } default int compare(Object value1, Object value2) { diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/AttributeMetadataAccess.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/AttributeMetadataAccess.java deleted file mode 100644 index 4e00167670..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/AttributeMetadataAccess.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later - * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html - */ -package org.hibernate.metamodel.mapping; - -/** - * Provides access to details about an attribute specific to a particular - * entity in the hierarchy. Accounts for attribute/association overrides, etc - * - * @author Steve Ebersole - */ -public interface AttributeMetadataAccess { - /** - * Resolve the details about the attribute - */ - AttributeMetadata resolveAttributeMetadata(EntityMappingType entityMappingType); -} diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractEmbeddableMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractEmbeddableMapping.java index 4491c58e9e..2c1fd22dec 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractEmbeddableMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractEmbeddableMapping.java @@ -7,7 +7,6 @@ package org.hibernate.metamodel.mapping.internal; import java.io.Serializable; -import java.util.List; import java.util.Locale; import java.util.function.Consumer; @@ -86,8 +85,7 @@ public abstract class AbstractEmbeddableMapping implements EmbeddableMappingType final Object[] results = new Object[getNumberOfAttributeMappings()]; forEachAttributeMapping( (position, attribute) -> { - final Getter getter = attribute.getAttributeMetadataAccess() - .resolveAttributeMetadata( findContainingEntityMapping() ) + final Getter getter = attribute.getAttributeMetadata() .getPropertyAccess() .getGetter(); results[position] = getter.get( compositeInstance ); @@ -362,13 +360,14 @@ public abstract class AbstractEmbeddableMapping implements EmbeddableMappingType mutabilityPlan = ImmutableMutabilityPlan.INSTANCE; } - BasicAttributeMetadataAccess attributeMetadataAccess = new BasicAttributeMetadataAccess( propertyAccess, - mutabilityPlan, - nullable, - insertable, - updateable, - includeInOptimisticLocking, - cascadeStyle + SimpleAttributeMetadata attributeMetadataAccess = new SimpleAttributeMetadata( + propertyAccess, + mutabilityPlan, + nullable, + insertable, + updateable, + includeInOptimisticLocking, + cascadeStyle ); attributeMapping = new DiscriminatedAssociationAttributeMapping( diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractSingularAttributeMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractSingularAttributeMapping.java index c0f121c6ea..f8f2fb3614 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractSingularAttributeMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractSingularAttributeMapping.java @@ -8,7 +8,7 @@ package org.hibernate.metamodel.mapping.internal; import org.hibernate.engine.FetchStyle; import org.hibernate.engine.FetchTiming; -import org.hibernate.metamodel.mapping.AttributeMetadataAccess; +import org.hibernate.metamodel.mapping.AttributeMetadata; import org.hibernate.metamodel.mapping.ManagedMappingType; import org.hibernate.metamodel.mapping.SingularAttributeMapping; import org.hibernate.property.access.spi.PropertyAccess; @@ -27,23 +27,23 @@ public abstract class AbstractSingularAttributeMapping public AbstractSingularAttributeMapping( String name, int stateArrayPosition, - AttributeMetadataAccess attributeMetadataAccess, + AttributeMetadata attributeMetadata, FetchOptions mappedFetchOptions, ManagedMappingType declaringType, PropertyAccess propertyAccess) { - super( name, attributeMetadataAccess, mappedFetchOptions, stateArrayPosition, declaringType ); + super( name, attributeMetadata, mappedFetchOptions, stateArrayPosition, declaringType ); this.propertyAccess = propertyAccess; } public AbstractSingularAttributeMapping( String name, int stateArrayPosition, - AttributeMetadataAccess attributeMetadataAccess, + AttributeMetadata attributeMetadata, FetchTiming fetchTiming, FetchStyle fetchStyle, ManagedMappingType declaringType, PropertyAccess propertyAccess) { - super( name, attributeMetadataAccess, fetchTiming, fetchStyle, stateArrayPosition, declaringType ); + super( name, attributeMetadata, fetchTiming, fetchStyle, stateArrayPosition, declaringType ); this.propertyAccess = propertyAccess; } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractStateArrayContributorMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractStateArrayContributorMapping.java index 78b825d6f2..bfdc2be92d 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractStateArrayContributorMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractStateArrayContributorMapping.java @@ -8,7 +8,7 @@ package org.hibernate.metamodel.mapping.internal; import org.hibernate.engine.FetchStyle; import org.hibernate.engine.FetchTiming; -import org.hibernate.metamodel.mapping.AttributeMetadataAccess; +import org.hibernate.metamodel.mapping.AttributeMetadata; import org.hibernate.metamodel.mapping.ManagedMappingType; import org.hibernate.sql.results.graph.FetchOptions; @@ -19,21 +19,20 @@ public abstract class AbstractStateArrayContributorMapping extends AbstractAttributeMapping implements FetchOptions { - private final AttributeMetadataAccess attributeMetadataAccess; + private final AttributeMetadata attributeMetadata; private final FetchTiming fetchTiming; private final FetchStyle fetchStyle; private final int stateArrayPosition; - public AbstractStateArrayContributorMapping( String name, - AttributeMetadataAccess attributeMetadataAccess, + AttributeMetadata attributeMetadata, FetchTiming fetchTiming, FetchStyle fetchStyle, int stateArrayPosition, ManagedMappingType declaringType) { super( name, declaringType ); - this.attributeMetadataAccess = attributeMetadataAccess; + this.attributeMetadata = attributeMetadata; this.fetchTiming = fetchTiming; this.fetchStyle = fetchStyle; this.stateArrayPosition = stateArrayPosition; @@ -41,13 +40,13 @@ public abstract class AbstractStateArrayContributorMapping public AbstractStateArrayContributorMapping( String name, - AttributeMetadataAccess attributeMetadataAccess, + AttributeMetadata attributeMetadata, FetchOptions mappedFetchOptions, int stateArrayPosition, ManagedMappingType declaringType) { this( name, - attributeMetadataAccess, + attributeMetadata, mappedFetchOptions.getTiming(), mappedFetchOptions.getStyle(), stateArrayPosition, @@ -61,8 +60,8 @@ public abstract class AbstractStateArrayContributorMapping } @Override - public AttributeMetadataAccess getAttributeMetadataAccess() { - return attributeMetadataAccess; + public AttributeMetadata getAttributeMetadata() { + return attributeMetadata; } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicAttributeMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicAttributeMapping.java index 2186d2f27d..a0adbc4c5f 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicAttributeMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicAttributeMapping.java @@ -13,7 +13,7 @@ import org.hibernate.engine.FetchTiming; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.mapping.GeneratorCreator; import org.hibernate.mapping.IndexedConsumer; -import org.hibernate.metamodel.mapping.AttributeMetadataAccess; +import org.hibernate.metamodel.mapping.AttributeMetadata; import org.hibernate.metamodel.mapping.BasicValuedModelPart; import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.JdbcMapping; @@ -69,7 +69,7 @@ public class BasicAttributeMapping String attributeName, NavigableRole navigableRole, int stateArrayPosition, - AttributeMetadataAccess attributeMetadataAccess, + AttributeMetadata attributeMetadata, FetchTiming mappedFetchTiming, FetchStyle mappedFetchStyle, String tableExpression, @@ -90,7 +90,7 @@ public class BasicAttributeMapping super( attributeName, stateArrayPosition, - attributeMetadataAccess, + attributeMetadata, mappedFetchTiming, mappedFetchStyle, declaringType, @@ -129,26 +129,26 @@ public class BasicAttributeMapping SelectableMapping selectableMapping) { String attributeName = null; int stateArrayPosition = 0; - AttributeMetadataAccess attributeMetadataAccess; + AttributeMetadata attributeMetadata; if ( original instanceof SingleAttributeIdentifierMapping ) { final SingleAttributeIdentifierMapping mapping = (SingleAttributeIdentifierMapping) original; attributeName = mapping.getAttributeName(); - attributeMetadataAccess = null; + attributeMetadata = null; } else if ( original instanceof SingularAttributeMapping ) { final SingularAttributeMapping mapping = (SingularAttributeMapping) original; attributeName = mapping.getAttributeName(); stateArrayPosition = mapping.getStateArrayPosition(); - attributeMetadataAccess = mapping.getAttributeMetadataAccess(); + attributeMetadata = mapping.getAttributeMetadata(); } else { - attributeMetadataAccess = null; + attributeMetadata = null; } return new BasicAttributeMapping( attributeName, original.getNavigableRole(), stateArrayPosition, - attributeMetadataAccess, + attributeMetadata, FetchTiming.IMMEDIATE, FetchStyle.JOIN, selectableMapping.getContainingTableExpression(), diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/CompoundNaturalIdMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/CompoundNaturalIdMapping.java index ef3a9c1422..77f7bb14b8 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/CompoundNaturalIdMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/CompoundNaturalIdMapping.java @@ -25,7 +25,7 @@ import org.hibernate.loader.ast.spi.MultiNaturalIdLoader; import org.hibernate.loader.ast.spi.NaturalIdLoader; import org.hibernate.mapping.IndexedConsumer; import org.hibernate.metamodel.UnsupportedMappingException; -import org.hibernate.metamodel.mapping.AttributeMetadataAccess; +import org.hibernate.metamodel.mapping.AttributeMetadata; import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.metamodel.mapping.MappingType; @@ -97,9 +97,8 @@ public class CompoundNaturalIdMapping extends AbstractNaturalIdMapping implement MappingModelCreationProcess creationProcess) { for ( int i = 0; i < attributes.size(); i++ ) { final SingularAttributeMapping attributeMapping = attributes.get( i ); - final AttributeMetadataAccess metadataAccess = attributeMapping.getAttributeMetadataAccess(); - - if ( ! metadataAccess.resolveAttributeMetadata( entityDescriptor ).isUpdatable() ) { + final AttributeMetadata metadata = attributeMapping.getAttributeMetadata(); + if ( ! metadata.isUpdatable() ) { return false; } } @@ -209,7 +208,7 @@ public class CompoundNaturalIdMapping extends AbstractNaturalIdMapping implement for ( int i = 0; i < getNaturalIdAttributes().size(); i++ ) { final SingularAttributeMapping attributeMapping = getNaturalIdAttributes().get( i ); - final boolean updatable = attributeMapping.getAttributeMetadataAccess().resolveAttributeMetadata( persister ).isUpdatable(); + final boolean updatable = attributeMapping.getAttributeMetadata().isUpdatable(); if ( updatable ) { // property is updatable (mutable), there is nothing to check continue; diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/DiscriminatedAssociationAttributeMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/DiscriminatedAssociationAttributeMapping.java index 9631dcaa5c..3c29a93afe 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/DiscriminatedAssociationAttributeMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/DiscriminatedAssociationAttributeMapping.java @@ -19,7 +19,7 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.mapping.Any; import org.hibernate.mapping.IndexedConsumer; import org.hibernate.mapping.Property; -import org.hibernate.metamodel.mapping.AttributeMetadataAccess; +import org.hibernate.metamodel.mapping.AttributeMetadata; import org.hibernate.metamodel.mapping.BasicValuedModelPart; import org.hibernate.metamodel.mapping.DiscriminatedAssociationModelPart; import org.hibernate.metamodel.mapping.EntityIdentifierMapping; @@ -72,7 +72,7 @@ public class DiscriminatedAssociationAttributeMapping JavaType baseAssociationJtd, ManagedMappingType declaringType, int stateArrayPosition, - AttributeMetadataAccess attributeMetadataAccess, + AttributeMetadata attributeMetadata, FetchTiming fetchTiming, PropertyAccess propertyAccess, Property bootProperty, @@ -82,7 +82,7 @@ public class DiscriminatedAssociationAttributeMapping super( bootProperty.getName(), stateArrayPosition, - attributeMetadataAccess, + attributeMetadata, fetchTiming, FetchStyle.SELECT, declaringType, diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddableMappingTypeImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddableMappingTypeImpl.java index 32879974bb..6110be08de 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddableMappingTypeImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddableMappingTypeImpl.java @@ -372,7 +372,7 @@ public class EmbeddableMappingTypeImpl extends AbstractEmbeddableMapping impleme mutabilityPlan = ImmutableMutabilityPlan.INSTANCE; } - BasicAttributeMetadataAccess attributeMetadataAccess = new BasicAttributeMetadataAccess( + SimpleAttributeMetadata attributeMetadataAccess = new SimpleAttributeMetadata( propertyAccess, mutabilityPlan, nullable, diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddedAttributeMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddedAttributeMapping.java index b046e85a77..e85dd0f5eb 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddedAttributeMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddedAttributeMapping.java @@ -14,7 +14,7 @@ import org.hibernate.engine.FetchStyle; import org.hibernate.engine.FetchTiming; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.internal.util.collections.CollectionHelper; -import org.hibernate.metamodel.mapping.AttributeMetadataAccess; +import org.hibernate.metamodel.mapping.AttributeMetadata; import org.hibernate.metamodel.mapping.EmbeddableMappingType; import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart; import org.hibernate.metamodel.mapping.EntityMappingType; @@ -72,7 +72,7 @@ public class EmbeddedAttributeMapping NavigableRole navigableRole, int stateArrayPosition, String tableExpression, - AttributeMetadataAccess attributeMetadataAccess, + AttributeMetadata attributeMetadata, String parentInjectionAttributeName, FetchTiming mappedFetchTiming, FetchStyle mappedFetchStyle, @@ -84,7 +84,7 @@ public class EmbeddedAttributeMapping navigableRole, stateArrayPosition, tableExpression, - attributeMetadataAccess, + attributeMetadata, getPropertyAccess( parentInjectionAttributeName, embeddableMappingType ), mappedFetchTiming, mappedFetchStyle, @@ -99,7 +99,7 @@ public class EmbeddedAttributeMapping NavigableRole navigableRole, int stateArrayPosition, String tableExpression, - AttributeMetadataAccess attributeMetadataAccess, + AttributeMetadata attributeMetadata, PropertyAccess parentInjectionAttributePropertyAccess, FetchTiming mappedFetchTiming, FetchStyle mappedFetchStyle, @@ -109,7 +109,7 @@ public class EmbeddedAttributeMapping super( name, stateArrayPosition, - attributeMetadataAccess, + attributeMetadata, mappedFetchTiming, mappedFetchStyle, declaringType, diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/GeneratedValuesProcessor.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/GeneratedValuesProcessor.java index 5ddff0c3ad..926ebecdca 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/GeneratedValuesProcessor.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/GeneratedValuesProcessor.java @@ -153,8 +153,7 @@ public class GeneratedValuesProcessor { final Object generatedValue = descriptor.resolver.resolveGeneratedValue( selectionResults, entity, session, state[i] ); state[ descriptor.attribute.getStateArrayPosition() ] = generatedValue; - descriptor.attribute.getAttributeMetadataAccess() - .resolveAttributeMetadata( entityDescriptor ) + descriptor.attribute.getAttributeMetadata() .getPropertyAccess() .getSetter() .set( entity, generatedValue ); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/IdClassEmbeddable.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/IdClassEmbeddable.java index 5241f381f5..2367a3edaf 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/IdClassEmbeddable.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/IdClassEmbeddable.java @@ -20,7 +20,7 @@ import org.hibernate.mapping.Component; import org.hibernate.mapping.IndexedConsumer; import org.hibernate.mapping.RootClass; import org.hibernate.metamodel.mapping.AttributeMapping; -import org.hibernate.metamodel.mapping.AttributeMetadataAccess; +import org.hibernate.metamodel.mapping.AttributeMetadata; import org.hibernate.metamodel.mapping.EmbeddableMappingType; import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart; import org.hibernate.metamodel.mapping.EntityIdentifierMapping; @@ -54,7 +54,7 @@ import org.hibernate.type.CompositeType; import org.hibernate.type.descriptor.java.JavaType; import org.hibernate.type.spi.CompositeTypeImplementor; -import static org.hibernate.metamodel.mapping.internal.MappingModelCreationHelper.getAttributeMetadataAccess; +import static org.hibernate.metamodel.mapping.internal.MappingModelCreationHelper.getAttributeMetadata; /** * EmbeddableMappingType implementation describing an {@link jakarta.persistence.IdClass} @@ -98,7 +98,7 @@ public class IdClassEmbeddable extends AbstractEmbeddableMapping implements Iden null, EntityIdentifierMapping.ROLE_LOCAL_NAME, true ); - final AttributeMetadataAccess attributeMetadataAccess = getAttributeMetadataAccess( + final AttributeMetadata attributeMetadata = MappingModelCreationHelper.getAttributeMetadata( propertyAccess ); @@ -109,7 +109,7 @@ public class IdClassEmbeddable extends AbstractEmbeddableMapping implements Iden .append( NavigablePath.IDENTIFIER_MAPPER_PROPERTY ), -1, idTable, - attributeMetadataAccess, + attributeMetadata, (PropertyAccess) null, FetchTiming.IMMEDIATE, FetchStyle.JOIN, diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/MappingModelCreationHelper.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/MappingModelCreationHelper.java index eb85e65250..50c3178766 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/MappingModelCreationHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/MappingModelCreationHelper.java @@ -50,7 +50,7 @@ import org.hibernate.mapping.ToOne; import org.hibernate.mapping.Value; import org.hibernate.metamodel.CollectionClassification; import org.hibernate.metamodel.MappingMetamodel; -import org.hibernate.metamodel.mapping.AttributeMetadataAccess; +import org.hibernate.metamodel.mapping.AttributeMetadata; import org.hibernate.metamodel.mapping.BasicValuedModelPart; import org.hibernate.metamodel.mapping.CollectionIdentifierDescriptor; import org.hibernate.metamodel.mapping.CollectionMappingType; @@ -196,7 +196,7 @@ public class MappingModelCreationHelper { MappingModelCreationProcess creationProcess) { final Value value = bootProperty.getValue(); final BasicValue.Resolution resolution = ( (Resolvable) value ).resolve(); - BasicAttributeMetadataAccess attributeMetadataAccess = new BasicAttributeMetadataAccess( propertyAccess, resolution.getMutabilityPlan(), bootProperty, value ); + SimpleAttributeMetadata attributeMetadata = new SimpleAttributeMetadata( propertyAccess, resolution.getMutabilityPlan(), bootProperty, value ); final FetchTiming fetchTiming; final FetchStyle fetchStyle; @@ -220,7 +220,7 @@ public class MappingModelCreationHelper { attrName, navigableRole, stateArrayPosition, - attributeMetadataAccess, + attributeMetadata, fetchTiming, fetchStyle, tableExpression, @@ -253,7 +253,7 @@ public class MappingModelCreationHelper { PropertyAccess propertyAccess, CascadeStyle cascadeStyle, MappingModelCreationProcess creationProcess) { - final AttributeMetadataAccess attributeMetadataAccess = getAttributeMetadataAccess( + final AttributeMetadata attributeMetadataAccess = getAttributeMetadata( bootProperty, attrType, propertyAccess, @@ -308,7 +308,7 @@ public class MappingModelCreationHelper { } @SuppressWarnings("rawtypes") - protected static AttributeMetadataAccess getAttributeMetadataAccess( + protected static AttributeMetadata getAttributeMetadata( Property bootProperty, Type attrType, PropertyAccess propertyAccess, @@ -349,19 +349,19 @@ public class MappingModelCreationHelper { else { mutabilityPlan = ImmutableMutabilityPlan.INSTANCE; } - BasicAttributeMetadataAccess basicAttributeMetadataAccess = new BasicAttributeMetadataAccess( propertyAccess, - mutabilityPlan, - bootProperty.getValue().isNullable(), - bootProperty.isInsertable(), - bootProperty.isUpdateable(), - bootProperty.isOptimisticLocked(), - cascadeStyle ); + SimpleAttributeMetadata basicAttributeMetadataAccess = new SimpleAttributeMetadata( propertyAccess, + mutabilityPlan, + bootProperty.getValue().isNullable(), + bootProperty.isInsertable(), + bootProperty.isUpdateable(), + bootProperty.isOptimisticLocked(), + cascadeStyle ); return basicAttributeMetadataAccess; } @SuppressWarnings("rawtypes") - public static AttributeMetadataAccess getAttributeMetadataAccess(PropertyAccess propertyAccess) { - return new BasicAttributeMetadataAccess(propertyAccess, ImmutableMutabilityPlan.INSTANCE, false, true, false, false, null);// todo (6.0) : not sure if CascadeStyle=null is correct + public static AttributeMetadata getAttributeMetadata(PropertyAccess propertyAccess) { + return new SimpleAttributeMetadata( propertyAccess, ImmutableMutabilityPlan.INSTANCE, false, true, false, false, null);// todo (6.0) : not sure if CascadeStyle=null is correct } @SuppressWarnings("rawtypes") @@ -542,13 +542,14 @@ public class MappingModelCreationHelper { } } - BasicAttributeMetadataAccess attributeMetadata = new BasicAttributeMetadataAccess( propertyAccess, - ImmutableMutabilityPlan.instance(), - bootProperty.isOptional(), - bootProperty.isInsertable(), - bootProperty.isUpdateable(), - bootProperty.isOptimisticLocked(), - cascadeStyle + SimpleAttributeMetadata attributeMetadata = new SimpleAttributeMetadata( + propertyAccess, + ImmutableMutabilityPlan.instance(), + bootProperty.isOptional(), + bootProperty.isInsertable(), + bootProperty.isUpdateable(), + bootProperty.isOptimisticLocked(), + cascadeStyle ); final FetchStyle style = FetchOptionsHelper.determineFetchStyleByMetadata( @@ -1491,7 +1492,7 @@ public class MappingModelCreationHelper { if ( bootProperty.getValue() instanceof ToOne ) { final ToOne value = (ToOne) bootProperty.getValue(); final EntityPersister entityPersister = creationProcess.getEntityPersister( value.getReferencedEntityName() ); - final AttributeMetadataAccess attributeMetadataAccess = getAttributeMetadataAccess( + final AttributeMetadata attributeMetadata = getAttributeMetadata( bootProperty, attrType, propertyAccess, @@ -1536,7 +1537,7 @@ public class MappingModelCreationHelper { navigableRole, stateArrayPosition, (ToOne) bootProperty.getValue(), - attributeMetadataAccess, + attributeMetadata, fetchTiming, fetchStyle, entityPersister, diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/PluralAttributeMappingImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/PluralAttributeMappingImpl.java index a57548bc03..73f7358075 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/PluralAttributeMappingImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/PluralAttributeMappingImpl.java @@ -22,7 +22,7 @@ import org.hibernate.mapping.IndexedConsumer; import org.hibernate.mapping.List; import org.hibernate.mapping.Map; import org.hibernate.mapping.Property; -import org.hibernate.metamodel.mapping.AttributeMetadataAccess; +import org.hibernate.metamodel.mapping.AttributeMetadata; import org.hibernate.metamodel.mapping.CollectionIdentifierDescriptor; import org.hibernate.metamodel.mapping.CollectionMappingType; import org.hibernate.metamodel.mapping.CollectionPart; @@ -89,7 +89,7 @@ public class PluralAttributeMappingImpl private final CollectionMappingType collectionMappingType; private final int stateArrayPosition; private final PropertyAccess propertyAccess; - private final AttributeMetadataAccess attributeMetadataAccess; + private final AttributeMetadata attributeMetadata; private final String referencedPropertyName; private final String mapKeyPropertyName; @@ -117,7 +117,7 @@ public class PluralAttributeMappingImpl String attributeName, Collection bootDescriptor, PropertyAccess propertyAccess, - AttributeMetadataAccess attributeMetadataAccess, + AttributeMetadata attributeMetadata, CollectionMappingType collectionMappingType, int stateArrayPosition, CollectionPart elementDescriptor, @@ -130,7 +130,7 @@ public class PluralAttributeMappingImpl CollectionPersister collectionDescriptor) { super( attributeName, declaringType ); this.propertyAccess = propertyAccess; - this.attributeMetadataAccess = attributeMetadataAccess; + this.attributeMetadata = attributeMetadata; this.collectionMappingType = collectionMappingType; this.stateArrayPosition = stateArrayPosition; this.elementDescriptor = elementDescriptor; @@ -316,8 +316,8 @@ public class PluralAttributeMappingImpl } @Override - public AttributeMetadataAccess getAttributeMetadataAccess() { - return attributeMetadataAccess; + public AttributeMetadata getAttributeMetadata() { + return attributeMetadata; } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicAttributeMetadataAccess.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SimpleAttributeMetadata.java similarity index 85% rename from hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicAttributeMetadataAccess.java rename to hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SimpleAttributeMetadata.java index e6ff70dcad..e18778fc1b 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicAttributeMetadataAccess.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SimpleAttributeMetadata.java @@ -11,12 +11,10 @@ import org.hibernate.engine.spi.CascadeStyles; import org.hibernate.mapping.Property; import org.hibernate.mapping.Value; import org.hibernate.metamodel.mapping.AttributeMetadata; -import org.hibernate.metamodel.mapping.AttributeMetadataAccess; -import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.property.access.spi.PropertyAccess; import org.hibernate.type.descriptor.java.MutabilityPlan; -public final class BasicAttributeMetadataAccess implements AttributeMetadataAccess, AttributeMetadata { +public final class SimpleAttributeMetadata implements AttributeMetadata { private final PropertyAccess propertyAccess; private final MutabilityPlan mutabilityPlan; @@ -26,7 +24,7 @@ public final class BasicAttributeMetadataAccess implements AttributeMetadataAcce private final boolean includeInOptimisticLocking; private final CascadeStyle cascadeStyle; - public BasicAttributeMetadataAccess( + public SimpleAttributeMetadata( PropertyAccess propertyAccess, MutabilityPlan mutabilityPlan, Property bootProperty, @@ -42,7 +40,7 @@ public final class BasicAttributeMetadataAccess implements AttributeMetadataAcce ); } - public BasicAttributeMetadataAccess( + public SimpleAttributeMetadata( PropertyAccess propertyAccess, MutabilityPlan mutabilityPlan, boolean nullable, boolean insertable, boolean updateable, boolean includeInOptimisticLocking) { @@ -57,7 +55,7 @@ public final class BasicAttributeMetadataAccess implements AttributeMetadataAcce ); } - public BasicAttributeMetadataAccess( + public SimpleAttributeMetadata( PropertyAccess propertyAccess, MutabilityPlan mutabilityPlan, boolean nullable, @@ -74,11 +72,6 @@ public final class BasicAttributeMetadataAccess implements AttributeMetadataAcce this.cascadeStyle = cascadeStyle; } - @Override - public AttributeMetadata resolveAttributeMetadata(EntityMappingType entityMappingType) { - return this; - } - @Override public PropertyAccess getPropertyAccess() { return propertyAccess; diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SimpleNaturalIdMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SimpleNaturalIdMapping.java index d40879d4cb..7ce2e8b9c6 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SimpleNaturalIdMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SimpleNaturalIdMapping.java @@ -48,7 +48,7 @@ public class SimpleNaturalIdMapping extends AbstractNaturalIdMapping implements MappingModelCreationProcess creationProcess) { super( declaringType, - attribute.getAttributeMetadataAccess().resolveAttributeMetadata( declaringType ).isUpdatable() + attribute.getAttributeMetadata().isUpdatable() ); this.attribute = attribute; diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/ToOneAttributeMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/ToOneAttributeMapping.java index 55790ee561..54c29242f6 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/ToOneAttributeMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/ToOneAttributeMapping.java @@ -34,7 +34,7 @@ import org.hibernate.mapping.ToOne; import org.hibernate.mapping.Value; import org.hibernate.metamodel.mapping.AssociationKey; import org.hibernate.metamodel.mapping.AttributeMapping; -import org.hibernate.metamodel.mapping.AttributeMetadataAccess; +import org.hibernate.metamodel.mapping.AttributeMetadata; import org.hibernate.metamodel.mapping.CollectionPart; import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart; import org.hibernate.metamodel.mapping.EntityAssociationMapping; @@ -162,7 +162,7 @@ public class ToOneAttributeMapping NavigableRole navigableRole, int stateArrayPosition, ToOne bootValue, - AttributeMetadataAccess attributeMetadataAccess, + AttributeMetadata attributeMetadata, FetchOptions mappedFetchOptions, EntityMappingType entityMappingType, ManagedMappingType declaringType, @@ -173,7 +173,7 @@ public class ToOneAttributeMapping navigableRole, stateArrayPosition, bootValue, - attributeMetadataAccess, + attributeMetadata, mappedFetchOptions.getTiming(), mappedFetchOptions.getStyle(), entityMappingType, @@ -188,7 +188,7 @@ public class ToOneAttributeMapping NavigableRole navigableRole, int stateArrayPosition, ToOne bootValue, - AttributeMetadataAccess attributeMetadataAccess, + AttributeMetadata attributeMetadata, FetchTiming mappedFetchTiming, FetchStyle mappedFetchStyle, EntityMappingType entityMappingType, @@ -198,7 +198,7 @@ public class ToOneAttributeMapping super( name, stateArrayPosition, - attributeMetadataAccess, + attributeMetadata, adjustFetchTiming( mappedFetchTiming, bootValue ), mappedFetchStyle, declaringType, @@ -549,7 +549,7 @@ public class ToOneAttributeMapping super( original.getAttributeName(), original.getStateArrayPosition(), - original.getAttributeMetadataAccess(), + original.getAttributeMetadata(), original, declaringType, original.getPropertyAccess() diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/VirtualEmbeddedAttributeMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/VirtualEmbeddedAttributeMapping.java index 879e73aba4..bb855e0a38 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/VirtualEmbeddedAttributeMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/VirtualEmbeddedAttributeMapping.java @@ -8,7 +8,7 @@ package org.hibernate.metamodel.mapping.internal; import org.hibernate.engine.FetchStyle; import org.hibernate.engine.FetchTiming; -import org.hibernate.metamodel.mapping.AttributeMetadataAccess; +import org.hibernate.metamodel.mapping.AttributeMetadata; import org.hibernate.metamodel.mapping.EmbeddableMappingType; import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart; import org.hibernate.metamodel.mapping.ManagedMappingType; @@ -28,7 +28,7 @@ public class VirtualEmbeddedAttributeMapping extends EmbeddedAttributeMapping im NavigableRole navigableRole, int stateArrayPosition, String tableExpression, - AttributeMetadataAccess attributeMetadataAccess, + AttributeMetadata attributeMetadata, String parentInjectionAttributeName, FetchTiming mappedFetchTiming, FetchStyle mappedFetchStyle, @@ -40,7 +40,7 @@ public class VirtualEmbeddedAttributeMapping extends EmbeddedAttributeMapping im navigableRole, stateArrayPosition, tableExpression, - attributeMetadataAccess, + attributeMetadata, parentInjectionAttributeName, mappedFetchTiming, mappedFetchStyle, @@ -55,7 +55,7 @@ public class VirtualEmbeddedAttributeMapping extends EmbeddedAttributeMapping im NavigableRole navigableRole, int stateArrayPosition, String tableExpression, - AttributeMetadataAccess attributeMetadataAccess, + AttributeMetadata attributeMetadata, PropertyAccess parentInjectionAttributePropertyAccess, FetchTiming mappedFetchTiming, FetchStyle mappedFetchStyle, @@ -67,7 +67,7 @@ public class VirtualEmbeddedAttributeMapping extends EmbeddedAttributeMapping im navigableRole, stateArrayPosition, tableExpression, - attributeMetadataAccess, + attributeMetadata, parentInjectionAttributePropertyAccess, mappedFetchTiming, mappedFetchStyle, diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java index c339a5f5b1..a0acb3db17 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java @@ -78,7 +78,6 @@ import org.hibernate.engine.jdbc.mutation.spi.MutationExecutorService; import org.hibernate.engine.jdbc.spi.JdbcServices; import org.hibernate.engine.spi.CachedNaturalIdValueSource; import org.hibernate.engine.spi.CascadeStyle; -import org.hibernate.engine.spi.CascadeStyles; import org.hibernate.engine.spi.CollectionKey; import org.hibernate.engine.spi.EntityEntry; import org.hibernate.engine.spi.EntityEntryFactory; @@ -154,7 +153,6 @@ import org.hibernate.metamodel.RepresentationMode; import org.hibernate.metamodel.mapping.Association; import org.hibernate.metamodel.mapping.AttributeMapping; import org.hibernate.metamodel.mapping.AttributeMetadata; -import org.hibernate.metamodel.mapping.AttributeMetadataAccess; import org.hibernate.metamodel.mapping.BasicValuedModelPart; import org.hibernate.metamodel.mapping.DiscriminatedAssociationModelPart; import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart; @@ -175,7 +173,7 @@ import org.hibernate.metamodel.mapping.SelectableConsumer; import org.hibernate.metamodel.mapping.SelectableMapping; import org.hibernate.metamodel.mapping.SingularAttributeMapping; import org.hibernate.metamodel.mapping.VirtualModelPart; -import org.hibernate.metamodel.mapping.internal.BasicAttributeMetadataAccess; +import org.hibernate.metamodel.mapping.internal.SimpleAttributeMetadata; import org.hibernate.metamodel.mapping.internal.BasicEntityIdentifierMappingImpl; import org.hibernate.metamodel.mapping.internal.CompoundNaturalIdMapping; import org.hibernate.metamodel.mapping.internal.DiscriminatedAssociationAttributeMapping; @@ -4253,11 +4251,10 @@ public abstract class AbstractEntityPersister final Object[] values = new Object[ getNumberOfAttributeMappings() ]; for ( int i = 0; i < attributeMappings.size(); i++ ) { final AttributeMapping attributeMapping = attributeMappings.get( i ); - final AttributeMetadataAccess attributeMetadataAccess = attributeMapping.getAttributeMetadataAccess(); + final AttributeMetadata attributeMetadata = attributeMapping.getAttributeMetadata(); if ( ! lazyAttributesMetadata.isLazyAttribute( attributeMapping.getAttributeName() ) || enhancementMetadata.isAttributeLoaded( object, attributeMapping.getAttributeName() ) ) { - values[i] = attributeMetadataAccess - .resolveAttributeMetadata( this ) + values[i] = attributeMetadata .getPropertyAccess() .getGetter() .get( object ); @@ -4273,8 +4270,7 @@ public abstract class AbstractEntityPersister @Override public Object getPropertyValue(Object object, int i) { - return attributeMappings.get( i ).getAttributeMetadataAccess() - .resolveAttributeMetadata( this ) + return attributeMappings.get( i ).getAttributeMetadata() .getPropertyAccess() .getGetter() .get( object ); @@ -4290,8 +4286,7 @@ public abstract class AbstractEntityPersister ManagedMappingType baseValueType = null; Object baseValue = null; if ( attributeMapping != null ) { - baseValue = attributeMapping.getAttributeMetadataAccess() - .resolveAttributeMetadata( this ) + baseValue = attributeMapping.getAttributeMetadata() .getPropertyAccess() .getGetter() .get( object ); @@ -4305,8 +4300,7 @@ public abstract class AbstractEntityPersister ? null : embeddedAttributeMapping.getMappedType().findAttributeMapping( basePropertyName ); if ( mapping != null ) { - baseValue = mapping.getAttributeMetadataAccess() - .resolveAttributeMetadata( this ) + baseValue = mapping.getAttributeMetadata() .getPropertyAccess() .getGetter() .get( object ); @@ -4332,8 +4326,7 @@ public abstract class AbstractEntityPersister attributeMapping = baseValueType.findAttributeMapping( propertyName.substring( dotIndex + 1, endIndex ) ); - baseValue = attributeMapping.getAttributeMetadataAccess() - .resolveAttributeMetadata( this ) + baseValue = attributeMapping.getAttributeMetadata() .getPropertyAccess() .getGetter() .get( baseValue ); @@ -4613,7 +4606,7 @@ public abstract class AbstractEntityPersister @Override public void setPropertyValue(Object object, String propertyName, Object value) { final AttributeMapping attributeMapping = findSubPart( propertyName, this ).asAttributeMapping(); - final AttributeMetadata attributeMetadata = attributeMapping.getAttributeMetadataAccess().resolveAttributeMetadata( this ); + final AttributeMetadata attributeMetadata = attributeMapping.getAttributeMetadata(); attributeMetadata.getPropertyAccess().getSetter().set( object, value ); } @@ -5502,7 +5495,7 @@ public abstract class AbstractEntityPersister final AnyType anyType = (AnyType) attrType; final MutabilityPlan mutabilityPlan = new DiscriminatedAssociationAttributeMapping.MutabilityPlanImpl( anyType ); - final BasicAttributeMetadataAccess attributeMetadataAccess = new BasicAttributeMetadataAccess( + final SimpleAttributeMetadata attributeMetadataAccess = new SimpleAttributeMetadata( propertyAccess, mutabilityPlan, bootProperty.isOptional(), diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/UpdateCoordinatorStandard.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/UpdateCoordinatorStandard.java index b718491036..1d21affba7 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/UpdateCoordinatorStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/UpdateCoordinatorStandard.java @@ -242,8 +242,7 @@ public class UpdateCoordinatorStandard extends AbstractMutationCoordinator imple // && updateableAttributeIndexes[position]; } - final boolean includeInLocking = attribute.getAttributeMetadataAccess() - .resolveAttributeMetadata( null ) + final boolean includeInLocking = attribute.getAttributeMetadata() .isIncludedInOptimisticLocking(); if ( !includeInLocking ) { return false; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/AbstractEntityInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/AbstractEntityInitializer.java index 55a7bd9775..fb052a0232 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/AbstractEntityInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/AbstractEntityInitializer.java @@ -211,8 +211,7 @@ public abstract class AbstractEntityInitializer extends AbstractFetchParentAcces final int numberOfAttributeMappings = containerDescriptor.getNumberOfAttributeMappings(); for ( int i = 0; i < numberOfAttributeMappings; i++ ) { final AttributeMapping attributeMapping = containerDescriptor.getAttributeMapping( i ); - final AttributeMetadata attributeMetadata = attributeMapping.getAttributeMetadataAccess() - .resolveAttributeMetadata( concreteDescriptor ); + final AttributeMetadata attributeMetadata = attributeMapping.getAttributeMetadata(); if ( attributeMetadata.isUpdatable() ) { final int position = attributeMapping.getStateArrayPosition(); Object result; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/naturalid/cid/AbstractCompositeIdAndNaturalIdTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/naturalid/cid/AbstractCompositeIdAndNaturalIdTest.java index 22d946026c..c56e141453 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/naturalid/cid/AbstractCompositeIdAndNaturalIdTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/naturalid/cid/AbstractCompositeIdAndNaturalIdTest.java @@ -31,7 +31,7 @@ public abstract class AbstractCompositeIdAndNaturalIdTest { public void testNaturalIdNullability(SessionFactoryScope scope) { final EntityMappingType accountMapping = scope.getSessionFactory().getRuntimeMetamodels().getEntityMappingType( Account.class ); final SingularAttributeMapping shortCodeMapping = ((SimpleNaturalIdMapping) accountMapping.getNaturalIdMapping()).getAttribute(); - final AttributeMetadata shortCodeMetadata = shortCodeMapping.getAttributeMetadataAccess().resolveAttributeMetadata( null ); + final AttributeMetadata shortCodeMetadata = shortCodeMapping.getAttributeMetadata(); assertThat( shortCodeMetadata.isNullable(), is( false ) ); final EntityPersister rootEntityPersister = accountMapping.getRootEntityDescriptor().getEntityPersister(); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/naturalid/immutable/ImmutableManyToOneNaturalIdAnnotationTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/naturalid/immutable/ImmutableManyToOneNaturalIdAnnotationTest.java index 14f8d8e3de..21e4bea339 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/naturalid/immutable/ImmutableManyToOneNaturalIdAnnotationTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/naturalid/immutable/ImmutableManyToOneNaturalIdAnnotationTest.java @@ -62,12 +62,12 @@ public class ImmutableManyToOneNaturalIdAnnotationTest { // access by list-index should again be alphabetically sorted final SingularAttributeMapping first = naturalIdMapping.getNaturalIdAttributes().get( 0 ); assertThat( first.getAttributeName(), is( "name" ) ); - final AttributeMetadata firstMetadata = first.getAttributeMetadataAccess().resolveAttributeMetadata( null ); + final AttributeMetadata firstMetadata = first.getAttributeMetadata(); assertFalse( firstMetadata.getMutabilityPlan().isMutable() ); final SingularAttributeMapping second = naturalIdMapping.getNaturalIdAttributes().get( 1 ); assertThat( second.getAttributeName(), is( "parent" ) ); - final AttributeMetadata secondMetadata = second.getAttributeMetadataAccess().resolveAttributeMetadata( null ); + final AttributeMetadata secondMetadata = second.getAttributeMetadata(); assertFalse( secondMetadata.getMutabilityPlan().isMutable() ); } } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/naturalid/immutable/ImmutableManyToOneNaturalIdHbmTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/naturalid/immutable/ImmutableManyToOneNaturalIdHbmTest.java index 243ab008b2..86cc3f4475 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/naturalid/immutable/ImmutableManyToOneNaturalIdHbmTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/naturalid/immutable/ImmutableManyToOneNaturalIdHbmTest.java @@ -100,12 +100,12 @@ public class ImmutableManyToOneNaturalIdHbmTest { final SingularAttributeMapping first = naturalIdMapping.getNaturalIdAttributes().get( 0 ); assertThat( first.getAttributeName(), is( "name" ) ); - final AttributeMetadata firstMetadata = first.getAttributeMetadataAccess().resolveAttributeMetadata( null ); + final AttributeMetadata firstMetadata = first.getAttributeMetadata(); assertFalse( firstMetadata.getMutabilityPlan().isMutable() ); final SingularAttributeMapping second = naturalIdMapping.getNaturalIdAttributes().get( 1 ); assertThat( second.getAttributeName(), is( "parent" ) ); - final AttributeMetadata secondMetadata = second.getAttributeMetadataAccess().resolveAttributeMetadata( null ); + final AttributeMetadata secondMetadata = second.getAttributeMetadata(); assertFalse( secondMetadata.getMutabilityPlan().isMutable() ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/naturalid/immutable/ImmutableNaturalIdTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/naturalid/immutable/ImmutableNaturalIdTest.java index 2d9f35be1b..6ec6756cdd 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/naturalid/immutable/ImmutableNaturalIdTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/naturalid/immutable/ImmutableNaturalIdTest.java @@ -56,7 +56,7 @@ public class ImmutableNaturalIdTest { final EntityMappingType entityMappingType = sessionFactory.getRuntimeMetamodels().getEntityMappingType( User.class ); final AttributeMapping userNameMapping = entityMappingType.findAttributeMapping( "userName" ); - assertFalse( userNameMapping.getAttributeMetadataAccess().resolveAttributeMetadata( null ).isNullable() ); + assertFalse( userNameMapping.getAttributeMetadata().isNullable() ); final EntityPersister persister = entityMappingType.getEntityPersister(); final int propertyIndex = persister.getEntityMetamodel().getPropertyIndex( "userName" ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/naturalid/immutableentity/ImmutableEntityNaturalIdTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/naturalid/immutableentity/ImmutableEntityNaturalIdTest.java index bf58b33f79..ad50aab68b 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/naturalid/immutableentity/ImmutableEntityNaturalIdTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/naturalid/immutableentity/ImmutableEntityNaturalIdTest.java @@ -95,7 +95,7 @@ public class ImmutableEntityNaturalIdTest { assertThat( naturalIdMapping.getNaturalIdAttributes().size(), is( 3 ) ); // nullability is not specified, so they should be nullable by annotations-specific default for ( SingularAttributeMapping attribute : naturalIdMapping.getNaturalIdAttributes() ) { - assertThat( attribute.getAttributeMetadataAccess().resolveAttributeMetadata( null ).isNullable(), is( true ) ); + assertThat( attribute.getAttributeMetadata().isNullable(), is( true ) ); } final EntityPersister entityPersister = buildingMapping.getEntityPersister(); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/naturalid/inheritance/InheritedNaturalIdTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/naturalid/inheritance/InheritedNaturalIdTest.java index 8e9a561420..b2d4bbb0e4 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/naturalid/inheritance/InheritedNaturalIdTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/naturalid/inheritance/InheritedNaturalIdTest.java @@ -46,7 +46,7 @@ public class InheritedNaturalIdTest { final SingularAttributeMapping uidMapping = ((SimpleNaturalIdMapping) userMapping.getNaturalIdMapping()).getAttribute(); assertThat( uidMapping.getAttributeName(), is ("uid" ) ); - final AttributeMetadata uidMetadata = uidMapping.getAttributeMetadataAccess().resolveAttributeMetadata( null ); + final AttributeMetadata uidMetadata = uidMapping.getAttributeMetadata(); assertThat( uidMetadata.isNullable(), is( true ) ); final EntityPersister rootEntityPersister = userMapping.getEntityPersister(); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/naturalid/nullable/NullableNaturalIdTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/naturalid/nullable/NullableNaturalIdTest.java index befb36003d..4a07ebd88b 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/naturalid/nullable/NullableNaturalIdTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/naturalid/nullable/NullableNaturalIdTest.java @@ -77,12 +77,12 @@ public class NullableNaturalIdTest { final SingularAttributeMapping firstAttribute = naturalIdMapping.getNaturalIdAttributes().get(0); assertThat( firstAttribute.getAttributeName(), is( "assA" ) ); assertThat( firstAttribute.getStateArrayPosition(), is( entityMetamodel.getPropertyIndex( "assA" ) ) ); - assertTrue( firstAttribute.getAttributeMetadataAccess().resolveAttributeMetadata( null ).isNullable() ); + assertTrue( firstAttribute.getAttributeMetadata().isNullable() ); final SingularAttributeMapping secondAttribute = naturalIdMapping.getNaturalIdAttributes().get(1); assertThat( secondAttribute.getAttributeName(), is( "naturalid" ) ); assertThat( secondAttribute.getStateArrayPosition(), is( entityMetamodel.getPropertyIndex( "naturalid" ) ) ); - assertFalse( secondAttribute.getAttributeMetadataAccess().resolveAttributeMetadata( null ).isNullable() ); + assertFalse( secondAttribute.getAttributeMetadata().isNullable() ); } { @@ -96,7 +96,7 @@ public class NullableNaturalIdTest { final SingularAttributeMapping attribute = naturalIdMapping.getNaturalIdAttributes().get(0); assertThat( attribute.getStateArrayPosition(), is( entityMetamodel.getPropertyIndex( "name" ) ) ); - assertTrue( attribute.getAttributeMetadataAccess().resolveAttributeMetadata( null ).isNullable() ); + assertTrue( attribute.getAttributeMetadata().isNullable() ); } { @@ -112,12 +112,12 @@ public class NullableNaturalIdTest { final SingularAttributeMapping firstAttribute = naturalIdMapping.getNaturalIdAttributes().get(0); assertThat( firstAttribute.getAttributeName(), is( "associatedC" ) ); assertThat( firstAttribute.getStateArrayPosition(), is( entityMetamodel.getPropertyIndex( "associatedC" ) ) ); - assertTrue( firstAttribute.getAttributeMetadataAccess().resolveAttributeMetadata( null ).isNullable() ); + assertTrue( firstAttribute.getAttributeMetadata().isNullable() ); final SingularAttributeMapping secondAttribute = naturalIdMapping.getNaturalIdAttributes().get(1); assertThat( secondAttribute.getAttributeName(), is( "name" ) ); assertThat( secondAttribute.getStateArrayPosition(), is( entityMetamodel.getPropertyIndex( "name" ) ) ); - assertTrue( secondAttribute.getAttributeMetadataAccess().resolveAttributeMetadata( null ).isNullable() ); + assertTrue( secondAttribute.getAttributeMetadata().isNullable() ); } { @@ -136,17 +136,17 @@ public class NullableNaturalIdTest { final SingularAttributeMapping firstAttribute = naturalIdMapping.getNaturalIdAttributes().get(0); assertThat( firstAttribute.getAttributeName(), is( "intVal" ) ); assertThat( firstAttribute.getStateArrayPosition(), is( entityMetamodel.getPropertyIndex( "intVal" ) ) ); - assertTrue( firstAttribute.getAttributeMetadataAccess().resolveAttributeMetadata( null ).isNullable() ); + assertTrue( firstAttribute.getAttributeMetadata().isNullable() ); final SingularAttributeMapping secondAttribute = naturalIdMapping.getNaturalIdAttributes().get(1); assertThat( secondAttribute.getAttributeName(), is( "name" ) ); assertThat( secondAttribute.getStateArrayPosition(), is( entityMetamodel.getPropertyIndex( "name" ) ) ); - assertTrue( secondAttribute.getAttributeMetadataAccess().resolveAttributeMetadata( null ).isNullable() ); + assertTrue( secondAttribute.getAttributeMetadata().isNullable() ); final SingularAttributeMapping thirdAttribute = naturalIdMapping.getNaturalIdAttributes().get(2); assertThat( thirdAttribute.getAttributeName(), is( "org" ) ); assertThat( thirdAttribute.getStateArrayPosition(), is( entityMetamodel.getPropertyIndex( "org" ) ) ); - assertTrue( thirdAttribute.getAttributeMetadataAccess().resolveAttributeMetadata( null ).isNullable() ); + assertTrue( thirdAttribute.getAttributeMetadata().isNullable() ); } }