Top Description Fields Constructors Methods
org.hibernate.metamodel.mapping.internal

public Class SimpleNaturalIdMapping

extends AbstractNaturalIdMapping
implements CoercionContext, BasicValuedMapping
Class Inheritance
All Implemented Interfaces
org.hibernate.metamodel.mapping.BasicValuedMapping, org.hibernate.metamodel.mapping.SqlExpressible, org.hibernate.metamodel.mapping.JdbcMappingContainer, org.hibernate.metamodel.mapping.ValueMapping, org.hibernate.type.descriptor.java.JavaTypedExpressible, org.hibernate.metamodel.mapping.MappingModelExpressible, org.hibernate.metamodel.mapping.Bindable, org.hibernate.type.descriptor.java.JavaType.CoercionContext
Imports
java.util.Collections, .List, .Locale, .Map, java.util.function.BiConsumer, org.hibernate.HibernateException, org.hibernate.cache.MutableCacheKeyBuilder, org.hibernate.engine.spi.PersistenceContext, .SessionFactoryImplementor, .SharedSessionContractImplementor, org.hibernate.internal.util.IndexedConsumer, org.hibernate.loader.ast.internal.MultiNaturalIdLoaderArrayParam, .MultiNaturalIdLoaderInPredicate, .SimpleNaturalIdLoader, org.hibernate.loader.ast.spi.MultiNaturalIdLoader, .NaturalIdLoader, org.hibernate.metamodel.mapping.AttributeMapping, .BasicValuedMapping, .EntityMappingType, .JdbcMapping, .MappingType, .SelectableConsumer, .SingularAttributeMapping, org.hibernate.persister.entity.EntityPersister, org.hibernate.spi.NavigablePath, org.hibernate.sql.ast.spi.SqlSelection, org.hibernate.sql.ast.tree.from.TableGroup, org.hibernate.sql.results.graph.DomainResult, .DomainResultCreationState, org.hibernate.type.descriptor.java.JavaType, org.hibernate.type.spi.TypeConfiguration

Single-attribute NaturalIdMapping implementation

Field Summary

Modifier and TypeField and Description
private final SingularAttributeMapping
private final SessionFactoryImplementor
sessionFactory

Deprecated as a consequence of SessionFactoryImplementor being deprecated.
private final TypeConfiguration

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addToCacheKey(MutableCacheKeyBuilder
the MutableCacheKey used to add the disassembled value and the hashCode
cacheKey
,
Object
the value to disassemble
value
,
SharedSessionContractImplementor
the SharedSessionContractImplementor
session
)

Overrides default org.hibernate.metamodel.mapping.BasicValuedMapping.addToCacheKey.

Implements org.hibernate.metamodel.mapping.Bindable.addToCacheKey.

Add to the MutableCacheKey the values obtained disassembling the value and the hasCode generated from the disassembled value.
public void
applySqlSelections(NavigablePath navigablePath, TableGroup tableGroup, DomainResultCreationState creationState)

Implements org.hibernate.metamodel.mapping.ModelPart.applySqlSelections.

Apply SQL selections for a specific reference to this ModelPart outside the domain query's root select clause.
public void
applySqlSelections(NavigablePath navigablePath, TableGroup tableGroup, DomainResultCreationState creationState, BiConsumer<SqlSelection, JdbcMapping> selectionConsumer)

Implements org.hibernate.metamodel.mapping.ModelPart.applySqlSelections.

Apply SQL selections for a specific reference to this ModelPart outside the domain query's root select clause.
public AttributeMapping
public <X, Y> int
breakDownJdbcValues(Object domainValue, int offset, X x, Y y, ModelPart.JdbcValueBiConsumer<X, Y> valueConsumer, SharedSessionContractImplementor session)

Implements org.hibernate.metamodel.mapping.ModelPart.breakDownJdbcValues.

Breaks down the domain value to its constituent JDBC values.
public int
calculateHashCode(Object
The natural-id value
value
)

Implements org.hibernate.metamodel.mapping.NaturalIdMapping.calculateHashCode.

Calculate the hash-code of a natural-id value
public <T> DomainResult<T>
createDomainResult(NavigablePath navigablePath, TableGroup tableGroup, String resultVariable, DomainResultCreationState creationState)

Implements org.hibernate.metamodel.mapping.ModelPart.createDomainResult.

Create a DomainResult for a specific reference to this ModelPart.
public Object
public Object
extractNaturalIdFromEntity(Object
The entity instance
entity
)

Implements org.hibernate.metamodel.mapping.NaturalIdMapping.extractNaturalIdFromEntity.

Given an entity instance, extract the normalized natural id representation
public Object
extractNaturalIdFromEntityState(Object[]
The attribute state array
state
)

Implements org.hibernate.metamodel.mapping.NaturalIdMapping.extractNaturalIdFromEntityState.

Given an array of "full entity state", extract the normalized natural id representation
public <X, Y> int
public int
forEachJdbcType(int offset, IndexedConsumer<JdbcMapping> action)

Implements org.hibernate.metamodel.mapping.JdbcMappingContainer.forEachJdbcType.

Visit each JdbcMapping starting from the given offset
public <X, Y> int
forEachJdbcValue(Object value, int offset, X x, Y y, Bindable.JdbcValuesBiConsumer<X, Y> valuesConsumer, SharedSessionContractImplementor session)

Overrides default org.hibernate.metamodel.mapping.Bindable.forEachJdbcValue.

Visit each constituent JDBC value extracted from the entity instance itself.
public int
forEachSelectable(int offset, SelectableConsumer consumer)

Overrides default org.hibernate.metamodel.mapping.ModelPart.forEachSelectable.

Visits each selectable mapping with the selectable index offset by the given value.
public SingularAttributeMapping
public JavaType<?>
getJavaType()

Implements org.hibernate.metamodel.mapping.ModelPart.getJavaType.

The Java type for this part.
public JdbcMapping
public JdbcMapping
getJdbcMapping()

Implements org.hibernate.metamodel.mapping.BasicValuedMapping.getJdbcMapping.

Anything that is expressible at the SQL AST level would be of basic type.
public int
public MappingType
getMappedType()

Implements org.hibernate.metamodel.mapping.ValueMapping.getMappedType.

Descriptor for the type of this mapping
public List<SingularAttributeMapping>
public MappingType
public JdbcMapping
public TypeConfiguration
public boolean
public NaturalIdLoader<?>
makeLoader(EntityMappingType entityDescriptor)

Implements org.hibernate.metamodel.mapping.NaturalIdMapping.makeLoader.

Make a loader capable of loading a single entity by natural-id
public MultiNaturalIdLoader<?>
makeMultiLoader(EntityMappingType entityDescriptor)

Implements org.hibernate.metamodel.mapping.NaturalIdMapping.makeMultiLoader.

Make a loader capable of loading multiple entities by natural-id
public Object
normalizeIncomingValue(Object naturalIdToLoad)

public Object
normalizeInput(Object
The user-supplied value
incoming
)

Implements org.hibernate.metamodel.mapping.NaturalIdMapping.normalizeInput.

Normalize a user-provided natural-id value into the representation Hibernate uses internally
public void
validateInternalForm(Object naturalIdValue)

Implements org.hibernate.metamodel.mapping.NaturalIdMapping.validateInternalForm.

Validates a natural id value(s) for the described natural-id based on the expected internal representation
public void
verifyFlushState(Object id, Object[] currentState, Object[] loadedState, SharedSessionContractImplementor session)

Implements org.hibernate.metamodel.mapping.NaturalIdMapping.verifyFlushState.

Verify the natural-id value(s) we are about to flush to the database
Inherited from org.hibernate.metamodel.mapping.internal.AbstractNaturalIdMapping:
findContainingEntityMappinggetCacheAccessgetDeclaringTypegetNavigableRoleisMutable

Field Detail

attributeback to summary
private final SingularAttributeMapping attribute
sessionFactoryback to summary
private final SessionFactoryImplementor sessionFactory

Deprecated

as a consequence of SessionFactoryImplementor being deprecated. See corresponding docs for further information.

typeConfigurationback to summary
private final TypeConfiguration typeConfiguration

Constructor Detail

SimpleNaturalIdMappingback to summary
public SimpleNaturalIdMapping(SingularAttributeMapping attribute, EntityMappingType declaringType, MappingModelCreationProcess creationProcess)

Method Detail

addToCacheKeyback to summary
public void addToCacheKey(MutableCacheKeyBuilder cacheKey, Object value, SharedSessionContractImplementor session)

Overrides default org.hibernate.metamodel.mapping.BasicValuedMapping.addToCacheKey.

Implements org.hibernate.metamodel.mapping.Bindable.addToCacheKey.

Doc from org.hibernate.metamodel.mapping.Bindable.addToCacheKey.

Add to the MutableCacheKey the values obtained disassembling the value and the hasCode generated from the disassembled value.

Parameters
cacheKey:MutableCacheKeyBuilder

the MutableCacheKey used to add the disassembled value and the hashCode

value:Object

the value to disassemble

session:SharedSessionContractImplementor

the SharedSessionContractImplementor

Annotations
@Override
applySqlSelectionsback to summary
public void applySqlSelections(NavigablePath navigablePath, TableGroup tableGroup, DomainResultCreationState creationState)

Implements org.hibernate.metamodel.mapping.ModelPart.applySqlSelections.

Doc from org.hibernate.metamodel.mapping.ModelPart.applySqlSelections.

Apply SQL selections for a specific reference to this ModelPart outside the domain query's root select clause.

Annotations
@Override
applySqlSelectionsback to summary
public void applySqlSelections(NavigablePath navigablePath, TableGroup tableGroup, DomainResultCreationState creationState, BiConsumer<SqlSelection, JdbcMapping> selectionConsumer)

Implements org.hibernate.metamodel.mapping.ModelPart.applySqlSelections.

Doc from org.hibernate.metamodel.mapping.ModelPart.applySqlSelections.

Apply SQL selections for a specific reference to this ModelPart outside the domain query's root select clause.

Annotations
@Override
asAttributeMappingback to summary
public AttributeMapping asAttributeMapping()

Overrides default org.hibernate.metamodel.mapping.ModelPart.asAttributeMapping.

Annotations
@Override
breakDownJdbcValuesback to summary
public <X, Y> int breakDownJdbcValues(Object domainValue, int offset, X x, Y y, ModelPart.JdbcValueBiConsumer<X, Y> valueConsumer, SharedSessionContractImplementor session)

Implements org.hibernate.metamodel.mapping.ModelPart.breakDownJdbcValues.

Doc from org.hibernate.metamodel.mapping.ModelPart.breakDownJdbcValues.

Breaks down the domain value to its constituent JDBC values. Think of it as breaking the multi-dimensional array into a visitable flat array. Additionally, it passes through the values X and Y to the consumer. Returns the amount of jdbc types that have been visited.

Annotations
@Override
calculateHashCodeback to summary
public int calculateHashCode(Object value)

Implements org.hibernate.metamodel.mapping.NaturalIdMapping.calculateHashCode.

Doc from org.hibernate.metamodel.mapping.NaturalIdMapping.calculateHashCode.

Calculate the hash-code of a natural-id value

Parameters
value:Object

The natural-id value

Returns:int

The hash-code

Annotations
@Override
createDomainResultback to summary
public <T> DomainResult<T> createDomainResult(NavigablePath navigablePath, TableGroup tableGroup, String resultVariable, DomainResultCreationState creationState)

Implements org.hibernate.metamodel.mapping.ModelPart.createDomainResult.

Doc from org.hibernate.metamodel.mapping.ModelPart.createDomainResult.

Create a DomainResult for a specific reference to this ModelPart.

Annotations
@Override
disassembleback to summary
public Object disassemble(Object value, SharedSessionContractImplementor session)

Overrides default org.hibernate.metamodel.mapping.BasicValuedMapping.disassemble.

Implements org.hibernate.metamodel.mapping.Bindable.disassemble.

Doc from org.hibernate.metamodel.mapping.Bindable.disassemble.

Breaks down a value of J into its simple pieces. E.g., an embedded value gets broken down into an array of its attribute state; a basic value converts to itself; etc.

Generally speaking, this is the form in which entity state is kept relative to a Session via EntityEntry.

@Entity class Person {
    @Id Integer id;
    @Embedded Name name;
    int age;
}

@Embeddable class Name {
    String familiarName;
    String familyName;
}

At the top level, we would want to disassemble a Person value, so we'd ask the Bindable for the Person entity to disassemble. Given a Person value:

Person( id=1, name=Name( 'Steve', 'Ebersole' ), 28 )

this disassemble would result in a multidimensional array:

[ ["Steve", "Ebersole"], 28 ]

Note that the identifier is not part of this disassembled state. Note also how the embedded value results in a sub-array.

Annotations
@Override
extractNaturalIdFromEntityback to summary
public Object extractNaturalIdFromEntity(Object entity)

Implements org.hibernate.metamodel.mapping.NaturalIdMapping.extractNaturalIdFromEntity.

Doc from org.hibernate.metamodel.mapping.NaturalIdMapping.extractNaturalIdFromEntity.

Given an entity instance, extract the normalized natural id representation

Parameters
entity:Object

The entity instance

Returns:Object

The extracted natural id values

Annotations
@Override
extractNaturalIdFromEntityStateback to summary
public Object extractNaturalIdFromEntityState(Object[] state)

Implements org.hibernate.metamodel.mapping.NaturalIdMapping.extractNaturalIdFromEntityState.

Doc from org.hibernate.metamodel.mapping.NaturalIdMapping.extractNaturalIdFromEntityState.

Given an array of "full entity state", extract the normalized natural id representation

Parameters
state:Object[]

The attribute state array

Returns:Object

The extracted natural id values. This is a normalized

Annotations
@Override
forEachDisassembledJdbcValueback to summary
public <X, Y> int forEachDisassembledJdbcValue(Object value, int offset, X x, Y y, Bindable.JdbcValuesBiConsumer<X, Y> valuesConsumer, SharedSessionContractImplementor session)

Implements org.hibernate.metamodel.mapping.Bindable.forEachDisassembledJdbcValue.

Doc from org.hibernate.metamodel.mapping.Bindable.forEachDisassembledJdbcValue.

Like forEachDisassembledJdbcValue(Object, Object, Object, JdbcValuesBiConsumer, SharedSessionContractImplementor), but additionally receives an offset by which the selectionIndex is incremented when calling JdbcValuesBiConsumer#consume(int, Object, Object, Object, JdbcMapping).

Annotations
@Override
forEachJdbcTypeback to summary
public int forEachJdbcType(int offset, IndexedConsumer<JdbcMapping> action)

Implements org.hibernate.metamodel.mapping.JdbcMappingContainer.forEachJdbcType.

Doc from org.hibernate.metamodel.mapping.JdbcMappingContainer.forEachJdbcType.

Visit each JdbcMapping starting from the given offset

Annotations
@Override
forEachJdbcValueback to summary
public <X, Y> int forEachJdbcValue(Object value, int offset, X x, Y y, Bindable.JdbcValuesBiConsumer<X, Y> valuesConsumer, SharedSessionContractImplementor session)

Overrides default org.hibernate.metamodel.mapping.Bindable.forEachJdbcValue.

Doc from org.hibernate.metamodel.mapping.Bindable.forEachJdbcValue.

Visit each constituent JDBC value extracted from the entity instance itself. Short-hand form of calling disassemble and piping its result to forEachDisassembledJdbcValue(Object, int, JdbcValuesConsumer, SharedSessionContractImplementor)

Annotations
@Override
forEachSelectableback to summary
public int forEachSelectable(int offset, SelectableConsumer consumer)

Overrides default org.hibernate.metamodel.mapping.ModelPart.forEachSelectable.

Doc from org.hibernate.metamodel.mapping.ModelPart.forEachSelectable.

Visits each selectable mapping with the selectable index offset by the given value. Returns the amount of jdbc types that have been visited.

Annotations
@Override
getAttributeback to summary
public SingularAttributeMapping getAttribute()
getJavaTypeback to summary
public JavaType<?> getJavaType()

Implements org.hibernate.metamodel.mapping.ModelPart.getJavaType.

Doc from org.hibernate.metamodel.mapping.ModelPart.getJavaType.

The Java type for this part. Generally equivalent to MappingType#getMappedJavaType() relative to getPartMappingType()

Annotations
@Override
getJdbcMappingback to summary
public JdbcMapping getJdbcMapping(int index)

Overrides default org.hibernate.metamodel.mapping.BasicValuedMapping.getJdbcMapping.

Implements org.hibernate.metamodel.mapping.JdbcMappingContainer.getJdbcMapping.

Annotations
@Override
getJdbcMappingback to summary
public JdbcMapping getJdbcMapping()

Implements org.hibernate.metamodel.mapping.BasicValuedMapping.getJdbcMapping.

Doc from org.hibernate.metamodel.mapping.SqlExpressible.getJdbcMapping.

Anything that is expressible at the SQL AST level would be of basic type.

Annotations
@Override
getJdbcTypeCountback to summary
public int getJdbcTypeCount()

Overrides default org.hibernate.metamodel.mapping.BasicValuedMapping.getJdbcTypeCount, org.hibernate.metamodel.mapping.Bindable.getJdbcTypeCount.

Doc from org.hibernate.metamodel.mapping.Bindable.getJdbcTypeCount.

The number of JDBC mappings

Annotations
@Override
getMappedTypeback to summary
public MappingType getMappedType()

Implements org.hibernate.metamodel.mapping.ValueMapping.getMappedType.

Doc from org.hibernate.metamodel.mapping.ValueMapping.getMappedType.

Descriptor for the type of this mapping

Annotations
@Override
getNaturalIdAttributesback to summary
public List<SingularAttributeMapping> getNaturalIdAttributes()

Implements org.hibernate.metamodel.mapping.NaturalIdMapping.getNaturalIdAttributes.

Doc from org.hibernate.metamodel.mapping.NaturalIdMapping.getNaturalIdAttributes.

The attribute(s) making up the natural-id.

Annotations
@Override
getPartMappingTypeback to summary
public MappingType getPartMappingType()

Implements org.hibernate.metamodel.mapping.ModelPart.getPartMappingType.

Doc from org.hibernate.metamodel.mapping.ModelPart.getPartMappingType.

The type for this part.

Annotations
@Override
getSingleJdbcMappingback to summary
public JdbcMapping getSingleJdbcMapping()

Overrides default org.hibernate.metamodel.mapping.BasicValuedMapping.getSingleJdbcMapping, org.hibernate.metamodel.mapping.JdbcMappingContainer.getSingleJdbcMapping.

Annotations
@Override
getTypeConfigurationback to summary
public TypeConfiguration getTypeConfiguration()

Implements org.hibernate.type.descriptor.java.JavaType.CoercionContext.getTypeConfiguration.

Annotations
@Override
hasPartitionedSelectionMappingback to summary
public boolean hasPartitionedSelectionMapping()

Implements org.hibernate.metamodel.mapping.ModelPart.hasPartitionedSelectionMapping.

Annotations
@Override
makeLoaderback to summary
public NaturalIdLoader<?> makeLoader(EntityMappingType entityDescriptor)

Implements org.hibernate.metamodel.mapping.NaturalIdMapping.makeLoader.

Doc from org.hibernate.metamodel.mapping.NaturalIdMapping.makeLoader.

Make a loader capable of loading a single entity by natural-id

Annotations
@Override
makeMultiLoaderback to summary
public MultiNaturalIdLoader<?> makeMultiLoader(EntityMappingType entityDescriptor)

Implements org.hibernate.metamodel.mapping.NaturalIdMapping.makeMultiLoader.

Doc from org.hibernate.metamodel.mapping.NaturalIdMapping.makeMultiLoader.

Make a loader capable of loading multiple entities by natural-id

Annotations
@Override
normalizeIncomingValueback to summary
public Object normalizeIncomingValue(Object naturalIdToLoad)
Annotations
@SuppressWarnings:rawtypes
normalizeInputback to summary
public Object normalizeInput(Object incoming)

Implements org.hibernate.metamodel.mapping.NaturalIdMapping.normalizeInput.

Doc from org.hibernate.metamodel.mapping.NaturalIdMapping.normalizeInput.

Normalize a user-provided natural-id value into the representation Hibernate uses internally

Parameters
incoming:Object

The user-supplied value

Returns:Object

The normalized, internal representation

Annotations
@Override
validateInternalFormback to summary
public void validateInternalForm(Object naturalIdValue)

Implements org.hibernate.metamodel.mapping.NaturalIdMapping.validateInternalForm.

Doc from org.hibernate.metamodel.mapping.NaturalIdMapping.validateInternalForm.

Validates a natural id value(s) for the described natural-id based on the expected internal representation

Annotations
@Override
verifyFlushStateback to summary
public void verifyFlushState(Object id, Object[] currentState, Object[] loadedState, SharedSessionContractImplementor session)

Implements org.hibernate.metamodel.mapping.NaturalIdMapping.verifyFlushState.

Doc from org.hibernate.metamodel.mapping.NaturalIdMapping.verifyFlushState.

Verify the natural-id value(s) we are about to flush to the database

Annotations
@Override