Class SimpleForeignKeyDescriptor
- java.lang.Object
-
- org.hibernate.metamodel.mapping.internal.SimpleForeignKeyDescriptor
-
- All Implemented Interfaces:
BasicValuedMapping
,BasicValuedModelPart
,Bindable
,ForeignKeyDescriptor
,JdbcMappingContainer
,MappingModelExpressible
,ModelPart
,SelectableMapping
,SelectableMappings
,SqlExpressible
,SqlTypedMapping
,ValuedModelPart
,ValueMapping
,VirtualModelPart
,Fetchable
,FetchOptions
,FetchStyleAccess
,FetchTimingAccess
,JavaTypedExpressible
public class SimpleForeignKeyDescriptor extends Object implements ForeignKeyDescriptor, BasicValuedModelPart, FetchOptions
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.hibernate.metamodel.mapping.Bindable
Bindable.JdbcValuesConsumer
-
Nested classes/interfaces inherited from interface org.hibernate.metamodel.mapping.ForeignKeyDescriptor
ForeignKeyDescriptor.Nature, ForeignKeyDescriptor.Side
-
Nested classes/interfaces inherited from interface org.hibernate.metamodel.mapping.ModelPart
ModelPart.IndexedJdbcValueConsumer, ModelPart.JdbcValueConsumer
-
-
Field Summary
-
Fields inherited from interface org.hibernate.metamodel.mapping.ForeignKeyDescriptor
PART_NAME, TARGET_PART_NAME
-
-
Constructor Summary
Constructors Constructor Description SimpleForeignKeyDescriptor(BasicValuedModelPart keyModelPart, BasicValuedModelPart targetModelPart, boolean refersToPrimaryKey, boolean hasConstraint, boolean swapDirection)
SimpleForeignKeyDescriptor(ManagedMappingType keyDeclaringType, BasicValuedModelPart keyModelPart, PropertyAccess keyPropertyAccess, SelectableMapping keySelectableMapping, BasicValuedModelPart targetModelPart, boolean insertable, boolean updateable, boolean refersToPrimaryKey, boolean hasConstraint)
SimpleForeignKeyDescriptor(ManagedMappingType keyDeclaringType, SelectableMapping keySelectableMapping, BasicValuedModelPart targetModelPart, boolean refersToPrimaryKey, boolean hasConstraint)
SimpleForeignKeyDescriptor(ManagedMappingType keyDeclaringType, SelectableMapping keySelectableMapping, PropertyAccess valueAccess, BasicValuedModelPart targetModelPart, boolean refersToPrimaryKey, boolean hasConstraint, boolean swapDirection)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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)
int
compare(Object key1, Object key2)
Compare the 2 values<T> DomainResult<T>
createDomainResult(NavigablePath navigablePath, TableGroup tableGroup, String resultVariable, DomainResultCreationState creationState)
Create a DomainResult for a specific reference to this ModelPart.DomainResult<?>
createDomainResult(NavigablePath navigablePath, TableGroup tableGroup, ForeignKeyDescriptor.Nature side, FetchParent fetchParent, DomainResultCreationState creationState)
DomainResult<?>
createKeyDomainResult(NavigablePath navigablePath, TableGroup tableGroup, FetchParent fetchParent, DomainResultCreationState creationState)
Create a DomainResult for the referring-side of the fkDomainResult<?>
createTargetDomainResult(NavigablePath navigablePath, TableGroup tableGroup, FetchParent fetchParent, DomainResultCreationState creationState)
Create a DomainResult for the target-side of the fkObject
disassemble(Object value, SharedSessionContractImplementor session)
EntityMappingType
findContainingEntityMapping()
int
forEachDisassembledJdbcValue(Object value, 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, int offset, Bindable.JdbcValuesConsumer valuesConsumer, SharedSessionContractImplementor session)
int
forEachSelectable(int offset, SelectableConsumer consumer)
Visits the FK "referring" columnsFetch
generateFetch(FetchParent fetchParent, NavigablePath fetchablePath, FetchTiming fetchTiming, boolean selected, String resultVariable, DomainResultCreationState creationState)
Generates a Fetch of this fetchablePredicate
generateJoinPredicate(TableGroup targetSideTableGroup, TableGroup keySideTableGroup, SqlExpressionResolver sqlExpressionResolver, SqlAstCreationContext creationContext)
Predicate
generateJoinPredicate(TableReference targetSideReference, TableReference keySideReference, SqlExpressionResolver sqlExpressionResolver, SqlAstCreationContext creationContext)
AssociationKey
getAssociationKey()
Object
getAssociationKeyFromSide(Object targetObject, ForeignKeyDescriptor.Side side, SharedSessionContractImplementor session)
String
getColumnDefinition()
String
getContainingTableExpression()
The table which contains the columns mapped by this valueString
getCustomReadExpression()
The selection's read expression accounting for formula treatment as well asColumnTransformer.read()
String
getCustomWriteExpression()
The selection's write expression accountingColumnTransformer.write()
int
getFetchableKey()
The key that identifies this Fetchable within aFetchableContainer
.String
getFetchableName()
The name of the fetchable.JavaType<?>
getJavaType()
The Java type for this part.JdbcMapping
getJdbcMapping()
Anything that is expressible at the SQL AST level would be of basic type.List<JdbcMapping>
getJdbcMappings()
The list of JDBC mappingsBasicValuedModelPart
getKeyPart()
ForeignKeyDescriptor.Side
getKeySide()
String
getKeyTable()
Long
getLength()
FetchOptions
getMappedFetchOptions()
The configured fetch timing and styleMappingType
getMappedType()
Descriptor for the type of this mappingNavigableRole
getNavigableRole()
MappingType
getPartMappingType()
The type for this part.Integer
getPrecision()
Integer
getScale()
SelectableMapping
getSelectable(int columnIndex)
Get the selectable at the given positionString
getSelectionExpression()
The selection's expression.FetchStyle
getStyle()
BasicValuedModelPart
getTargetPart()
ForeignKeyDescriptor.Side
getTargetSide()
String
getTargetTable()
FetchTiming
getTiming()
boolean
hasConstraint()
boolean
isFormula()
Is the mapping a formula instead of a physical column?boolean
isInsertable()
boolean
isNullable()
Is the mapping considered nullable?boolean
isPartitioned()
boolean
isSimpleJoinPredicate(Predicate predicate)
boolean
isUpdateable()
String
toString()
int
visitKeySelectables(int offset, SelectableConsumer consumer)
int
visitTargetSelectables(int offset, SelectableConsumer consumer)
ForeignKeyDescriptor
withKeySelectionMapping(ManagedMappingType declaringType, TableGroupProducer declaringTableGroupProducer, IntFunction<SelectableMapping> selectableMappingAccess, MappingModelCreationProcess creationProcess)
Return a copy of this foreign key descriptor with the selectable mappings as provided by the given accessor.-
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.BasicValuedModelPart
forEachSelectable, getJdbcTypeCount, hasPartitionedSelectionMapping
-
Methods inherited from interface org.hibernate.metamodel.mapping.Bindable
forEachDisassembledJdbcValue, forEachJdbcType, forEachJdbcValue
-
Methods inherited from interface org.hibernate.sql.results.graph.Fetchable
asAttributeMapping, incrementFetchDepth, resolveCircularFetch
-
Methods inherited from interface org.hibernate.metamodel.mapping.ForeignKeyDescriptor
getAssociationKeyFromSide, getPart, getPartName, getSide, visitKeySelectables, visitTargetSelectables
-
Methods inherited from interface org.hibernate.metamodel.mapping.SelectableMapping
getSelectableName, getSelectablePath, getWriteExpression
-
Methods inherited from interface org.hibernate.metamodel.mapping.ValuedModelPart
forEachInsertable, forEachUpdatable, getJdbcTypeCount
-
Methods inherited from interface org.hibernate.metamodel.mapping.ValueMapping
getExpressibleJavaType, treatAs
-
Methods inherited from interface org.hibernate.metamodel.mapping.VirtualModelPart
isVirtual
-
-
-
-
Constructor Detail
-
SimpleForeignKeyDescriptor
public SimpleForeignKeyDescriptor(ManagedMappingType keyDeclaringType, BasicValuedModelPart keyModelPart, PropertyAccess keyPropertyAccess, SelectableMapping keySelectableMapping, BasicValuedModelPart targetModelPart, boolean insertable, boolean updateable, boolean refersToPrimaryKey, boolean hasConstraint)
-
SimpleForeignKeyDescriptor
public SimpleForeignKeyDescriptor(BasicValuedModelPart keyModelPart, BasicValuedModelPart targetModelPart, boolean refersToPrimaryKey, boolean hasConstraint, boolean swapDirection)
-
SimpleForeignKeyDescriptor
public SimpleForeignKeyDescriptor(ManagedMappingType keyDeclaringType, SelectableMapping keySelectableMapping, BasicValuedModelPart targetModelPart, boolean refersToPrimaryKey, boolean hasConstraint)
-
SimpleForeignKeyDescriptor
public SimpleForeignKeyDescriptor(ManagedMappingType keyDeclaringType, SelectableMapping keySelectableMapping, PropertyAccess valueAccess, BasicValuedModelPart targetModelPart, boolean refersToPrimaryKey, boolean hasConstraint, boolean swapDirection)
-
-
Method Detail
-
getKeyTable
public String getKeyTable()
- Specified by:
getKeyTable
in interfaceForeignKeyDescriptor
-
getTargetTable
public String getTargetTable()
- Specified by:
getTargetTable
in interfaceForeignKeyDescriptor
-
getKeyPart
public BasicValuedModelPart getKeyPart()
- Specified by:
getKeyPart
in interfaceForeignKeyDescriptor
-
getTargetPart
public BasicValuedModelPart getTargetPart()
- Specified by:
getTargetPart
in interfaceForeignKeyDescriptor
-
getKeySide
public ForeignKeyDescriptor.Side getKeySide()
- Specified by:
getKeySide
in interfaceForeignKeyDescriptor
-
getTargetSide
public ForeignKeyDescriptor.Side getTargetSide()
- Specified by:
getTargetSide
in interfaceForeignKeyDescriptor
-
compare
public int compare(Object key1, Object key2)
Description copied from interface:ForeignKeyDescriptor
Compare the 2 values- Specified by:
compare
in interfaceForeignKeyDescriptor
-
withKeySelectionMapping
public ForeignKeyDescriptor withKeySelectionMapping(ManagedMappingType declaringType, TableGroupProducer declaringTableGroupProducer, IntFunction<SelectableMapping> selectableMappingAccess, MappingModelCreationProcess creationProcess)
Description copied from interface:ForeignKeyDescriptor
Return a copy of this foreign key descriptor with the selectable mappings as provided by the given accessor.- Specified by:
withKeySelectionMapping
in interfaceForeignKeyDescriptor
-
createKeyDomainResult
public DomainResult<?> createKeyDomainResult(NavigablePath navigablePath, TableGroup tableGroup, FetchParent fetchParent, DomainResultCreationState creationState)
Description copied from interface:ForeignKeyDescriptor
Create a DomainResult for the referring-side of the fk- Specified by:
createKeyDomainResult
in interfaceForeignKeyDescriptor
-
createTargetDomainResult
public DomainResult<?> createTargetDomainResult(NavigablePath navigablePath, TableGroup tableGroup, FetchParent fetchParent, DomainResultCreationState creationState)
Description copied from interface:ForeignKeyDescriptor
Create a DomainResult for the target-side of the fk- Specified by:
createTargetDomainResult
in interfaceForeignKeyDescriptor
-
createDomainResult
public DomainResult<?> createDomainResult(NavigablePath navigablePath, TableGroup tableGroup, ForeignKeyDescriptor.Nature side, FetchParent fetchParent, DomainResultCreationState creationState)
- Specified by:
createDomainResult
in interfaceForeignKeyDescriptor
-
createDomainResult
public <T> DomainResult<T> createDomainResult(NavigablePath navigablePath, TableGroup tableGroup, String resultVariable, DomainResultCreationState creationState)
Description copied from interface:ModelPart
Create a DomainResult for a specific reference to this ModelPart.- Specified by:
createDomainResult
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 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 interfaceModelPart
-
generateJoinPredicate
public Predicate generateJoinPredicate(TableReference targetSideReference, TableReference keySideReference, SqlExpressionResolver sqlExpressionResolver, SqlAstCreationContext creationContext)
- Specified by:
generateJoinPredicate
in interfaceForeignKeyDescriptor
-
generateJoinPredicate
public Predicate generateJoinPredicate(TableGroup targetSideTableGroup, TableGroup keySideTableGroup, SqlExpressionResolver sqlExpressionResolver, SqlAstCreationContext creationContext)
- Specified by:
generateJoinPredicate
in interfaceForeignKeyDescriptor
-
isSimpleJoinPredicate
public boolean isSimpleJoinPredicate(Predicate predicate)
- Specified by:
isSimpleJoinPredicate
in interfaceForeignKeyDescriptor
-
getPartMappingType
public MappingType getPartMappingType()
Description copied from interface:ModelPart
The type for this part.- Specified by:
getPartMappingType
in interfaceBasicValuedModelPart
- Specified by:
getPartMappingType
in interfaceModelPart
-
forEachSelectable
public int forEachSelectable(int offset, SelectableConsumer consumer)
Description copied from interface:ForeignKeyDescriptor
Visits the FK "referring" columns- Specified by:
forEachSelectable
in interfaceBasicValuedModelPart
- Specified by:
forEachSelectable
in interfaceForeignKeyDescriptor
- Specified by:
forEachSelectable
in interfaceModelPart
- Specified by:
forEachSelectable
in interfaceSelectableMappings
- Specified by:
forEachSelectable
in interfaceValuedModelPart
- See Also:
SelectableConsumer.accept(int, SelectableMapping)
-
getJavaType
public JavaType<?> getJavaType()
Description copied from interface:ModelPart
The Java type for this part. Generally equivalent toMappingType.getMappedJavaType()
relative toModelPart.getPartMappingType()
- Specified by:
getJavaType
in interfaceModelPart
-
getNavigableRole
public NavigableRole getNavigableRole()
- Specified by:
getNavigableRole
in interfaceModelPart
- See Also:
ModelPart.getPartName()
-
findContainingEntityMapping
public EntityMappingType findContainingEntityMapping()
- Specified by:
findContainingEntityMapping
in interfaceModelPart
-
disassemble
public Object disassemble(Object value, SharedSessionContractImplementor session)
- Specified by:
disassemble
in interfaceBindable
- See Also:
As an example, consider the following domain model: ````
-
getAssociationKeyFromSide
public Object getAssociationKeyFromSide(Object targetObject, ForeignKeyDescriptor.Side side, SharedSessionContractImplementor session)
- Specified by:
getAssociationKeyFromSide
in interfaceForeignKeyDescriptor
-
forEachDisassembledJdbcValue
public int forEachDisassembledJdbcValue(Object value, int offset, Bindable.JdbcValuesConsumer valuesConsumer, SharedSessionContractImplementor session)
- Specified by:
forEachDisassembledJdbcValue
in interfaceBindable
-
breakDownJdbcValues
public void breakDownJdbcValues(Object domainValue, ModelPart.JdbcValueConsumer valueConsumer, SharedSessionContractImplementor session)
- Specified by:
breakDownJdbcValues
in interfaceModelPart
-
visitKeySelectables
public int visitKeySelectables(int offset, SelectableConsumer consumer)
- Specified by:
visitKeySelectables
in interfaceForeignKeyDescriptor
-
visitTargetSelectables
public int visitTargetSelectables(int offset, SelectableConsumer consumer)
- Specified by:
visitTargetSelectables
in interfaceForeignKeyDescriptor
-
hasConstraint
public boolean hasConstraint()
- Specified by:
hasConstraint
in interfaceForeignKeyDescriptor
-
getAssociationKey
public AssociationKey getAssociationKey()
- Specified by:
getAssociationKey
in interfaceForeignKeyDescriptor
-
getJdbcMappings
public List<JdbcMapping> getJdbcMappings()
Description copied from interface:Bindable
The list of JDBC mappings- Specified by:
getJdbcMappings
in interfaceBasicValuedMapping
- Specified by:
getJdbcMappings
in interfaceBasicValuedModelPart
- Specified by:
getJdbcMappings
in interfaceBindable
- Specified by:
getJdbcMappings
in interfaceJdbcMappingContainer
- Specified by:
getJdbcMappings
in interfaceSelectableMappings
- Specified by:
getJdbcMappings
in interfaceValuedModelPart
- See Also:
SqlTypedMapping.getJdbcMapping()
-
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 interfaceJdbcMappingContainer
-
forEachJdbcValue
public int forEachJdbcValue(Object value, int offset, Bindable.JdbcValuesConsumer valuesConsumer, SharedSessionContractImplementor session)
- Specified by:
forEachJdbcValue
in interfaceBindable
-
getContainingTableExpression
public String getContainingTableExpression()
Description copied from interface:ValuedModelPart
The table which contains the columns mapped by this value- Specified by:
getContainingTableExpression
in interfaceForeignKeyDescriptor
- Specified by:
getContainingTableExpression
in interfaceSelectableMapping
- Specified by:
getContainingTableExpression
in interfaceValuedModelPart
-
getSelectionExpression
public String getSelectionExpression()
Description copied from interface:SelectableMapping
The selection's expression. This is the column name or formula- Specified by:
getSelectionExpression
in interfaceSelectableMapping
-
getSelectable
public SelectableMapping getSelectable(int columnIndex)
Description copied from interface:SelectableMappings
Get the selectable at the given position- Specified by:
getSelectable
in interfaceBasicValuedModelPart
- Specified by:
getSelectable
in interfaceForeignKeyDescriptor
- Specified by:
getSelectable
in interfaceSelectableMappings
-
isFormula
public boolean isFormula()
Description copied from interface:SelectableMapping
Is the mapping a formula instead of a physical column?- Specified by:
isFormula
in interfaceSelectableMapping
-
isNullable
public boolean isNullable()
Description copied from interface:SelectableMapping
Is the mapping considered nullable?- Specified by:
isNullable
in interfaceSelectableMapping
-
isInsertable
public boolean isInsertable()
- Specified by:
isInsertable
in interfaceSelectableMapping
-
isUpdateable
public boolean isUpdateable()
- Specified by:
isUpdateable
in interfaceSelectableMapping
-
isPartitioned
public boolean isPartitioned()
- Specified by:
isPartitioned
in interfaceSelectableMapping
-
getCustomReadExpression
public String getCustomReadExpression()
Description copied from interface:SelectableMapping
The selection's read expression accounting for formula treatment as well asColumnTransformer.read()
- Specified by:
getCustomReadExpression
in interfaceSelectableMapping
-
getCustomWriteExpression
public String getCustomWriteExpression()
Description copied from interface:SelectableMapping
The selection's write expression accountingColumnTransformer.write()
- Specified by:
getCustomWriteExpression
in interfaceSelectableMapping
-
getColumnDefinition
public String getColumnDefinition()
- Specified by:
getColumnDefinition
in interfaceSqlTypedMapping
-
getLength
public Long getLength()
- Specified by:
getLength
in interfaceSqlTypedMapping
-
getPrecision
public Integer getPrecision()
- Specified by:
getPrecision
in interfaceSqlTypedMapping
-
getScale
public Integer getScale()
- Specified by:
getScale
in interfaceSqlTypedMapping
-
getFetchableName
public String getFetchableName()
Description copied from interface:Fetchable
The name of the fetchable. This is the part's "local name".- Specified by:
getFetchableName
in interfaceFetchable
- See Also:
ModelPart.getNavigableRole()
,NavigableRole.getLocalName()
-
getFetchableKey
public int getFetchableKey()
Description copied from interface:Fetchable
The key that identifies this Fetchable within aFetchableContainer
. If this Fetchable is part ofFetchableContainer.visitFetchables(IndexedConsumer, EntityMappingType)
, the values is guaranteed to be between 0 (inclusive) andFetchableContainer.getNumberOfFetchableKeys()
(exclusive). Other Fetchable objects may have a special negative value.The main intent of this key is to index e.g.
Fetch
objects in an array.- Specified by:
getFetchableKey
in interfaceFetchable
-
getMappedFetchOptions
public FetchOptions getMappedFetchOptions()
Description copied from interface:Fetchable
The configured fetch timing and style- Specified by:
getMappedFetchOptions
in interfaceFetchable
-
getStyle
public FetchStyle getStyle()
- Specified by:
getStyle
in interfaceFetchStyleAccess
-
getTiming
public FetchTiming getTiming()
- Specified by:
getTiming
in interfaceFetchTimingAccess
-
generateFetch
public Fetch 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 interfaceFetchable
- Parameters:
fetchParent
- The parent of the Fetch we are generatingfetchablePath
- The overall path within the graphfetchTiming
- The requested fetch timing
-
getMappedType
public MappingType getMappedType()
Description copied from interface:ValueMapping
Descriptor for the type of this mapping- Specified by:
getMappedType
in interfaceValueMapping
-
getJdbcMapping
public JdbcMapping getJdbcMapping()
Description copied from interface:SqlExpressible
Anything that is expressible at the SQL AST level would be of basic type.- Specified by:
getJdbcMapping
in interfaceBasicValuedMapping
- Specified by:
getJdbcMapping
in interfaceSqlExpressible
- Specified by:
getJdbcMapping
in interfaceSqlTypedMapping
-
-