HHH-15853 Remove the AttributeMetadataAccess interface

This commit is contained in:
Sanne Grinovero 2022-12-08 17:14:28 +00:00 committed by Sanne Grinovero
parent d2d40c7318
commit a5525a943f
29 changed files with 124 additions and 164 deletions

View File

@ -756,8 +756,7 @@ public class LoaderSelectBuilder {
} }
} }
else if ( loadQueryInfluencers.getEnabledCascadingFetchProfile() != null ) { else if ( loadQueryInfluencers.getEnabledCascadingFetchProfile() != null ) {
final CascadeStyle cascadeStyle = fetchable.asAttributeMapping().getAttributeMetadataAccess() final CascadeStyle cascadeStyle = fetchable.asAttributeMapping().getAttributeMetadata()
.resolveAttributeMetadata( fetchable.findContainingEntityMapping() )
.getCascadeStyle(); .getCascadeStyle();
final CascadingAction cascadingAction = loadQueryInfluencers.getEnabledCascadingFetchProfile() final CascadingAction cascadingAction = loadQueryInfluencers.getEnabledCascadingFetchProfile()
.getCascadingAction(); .getCascadingAction();

View File

@ -39,7 +39,7 @@ public interface AttributeMapping
/** /**
* Access to AttributeMetadata * Access to AttributeMetadata
*/ */
AttributeMetadataAccess getAttributeMetadataAccess(); AttributeMetadata getAttributeMetadata();
/** /**
* The managed type that declares this attribute * The managed type that declares this attribute
@ -79,7 +79,7 @@ public interface AttributeMapping
@Override @Override
default MutabilityPlan<?> getExposedMutabilityPlan() { default MutabilityPlan<?> getExposedMutabilityPlan() {
return getAttributeMetadataAccess().resolveAttributeMetadata( null ).getMutabilityPlan(); return getAttributeMetadata().getMutabilityPlan();
} }
default int compare(Object value1, Object value2) { default int compare(Object value1, Object value2) {

View File

@ -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);
}

View File

@ -7,7 +7,6 @@
package org.hibernate.metamodel.mapping.internal; package org.hibernate.metamodel.mapping.internal;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -86,8 +85,7 @@ public abstract class AbstractEmbeddableMapping implements EmbeddableMappingType
final Object[] results = new Object[getNumberOfAttributeMappings()]; final Object[] results = new Object[getNumberOfAttributeMappings()];
forEachAttributeMapping( (position, attribute) -> { forEachAttributeMapping( (position, attribute) -> {
final Getter getter = attribute.getAttributeMetadataAccess() final Getter getter = attribute.getAttributeMetadata()
.resolveAttributeMetadata( findContainingEntityMapping() )
.getPropertyAccess() .getPropertyAccess()
.getGetter(); .getGetter();
results[position] = getter.get( compositeInstance ); results[position] = getter.get( compositeInstance );
@ -362,13 +360,14 @@ public abstract class AbstractEmbeddableMapping implements EmbeddableMappingType
mutabilityPlan = ImmutableMutabilityPlan.INSTANCE; mutabilityPlan = ImmutableMutabilityPlan.INSTANCE;
} }
BasicAttributeMetadataAccess attributeMetadataAccess = new BasicAttributeMetadataAccess( propertyAccess, SimpleAttributeMetadata attributeMetadataAccess = new SimpleAttributeMetadata(
mutabilityPlan, propertyAccess,
nullable, mutabilityPlan,
insertable, nullable,
updateable, insertable,
includeInOptimisticLocking, updateable,
cascadeStyle includeInOptimisticLocking,
cascadeStyle
); );
attributeMapping = new DiscriminatedAssociationAttributeMapping( attributeMapping = new DiscriminatedAssociationAttributeMapping(

View File

@ -8,7 +8,7 @@ package org.hibernate.metamodel.mapping.internal;
import org.hibernate.engine.FetchStyle; import org.hibernate.engine.FetchStyle;
import org.hibernate.engine.FetchTiming; 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.ManagedMappingType;
import org.hibernate.metamodel.mapping.SingularAttributeMapping; import org.hibernate.metamodel.mapping.SingularAttributeMapping;
import org.hibernate.property.access.spi.PropertyAccess; import org.hibernate.property.access.spi.PropertyAccess;
@ -27,23 +27,23 @@ public abstract class AbstractSingularAttributeMapping
public AbstractSingularAttributeMapping( public AbstractSingularAttributeMapping(
String name, String name,
int stateArrayPosition, int stateArrayPosition,
AttributeMetadataAccess attributeMetadataAccess, AttributeMetadata attributeMetadata,
FetchOptions mappedFetchOptions, FetchOptions mappedFetchOptions,
ManagedMappingType declaringType, ManagedMappingType declaringType,
PropertyAccess propertyAccess) { PropertyAccess propertyAccess) {
super( name, attributeMetadataAccess, mappedFetchOptions, stateArrayPosition, declaringType ); super( name, attributeMetadata, mappedFetchOptions, stateArrayPosition, declaringType );
this.propertyAccess = propertyAccess; this.propertyAccess = propertyAccess;
} }
public AbstractSingularAttributeMapping( public AbstractSingularAttributeMapping(
String name, String name,
int stateArrayPosition, int stateArrayPosition,
AttributeMetadataAccess attributeMetadataAccess, AttributeMetadata attributeMetadata,
FetchTiming fetchTiming, FetchTiming fetchTiming,
FetchStyle fetchStyle, FetchStyle fetchStyle,
ManagedMappingType declaringType, ManagedMappingType declaringType,
PropertyAccess propertyAccess) { PropertyAccess propertyAccess) {
super( name, attributeMetadataAccess, fetchTiming, fetchStyle, stateArrayPosition, declaringType ); super( name, attributeMetadata, fetchTiming, fetchStyle, stateArrayPosition, declaringType );
this.propertyAccess = propertyAccess; this.propertyAccess = propertyAccess;
} }

View File

@ -8,7 +8,7 @@ package org.hibernate.metamodel.mapping.internal;
import org.hibernate.engine.FetchStyle; import org.hibernate.engine.FetchStyle;
import org.hibernate.engine.FetchTiming; 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.ManagedMappingType;
import org.hibernate.sql.results.graph.FetchOptions; import org.hibernate.sql.results.graph.FetchOptions;
@ -19,21 +19,20 @@ public abstract class AbstractStateArrayContributorMapping
extends AbstractAttributeMapping extends AbstractAttributeMapping
implements FetchOptions { implements FetchOptions {
private final AttributeMetadataAccess attributeMetadataAccess; private final AttributeMetadata attributeMetadata;
private final FetchTiming fetchTiming; private final FetchTiming fetchTiming;
private final FetchStyle fetchStyle; private final FetchStyle fetchStyle;
private final int stateArrayPosition; private final int stateArrayPosition;
public AbstractStateArrayContributorMapping( public AbstractStateArrayContributorMapping(
String name, String name,
AttributeMetadataAccess attributeMetadataAccess, AttributeMetadata attributeMetadata,
FetchTiming fetchTiming, FetchTiming fetchTiming,
FetchStyle fetchStyle, FetchStyle fetchStyle,
int stateArrayPosition, int stateArrayPosition,
ManagedMappingType declaringType) { ManagedMappingType declaringType) {
super( name, declaringType ); super( name, declaringType );
this.attributeMetadataAccess = attributeMetadataAccess; this.attributeMetadata = attributeMetadata;
this.fetchTiming = fetchTiming; this.fetchTiming = fetchTiming;
this.fetchStyle = fetchStyle; this.fetchStyle = fetchStyle;
this.stateArrayPosition = stateArrayPosition; this.stateArrayPosition = stateArrayPosition;
@ -41,13 +40,13 @@ public abstract class AbstractStateArrayContributorMapping
public AbstractStateArrayContributorMapping( public AbstractStateArrayContributorMapping(
String name, String name,
AttributeMetadataAccess attributeMetadataAccess, AttributeMetadata attributeMetadata,
FetchOptions mappedFetchOptions, FetchOptions mappedFetchOptions,
int stateArrayPosition, int stateArrayPosition,
ManagedMappingType declaringType) { ManagedMappingType declaringType) {
this( this(
name, name,
attributeMetadataAccess, attributeMetadata,
mappedFetchOptions.getTiming(), mappedFetchOptions.getTiming(),
mappedFetchOptions.getStyle(), mappedFetchOptions.getStyle(),
stateArrayPosition, stateArrayPosition,
@ -61,8 +60,8 @@ public abstract class AbstractStateArrayContributorMapping
} }
@Override @Override
public AttributeMetadataAccess getAttributeMetadataAccess() { public AttributeMetadata getAttributeMetadata() {
return attributeMetadataAccess; return attributeMetadata;
} }
@Override @Override

View File

@ -13,7 +13,7 @@ import org.hibernate.engine.FetchTiming;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.mapping.GeneratorCreator; import org.hibernate.mapping.GeneratorCreator;
import org.hibernate.mapping.IndexedConsumer; 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.BasicValuedModelPart;
import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.metamodel.mapping.JdbcMapping;
@ -69,7 +69,7 @@ public class BasicAttributeMapping
String attributeName, String attributeName,
NavigableRole navigableRole, NavigableRole navigableRole,
int stateArrayPosition, int stateArrayPosition,
AttributeMetadataAccess attributeMetadataAccess, AttributeMetadata attributeMetadata,
FetchTiming mappedFetchTiming, FetchTiming mappedFetchTiming,
FetchStyle mappedFetchStyle, FetchStyle mappedFetchStyle,
String tableExpression, String tableExpression,
@ -90,7 +90,7 @@ public class BasicAttributeMapping
super( super(
attributeName, attributeName,
stateArrayPosition, stateArrayPosition,
attributeMetadataAccess, attributeMetadata,
mappedFetchTiming, mappedFetchTiming,
mappedFetchStyle, mappedFetchStyle,
declaringType, declaringType,
@ -129,26 +129,26 @@ public class BasicAttributeMapping
SelectableMapping selectableMapping) { SelectableMapping selectableMapping) {
String attributeName = null; String attributeName = null;
int stateArrayPosition = 0; int stateArrayPosition = 0;
AttributeMetadataAccess attributeMetadataAccess; AttributeMetadata attributeMetadata;
if ( original instanceof SingleAttributeIdentifierMapping ) { if ( original instanceof SingleAttributeIdentifierMapping ) {
final SingleAttributeIdentifierMapping mapping = (SingleAttributeIdentifierMapping) original; final SingleAttributeIdentifierMapping mapping = (SingleAttributeIdentifierMapping) original;
attributeName = mapping.getAttributeName(); attributeName = mapping.getAttributeName();
attributeMetadataAccess = null; attributeMetadata = null;
} }
else if ( original instanceof SingularAttributeMapping ) { else if ( original instanceof SingularAttributeMapping ) {
final SingularAttributeMapping mapping = (SingularAttributeMapping) original; final SingularAttributeMapping mapping = (SingularAttributeMapping) original;
attributeName = mapping.getAttributeName(); attributeName = mapping.getAttributeName();
stateArrayPosition = mapping.getStateArrayPosition(); stateArrayPosition = mapping.getStateArrayPosition();
attributeMetadataAccess = mapping.getAttributeMetadataAccess(); attributeMetadata = mapping.getAttributeMetadata();
} }
else { else {
attributeMetadataAccess = null; attributeMetadata = null;
} }
return new BasicAttributeMapping( return new BasicAttributeMapping(
attributeName, attributeName,
original.getNavigableRole(), original.getNavigableRole(),
stateArrayPosition, stateArrayPosition,
attributeMetadataAccess, attributeMetadata,
FetchTiming.IMMEDIATE, FetchTiming.IMMEDIATE,
FetchStyle.JOIN, FetchStyle.JOIN,
selectableMapping.getContainingTableExpression(), selectableMapping.getContainingTableExpression(),

View File

@ -25,7 +25,7 @@ import org.hibernate.loader.ast.spi.MultiNaturalIdLoader;
import org.hibernate.loader.ast.spi.NaturalIdLoader; import org.hibernate.loader.ast.spi.NaturalIdLoader;
import org.hibernate.mapping.IndexedConsumer; import org.hibernate.mapping.IndexedConsumer;
import org.hibernate.metamodel.UnsupportedMappingException; 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.EntityMappingType;
import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.MappingType; import org.hibernate.metamodel.mapping.MappingType;
@ -97,9 +97,8 @@ public class CompoundNaturalIdMapping extends AbstractNaturalIdMapping implement
MappingModelCreationProcess creationProcess) { MappingModelCreationProcess creationProcess) {
for ( int i = 0; i < attributes.size(); i++ ) { for ( int i = 0; i < attributes.size(); i++ ) {
final SingularAttributeMapping attributeMapping = attributes.get( i ); final SingularAttributeMapping attributeMapping = attributes.get( i );
final AttributeMetadataAccess metadataAccess = attributeMapping.getAttributeMetadataAccess(); final AttributeMetadata metadata = attributeMapping.getAttributeMetadata();
if ( ! metadata.isUpdatable() ) {
if ( ! metadataAccess.resolveAttributeMetadata( entityDescriptor ).isUpdatable() ) {
return false; return false;
} }
} }
@ -209,7 +208,7 @@ public class CompoundNaturalIdMapping extends AbstractNaturalIdMapping implement
for ( int i = 0; i < getNaturalIdAttributes().size(); i++ ) { for ( int i = 0; i < getNaturalIdAttributes().size(); i++ ) {
final SingularAttributeMapping attributeMapping = getNaturalIdAttributes().get( i ); final SingularAttributeMapping attributeMapping = getNaturalIdAttributes().get( i );
final boolean updatable = attributeMapping.getAttributeMetadataAccess().resolveAttributeMetadata( persister ).isUpdatable(); final boolean updatable = attributeMapping.getAttributeMetadata().isUpdatable();
if ( updatable ) { if ( updatable ) {
// property is updatable (mutable), there is nothing to check // property is updatable (mutable), there is nothing to check
continue; continue;

View File

@ -19,7 +19,7 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.mapping.Any; import org.hibernate.mapping.Any;
import org.hibernate.mapping.IndexedConsumer; import org.hibernate.mapping.IndexedConsumer;
import org.hibernate.mapping.Property; 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.BasicValuedModelPart;
import org.hibernate.metamodel.mapping.DiscriminatedAssociationModelPart; import org.hibernate.metamodel.mapping.DiscriminatedAssociationModelPart;
import org.hibernate.metamodel.mapping.EntityIdentifierMapping; import org.hibernate.metamodel.mapping.EntityIdentifierMapping;
@ -72,7 +72,7 @@ public class DiscriminatedAssociationAttributeMapping
JavaType<?> baseAssociationJtd, JavaType<?> baseAssociationJtd,
ManagedMappingType declaringType, ManagedMappingType declaringType,
int stateArrayPosition, int stateArrayPosition,
AttributeMetadataAccess attributeMetadataAccess, AttributeMetadata attributeMetadata,
FetchTiming fetchTiming, FetchTiming fetchTiming,
PropertyAccess propertyAccess, PropertyAccess propertyAccess,
Property bootProperty, Property bootProperty,
@ -82,7 +82,7 @@ public class DiscriminatedAssociationAttributeMapping
super( super(
bootProperty.getName(), bootProperty.getName(),
stateArrayPosition, stateArrayPosition,
attributeMetadataAccess, attributeMetadata,
fetchTiming, fetchTiming,
FetchStyle.SELECT, FetchStyle.SELECT,
declaringType, declaringType,

View File

@ -372,7 +372,7 @@ public class EmbeddableMappingTypeImpl extends AbstractEmbeddableMapping impleme
mutabilityPlan = ImmutableMutabilityPlan.INSTANCE; mutabilityPlan = ImmutableMutabilityPlan.INSTANCE;
} }
BasicAttributeMetadataAccess attributeMetadataAccess = new BasicAttributeMetadataAccess( SimpleAttributeMetadata attributeMetadataAccess = new SimpleAttributeMetadata(
propertyAccess, propertyAccess,
mutabilityPlan, mutabilityPlan,
nullable, nullable,

View File

@ -14,7 +14,7 @@ import org.hibernate.engine.FetchStyle;
import org.hibernate.engine.FetchTiming; import org.hibernate.engine.FetchTiming;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.internal.util.collections.CollectionHelper; 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.EmbeddableMappingType;
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart; import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.EntityMappingType;
@ -72,7 +72,7 @@ public class EmbeddedAttributeMapping
NavigableRole navigableRole, NavigableRole navigableRole,
int stateArrayPosition, int stateArrayPosition,
String tableExpression, String tableExpression,
AttributeMetadataAccess attributeMetadataAccess, AttributeMetadata attributeMetadata,
String parentInjectionAttributeName, String parentInjectionAttributeName,
FetchTiming mappedFetchTiming, FetchTiming mappedFetchTiming,
FetchStyle mappedFetchStyle, FetchStyle mappedFetchStyle,
@ -84,7 +84,7 @@ public class EmbeddedAttributeMapping
navigableRole, navigableRole,
stateArrayPosition, stateArrayPosition,
tableExpression, tableExpression,
attributeMetadataAccess, attributeMetadata,
getPropertyAccess( parentInjectionAttributeName, embeddableMappingType ), getPropertyAccess( parentInjectionAttributeName, embeddableMappingType ),
mappedFetchTiming, mappedFetchTiming,
mappedFetchStyle, mappedFetchStyle,
@ -99,7 +99,7 @@ public class EmbeddedAttributeMapping
NavigableRole navigableRole, NavigableRole navigableRole,
int stateArrayPosition, int stateArrayPosition,
String tableExpression, String tableExpression,
AttributeMetadataAccess attributeMetadataAccess, AttributeMetadata attributeMetadata,
PropertyAccess parentInjectionAttributePropertyAccess, PropertyAccess parentInjectionAttributePropertyAccess,
FetchTiming mappedFetchTiming, FetchTiming mappedFetchTiming,
FetchStyle mappedFetchStyle, FetchStyle mappedFetchStyle,
@ -109,7 +109,7 @@ public class EmbeddedAttributeMapping
super( super(
name, name,
stateArrayPosition, stateArrayPosition,
attributeMetadataAccess, attributeMetadata,
mappedFetchTiming, mappedFetchTiming,
mappedFetchStyle, mappedFetchStyle,
declaringType, declaringType,

View File

@ -153,8 +153,7 @@ public class GeneratedValuesProcessor {
final Object generatedValue = final Object generatedValue =
descriptor.resolver.resolveGeneratedValue( selectionResults, entity, session, state[i] ); descriptor.resolver.resolveGeneratedValue( selectionResults, entity, session, state[i] );
state[ descriptor.attribute.getStateArrayPosition() ] = generatedValue; state[ descriptor.attribute.getStateArrayPosition() ] = generatedValue;
descriptor.attribute.getAttributeMetadataAccess() descriptor.attribute.getAttributeMetadata()
.resolveAttributeMetadata( entityDescriptor )
.getPropertyAccess() .getPropertyAccess()
.getSetter() .getSetter()
.set( entity, generatedValue ); .set( entity, generatedValue );

View File

@ -20,7 +20,7 @@ import org.hibernate.mapping.Component;
import org.hibernate.mapping.IndexedConsumer; import org.hibernate.mapping.IndexedConsumer;
import org.hibernate.mapping.RootClass; import org.hibernate.mapping.RootClass;
import org.hibernate.metamodel.mapping.AttributeMapping; 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.EmbeddableMappingType;
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart; import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
import org.hibernate.metamodel.mapping.EntityIdentifierMapping; 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.descriptor.java.JavaType;
import org.hibernate.type.spi.CompositeTypeImplementor; 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} * EmbeddableMappingType implementation describing an {@link jakarta.persistence.IdClass}
@ -98,7 +98,7 @@ public class IdClassEmbeddable extends AbstractEmbeddableMapping implements Iden
null, null,
EntityIdentifierMapping.ROLE_LOCAL_NAME, EntityIdentifierMapping.ROLE_LOCAL_NAME,
true ); true );
final AttributeMetadataAccess attributeMetadataAccess = getAttributeMetadataAccess( final AttributeMetadata attributeMetadata = MappingModelCreationHelper.getAttributeMetadata(
propertyAccess propertyAccess
); );
@ -109,7 +109,7 @@ public class IdClassEmbeddable extends AbstractEmbeddableMapping implements Iden
.append( NavigablePath.IDENTIFIER_MAPPER_PROPERTY ), .append( NavigablePath.IDENTIFIER_MAPPER_PROPERTY ),
-1, -1,
idTable, idTable,
attributeMetadataAccess, attributeMetadata,
(PropertyAccess) null, (PropertyAccess) null,
FetchTiming.IMMEDIATE, FetchTiming.IMMEDIATE,
FetchStyle.JOIN, FetchStyle.JOIN,

View File

@ -50,7 +50,7 @@ import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.Value; import org.hibernate.mapping.Value;
import org.hibernate.metamodel.CollectionClassification; import org.hibernate.metamodel.CollectionClassification;
import org.hibernate.metamodel.MappingMetamodel; 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.BasicValuedModelPart;
import org.hibernate.metamodel.mapping.CollectionIdentifierDescriptor; import org.hibernate.metamodel.mapping.CollectionIdentifierDescriptor;
import org.hibernate.metamodel.mapping.CollectionMappingType; import org.hibernate.metamodel.mapping.CollectionMappingType;
@ -196,7 +196,7 @@ public class MappingModelCreationHelper {
MappingModelCreationProcess creationProcess) { MappingModelCreationProcess creationProcess) {
final Value value = bootProperty.getValue(); final Value value = bootProperty.getValue();
final BasicValue.Resolution<?> resolution = ( (Resolvable) value ).resolve(); 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 FetchTiming fetchTiming;
final FetchStyle fetchStyle; final FetchStyle fetchStyle;
@ -220,7 +220,7 @@ public class MappingModelCreationHelper {
attrName, attrName,
navigableRole, navigableRole,
stateArrayPosition, stateArrayPosition,
attributeMetadataAccess, attributeMetadata,
fetchTiming, fetchTiming,
fetchStyle, fetchStyle,
tableExpression, tableExpression,
@ -253,7 +253,7 @@ public class MappingModelCreationHelper {
PropertyAccess propertyAccess, PropertyAccess propertyAccess,
CascadeStyle cascadeStyle, CascadeStyle cascadeStyle,
MappingModelCreationProcess creationProcess) { MappingModelCreationProcess creationProcess) {
final AttributeMetadataAccess attributeMetadataAccess = getAttributeMetadataAccess( final AttributeMetadata attributeMetadataAccess = getAttributeMetadata(
bootProperty, bootProperty,
attrType, attrType,
propertyAccess, propertyAccess,
@ -308,7 +308,7 @@ public class MappingModelCreationHelper {
} }
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
protected static AttributeMetadataAccess getAttributeMetadataAccess( protected static AttributeMetadata getAttributeMetadata(
Property bootProperty, Property bootProperty,
Type attrType, Type attrType,
PropertyAccess propertyAccess, PropertyAccess propertyAccess,
@ -349,19 +349,19 @@ public class MappingModelCreationHelper {
else { else {
mutabilityPlan = ImmutableMutabilityPlan.INSTANCE; mutabilityPlan = ImmutableMutabilityPlan.INSTANCE;
} }
BasicAttributeMetadataAccess basicAttributeMetadataAccess = new BasicAttributeMetadataAccess( propertyAccess, SimpleAttributeMetadata basicAttributeMetadataAccess = new SimpleAttributeMetadata( propertyAccess,
mutabilityPlan, mutabilityPlan,
bootProperty.getValue().isNullable(), bootProperty.getValue().isNullable(),
bootProperty.isInsertable(), bootProperty.isInsertable(),
bootProperty.isUpdateable(), bootProperty.isUpdateable(),
bootProperty.isOptimisticLocked(), bootProperty.isOptimisticLocked(),
cascadeStyle ); cascadeStyle );
return basicAttributeMetadataAccess; return basicAttributeMetadataAccess;
} }
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public static AttributeMetadataAccess getAttributeMetadataAccess(PropertyAccess propertyAccess) { public static AttributeMetadata getAttributeMetadata(PropertyAccess propertyAccess) {
return new BasicAttributeMetadataAccess(propertyAccess, ImmutableMutabilityPlan.INSTANCE, false, true, false, false, null);// todo (6.0) : not sure if CascadeStyle=null is correct return new SimpleAttributeMetadata( propertyAccess, ImmutableMutabilityPlan.INSTANCE, false, true, false, false, null);// todo (6.0) : not sure if CascadeStyle=null is correct
} }
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@ -542,13 +542,14 @@ public class MappingModelCreationHelper {
} }
} }
BasicAttributeMetadataAccess attributeMetadata = new BasicAttributeMetadataAccess( propertyAccess, SimpleAttributeMetadata attributeMetadata = new SimpleAttributeMetadata(
ImmutableMutabilityPlan.instance(), propertyAccess,
bootProperty.isOptional(), ImmutableMutabilityPlan.instance(),
bootProperty.isInsertable(), bootProperty.isOptional(),
bootProperty.isUpdateable(), bootProperty.isInsertable(),
bootProperty.isOptimisticLocked(), bootProperty.isUpdateable(),
cascadeStyle bootProperty.isOptimisticLocked(),
cascadeStyle
); );
final FetchStyle style = FetchOptionsHelper.determineFetchStyleByMetadata( final FetchStyle style = FetchOptionsHelper.determineFetchStyleByMetadata(
@ -1491,7 +1492,7 @@ public class MappingModelCreationHelper {
if ( bootProperty.getValue() instanceof ToOne ) { if ( bootProperty.getValue() instanceof ToOne ) {
final ToOne value = (ToOne) bootProperty.getValue(); final ToOne value = (ToOne) bootProperty.getValue();
final EntityPersister entityPersister = creationProcess.getEntityPersister( value.getReferencedEntityName() ); final EntityPersister entityPersister = creationProcess.getEntityPersister( value.getReferencedEntityName() );
final AttributeMetadataAccess attributeMetadataAccess = getAttributeMetadataAccess( final AttributeMetadata attributeMetadata = getAttributeMetadata(
bootProperty, bootProperty,
attrType, attrType,
propertyAccess, propertyAccess,
@ -1536,7 +1537,7 @@ public class MappingModelCreationHelper {
navigableRole, navigableRole,
stateArrayPosition, stateArrayPosition,
(ToOne) bootProperty.getValue(), (ToOne) bootProperty.getValue(),
attributeMetadataAccess, attributeMetadata,
fetchTiming, fetchTiming,
fetchStyle, fetchStyle,
entityPersister, entityPersister,

View File

@ -22,7 +22,7 @@ import org.hibernate.mapping.IndexedConsumer;
import org.hibernate.mapping.List; import org.hibernate.mapping.List;
import org.hibernate.mapping.Map; import org.hibernate.mapping.Map;
import org.hibernate.mapping.Property; 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.CollectionIdentifierDescriptor;
import org.hibernate.metamodel.mapping.CollectionMappingType; import org.hibernate.metamodel.mapping.CollectionMappingType;
import org.hibernate.metamodel.mapping.CollectionPart; import org.hibernate.metamodel.mapping.CollectionPart;
@ -89,7 +89,7 @@ public class PluralAttributeMappingImpl
private final CollectionMappingType collectionMappingType; private final CollectionMappingType collectionMappingType;
private final int stateArrayPosition; private final int stateArrayPosition;
private final PropertyAccess propertyAccess; private final PropertyAccess propertyAccess;
private final AttributeMetadataAccess attributeMetadataAccess; private final AttributeMetadata attributeMetadata;
private final String referencedPropertyName; private final String referencedPropertyName;
private final String mapKeyPropertyName; private final String mapKeyPropertyName;
@ -117,7 +117,7 @@ public class PluralAttributeMappingImpl
String attributeName, String attributeName,
Collection bootDescriptor, Collection bootDescriptor,
PropertyAccess propertyAccess, PropertyAccess propertyAccess,
AttributeMetadataAccess attributeMetadataAccess, AttributeMetadata attributeMetadata,
CollectionMappingType<?> collectionMappingType, CollectionMappingType<?> collectionMappingType,
int stateArrayPosition, int stateArrayPosition,
CollectionPart elementDescriptor, CollectionPart elementDescriptor,
@ -130,7 +130,7 @@ public class PluralAttributeMappingImpl
CollectionPersister collectionDescriptor) { CollectionPersister collectionDescriptor) {
super( attributeName, declaringType ); super( attributeName, declaringType );
this.propertyAccess = propertyAccess; this.propertyAccess = propertyAccess;
this.attributeMetadataAccess = attributeMetadataAccess; this.attributeMetadata = attributeMetadata;
this.collectionMappingType = collectionMappingType; this.collectionMappingType = collectionMappingType;
this.stateArrayPosition = stateArrayPosition; this.stateArrayPosition = stateArrayPosition;
this.elementDescriptor = elementDescriptor; this.elementDescriptor = elementDescriptor;
@ -316,8 +316,8 @@ public class PluralAttributeMappingImpl
} }
@Override @Override
public AttributeMetadataAccess getAttributeMetadataAccess() { public AttributeMetadata getAttributeMetadata() {
return attributeMetadataAccess; return attributeMetadata;
} }
@Override @Override

View File

@ -11,12 +11,10 @@ import org.hibernate.engine.spi.CascadeStyles;
import org.hibernate.mapping.Property; import org.hibernate.mapping.Property;
import org.hibernate.mapping.Value; import org.hibernate.mapping.Value;
import org.hibernate.metamodel.mapping.AttributeMetadata; 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.property.access.spi.PropertyAccess;
import org.hibernate.type.descriptor.java.MutabilityPlan; 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 PropertyAccess propertyAccess;
private final MutabilityPlan<?> mutabilityPlan; private final MutabilityPlan<?> mutabilityPlan;
@ -26,7 +24,7 @@ public final class BasicAttributeMetadataAccess implements AttributeMetadataAcce
private final boolean includeInOptimisticLocking; private final boolean includeInOptimisticLocking;
private final CascadeStyle cascadeStyle; private final CascadeStyle cascadeStyle;
public BasicAttributeMetadataAccess( public SimpleAttributeMetadata(
PropertyAccess propertyAccess, PropertyAccess propertyAccess,
MutabilityPlan mutabilityPlan, MutabilityPlan mutabilityPlan,
Property bootProperty, Property bootProperty,
@ -42,7 +40,7 @@ public final class BasicAttributeMetadataAccess implements AttributeMetadataAcce
); );
} }
public BasicAttributeMetadataAccess( public SimpleAttributeMetadata(
PropertyAccess propertyAccess, PropertyAccess propertyAccess,
MutabilityPlan mutabilityPlan, MutabilityPlan mutabilityPlan,
boolean nullable, boolean insertable, boolean updateable, boolean includeInOptimisticLocking) { boolean nullable, boolean insertable, boolean updateable, boolean includeInOptimisticLocking) {
@ -57,7 +55,7 @@ public final class BasicAttributeMetadataAccess implements AttributeMetadataAcce
); );
} }
public BasicAttributeMetadataAccess( public SimpleAttributeMetadata(
PropertyAccess propertyAccess, PropertyAccess propertyAccess,
MutabilityPlan mutabilityPlan, MutabilityPlan mutabilityPlan,
boolean nullable, boolean nullable,
@ -74,11 +72,6 @@ public final class BasicAttributeMetadataAccess implements AttributeMetadataAcce
this.cascadeStyle = cascadeStyle; this.cascadeStyle = cascadeStyle;
} }
@Override
public AttributeMetadata resolveAttributeMetadata(EntityMappingType entityMappingType) {
return this;
}
@Override @Override
public PropertyAccess getPropertyAccess() { public PropertyAccess getPropertyAccess() {
return propertyAccess; return propertyAccess;

View File

@ -48,7 +48,7 @@ public class SimpleNaturalIdMapping extends AbstractNaturalIdMapping implements
MappingModelCreationProcess creationProcess) { MappingModelCreationProcess creationProcess) {
super( super(
declaringType, declaringType,
attribute.getAttributeMetadataAccess().resolveAttributeMetadata( declaringType ).isUpdatable() attribute.getAttributeMetadata().isUpdatable()
); );
this.attribute = attribute; this.attribute = attribute;

View File

@ -34,7 +34,7 @@ import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.Value; import org.hibernate.mapping.Value;
import org.hibernate.metamodel.mapping.AssociationKey; import org.hibernate.metamodel.mapping.AssociationKey;
import org.hibernate.metamodel.mapping.AttributeMapping; 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.CollectionPart;
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart; import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
import org.hibernate.metamodel.mapping.EntityAssociationMapping; import org.hibernate.metamodel.mapping.EntityAssociationMapping;
@ -162,7 +162,7 @@ public class ToOneAttributeMapping
NavigableRole navigableRole, NavigableRole navigableRole,
int stateArrayPosition, int stateArrayPosition,
ToOne bootValue, ToOne bootValue,
AttributeMetadataAccess attributeMetadataAccess, AttributeMetadata attributeMetadata,
FetchOptions mappedFetchOptions, FetchOptions mappedFetchOptions,
EntityMappingType entityMappingType, EntityMappingType entityMappingType,
ManagedMappingType declaringType, ManagedMappingType declaringType,
@ -173,7 +173,7 @@ public class ToOneAttributeMapping
navigableRole, navigableRole,
stateArrayPosition, stateArrayPosition,
bootValue, bootValue,
attributeMetadataAccess, attributeMetadata,
mappedFetchOptions.getTiming(), mappedFetchOptions.getTiming(),
mappedFetchOptions.getStyle(), mappedFetchOptions.getStyle(),
entityMappingType, entityMappingType,
@ -188,7 +188,7 @@ public class ToOneAttributeMapping
NavigableRole navigableRole, NavigableRole navigableRole,
int stateArrayPosition, int stateArrayPosition,
ToOne bootValue, ToOne bootValue,
AttributeMetadataAccess attributeMetadataAccess, AttributeMetadata attributeMetadata,
FetchTiming mappedFetchTiming, FetchTiming mappedFetchTiming,
FetchStyle mappedFetchStyle, FetchStyle mappedFetchStyle,
EntityMappingType entityMappingType, EntityMappingType entityMappingType,
@ -198,7 +198,7 @@ public class ToOneAttributeMapping
super( super(
name, name,
stateArrayPosition, stateArrayPosition,
attributeMetadataAccess, attributeMetadata,
adjustFetchTiming( mappedFetchTiming, bootValue ), adjustFetchTiming( mappedFetchTiming, bootValue ),
mappedFetchStyle, mappedFetchStyle,
declaringType, declaringType,
@ -549,7 +549,7 @@ public class ToOneAttributeMapping
super( super(
original.getAttributeName(), original.getAttributeName(),
original.getStateArrayPosition(), original.getStateArrayPosition(),
original.getAttributeMetadataAccess(), original.getAttributeMetadata(),
original, original,
declaringType, declaringType,
original.getPropertyAccess() original.getPropertyAccess()

View File

@ -8,7 +8,7 @@ package org.hibernate.metamodel.mapping.internal;
import org.hibernate.engine.FetchStyle; import org.hibernate.engine.FetchStyle;
import org.hibernate.engine.FetchTiming; 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.EmbeddableMappingType;
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart; import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
import org.hibernate.metamodel.mapping.ManagedMappingType; import org.hibernate.metamodel.mapping.ManagedMappingType;
@ -28,7 +28,7 @@ public class VirtualEmbeddedAttributeMapping extends EmbeddedAttributeMapping im
NavigableRole navigableRole, NavigableRole navigableRole,
int stateArrayPosition, int stateArrayPosition,
String tableExpression, String tableExpression,
AttributeMetadataAccess attributeMetadataAccess, AttributeMetadata attributeMetadata,
String parentInjectionAttributeName, String parentInjectionAttributeName,
FetchTiming mappedFetchTiming, FetchTiming mappedFetchTiming,
FetchStyle mappedFetchStyle, FetchStyle mappedFetchStyle,
@ -40,7 +40,7 @@ public class VirtualEmbeddedAttributeMapping extends EmbeddedAttributeMapping im
navigableRole, navigableRole,
stateArrayPosition, stateArrayPosition,
tableExpression, tableExpression,
attributeMetadataAccess, attributeMetadata,
parentInjectionAttributeName, parentInjectionAttributeName,
mappedFetchTiming, mappedFetchTiming,
mappedFetchStyle, mappedFetchStyle,
@ -55,7 +55,7 @@ public class VirtualEmbeddedAttributeMapping extends EmbeddedAttributeMapping im
NavigableRole navigableRole, NavigableRole navigableRole,
int stateArrayPosition, int stateArrayPosition,
String tableExpression, String tableExpression,
AttributeMetadataAccess attributeMetadataAccess, AttributeMetadata attributeMetadata,
PropertyAccess parentInjectionAttributePropertyAccess, PropertyAccess parentInjectionAttributePropertyAccess,
FetchTiming mappedFetchTiming, FetchTiming mappedFetchTiming,
FetchStyle mappedFetchStyle, FetchStyle mappedFetchStyle,
@ -67,7 +67,7 @@ public class VirtualEmbeddedAttributeMapping extends EmbeddedAttributeMapping im
navigableRole, navigableRole,
stateArrayPosition, stateArrayPosition,
tableExpression, tableExpression,
attributeMetadataAccess, attributeMetadata,
parentInjectionAttributePropertyAccess, parentInjectionAttributePropertyAccess,
mappedFetchTiming, mappedFetchTiming,
mappedFetchStyle, mappedFetchStyle,

View File

@ -78,7 +78,6 @@ import org.hibernate.engine.jdbc.mutation.spi.MutationExecutorService;
import org.hibernate.engine.jdbc.spi.JdbcServices; import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.spi.CachedNaturalIdValueSource; import org.hibernate.engine.spi.CachedNaturalIdValueSource;
import org.hibernate.engine.spi.CascadeStyle; import org.hibernate.engine.spi.CascadeStyle;
import org.hibernate.engine.spi.CascadeStyles;
import org.hibernate.engine.spi.CollectionKey; import org.hibernate.engine.spi.CollectionKey;
import org.hibernate.engine.spi.EntityEntry; import org.hibernate.engine.spi.EntityEntry;
import org.hibernate.engine.spi.EntityEntryFactory; 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.Association;
import org.hibernate.metamodel.mapping.AttributeMapping; import org.hibernate.metamodel.mapping.AttributeMapping;
import org.hibernate.metamodel.mapping.AttributeMetadata; import org.hibernate.metamodel.mapping.AttributeMetadata;
import org.hibernate.metamodel.mapping.AttributeMetadataAccess;
import org.hibernate.metamodel.mapping.BasicValuedModelPart; import org.hibernate.metamodel.mapping.BasicValuedModelPart;
import org.hibernate.metamodel.mapping.DiscriminatedAssociationModelPart; import org.hibernate.metamodel.mapping.DiscriminatedAssociationModelPart;
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart; 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.SelectableMapping;
import org.hibernate.metamodel.mapping.SingularAttributeMapping; import org.hibernate.metamodel.mapping.SingularAttributeMapping;
import org.hibernate.metamodel.mapping.VirtualModelPart; 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.BasicEntityIdentifierMappingImpl;
import org.hibernate.metamodel.mapping.internal.CompoundNaturalIdMapping; import org.hibernate.metamodel.mapping.internal.CompoundNaturalIdMapping;
import org.hibernate.metamodel.mapping.internal.DiscriminatedAssociationAttributeMapping; import org.hibernate.metamodel.mapping.internal.DiscriminatedAssociationAttributeMapping;
@ -4253,11 +4251,10 @@ public abstract class AbstractEntityPersister
final Object[] values = new Object[ getNumberOfAttributeMappings() ]; final Object[] values = new Object[ getNumberOfAttributeMappings() ];
for ( int i = 0; i < attributeMappings.size(); i++ ) { for ( int i = 0; i < attributeMappings.size(); i++ ) {
final AttributeMapping attributeMapping = attributeMappings.get( i ); final AttributeMapping attributeMapping = attributeMappings.get( i );
final AttributeMetadataAccess attributeMetadataAccess = attributeMapping.getAttributeMetadataAccess(); final AttributeMetadata attributeMetadata = attributeMapping.getAttributeMetadata();
if ( ! lazyAttributesMetadata.isLazyAttribute( attributeMapping.getAttributeName() ) if ( ! lazyAttributesMetadata.isLazyAttribute( attributeMapping.getAttributeName() )
|| enhancementMetadata.isAttributeLoaded( object, attributeMapping.getAttributeName() ) ) { || enhancementMetadata.isAttributeLoaded( object, attributeMapping.getAttributeName() ) ) {
values[i] = attributeMetadataAccess values[i] = attributeMetadata
.resolveAttributeMetadata( this )
.getPropertyAccess() .getPropertyAccess()
.getGetter() .getGetter()
.get( object ); .get( object );
@ -4273,8 +4270,7 @@ public abstract class AbstractEntityPersister
@Override @Override
public Object getPropertyValue(Object object, int i) { public Object getPropertyValue(Object object, int i) {
return attributeMappings.get( i ).getAttributeMetadataAccess() return attributeMappings.get( i ).getAttributeMetadata()
.resolveAttributeMetadata( this )
.getPropertyAccess() .getPropertyAccess()
.getGetter() .getGetter()
.get( object ); .get( object );
@ -4290,8 +4286,7 @@ public abstract class AbstractEntityPersister
ManagedMappingType baseValueType = null; ManagedMappingType baseValueType = null;
Object baseValue = null; Object baseValue = null;
if ( attributeMapping != null ) { if ( attributeMapping != null ) {
baseValue = attributeMapping.getAttributeMetadataAccess() baseValue = attributeMapping.getAttributeMetadata()
.resolveAttributeMetadata( this )
.getPropertyAccess() .getPropertyAccess()
.getGetter() .getGetter()
.get( object ); .get( object );
@ -4305,8 +4300,7 @@ public abstract class AbstractEntityPersister
? null ? null
: embeddedAttributeMapping.getMappedType().findAttributeMapping( basePropertyName ); : embeddedAttributeMapping.getMappedType().findAttributeMapping( basePropertyName );
if ( mapping != null ) { if ( mapping != null ) {
baseValue = mapping.getAttributeMetadataAccess() baseValue = mapping.getAttributeMetadata()
.resolveAttributeMetadata( this )
.getPropertyAccess() .getPropertyAccess()
.getGetter() .getGetter()
.get( object ); .get( object );
@ -4332,8 +4326,7 @@ public abstract class AbstractEntityPersister
attributeMapping = baseValueType.findAttributeMapping( attributeMapping = baseValueType.findAttributeMapping(
propertyName.substring( dotIndex + 1, endIndex ) propertyName.substring( dotIndex + 1, endIndex )
); );
baseValue = attributeMapping.getAttributeMetadataAccess() baseValue = attributeMapping.getAttributeMetadata()
.resolveAttributeMetadata( this )
.getPropertyAccess() .getPropertyAccess()
.getGetter() .getGetter()
.get( baseValue ); .get( baseValue );
@ -4613,7 +4606,7 @@ public abstract class AbstractEntityPersister
@Override @Override
public void setPropertyValue(Object object, String propertyName, Object value) { public void setPropertyValue(Object object, String propertyName, Object value) {
final AttributeMapping attributeMapping = findSubPart( propertyName, this ).asAttributeMapping(); 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 ); attributeMetadata.getPropertyAccess().getSetter().set( object, value );
} }
@ -5502,7 +5495,7 @@ public abstract class AbstractEntityPersister
final AnyType anyType = (AnyType) attrType; final AnyType anyType = (AnyType) attrType;
final MutabilityPlan<?> mutabilityPlan = new DiscriminatedAssociationAttributeMapping.MutabilityPlanImpl( anyType ); final MutabilityPlan<?> mutabilityPlan = new DiscriminatedAssociationAttributeMapping.MutabilityPlanImpl( anyType );
final BasicAttributeMetadataAccess attributeMetadataAccess = new BasicAttributeMetadataAccess( final SimpleAttributeMetadata attributeMetadataAccess = new SimpleAttributeMetadata(
propertyAccess, propertyAccess,
mutabilityPlan, mutabilityPlan,
bootProperty.isOptional(), bootProperty.isOptional(),

View File

@ -242,8 +242,7 @@ public class UpdateCoordinatorStandard extends AbstractMutationCoordinator imple
// && updateableAttributeIndexes[position]; // && updateableAttributeIndexes[position];
} }
final boolean includeInLocking = attribute.getAttributeMetadataAccess() final boolean includeInLocking = attribute.getAttributeMetadata()
.resolveAttributeMetadata( null )
.isIncludedInOptimisticLocking(); .isIncludedInOptimisticLocking();
if ( !includeInLocking ) { if ( !includeInLocking ) {
return false; return false;

View File

@ -211,8 +211,7 @@ public abstract class AbstractEntityInitializer extends AbstractFetchParentAcces
final int numberOfAttributeMappings = containerDescriptor.getNumberOfAttributeMappings(); final int numberOfAttributeMappings = containerDescriptor.getNumberOfAttributeMappings();
for ( int i = 0; i < numberOfAttributeMappings; i++ ) { for ( int i = 0; i < numberOfAttributeMappings; i++ ) {
final AttributeMapping attributeMapping = containerDescriptor.getAttributeMapping( i ); final AttributeMapping attributeMapping = containerDescriptor.getAttributeMapping( i );
final AttributeMetadata attributeMetadata = attributeMapping.getAttributeMetadataAccess() final AttributeMetadata attributeMetadata = attributeMapping.getAttributeMetadata();
.resolveAttributeMetadata( concreteDescriptor );
if ( attributeMetadata.isUpdatable() ) { if ( attributeMetadata.isUpdatable() ) {
final int position = attributeMapping.getStateArrayPosition(); final int position = attributeMapping.getStateArrayPosition();
Object result; Object result;

View File

@ -31,7 +31,7 @@ public abstract class AbstractCompositeIdAndNaturalIdTest {
public void testNaturalIdNullability(SessionFactoryScope scope) { public void testNaturalIdNullability(SessionFactoryScope scope) {
final EntityMappingType accountMapping = scope.getSessionFactory().getRuntimeMetamodels().getEntityMappingType( Account.class ); final EntityMappingType accountMapping = scope.getSessionFactory().getRuntimeMetamodels().getEntityMappingType( Account.class );
final SingularAttributeMapping shortCodeMapping = ((SimpleNaturalIdMapping) accountMapping.getNaturalIdMapping()).getAttribute(); final SingularAttributeMapping shortCodeMapping = ((SimpleNaturalIdMapping) accountMapping.getNaturalIdMapping()).getAttribute();
final AttributeMetadata shortCodeMetadata = shortCodeMapping.getAttributeMetadataAccess().resolveAttributeMetadata( null ); final AttributeMetadata shortCodeMetadata = shortCodeMapping.getAttributeMetadata();
assertThat( shortCodeMetadata.isNullable(), is( false ) ); assertThat( shortCodeMetadata.isNullable(), is( false ) );
final EntityPersister rootEntityPersister = accountMapping.getRootEntityDescriptor().getEntityPersister(); final EntityPersister rootEntityPersister = accountMapping.getRootEntityDescriptor().getEntityPersister();

View File

@ -62,12 +62,12 @@ public class ImmutableManyToOneNaturalIdAnnotationTest {
// access by list-index should again be alphabetically sorted // access by list-index should again be alphabetically sorted
final SingularAttributeMapping first = naturalIdMapping.getNaturalIdAttributes().get( 0 ); final SingularAttributeMapping first = naturalIdMapping.getNaturalIdAttributes().get( 0 );
assertThat( first.getAttributeName(), is( "name" ) ); assertThat( first.getAttributeName(), is( "name" ) );
final AttributeMetadata firstMetadata = first.getAttributeMetadataAccess().resolveAttributeMetadata( null ); final AttributeMetadata firstMetadata = first.getAttributeMetadata();
assertFalse( firstMetadata.getMutabilityPlan().isMutable() ); assertFalse( firstMetadata.getMutabilityPlan().isMutable() );
final SingularAttributeMapping second = naturalIdMapping.getNaturalIdAttributes().get( 1 ); final SingularAttributeMapping second = naturalIdMapping.getNaturalIdAttributes().get( 1 );
assertThat( second.getAttributeName(), is( "parent" ) ); assertThat( second.getAttributeName(), is( "parent" ) );
final AttributeMetadata secondMetadata = second.getAttributeMetadataAccess().resolveAttributeMetadata( null ); final AttributeMetadata secondMetadata = second.getAttributeMetadata();
assertFalse( secondMetadata.getMutabilityPlan().isMutable() ); assertFalse( secondMetadata.getMutabilityPlan().isMutable() );
} }
} }

View File

@ -100,12 +100,12 @@ public class ImmutableManyToOneNaturalIdHbmTest {
final SingularAttributeMapping first = naturalIdMapping.getNaturalIdAttributes().get( 0 ); final SingularAttributeMapping first = naturalIdMapping.getNaturalIdAttributes().get( 0 );
assertThat( first.getAttributeName(), is( "name" ) ); assertThat( first.getAttributeName(), is( "name" ) );
final AttributeMetadata firstMetadata = first.getAttributeMetadataAccess().resolveAttributeMetadata( null ); final AttributeMetadata firstMetadata = first.getAttributeMetadata();
assertFalse( firstMetadata.getMutabilityPlan().isMutable() ); assertFalse( firstMetadata.getMutabilityPlan().isMutable() );
final SingularAttributeMapping second = naturalIdMapping.getNaturalIdAttributes().get( 1 ); final SingularAttributeMapping second = naturalIdMapping.getNaturalIdAttributes().get( 1 );
assertThat( second.getAttributeName(), is( "parent" ) ); assertThat( second.getAttributeName(), is( "parent" ) );
final AttributeMetadata secondMetadata = second.getAttributeMetadataAccess().resolveAttributeMetadata( null ); final AttributeMetadata secondMetadata = second.getAttributeMetadata();
assertFalse( secondMetadata.getMutabilityPlan().isMutable() ); assertFalse( secondMetadata.getMutabilityPlan().isMutable() );
} }

View File

@ -56,7 +56,7 @@ public class ImmutableNaturalIdTest {
final EntityMappingType entityMappingType = sessionFactory.getRuntimeMetamodels().getEntityMappingType( User.class ); final EntityMappingType entityMappingType = sessionFactory.getRuntimeMetamodels().getEntityMappingType( User.class );
final AttributeMapping userNameMapping = entityMappingType.findAttributeMapping( "userName" ); final AttributeMapping userNameMapping = entityMappingType.findAttributeMapping( "userName" );
assertFalse( userNameMapping.getAttributeMetadataAccess().resolveAttributeMetadata( null ).isNullable() ); assertFalse( userNameMapping.getAttributeMetadata().isNullable() );
final EntityPersister persister = entityMappingType.getEntityPersister(); final EntityPersister persister = entityMappingType.getEntityPersister();
final int propertyIndex = persister.getEntityMetamodel().getPropertyIndex( "userName" ); final int propertyIndex = persister.getEntityMetamodel().getPropertyIndex( "userName" );

View File

@ -95,7 +95,7 @@ public class ImmutableEntityNaturalIdTest {
assertThat( naturalIdMapping.getNaturalIdAttributes().size(), is( 3 ) ); assertThat( naturalIdMapping.getNaturalIdAttributes().size(), is( 3 ) );
// nullability is not specified, so they should be nullable by annotations-specific default // nullability is not specified, so they should be nullable by annotations-specific default
for ( SingularAttributeMapping attribute : naturalIdMapping.getNaturalIdAttributes() ) { for ( SingularAttributeMapping attribute : naturalIdMapping.getNaturalIdAttributes() ) {
assertThat( attribute.getAttributeMetadataAccess().resolveAttributeMetadata( null ).isNullable(), is( true ) ); assertThat( attribute.getAttributeMetadata().isNullable(), is( true ) );
} }
final EntityPersister entityPersister = buildingMapping.getEntityPersister(); final EntityPersister entityPersister = buildingMapping.getEntityPersister();

View File

@ -46,7 +46,7 @@ public class InheritedNaturalIdTest {
final SingularAttributeMapping uidMapping = ((SimpleNaturalIdMapping) userMapping.getNaturalIdMapping()).getAttribute(); final SingularAttributeMapping uidMapping = ((SimpleNaturalIdMapping) userMapping.getNaturalIdMapping()).getAttribute();
assertThat( uidMapping.getAttributeName(), is ("uid" ) ); assertThat( uidMapping.getAttributeName(), is ("uid" ) );
final AttributeMetadata uidMetadata = uidMapping.getAttributeMetadataAccess().resolveAttributeMetadata( null ); final AttributeMetadata uidMetadata = uidMapping.getAttributeMetadata();
assertThat( uidMetadata.isNullable(), is( true ) ); assertThat( uidMetadata.isNullable(), is( true ) );
final EntityPersister rootEntityPersister = userMapping.getEntityPersister(); final EntityPersister rootEntityPersister = userMapping.getEntityPersister();

View File

@ -77,12 +77,12 @@ public class NullableNaturalIdTest {
final SingularAttributeMapping firstAttribute = naturalIdMapping.getNaturalIdAttributes().get(0); final SingularAttributeMapping firstAttribute = naturalIdMapping.getNaturalIdAttributes().get(0);
assertThat( firstAttribute.getAttributeName(), is( "assA" ) ); assertThat( firstAttribute.getAttributeName(), is( "assA" ) );
assertThat( firstAttribute.getStateArrayPosition(), is( entityMetamodel.getPropertyIndex( "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); final SingularAttributeMapping secondAttribute = naturalIdMapping.getNaturalIdAttributes().get(1);
assertThat( secondAttribute.getAttributeName(), is( "naturalid" ) ); assertThat( secondAttribute.getAttributeName(), is( "naturalid" ) );
assertThat( secondAttribute.getStateArrayPosition(), is( entityMetamodel.getPropertyIndex( "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); final SingularAttributeMapping attribute = naturalIdMapping.getNaturalIdAttributes().get(0);
assertThat( attribute.getStateArrayPosition(), is( entityMetamodel.getPropertyIndex( "name" ) ) ); 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); final SingularAttributeMapping firstAttribute = naturalIdMapping.getNaturalIdAttributes().get(0);
assertThat( firstAttribute.getAttributeName(), is( "associatedC" ) ); assertThat( firstAttribute.getAttributeName(), is( "associatedC" ) );
assertThat( firstAttribute.getStateArrayPosition(), is( entityMetamodel.getPropertyIndex( "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); final SingularAttributeMapping secondAttribute = naturalIdMapping.getNaturalIdAttributes().get(1);
assertThat( secondAttribute.getAttributeName(), is( "name" ) ); assertThat( secondAttribute.getAttributeName(), is( "name" ) );
assertThat( secondAttribute.getStateArrayPosition(), is( entityMetamodel.getPropertyIndex( "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); final SingularAttributeMapping firstAttribute = naturalIdMapping.getNaturalIdAttributes().get(0);
assertThat( firstAttribute.getAttributeName(), is( "intVal" ) ); assertThat( firstAttribute.getAttributeName(), is( "intVal" ) );
assertThat( firstAttribute.getStateArrayPosition(), is( entityMetamodel.getPropertyIndex( "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); final SingularAttributeMapping secondAttribute = naturalIdMapping.getNaturalIdAttributes().get(1);
assertThat( secondAttribute.getAttributeName(), is( "name" ) ); assertThat( secondAttribute.getAttributeName(), is( "name" ) );
assertThat( secondAttribute.getStateArrayPosition(), is( entityMetamodel.getPropertyIndex( "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); final SingularAttributeMapping thirdAttribute = naturalIdMapping.getNaturalIdAttributes().get(2);
assertThat( thirdAttribute.getAttributeName(), is( "org" ) ); assertThat( thirdAttribute.getAttributeName(), is( "org" ) );
assertThat( thirdAttribute.getStateArrayPosition(), is( entityMetamodel.getPropertyIndex( "org" ) ) ); assertThat( thirdAttribute.getStateArrayPosition(), is( entityMetamodel.getPropertyIndex( "org" ) ) );
assertTrue( thirdAttribute.getAttributeMetadataAccess().resolveAttributeMetadata( null ).isNullable() ); assertTrue( thirdAttribute.getAttributeMetadata().isNullable() );
} }
} }