Class BasicEntityIdentifierMappingImpl
- java.lang.Object
-
- org.hibernate.metamodel.mapping.internal.BasicEntityIdentifierMappingImpl
-
- All Implemented Interfaces:
AttributeMapping,AttributeMetadata,BasicEntityIdentifierMapping,BasicValuedMapping,BasicValuedModelPart,Bindable,EntityIdentifierMapping,SingleAttributeIdentifierMapping,JdbcMappingContainer,MappingModelExpressible,ModelPart,OwnedValuedModelPart,PropertyBasedMapping,SelectableMapping,SelectableMappings,SqlExpressible,SqlTypedMapping,ValuedModelPart,ValueMapping,DatabaseSnapshotContributor,Fetchable,FetchOptions,FetchStyleAccess,FetchTimingAccess,JavaTypedExpressible,MutabilityPlanExposer
public class BasicEntityIdentifierMappingImpl extends Object implements BasicEntityIdentifierMapping, FetchOptions
Mapping of a simple identifier- See Also:
Id
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.hibernate.metamodel.mapping.Bindable
Bindable.JdbcValuesBiConsumer<X,Y>, Bindable.JdbcValuesConsumer
-
Nested classes/interfaces inherited from interface org.hibernate.metamodel.mapping.EntityIdentifierMapping
EntityIdentifierMapping.Nature
-
Nested classes/interfaces inherited from interface org.hibernate.metamodel.mapping.ModelPart
ModelPart.JdbcValueBiConsumer<X,Y>, ModelPart.JdbcValueConsumer
-
-
Field Summary
-
Fields inherited from interface org.hibernate.metamodel.mapping.EntityIdentifierMapping
ID_ROLE_NAME, LEGACY_ID_NAME
-
-
Constructor Summary
Constructors Constructor Description BasicEntityIdentifierMappingImpl(EntityPersister entityPersister, Supplier<?> instanceCreator, String attributeName, String rootTable, String pkColumnName, String columnDefinition, Long length, Integer precision, Integer scale, boolean insertable, boolean updateable, BasicType<?> idType, MappingModelCreationProcess creationProcess)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddToCacheKey(MutableCacheKeyBuilder cacheKey, Object value, SharedSessionContractImplementor session)Add to the MutableCacheKey the values obtained disassembling the value and the hasCode generated from the disassembled value.voidapplySqlSelections(NavigablePath navigablePath, TableGroup tableGroup, DomainResultCreationState creationState)Apply SQL selections for a specific reference to this ModelPart outside the domain query's root select clause.voidapplySqlSelections(NavigablePath navigablePath, TableGroup tableGroup, DomainResultCreationState creationState, BiConsumer<SqlSelection,JdbcMapping> selectionConsumer)Apply SQL selections for a specific reference to this ModelPart outside the domain query's root select clause.<X,Y>
intbreakDownJdbcValues(Object domainValue, int offset, X x, Y y, ModelPart.JdbcValueBiConsumer<X,Y> valueConsumer, SharedSessionContractImplementor session)Breaks down the domain value to its constituent JDBC values.<T> DomainResult<T>createDomainResult(NavigablePath navigablePath, TableGroup tableGroup, String resultVariable, DomainResultCreationState creationState)Create a DomainResult for a specific reference to this ModelPart.Objectdisassemble(Object value, SharedSessionContractImplementor session)Breaks down a value ofJinto its simple pieces.EntityMappingTypefindContainingEntityMapping()<X,Y>
intforEachDisassembledJdbcValue(Object value, int offset, X x, Y y, Bindable.JdbcValuesBiConsumer<X,Y> valuesConsumer, SharedSessionContractImplementor session)LikeBindable.forEachDisassembledJdbcValue(Object, Object, Object, JdbcValuesBiConsumer, SharedSessionContractImplementor), but additionally receives an offset by which the selectionIndex is incremented when callingBindable.JdbcValuesBiConsumer.consume(int, Object, Object, Object, JdbcMapping).intforEachJdbcType(int offset, IndexedConsumer<JdbcMapping> action)Visit each JdbcMapping starting from the given offsetintforEachSelectable(int offset, SelectableConsumer consumer)Visits each selectable mapping with the selectable index offset by the given value.FetchgenerateFetch(FetchParent fetchParent, NavigablePath fetchablePath, FetchTiming fetchTiming, boolean selected, String resultVariable, DomainResultCreationState creationState)Generates a Fetch of this fetchableStringgetAttributeName()The name of the attribute defining the id, if oneStringgetColumnDefinition()StringgetContainingTableExpression()The table which contains the columns mapped by this valueStringgetCustomReadExpression()The selection's read expression accounting for formula treatment as well asColumnTransformer.read()StringgetCustomWriteExpression()The selection's write expression accountingColumnTransformer.write()StringgetFetchableName()The name of the fetchable.ObjectgetIdentifier(Object entity)Extract the identifier from an instance of the entityJavaType<?>getJavaType()The Java type for this part.JdbcMappinggetJdbcMapping()Anything that is expressible at the SQL AST level would be of basic type.LonggetLength()FetchOptionsgetMappedFetchOptions()The configured fetch timing and styleMappingTypegetMappedType()Descriptor for the type of this mappingEntityIdentifierMapping.NaturegetNature()NavigableRolegetNavigableRole()MappingTypegetPartMappingType()The type for this part.IntegergetPrecision()PropertyAccessgetPropertyAccess()Access to the identifier attribute's PropertyAccessIntegergetScale()StringgetSelectionExpression()The selection's expression.FetchStylegetStyle()IntegergetTemporalPrecision()FetchTiminggetTiming()IdentifierValuegetUnsavedStrategy()The strategy for distinguishing between detached and transient state based on the identifier mappingbooleanhasPartitionedSelectionMapping()Objectinstantiate()Instantiate an instance of the identifier.booleanisFormula()Is the mapping a formula instead of a physical column?booleanisInsertable()booleanisNullable()Is the mapping considered nullable?booleanisPartitioned()booleanisUpdateable()voidsetIdentifier(Object entity, Object id, SharedSessionContractImplementor session)Inject an identifier value into an instance of the entityStringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.hibernate.metamodel.mapping.AttributeMapping
asAttributeMapping, asEmbeddedAttributeMapping, asPluralAttributeMapping, compare, getExposedMutabilityPlan, getValue, isEmbeddedAttributeMapping, isPluralAttributeMapping, setValue
-
Methods inherited from interface org.hibernate.metamodel.mapping.AttributeMetadata
getCascadeStyle
-
Methods inherited from interface org.hibernate.metamodel.mapping.BasicEntityIdentifierMapping
getFetchableKey
-
Methods inherited from interface org.hibernate.metamodel.mapping.BasicValuedModelPart
asBasicValuedModelPart, forEachSelectable, getJdbcMapping, getJdbcTypeCount, getSelectable, getSingleJdbcMapping
-
Methods inherited from interface org.hibernate.metamodel.mapping.Bindable
forEachDisassembledJdbcValue, forEachDisassembledJdbcValue, forEachDisassembledJdbcValue, forEachJdbcType, forEachJdbcValue, forEachJdbcValue, forEachJdbcValue, forEachJdbcValue
-
Methods inherited from interface org.hibernate.sql.results.graph.DatabaseSnapshotContributor
createSnapshotDomainResult
-
Methods inherited from interface org.hibernate.metamodel.mapping.EntityIdentifierMapping
getIdentifier, getIdentifierIfNotUnsaved, isEntityIdentifierMapping
-
Methods inherited from interface org.hibernate.sql.results.graph.Fetchable
incrementFetchDepth, resolveCircularFetch
-
Methods inherited from interface org.hibernate.metamodel.mapping.ModelPart
areEqual, asEntityMappingType, breakDownJdbcValues, decompose, decompose, isVirtual
-
Methods inherited from interface org.hibernate.metamodel.mapping.SelectableMapping
getSelectableName, getSelectablePath, getWriteExpression
-
Methods inherited from interface org.hibernate.metamodel.mapping.internal.SingleAttributeIdentifierMapping
getAttributeMetadata, getDeclaringType, getGenerator, getMutabilityPlan, getPartName, getStateArrayPosition, isIncludedInDirtyChecking, isIncludedInOptimisticLocking, isSelectable, isUpdatable
-
Methods inherited from interface org.hibernate.metamodel.mapping.SqlTypedMapping
isLob, toSize
-
Methods inherited from interface org.hibernate.metamodel.mapping.ValuedModelPart
forEachInsertable, forEachNonFormula, forEachUpdatable, getJdbcTypeCount, getSingleJdbcMapping
-
Methods inherited from interface org.hibernate.metamodel.mapping.ValueMapping
getExpressibleJavaType, treatAs
-
-
-
-
Constructor Detail
-
BasicEntityIdentifierMappingImpl
public BasicEntityIdentifierMappingImpl(EntityPersister entityPersister, Supplier<?> instanceCreator, String attributeName, String rootTable, String pkColumnName, String columnDefinition, Long length, Integer precision, Integer scale, boolean insertable, boolean updateable, BasicType<?> idType, MappingModelCreationProcess creationProcess)
-
-
Method Detail
-
getPropertyAccess
public PropertyAccess getPropertyAccess()
Description copied from interface:SingleAttributeIdentifierMappingAccess to the identifier attribute's PropertyAccess- Specified by:
getPropertyAccessin interfaceAttributeMapping- Specified by:
getPropertyAccessin interfaceAttributeMetadata- Specified by:
getPropertyAccessin interfacePropertyBasedMapping- Specified by:
getPropertyAccessin interfaceSingleAttributeIdentifierMapping
-
getAttributeName
public String getAttributeName()
Description copied from interface:EntityIdentifierMappingThe name of the attribute defining the id, if one- Specified by:
getAttributeNamein interfaceAttributeMapping- Specified by:
getAttributeNamein interfaceEntityIdentifierMapping- Specified by:
getAttributeNamein interfaceSingleAttributeIdentifierMapping
-
getNature
public EntityIdentifierMapping.Nature getNature()
- Specified by:
getNaturein interfaceEntityIdentifierMapping- See Also:
EntityIdentifierMapping.Nature
-
getUnsavedStrategy
public IdentifierValue getUnsavedStrategy()
Description copied from interface:EntityIdentifierMappingThe strategy for distinguishing between detached and transient state based on the identifier mapping- Specified by:
getUnsavedStrategyin interfaceEntityIdentifierMapping- See Also:
EntityVersionMapping.getUnsavedStrategy()
-
getIdentifier
public Object getIdentifier(Object entity)
Description copied from interface:EntityIdentifierMappingExtract the identifier from an instance of the entity- Specified by:
getIdentifierin interfaceEntityIdentifierMapping
-
setIdentifier
public void setIdentifier(Object entity, Object id, SharedSessionContractImplementor session)
Description copied from interface:EntityIdentifierMappingInject an identifier value into an instance of the entity- Specified by:
setIdentifierin interfaceEntityIdentifierMapping
-
instantiate
public Object instantiate()
Description copied from interface:EntityIdentifierMappingInstantiate an instance of the identifier.- Specified by:
instantiatein interfaceEntityIdentifierMapping
-
getPartMappingType
public MappingType getPartMappingType()
Description copied from interface:ModelPartThe type for this part.- Specified by:
getPartMappingTypein interfaceBasicValuedModelPart- Specified by:
getPartMappingTypein interfaceModelPart
-
getMappedType
public MappingType getMappedType()
Description copied from interface:ValueMappingDescriptor for the type of this mapping- Specified by:
getMappedTypein interfaceValueMapping
-
forEachSelectable
public int forEachSelectable(int offset, SelectableConsumer consumer)Description copied from interface:ModelPartVisits each selectable mapping with the selectable index offset by the given value. Returns the amount of jdbc types that have been visited.- Specified by:
forEachSelectablein interfaceBasicValuedModelPart- Specified by:
forEachSelectablein interfaceModelPart- Specified by:
forEachSelectablein interfaceSelectableMappings- Specified by:
forEachSelectablein interfaceValuedModelPart- See Also:
SelectableConsumer.accept(int, SelectableMapping)
-
breakDownJdbcValues
public <X,Y> int breakDownJdbcValues(Object domainValue, int offset, X x, Y y, ModelPart.JdbcValueBiConsumer<X,Y> valueConsumer, SharedSessionContractImplementor session)
Description copied from interface:ModelPartBreaks 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 valuesXandYto the consumer. Returns the amount of jdbc types that have been visited.- Specified by:
breakDownJdbcValuesin interfaceModelPart
-
findContainingEntityMapping
public EntityMappingType findContainingEntityMapping()
- Specified by:
findContainingEntityMappingin interfaceAttributeMapping- Specified by:
findContainingEntityMappingin interfaceModelPart
-
forEachJdbcType
public int forEachJdbcType(int offset, IndexedConsumer<JdbcMapping> action)Description copied from interface:JdbcMappingContainerVisit each JdbcMapping starting from the given offset- Specified by:
forEachJdbcTypein interfaceJdbcMappingContainer
-
getJavaType
public JavaType<?> getJavaType()
Description copied from interface:ModelPartThe Java type for this part. Generally equivalent toMappingType.getMappedJavaType()relative toModelPart.getPartMappingType()- Specified by:
getJavaTypein interfaceModelPart
-
getNavigableRole
public NavigableRole getNavigableRole()
- Specified by:
getNavigableRolein interfaceModelPart- See Also:
ModelPart.getPartName()
-
createDomainResult
public <T> DomainResult<T> createDomainResult(NavigablePath navigablePath, TableGroup tableGroup, String resultVariable, DomainResultCreationState creationState)
Description copied from interface:ModelPartCreate a DomainResult for a specific reference to this ModelPart.- Specified by:
createDomainResultin interfaceModelPart
-
applySqlSelections
public void applySqlSelections(NavigablePath navigablePath, TableGroup tableGroup, DomainResultCreationState creationState)
Description copied from interface:ModelPartApply SQL selections for a specific reference to this ModelPart outside the domain query's root select clause.- Specified by:
applySqlSelectionsin interfaceModelPart
-
applySqlSelections
public void applySqlSelections(NavigablePath navigablePath, TableGroup tableGroup, DomainResultCreationState creationState, BiConsumer<SqlSelection,JdbcMapping> selectionConsumer)
Description copied from interface:ModelPartApply SQL selections for a specific reference to this ModelPart outside the domain query's root select clause.- Specified by:
applySqlSelectionsin interfaceModelPart
-
getContainingTableExpression
public String getContainingTableExpression()
Description copied from interface:ValuedModelPartThe table which contains the columns mapped by this value- Specified by:
getContainingTableExpressionin interfaceSelectableMapping- Specified by:
getContainingTableExpressionin interfaceValuedModelPart
-
getSelectionExpression
public String getSelectionExpression()
Description copied from interface:SelectableMappingThe selection's expression. This is the column name or formula- Specified by:
getSelectionExpressionin interfaceSelectableMapping
-
isFormula
public boolean isFormula()
Description copied from interface:SelectableMappingIs the mapping a formula instead of a physical column?- Specified by:
isFormulain interfaceSelectableMapping
-
isNullable
public boolean isNullable()
Description copied from interface:SelectableMappingIs the mapping considered nullable?- Specified by:
isNullablein interfaceAttributeMetadata- Specified by:
isNullablein interfaceBasicEntityIdentifierMapping- Specified by:
isNullablein interfaceSelectableMapping- Specified by:
isNullablein interfaceSingleAttributeIdentifierMapping
-
isInsertable
public boolean isInsertable()
- Specified by:
isInsertablein interfaceAttributeMetadata- Specified by:
isInsertablein interfaceBasicEntityIdentifierMapping- Specified by:
isInsertablein interfaceSelectableMapping- Specified by:
isInsertablein interfaceSingleAttributeIdentifierMapping
-
isUpdateable
public boolean isUpdateable()
- Specified by:
isUpdateablein interfaceSelectableMapping
-
isPartitioned
public boolean isPartitioned()
- Specified by:
isPartitionedin interfaceSelectableMapping
-
hasPartitionedSelectionMapping
public boolean hasPartitionedSelectionMapping()
- Specified by:
hasPartitionedSelectionMappingin interfaceBasicValuedModelPart- Specified by:
hasPartitionedSelectionMappingin interfaceModelPart
-
getCustomReadExpression
public String getCustomReadExpression()
Description copied from interface:SelectableMappingThe selection's read expression accounting for formula treatment as well asColumnTransformer.read()- Specified by:
getCustomReadExpressionin interfaceSelectableMapping
-
getCustomWriteExpression
public String getCustomWriteExpression()
Description copied from interface:SelectableMappingThe selection's write expression accountingColumnTransformer.write()- Specified by:
getCustomWriteExpressionin interfaceSelectableMapping
-
getColumnDefinition
public String getColumnDefinition()
- Specified by:
getColumnDefinitionin interfaceSqlTypedMapping
-
getLength
public Long getLength()
- Specified by:
getLengthin interfaceSqlTypedMapping
-
getPrecision
public Integer getPrecision()
- Specified by:
getPrecisionin interfaceSqlTypedMapping
-
getTemporalPrecision
public Integer getTemporalPrecision()
- Specified by:
getTemporalPrecisionin interfaceSqlTypedMapping
-
getScale
public Integer getScale()
- Specified by:
getScalein interfaceSqlTypedMapping
-
getJdbcMapping
public JdbcMapping getJdbcMapping()
Description copied from interface:SqlExpressibleAnything that is expressible at the SQL AST level would be of basic type.- Specified by:
getJdbcMappingin interfaceBasicValuedMapping- Specified by:
getJdbcMappingin interfaceSqlExpressible- Specified by:
getJdbcMappingin interfaceSqlTypedMapping
-
getFetchableName
public String getFetchableName()
Description copied from interface:FetchableThe name of the fetchable. This is the part's "local name".- Specified by:
getFetchableNamein interfaceFetchable- See Also:
ModelPart.getNavigableRole(),NavigableRole.getLocalName()
-
getMappedFetchOptions
public FetchOptions getMappedFetchOptions()
Description copied from interface:FetchableThe configured fetch timing and style- Specified by:
getMappedFetchOptionsin interfaceFetchable
-
disassemble
public Object disassemble(Object value, SharedSessionContractImplementor session)
Description copied from interface:BindableBreaks down a value ofJinto 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
Personvalue, so we'd ask theBindablefor thePersonentity to disassemble. Given aPersonvalue: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.
- Specified by:
disassemblein interfaceBasicValuedMapping- Specified by:
disassemblein interfaceBindable- See Also:
EntityEntry
-
addToCacheKey
public void addToCacheKey(MutableCacheKeyBuilder cacheKey, Object value, SharedSessionContractImplementor session)
Description copied from interface:BindableAdd to the MutableCacheKey the values obtained disassembling the value and the hasCode generated from the disassembled value.- Specified by:
addToCacheKeyin interfaceBasicValuedMapping- Specified by:
addToCacheKeyin interfaceBindable- Specified by:
addToCacheKeyin interfaceJavaTypedExpressible- Parameters:
cacheKey- the MutableCacheKey used to add the disassembled value and the hashCodevalue- the value to disassemblesession- the SharedSessionContractImplementor
-
forEachDisassembledJdbcValue
public <X,Y> int forEachDisassembledJdbcValue(Object value, int offset, X x, Y y, Bindable.JdbcValuesBiConsumer<X,Y> valuesConsumer, SharedSessionContractImplementor session)
Description copied from interface:BindableLikeBindable.forEachDisassembledJdbcValue(Object, Object, Object, JdbcValuesBiConsumer, SharedSessionContractImplementor), but additionally receives an offset by which the selectionIndex is incremented when callingBindable.JdbcValuesBiConsumer.consume(int, Object, Object, Object, JdbcMapping).- Specified by:
forEachDisassembledJdbcValuein interfaceBindable
-
generateFetch
public Fetch generateFetch(FetchParent fetchParent, NavigablePath fetchablePath, FetchTiming fetchTiming, boolean selected, String resultVariable, DomainResultCreationState creationState)
Description copied from interface:FetchableGenerates a Fetch of this fetchable- Specified by:
generateFetchin interfaceFetchable- Parameters:
fetchParent- The parent of the Fetch we are generatingfetchablePath- The overall path within the graphfetchTiming- The requested fetch timing
-
getStyle
public FetchStyle getStyle()
- Specified by:
getStylein interfaceFetchStyleAccess
-
getTiming
public FetchTiming getTiming()
- Specified by:
getTimingin interfaceFetchTimingAccess
-
-