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
,Queryable
,SingularAttributeMapping
,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 class
ToOneAttributeMapping.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.JdbcValueConsumer
-
-
Constructor Summary
Constructors Constructor Description ToOneAttributeMapping(String name, NavigableRole navigableRole, int stateArrayPosition, ToOne bootValue, AttributeMetadataAccess attributeMetadataAccess, FetchTiming mappedFetchTiming, FetchStyle mappedFetchStyle, EntityMappingType entityMappingType, ManagedMappingType declaringType, EntityPersister declaringEntityPersister, PropertyAccess propertyAccess)
ToOneAttributeMapping(String name, NavigableRole navigableRole, int stateArrayPosition, ToOne bootValue, AttributeMetadataAccess attributeMetadataAccess, 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 void
addPrefixedPropertyNames(Set<String> targetKeyPropertyNames, String prefix, Type type, SessionFactoryImplementor factory)
void
applySqlSelections(NavigablePath navigablePath, TableGroup tableGroup, DomainResultCreationState creationState)
Apply SQL selections for a specific reference to this ModelPart outside the domain query's root select clause.void
applySqlSelections(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.void
breakDownJdbcValues(Object domainValue, ModelPart.JdbcValueConsumer valueConsumer, SharedSessionContractImplementor session)
ToOneAttributeMapping
copy(ManagedMappingType declaringType, TableGroupProducer declaringTableGroupProducer)
LazyTableGroup
createRootTableGroupJoin(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.TableGroup
createTableGroupInternal(boolean canUseInnerJoins, NavigablePath navigablePath, boolean fetched, String sourceAlias, SqlAliasBase sqlAliasBase, SqlExpressionResolver sqlExpressionResolver, SqlAstCreationContext creationContext)
TableGroupJoin
createTableGroupJoin(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.Object
disassemble(Object value, SharedSessionContractImplementor session)
ModelPart
findSubPart(String name)
ModelPart
findSubPart(String name, EntityMappingType targetType)
For an entity, this form allows for Hibernate's "implicit treat" support - meaning it should find a sub-part whether defined on the entity, its super-type or even one of its sub-types.int
forEachDisassembledJdbcValue(Object value, Clause clause, int offset, Bindable.JdbcValuesConsumer valuesConsumer, SharedSessionContractImplementor session)
int
forEachJdbcType(int offset, IndexedConsumer<JdbcMapping> action)
Visit each JdbcMapping starting from the given offsetint
forEachJdbcValue(Object value, Clause clause, int offset, Bindable.JdbcValuesConsumer consumer, SharedSessionContractImplementor session)
int
forEachSelectable(int offset, SelectableConsumer consumer)
EntityFetch
generateFetch(FetchParent fetchParent, NavigablePath fetchablePath, FetchTiming fetchTiming, boolean selected, String resultVariable, DomainResultCreationState creationState)
Generates a Fetch of this fetchableEntityMappingType
getAssociatedEntityMappingType()
String
getBidirectionalAttributeName()
ToOneAttributeMapping.Cardinality
getCardinality()
SqlAstJoinType
getDefaultSqlAstJoinType(TableGroup parentTableGroup)
EntityMappingType
getEntityMappingType()
Fetchable
getFetchable(int position)
ForeignKeyDescriptor
getForeignKeyDescriptor()
The descriptor, allowing access to column(s), etcString
getIdentifyingColumnsTableExpression()
int
getJdbcTypeCount()
The number of JDBC mappingsModelPart
getKeyTargetMatchPart()
The model sub-part relative to the associated entity type that is the target of this association's foreign-keyEntityMappingType
getMappedType()
Descriptor for the type of this mappingNavigableRole
getNavigableRole()
NotFoundAction
getNotFoundAction()
int
getNumberOfFetchables()
The number of fetchables in the containerString
getReferencedPropertyName()
ForeignKeyDescriptor.Nature
getSideNature()
Indicates which "side" of the foreign-key this association describesString
getSqlAliasStem()
Get the "stem" used as the base for generating SQL table aliases for table references that are part of the TableGroup being generatedString
getTargetKeyPropertyName()
Set<String>
getTargetKeyPropertyNames()
boolean
hasNotFoundAction()
protected boolean
isBidirectionalAttributeName(NavigablePath parentNavigablePath, ModelPart parentModelPart, NavigablePath fetchablePath, DomainResultCreationState creationState)
boolean
isFkOptimizationAllowed()
boolean
isIgnoreNotFound()
boolean
isInternalLoadNullable()
boolean
isNullable()
boolean
isOptional()
boolean
isReferenceToPrimaryKey()
boolean
isSimpleJoinPredicate(Predicate predicate)
Returns whether the given predicate is a simple join predicate for this attribute.boolean
isUnwrapProxy()
Fetch
resolveCircularFetch(NavigablePath fetchablePath, FetchParent fetchParent, FetchTiming fetchTiming, DomainResultCreationState creationState)
Check whether this Fetchable is considered a circular fetch.void
setForeignKeyDescriptor(ForeignKeyDescriptor foreignKeyDescriptor)
void
setIdentifyingColumnsTableExpression(String tableExpression)
String
toString()
-
Methods inherited from class org.hibernate.metamodel.mapping.internal.AbstractSingularAttributeMapping
getPropertyAccess, getValueGeneration
-
Methods inherited from class org.hibernate.metamodel.mapping.internal.AbstractStateArrayContributorMapping
getAttributeMetadataAccess, getFetchableName, getMappedFetchOptions, getStateArrayPosition, getStyle, getTiming
-
Methods inherited from class org.hibernate.metamodel.mapping.internal.AbstractAttributeMapping
getAttributeName, getDeclaringType, 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, asEmbeddedAttributeMapping, asPluralAttributeMapping, findContainingEntityMapping, getAttributeMetadataAccess, getAttributeName, getDeclaringType, getExposedMutabilityPlan, getPartName, getStateArrayPosition, getValue, isEmbeddedAttributeMapping, isPluralAttributeMapping, setValue
-
Methods inherited from interface org.hibernate.metamodel.mapping.Bindable
forEachDisassembledJdbcValue, forEachJdbcType, forEachJdbcValue, getJdbcMappings
-
Methods inherited from interface org.hibernate.metamodel.mapping.EntityAssociationMapping
getFetchableName, incrementFetchDepth
-
Methods inherited from interface org.hibernate.metamodel.mapping.EntityValuedModelPart
createDomainResult, visitSubParts
-
Methods inherited from interface org.hibernate.sql.results.graph.Fetchable
getMappedFetchOptions
-
Methods inherited from interface org.hibernate.sql.results.graph.FetchableContainer
getKeyFetchable, getNumberOfKeyFetchables, visitFetchables, visitFetchables, visitFetchables, visitKeyFetchables, visitKeyFetchables, visitKeyFetchables
-
Methods inherited from interface org.hibernate.metamodel.mapping.ModelPart
areEqual, forEachSelectable, getJavaType, getPartMappingType
-
Methods inherited from interface org.hibernate.metamodel.mapping.Queryable
findByPath, findSubTypesSubPart, resolveSubPart
-
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.ValueMapping
getExpressibleJavaType, treatAs
-
-
-
-
Constructor Detail
-
ToOneAttributeMapping
public ToOneAttributeMapping(String name, NavigableRole navigableRole, int stateArrayPosition, ToOne bootValue, AttributeMetadataAccess attributeMetadataAccess, FetchOptions mappedFetchOptions, EntityMappingType entityMappingType, ManagedMappingType declaringType, EntityPersister declaringEntityPersister, PropertyAccess propertyAccess)
-
ToOneAttributeMapping
public ToOneAttributeMapping(String name, NavigableRole navigableRole, int stateArrayPosition, ToOne bootValue, AttributeMetadataAccess attributeMetadataAccess, 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:Association
The descriptor, allowing access to column(s), etc- Specified by:
getForeignKeyDescriptor
in interfaceAssociation
-
getSideNature
public ForeignKeyDescriptor.Nature getSideNature()
Description copied from interface:Association
Indicates which "side" of the foreign-key this association describes- Specified by:
getSideNature
in interfaceAssociation
-
isReferenceToPrimaryKey
public boolean isReferenceToPrimaryKey()
- Specified by:
isReferenceToPrimaryKey
in interfaceEntityAssociationMapping
-
isFkOptimizationAllowed
public boolean isFkOptimizationAllowed()
- Specified by:
isFkOptimizationAllowed
in interfaceEntityAssociationMapping
-
getReferencedPropertyName
public String getReferencedPropertyName()
-
getTargetKeyPropertyName
public String getTargetKeyPropertyName()
-
getCardinality
public ToOneAttributeMapping.Cardinality getCardinality()
-
getMappedType
public EntityMappingType getMappedType()
Description copied from interface:ValueMapping
Descriptor for the type of this mapping- Specified by:
getMappedType
in interfaceValueMapping
-
getEntityMappingType
public EntityMappingType getEntityMappingType()
- Specified by:
getEntityMappingType
in interfaceEntityValuedModelPart
-
getNavigableRole
public NavigableRole getNavigableRole()
- Specified by:
getNavigableRole
in interfaceModelPart
- See Also:
ModelPart.getPartName()
-
findSubPart
public ModelPart findSubPart(String name)
- Specified by:
findSubPart
in interfaceEntityValuedModelPart
-
findSubPart
public ModelPart findSubPart(String name, EntityMappingType targetType)
Description copied from interface:Queryable
For an entity, this form allows for Hibernate's "implicit treat" support - meaning it should find a sub-part whether defined on the entity, its super-type or even one of its sub-types.- Specified by:
findSubPart
in interfaceEntityValuedModelPart
- Specified by:
findSubPart
in interfaceQueryable
-
resolveCircularFetch
public Fetch resolveCircularFetch(NavigablePath fetchablePath, FetchParent fetchParent, FetchTiming fetchTiming, DomainResultCreationState creationState)
Description copied from interface:Fetchable
Check whether this Fetchable is considered a circular fetch.- Specified by:
resolveCircularFetch
in interfaceFetchable
- Parameters:
fetchablePath
- The overall path within the graph- Returns:
- The Fetch representing the circularity;
null
indicates 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:Fetchable
Generates a Fetch of this fetchable- Specified by:
generateFetch
in interfaceEntityValuedFetchable
- Specified by:
generateFetch
in 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:DatabaseSnapshotContributor
Create a DomainResult to be used when selecting snapshots from the database. By default, simply useModelPart.createDomainResult(org.hibernate.spi.NavigablePath, org.hibernate.sql.ast.tree.from.TableGroup, java.lang.String, org.hibernate.sql.results.graph.DomainResultCreationState)
- Specified by:
createSnapshotDomainResult
in interfaceDatabaseSnapshotContributor
-
getDefaultSqlAstJoinType
public SqlAstJoinType getDefaultSqlAstJoinType(TableGroup parentTableGroup)
- Specified by:
getDefaultSqlAstJoinType
in interfaceTableGroupJoinProducer
-
isSimpleJoinPredicate
public boolean isSimpleJoinPredicate(Predicate predicate)
Description copied from interface:TableGroupJoinProducer
Returns 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:
isSimpleJoinPredicate
in interfaceTableGroupJoinProducer
-
getNumberOfFetchables
public int getNumberOfFetchables()
Description copied from interface:FetchableContainer
The number of fetchables in the container- Specified by:
getNumberOfFetchables
in interfaceFetchableContainer
-
getFetchable
public Fetchable getFetchable(int position)
- Specified by:
getFetchable
in 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:TableGroupJoinProducer
Create 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 explicitON
clause, and isfalse
otherwise.- Specified by:
createTableGroupJoin
in 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:TableGroupJoinProducer
Create 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:
createRootTableGroupJoin
in 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:TableGroupProducer
Get the "stem" used as the base for generating SQL table aliases for table references that are part of the TableGroup being generated Note that this is a metadata-ive value. It is only ever used internal to the producer producing its TableGroup.- Specified by:
getSqlAliasStem
in interfaceTableGroupProducer
- See Also:
SqlAliasBaseManager.createSqlAliasBase(java.lang.String)
-
isNullable
public boolean isNullable()
-
isOptional
public boolean isOptional()
- Specified by:
isOptional
in interfaceEntityValuedFetchable
-
isInternalLoadNullable
public boolean isInternalLoadNullable()
-
getNotFoundAction
public NotFoundAction getNotFoundAction()
-
isIgnoreNotFound
public boolean isIgnoreNotFound()
-
hasNotFoundAction
public boolean hasNotFoundAction()
-
isUnwrapProxy
public boolean isUnwrapProxy()
- Specified by:
isUnwrapProxy
in interfaceEntityValuedFetchable
-
getAssociatedEntityMappingType
public EntityMappingType getAssociatedEntityMappingType()
- Specified by:
getAssociatedEntityMappingType
in interfaceEntityAssociationMapping
-
getKeyTargetMatchPart
public ModelPart getKeyTargetMatchPart()
Description copied from interface:EntityAssociationMapping
The model sub-part relative to the associated entity type that is the target of this association's foreign-key- Specified by:
getKeyTargetMatchPart
in interfaceEntityAssociationMapping
-
breakDownJdbcValues
public void breakDownJdbcValues(Object domainValue, ModelPart.JdbcValueConsumer valueConsumer, SharedSessionContractImplementor session)
- Specified by:
breakDownJdbcValues
in interfaceModelPart
-
forEachSelectable
public int forEachSelectable(int offset, SelectableConsumer consumer)
- Specified by:
forEachSelectable
in interfaceModelPart
-
applySqlSelections
public void applySqlSelections(NavigablePath navigablePath, TableGroup tableGroup, DomainResultCreationState creationState)
Description copied from interface:ModelPart
Apply SQL selections for a specific reference to this ModelPart outside the domain query's root select clause.- Specified by:
applySqlSelections
in interfaceEntityValuedModelPart
- Specified by:
applySqlSelections
in interfaceModelPart
-
applySqlSelections
public void applySqlSelections(NavigablePath navigablePath, TableGroup tableGroup, DomainResultCreationState creationState, BiConsumer<SqlSelection,JdbcMapping> selectionConsumer)
Description copied from interface:ModelPart
Apply SQL selections for a specific reference to this ModelPart outside the domain query's root select clause.- Specified by:
applySqlSelections
in interfaceEntityValuedModelPart
- Specified by:
applySqlSelections
in interfaceModelPart
-
getJdbcTypeCount
public int getJdbcTypeCount()
Description copied from interface:Bindable
The number of JDBC mappings- Specified by:
getJdbcTypeCount
in interfaceBindable
- Specified by:
getJdbcTypeCount
in interfaceEntityValuedModelPart
- Specified by:
getJdbcTypeCount
in interfaceJdbcMappingContainer
-
forEachJdbcType
public int forEachJdbcType(int offset, IndexedConsumer<JdbcMapping> action)
Description copied from interface:JdbcMappingContainer
Visit each JdbcMapping starting from the given offset- Specified by:
forEachJdbcType
in interfaceEntityValuedModelPart
- Specified by:
forEachJdbcType
in interfaceJdbcMappingContainer
-
disassemble
public Object disassemble(Object value, SharedSessionContractImplementor session)
- Specified by:
disassemble
in interfaceBindable
- Specified by:
disassemble
in interfaceEntityValuedModelPart
- See Also:
As an example, consider the following domain model: ````
-
forEachDisassembledJdbcValue
public int forEachDisassembledJdbcValue(Object value, Clause clause, int offset, Bindable.JdbcValuesConsumer valuesConsumer, SharedSessionContractImplementor session)
- Specified by:
forEachDisassembledJdbcValue
in interfaceBindable
- Specified by:
forEachDisassembledJdbcValue
in interfaceEntityValuedModelPart
-
forEachJdbcValue
public int forEachJdbcValue(Object value, Clause clause, int offset, Bindable.JdbcValuesConsumer consumer, SharedSessionContractImplementor session)
- Specified by:
forEachJdbcValue
in interfaceBindable
- Specified by:
forEachJdbcValue
in interfaceEntityValuedModelPart
-
-