Class ToOneAttributeMapping
- java.lang.Object
-
- org.hibernate.metamodel.mapping.internal.AbstractAttributeMapping
-
- org.hibernate.metamodel.mapping.internal.AbstractStateArrayContributorMapping
-
- org.hibernate.metamodel.mapping.internal.AbstractSingularAttributeMapping
-
- org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping
-
- All Implemented Interfaces:
Association,AttributeMapping,Bindable,EntityAssociationMapping,EntityValuedModelPart,JdbcMappingContainer,MappingModelExpressible,ModelPart,ModelPartContainer,PropertyBasedMapping,SelectableMappings,SingularAttributeMapping,ValuedModelPart,ValueMapping,TableGroupJoinProducer,TableGroupProducer,DatabaseSnapshotContributor,EntityValuedFetchable,Fetchable,FetchableContainer,FetchOptions,FetchStyleAccess,FetchTimingAccess,JavaTypedExpressible,MutabilityPlanExposer
public class ToOneAttributeMapping extends AbstractSingularAttributeMapping implements EntityValuedFetchable, EntityAssociationMapping, TableGroupJoinProducer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classToOneAttributeMapping.Cardinality-
Nested classes/interfaces inherited from interface org.hibernate.metamodel.mapping.Bindable
Bindable.JdbcValuesConsumer
-
Nested classes/interfaces inherited from interface org.hibernate.metamodel.mapping.ModelPart
ModelPart.IndexedJdbcValueConsumer, ModelPart.JdbcValueConsumer
-
-
Constructor Summary
Constructors Constructor Description ToOneAttributeMapping(String name, NavigableRole navigableRole, int stateArrayPosition, int fetchableIndex, ToOne bootValue, AttributeMetadata attributeMetadata, FetchTiming mappedFetchTiming, FetchStyle mappedFetchStyle, EntityMappingType entityMappingType, ManagedMappingType declaringType, EntityPersister declaringEntityPersister, PropertyAccess propertyAccess)ToOneAttributeMapping(String name, NavigableRole navigableRole, int stateArrayPosition, int fetchableIndex, ToOne bootValue, AttributeMetadata attributeMetadata, FetchOptions mappedFetchOptions, EntityMappingType entityMappingType, ManagedMappingType declaringType, EntityPersister declaringEntityPersister, PropertyAccess propertyAccess)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidaddPrefixedPropertyNames(Set<String> targetKeyPropertyNames, String prefix, Type type, SessionFactoryImplementor factory)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.voidbreakDownJdbcValues(Object domainValue, ModelPart.JdbcValueConsumer valueConsumer, SharedSessionContractImplementor session)ToOneAttributeMappingcopy(ManagedMappingType declaringType, TableGroupProducer declaringTableGroupProducer)LazyTableGroupcreateRootTableGroupJoin(NavigablePath navigablePath, TableGroup lhs, String explicitSourceAlias, SqlAstJoinType requestedJoinType, boolean fetched, Consumer<Predicate> predicateConsumer, SqlAliasBaseGenerator aliasBaseGenerator, SqlExpressionResolver sqlExpressionResolver, FromClauseAccess fromClauseAccess, SqlAstCreationContext creationContext)Create a TableGroupJoin as defined for this producer, but as root TableGroup.<T> DomainResult<T>createSnapshotDomainResult(NavigablePath navigablePath, TableGroup tableGroup, String resultVariable, DomainResultCreationState creationState)Create a DomainResult to be used when selecting snapshots from the database.TableGroupcreateTableGroupInternal(boolean canUseInnerJoins, NavigablePath navigablePath, boolean fetched, String sourceAlias, SqlAliasBase sqlAliasBase, SqlExpressionResolver sqlExpressionResolver, SqlAstCreationContext creationContext)TableGroupJoincreateTableGroupJoin(NavigablePath navigablePath, TableGroup lhs, String explicitSourceAlias, SqlAstJoinType requestedJoinType, boolean fetched, boolean addsPredicate, SqlAliasBaseGenerator aliasBaseGenerator, SqlExpressionResolver sqlExpressionResolver, FromClauseAccess fromClauseAccess, SqlAstCreationContext creationContext)Create a TableGroupJoin as defined for this producer The sqlAstJoinType may be null to signal that the join is for an implicit path.Objectdisassemble(Object value, SharedSessionContractImplementor session)ModelPartfindSubPart(String name)ModelPartfindSubPart(String name, EntityMappingType targetType)intforEachDisassembledJdbcValue(Object value, int offset, Bindable.JdbcValuesConsumer valuesConsumer, SharedSessionContractImplementor session)intforEachJdbcType(int offset, IndexedConsumer<JdbcMapping> action)Visit each JdbcMapping starting from the given offsetintforEachJdbcValue(Object value, int offset, Bindable.JdbcValuesConsumer consumer, SharedSessionContractImplementor session)intforEachSelectable(int offset, SelectableConsumer consumer)Visit each contained selectable mapping.EntityFetchgenerateFetch(FetchParent fetchParent, NavigablePath fetchablePath, FetchTiming fetchTiming, boolean selected, String resultVariable, DomainResultCreationState creationState)Generates a Fetch of this fetchableEntityMappingTypegetAssociatedEntityMappingType()StringgetBidirectionalAttributeName()ToOneAttributeMapping.CardinalitygetCardinality()StringgetContainingTableExpression()The table which contains the columns mapped by this valueSqlAstJoinTypegetDefaultSqlAstJoinType(TableGroup parentTableGroup)EntityMappingTypegetEntityMappingType()The descriptor of the entity that is the type for this partFetchablegetFetchable(int position)ForeignKeyDescriptorgetForeignKeyDescriptor()The descriptor, allowing access to column(s), etcStringgetIdentifyingColumnsTableExpression()intgetJdbcTypeCount()The number of JDBC mappingsModelPartgetKeyTargetMatchPart()The model sub-part relative to the associated entity type that is the target of this association's foreign-keyEntityMappingTypegetMappedType()Descriptor for the type of this mappingNavigableRolegetNavigableRole()NotFoundActiongetNotFoundAction()intgetNumberOfFetchables()The number of fetchables in the containerStringgetReferencedPropertyName()SelectableMappinggetSelectable(int columnIndex)Get the selectable at the given positionForeignKeyDescriptor.NaturegetSideNature()Indicates which "side" of the foreign-key this association describesStringgetSqlAliasStem()Get the "stem" used as the base for generating SQL table aliases for table references that are part of the TableGroup being generatedStringgetTargetKeyPropertyName()Set<String>getTargetKeyPropertyNames()booleanhasNotFoundAction()booleanhasPartitionedSelectionMapping()protected booleanisBidirectionalAttributeName(NavigablePath parentNavigablePath, ModelPart parentModelPart, NavigablePath fetchablePath, DomainResultCreationState creationState)booleanisFkOptimizationAllowed()booleanisIgnoreNotFound()booleanisInternalLoadNullable()booleanisNullable()booleanisOptional()booleanisReferenceToPrimaryKey()booleanisSimpleJoinPredicate(Predicate predicate)Returns whether the given predicate is a simple join predicate for this attribute.booleanisUnwrapProxy()FetchresolveCircularFetch(NavigablePath fetchablePath, FetchParent fetchParent, FetchTiming fetchTiming, DomainResultCreationState creationState)Check whether this Fetchable is considered a circular fetch.voidsetForeignKeyDescriptor(ForeignKeyDescriptor foreignKeyDescriptor)voidsetIdentifyingColumnsTableExpression(String tableExpression)StringtoString()-
Methods inherited from class org.hibernate.metamodel.mapping.internal.AbstractSingularAttributeMapping
getGenerator, getPropertyAccess
-
Methods inherited from class org.hibernate.metamodel.mapping.internal.AbstractStateArrayContributorMapping
getAttributeMetadata, getFetchableName, getMappedFetchOptions, getStateArrayPosition, getStyle, getTiming
-
Methods inherited from class org.hibernate.metamodel.mapping.internal.AbstractAttributeMapping
getAttributeName, getDeclaringType, getFetchableKey, getJavaType, getPartMappingType
-
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, compare, findContainingEntityMapping, getAttributeMetadata, getAttributeName, getDeclaringType, getExposedMutabilityPlan, getPartName, getStateArrayPosition, getValue, setValue
-
Methods inherited from interface org.hibernate.metamodel.mapping.Bindable
forEachDisassembledJdbcValue, forEachJdbcType, forEachJdbcValue
-
Methods inherited from interface org.hibernate.metamodel.mapping.EntityAssociationMapping
getFetchableName, incrementFetchDepth
-
Methods inherited from interface org.hibernate.metamodel.mapping.EntityValuedModelPart
createDomainResult, forEachSubPart, visitSubParts
-
Methods inherited from interface org.hibernate.sql.results.graph.Fetchable
getFetchableKey, getMappedFetchOptions
-
Methods inherited from interface org.hibernate.sql.results.graph.FetchableContainer
getKeyFetchable, getNumberOfFetchableKeys, getNumberOfKeyFetchables, getSelectableIndex, visitFetchables, visitFetchables, visitFetchables, visitKeyFetchables, visitKeyFetchables, visitKeyFetchables
-
Methods inherited from interface org.hibernate.metamodel.mapping.ModelPart
areEqual, decompose, getJavaType, getPartMappingType, isVirtual
-
Methods inherited from interface org.hibernate.metamodel.mapping.ModelPartContainer
findByPath, forEachSubPart
-
Methods inherited from interface org.hibernate.sql.ast.tree.from.TableGroupJoinProducer
createRootTableGroupJoin, createTableGroupJoin
-
Methods inherited from interface org.hibernate.sql.ast.tree.from.TableGroupProducer
containsTableReference
-
Methods inherited from interface org.hibernate.metamodel.mapping.ValuedModelPart
forEachInsertable, forEachSelectable, forEachUpdatable, getJdbcMappings
-
Methods inherited from interface org.hibernate.metamodel.mapping.ValueMapping
getExpressibleJavaType, treatAs
-
-
-
-
Constructor Detail
-
ToOneAttributeMapping
public ToOneAttributeMapping(String name, NavigableRole navigableRole, int stateArrayPosition, int fetchableIndex, ToOne bootValue, AttributeMetadata attributeMetadata, FetchOptions mappedFetchOptions, EntityMappingType entityMappingType, ManagedMappingType declaringType, EntityPersister declaringEntityPersister, PropertyAccess propertyAccess)
-
ToOneAttributeMapping
public ToOneAttributeMapping(String name, NavigableRole navigableRole, int stateArrayPosition, int fetchableIndex, ToOne bootValue, AttributeMetadata attributeMetadata, FetchTiming mappedFetchTiming, FetchStyle mappedFetchStyle, EntityMappingType entityMappingType, ManagedMappingType declaringType, EntityPersister declaringEntityPersister, PropertyAccess propertyAccess)
-
-
Method Detail
-
addPrefixedPropertyNames
public static void addPrefixedPropertyNames(Set<String> targetKeyPropertyNames, String prefix, Type type, SessionFactoryImplementor factory)
-
copy
public ToOneAttributeMapping copy(ManagedMappingType declaringType, TableGroupProducer declaringTableGroupProducer)
-
setForeignKeyDescriptor
public void setForeignKeyDescriptor(ForeignKeyDescriptor foreignKeyDescriptor)
-
getIdentifyingColumnsTableExpression
public String getIdentifyingColumnsTableExpression()
-
setIdentifyingColumnsTableExpression
public void setIdentifyingColumnsTableExpression(String tableExpression)
-
getForeignKeyDescriptor
public ForeignKeyDescriptor getForeignKeyDescriptor()
Description copied from interface:AssociationThe descriptor, allowing access to column(s), etc- Specified by:
getForeignKeyDescriptorin interfaceAssociation
-
getSideNature
public ForeignKeyDescriptor.Nature getSideNature()
Description copied from interface:AssociationIndicates which "side" of the foreign-key this association describes- Specified by:
getSideNaturein interfaceAssociation
-
isReferenceToPrimaryKey
public boolean isReferenceToPrimaryKey()
- Specified by:
isReferenceToPrimaryKeyin interfaceEntityAssociationMapping
-
isFkOptimizationAllowed
public boolean isFkOptimizationAllowed()
- Specified by:
isFkOptimizationAllowedin interfaceEntityAssociationMapping
-
hasPartitionedSelectionMapping
public boolean hasPartitionedSelectionMapping()
- Specified by:
hasPartitionedSelectionMappingin interfaceModelPart
-
getReferencedPropertyName
public String getReferencedPropertyName()
-
getTargetKeyPropertyName
public String getTargetKeyPropertyName()
-
getCardinality
public ToOneAttributeMapping.Cardinality getCardinality()
-
getMappedType
public EntityMappingType getMappedType()
Description copied from interface:ValueMappingDescriptor for the type of this mapping- Specified by:
getMappedTypein interfaceValueMapping
-
getEntityMappingType
public EntityMappingType getEntityMappingType()
Description copied from interface:EntityValuedModelPartThe descriptor of the entity that is the type for this part- Specified by:
getEntityMappingTypein interfaceEntityValuedModelPart
-
getNavigableRole
public NavigableRole getNavigableRole()
- Specified by:
getNavigableRolein interfaceModelPart- See Also:
ModelPart.getPartName()
-
findSubPart
public ModelPart findSubPart(String name)
- Specified by:
findSubPartin interfaceEntityValuedModelPart
-
findSubPart
public ModelPart findSubPart(String name, EntityMappingType targetType)
- Specified by:
findSubPartin interfaceEntityValuedModelPart- Specified by:
findSubPartin interfaceModelPartContainer
-
resolveCircularFetch
public Fetch resolveCircularFetch(NavigablePath fetchablePath, FetchParent fetchParent, FetchTiming fetchTiming, DomainResultCreationState creationState)
Description copied from interface:FetchableCheck whether this Fetchable is considered a circular fetch.- Specified by:
resolveCircularFetchin interfaceFetchable- Parameters:
fetchablePath- The overall path within the graph- Returns:
- The Fetch representing the circularity;
nullindicates the fetch is not circular
-
isBidirectionalAttributeName
protected boolean isBidirectionalAttributeName(NavigablePath parentNavigablePath, ModelPart parentModelPart, NavigablePath fetchablePath, DomainResultCreationState creationState)
-
getBidirectionalAttributeName
public String getBidirectionalAttributeName()
-
generateFetch
public EntityFetch 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 interfaceEntityValuedFetchable- Specified by:
generateFetchin interfaceFetchable- Parameters:
fetchParent- The parent of the Fetch we are generatingfetchablePath- The overall path within the graphfetchTiming- The requested fetch timing
-
createSnapshotDomainResult
public <T> DomainResult<T> createSnapshotDomainResult(NavigablePath navigablePath, TableGroup tableGroup, String resultVariable, DomainResultCreationState creationState)
Description copied from interface:DatabaseSnapshotContributorCreate a DomainResult to be used when selecting snapshots from the database.By default, simply use
ModelPart.createDomainResult(org.hibernate.spi.NavigablePath, org.hibernate.sql.ast.tree.from.TableGroup, java.lang.String, org.hibernate.sql.results.graph.DomainResultCreationState)- Specified by:
createSnapshotDomainResultin interfaceDatabaseSnapshotContributor
-
getDefaultSqlAstJoinType
public SqlAstJoinType getDefaultSqlAstJoinType(TableGroup parentTableGroup)
- Specified by:
getDefaultSqlAstJoinTypein interfaceTableGroupJoinProducer
-
isSimpleJoinPredicate
public boolean isSimpleJoinPredicate(Predicate predicate)
Description copied from interface:TableGroupJoinProducerReturns whether the given predicate is a simple join predicate for this attribute. This is useful to understand if a predicate has additional conjunctions other than the FK related predicate.- Specified by:
isSimpleJoinPredicatein interfaceTableGroupJoinProducer
-
getNumberOfFetchables
public int getNumberOfFetchables()
Description copied from interface:FetchableContainerThe number of fetchables in the container- Specified by:
getNumberOfFetchablesin interfaceFetchableContainer
-
getFetchable
public Fetchable getFetchable(int position)
- Specified by:
getFetchablein interfaceFetchableContainer
-
createTableGroupJoin
public TableGroupJoin createTableGroupJoin(NavigablePath navigablePath, TableGroup lhs, String explicitSourceAlias, SqlAstJoinType requestedJoinType, boolean fetched, boolean addsPredicate, SqlAliasBaseGenerator aliasBaseGenerator, SqlExpressionResolver sqlExpressionResolver, FromClauseAccess fromClauseAccess, SqlAstCreationContext creationContext)
Description copied from interface:TableGroupJoinProducerCreate a TableGroupJoin as defined for this producer The sqlAstJoinType may be null to signal that the join is for an implicit path. When addsPredicate istrue, the SQM join for the attribute contains an explicitONclause, and isfalseotherwise.- Specified by:
createTableGroupJoinin interfaceTableGroupJoinProducer
-
createRootTableGroupJoin
public LazyTableGroup createRootTableGroupJoin(NavigablePath navigablePath, TableGroup lhs, String explicitSourceAlias, SqlAstJoinType requestedJoinType, boolean fetched, Consumer<Predicate> predicateConsumer, SqlAliasBaseGenerator aliasBaseGenerator, SqlExpressionResolver sqlExpressionResolver, FromClauseAccess fromClauseAccess, SqlAstCreationContext creationContext)
Description copied from interface:TableGroupJoinProducerCreate a TableGroupJoin as defined for this producer, but as root TableGroup. The main purpose of this is for correlating an association in a subquery i.e. `... alias where exists (select 1 from SomeEntity e where alias.association.attr = 1)`. The sqlAstJoinType may be null to signal that the join is for an implicit path.- Specified by:
createRootTableGroupJoinin interfaceTableGroupJoinProducer
-
createTableGroupInternal
public TableGroup createTableGroupInternal(boolean canUseInnerJoins, NavigablePath navigablePath, boolean fetched, String sourceAlias, SqlAliasBase sqlAliasBase, SqlExpressionResolver sqlExpressionResolver, SqlAstCreationContext creationContext)
-
getSqlAliasStem
public String getSqlAliasStem()
Description copied from interface:TableGroupProducerGet the "stem" used as the base for generating SQL table aliases for table references that are part of the TableGroup being generatedNote that this is a metadata-ive value. It is only ever used internal to the producer producing its TableGroup.
- Specified by:
getSqlAliasStemin interfaceTableGroupProducer- See Also:
SqlAliasBaseManager.createSqlAliasBase(java.lang.String)
-
isNullable
public boolean isNullable()
-
isOptional
public boolean isOptional()
- Specified by:
isOptionalin interfaceEntityValuedFetchable
-
isInternalLoadNullable
public boolean isInternalLoadNullable()
-
getNotFoundAction
public NotFoundAction getNotFoundAction()
-
isIgnoreNotFound
public boolean isIgnoreNotFound()
-
hasNotFoundAction
public boolean hasNotFoundAction()
-
isUnwrapProxy
public boolean isUnwrapProxy()
- Specified by:
isUnwrapProxyin interfaceEntityValuedFetchable
-
getAssociatedEntityMappingType
public EntityMappingType getAssociatedEntityMappingType()
- Specified by:
getAssociatedEntityMappingTypein interfaceEntityAssociationMapping
-
getKeyTargetMatchPart
public ModelPart getKeyTargetMatchPart()
Description copied from interface:EntityAssociationMappingThe model sub-part relative to the associated entity type that is the target of this association's foreign-key- Specified by:
getKeyTargetMatchPartin interfaceEntityAssociationMapping
-
breakDownJdbcValues
public void breakDownJdbcValues(Object domainValue, ModelPart.JdbcValueConsumer valueConsumer, SharedSessionContractImplementor session)
- Specified by:
breakDownJdbcValuesin interfaceModelPart
-
forEachSelectable
public int forEachSelectable(int offset, SelectableConsumer consumer)Description copied from interface:SelectableMappingsVisit each contained selectable mapping. As the selectables are iterated, we call `SelectionConsumer` passing along `offset` + our current iteration index. The return is the number of selectables we directly contain- Specified by:
forEachSelectablein interfaceModelPart- Specified by:
forEachSelectablein interfaceSelectableMappings- Specified by:
forEachSelectablein interfaceValuedModelPart- See Also:
SelectableConsumer.accept(int, SelectableMapping)
-
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 interfaceEntityValuedModelPart- 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 interfaceEntityValuedModelPart- 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 interfaceValuedModelPart
-
getJdbcTypeCount
public int getJdbcTypeCount()
Description copied from interface:BindableThe number of JDBC mappings- Specified by:
getJdbcTypeCountin interfaceBindable- Specified by:
getJdbcTypeCountin interfaceEntityValuedModelPart- Specified by:
getJdbcTypeCountin interfaceJdbcMappingContainer- Specified by:
getJdbcTypeCountin interfaceSelectableMappings- Specified by:
getJdbcTypeCountin interfaceValuedModelPart
-
getSelectable
public SelectableMapping getSelectable(int columnIndex)
Description copied from interface:SelectableMappingsGet the selectable at the given position- Specified by:
getSelectablein interfaceSelectableMappings
-
forEachJdbcType
public int forEachJdbcType(int offset, IndexedConsumer<JdbcMapping> action)Description copied from interface:JdbcMappingContainerVisit each JdbcMapping starting from the given offset- Specified by:
forEachJdbcTypein interfaceEntityValuedModelPart- Specified by:
forEachJdbcTypein interfaceJdbcMappingContainer
-
disassemble
public Object disassemble(Object value, SharedSessionContractImplementor session)
- Specified by:
disassemblein interfaceBindable- Specified by:
disassemblein interfaceEntityValuedModelPart- See Also:
As an example, consider the following domain model: ````
-
forEachDisassembledJdbcValue
public int forEachDisassembledJdbcValue(Object value, int offset, Bindable.JdbcValuesConsumer valuesConsumer, SharedSessionContractImplementor session)
- Specified by:
forEachDisassembledJdbcValuein interfaceBindable- Specified by:
forEachDisassembledJdbcValuein interfaceEntityValuedModelPart
-
forEachJdbcValue
public int forEachJdbcValue(Object value, int offset, Bindable.JdbcValuesConsumer consumer, SharedSessionContractImplementor session)
- Specified by:
forEachJdbcValuein interfaceBindable- Specified by:
forEachJdbcValuein interfaceEntityValuedModelPart
-
-