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 ) {
final CascadeStyle cascadeStyle = fetchable.asAttributeMapping().getAttributeMetadataAccess()
.resolveAttributeMetadata( fetchable.findContainingEntityMapping() )
final CascadeStyle cascadeStyle = fetchable.asAttributeMapping().getAttributeMetadata()
.getCascadeStyle();
final CascadingAction cascadingAction = loadQueryInfluencers.getEnabledCascadingFetchProfile()
.getCascadingAction();

View File

@ -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) {

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;
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(

View File

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

View File

@ -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

View File

@ -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(),

View File

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

View File

@ -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,

View File

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

View File

@ -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,

View File

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

View File

@ -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,

View File

@ -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,

View File

@ -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

View File

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

View File

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

View File

@ -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()

View File

@ -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,

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.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(),

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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