Class EmbeddedForeignKeyDescriptor
- java.lang.Object
-
- org.hibernate.metamodel.mapping.internal.EmbeddedForeignKeyDescriptor
-
- All Implemented Interfaces:
Bindable
,ForeignKeyDescriptor
,JdbcMappingContainer
,MappingModelExpressible
,ModelPart
,SelectableMappings
,ValuedModelPart
,ValueMapping
,VirtualModelPart
,JavaTypedExpressible
public class EmbeddedForeignKeyDescriptor extends Object implements ForeignKeyDescriptor
-
-
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.ForeignKeyDescriptor
ForeignKeyDescriptor.Nature, ForeignKeyDescriptor.Side
-
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.ForeignKeyDescriptor
PART_NAME, TARGET_PART_NAME
-
-
Constructor Summary
Constructors Constructor Description EmbeddedForeignKeyDescriptor(String keyTable, SelectableMappings keySelectableMappings, EmbeddableValuedModelPart keyMappingType, String targetTable, SelectableMappings targetSelectableMappings, EmbeddableValuedModelPart targetMappingType, boolean hasConstraint, MappingModelCreationProcess creationProcess)
EmbeddedForeignKeyDescriptor(EmbeddableValuedModelPart keyMappingType, EmbeddableValuedModelPart targetMappingType, String keyTable, SelectableMappings keySelectableMappings, String targetTable, SelectableMappings targetSelectableMappings, boolean hasConstraint, MappingModelCreationProcess creationProcess)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addToCacheKey(MutableCacheKeyBuilder cacheKey, Object value, SharedSessionContractImplementor session)
Add to the MutableCacheKey the values obtained disassembling the value and the hasCode generated from the disassembled value.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.<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.int
compare(Object key1, Object key2)
Compare the 2 values<T> DomainResult<T>
createDomainResult(NavigablePath navigablePath, TableGroup targetTableGroup, String resultVariable, DomainResultCreationState creationState)
Create a DomainResult for the referring-side of the fk The table group must be the one containing the target.DomainResult<?>
createKeyDomainResult(NavigablePath navigablePath, TableGroup targetTableGroup, ForeignKeyDescriptor.Nature fromSide, FetchParent fetchParent, DomainResultCreationState creationState)
Create a DomainResult for the referring-side of the fk The table group must be the one containing the target.DomainResult<?>
createKeyDomainResult(NavigablePath navigablePath, TableGroup targetTableGroup, FetchParent fetchParent, DomainResultCreationState creationState)
Create a DomainResult for the referring-side of the fk The table group must be the one containing the target.DomainResult<?>
createTargetDomainResult(NavigablePath navigablePath, TableGroup targetTableGroup, FetchParent fetchParent, DomainResultCreationState creationState)
Create a DomainResult for the target-side of the fk The table group must be the one containing the targetObject
disassemble(Object value, SharedSessionContractImplementor session)
Breaks down a value ofJ
into its simple pieces.EntityMappingType
findContainingEntityMapping()
<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)
.int
forEachJdbcType(int offset, IndexedConsumer<JdbcMapping> action)
Visit each JdbcMapping starting from the given offsetPredicate
generateJoinPredicate(TableGroup targetSideTableGroup, TableGroup keySideTableGroup, SqlAstCreationState creationState)
Predicate
generateJoinPredicate(TableReference targetSideReference, TableReference keySideReference, SqlAstCreationState creationState)
AssociationKey
getAssociationKey()
Object
getAssociationKeyFromSide(Object targetObject, ForeignKeyDescriptor.Side side, SharedSessionContractImplementor session)
JavaType<?>
getJavaType()
The Java type for this part.JdbcMapping
getJdbcMapping(int index)
EmbeddableValuedModelPart
getKeyPart()
ForeignKeyDescriptor.Side
getKeySide()
String
getKeyTable()
MappingType
getMappedType()
Descriptor for the type of this mappingNavigableRole
getNavigableRole()
MappingType
getPartMappingType()
The type for this part.SelectableMapping
getSelectable(int columnIndex)
Get the selectable at the given positionEmbeddableValuedModelPart
getTargetPart()
ForeignKeyDescriptor.Side
getTargetSide()
String
getTargetTable()
boolean
hasConstraint()
boolean
hasPartitionedSelectionMapping()
boolean
isEmbedded()
boolean
isKeyPart(ValuedModelPart modelPart)
boolean
isSimpleJoinPredicate(Predicate predicate)
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.ForeignKeyDescriptor
withTargetPart(ValuedModelPart targetPart)
Return a copy of this foreign key descriptor with the target part as given by the argument.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.metamodel.mapping.Bindable
forEachDisassembledJdbcValue, forEachDisassembledJdbcValue, forEachDisassembledJdbcValue, forEachJdbcType, forEachJdbcValue, forEachJdbcValue, forEachJdbcValue, forEachJdbcValue
-
Methods inherited from interface org.hibernate.metamodel.mapping.ForeignKeyDescriptor
forEachSelectable, getAssociationKeyFromSide, getContainingTableExpression, getPart, getPartName, getSide, visitKeySelectables, visitTargetSelectables
-
Methods inherited from interface org.hibernate.metamodel.mapping.ModelPart
areEqual, asAttributeMapping, asBasicValuedModelPart, asEntityMappingType, breakDownJdbcValues, decompose, decompose, isEntityIdentifierMapping
-
Methods inherited from interface org.hibernate.metamodel.mapping.ValuedModelPart
forEachInsertable, forEachNonFormula, forEachSelectable, forEachUpdatable, getJdbcTypeCount, getSingleJdbcMapping
-
Methods inherited from interface org.hibernate.metamodel.mapping.ValueMapping
getExpressibleJavaType, treatAs
-
Methods inherited from interface org.hibernate.metamodel.mapping.VirtualModelPart
isVirtual
-
-
-
-
Constructor Detail
-
EmbeddedForeignKeyDescriptor
public EmbeddedForeignKeyDescriptor(String keyTable, SelectableMappings keySelectableMappings, EmbeddableValuedModelPart keyMappingType, String targetTable, SelectableMappings targetSelectableMappings, EmbeddableValuedModelPart targetMappingType, boolean hasConstraint, MappingModelCreationProcess creationProcess)
-
EmbeddedForeignKeyDescriptor
public EmbeddedForeignKeyDescriptor(EmbeddableValuedModelPart keyMappingType, EmbeddableValuedModelPart targetMappingType, String keyTable, SelectableMappings keySelectableMappings, String targetTable, SelectableMappings targetSelectableMappings, boolean hasConstraint, MappingModelCreationProcess creationProcess)
-
-
Method Detail
-
getKeyTable
public String getKeyTable()
- Specified by:
getKeyTable
in interfaceForeignKeyDescriptor
-
getTargetTable
public String getTargetTable()
- Specified by:
getTargetTable
in interfaceForeignKeyDescriptor
-
getKeyPart
public EmbeddableValuedModelPart getKeyPart()
- Specified by:
getKeyPart
in interfaceForeignKeyDescriptor
-
getTargetPart
public EmbeddableValuedModelPart getTargetPart()
- Specified by:
getTargetPart
in interfaceForeignKeyDescriptor
-
isKeyPart
public boolean isKeyPart(ValuedModelPart modelPart)
- Specified by:
isKeyPart
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
-
withTargetPart
public ForeignKeyDescriptor withTargetPart(ValuedModelPart targetPart)
Description copied from interface:ForeignKeyDescriptor
Return a copy of this foreign key descriptor with the target part as given by the argument.- Specified by:
withTargetPart
in interfaceForeignKeyDescriptor
-
createKeyDomainResult
public DomainResult<?> createKeyDomainResult(NavigablePath navigablePath, TableGroup targetTableGroup, FetchParent fetchParent, DomainResultCreationState creationState)
Description copied from interface:ForeignKeyDescriptor
Create a DomainResult for the referring-side of the fk The table group must be the one containing the target.- Specified by:
createKeyDomainResult
in interfaceForeignKeyDescriptor
-
createKeyDomainResult
public DomainResult<?> createKeyDomainResult(NavigablePath navigablePath, TableGroup targetTableGroup, ForeignKeyDescriptor.Nature fromSide, FetchParent fetchParent, DomainResultCreationState creationState)
Description copied from interface:ForeignKeyDescriptor
Create a DomainResult for the referring-side of the fk The table group must be the one containing the target. TheForeignKeyDescriptor.Nature
is the association side of the foreign key i.e.Association.getSideNature()
.- Specified by:
createKeyDomainResult
in interfaceForeignKeyDescriptor
-
createTargetDomainResult
public DomainResult<?> createTargetDomainResult(NavigablePath navigablePath, TableGroup targetTableGroup, FetchParent fetchParent, DomainResultCreationState creationState)
Description copied from interface:ForeignKeyDescriptor
Create a DomainResult for the target-side of the fk The table group must be the one containing the target- Specified by:
createTargetDomainResult
in interfaceForeignKeyDescriptor
-
createDomainResult
public <T> DomainResult<T> createDomainResult(NavigablePath navigablePath, TableGroup targetTableGroup, String resultVariable, DomainResultCreationState creationState)
Description copied from interface:ForeignKeyDescriptor
Create a DomainResult for the referring-side of the fk The table group must be the one containing the target.- Specified by:
createDomainResult
in interfaceForeignKeyDescriptor
- 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(TableGroup targetSideTableGroup, TableGroup keySideTableGroup, SqlAstCreationState creationState)
- Specified by:
generateJoinPredicate
in interfaceForeignKeyDescriptor
-
generateJoinPredicate
public Predicate generateJoinPredicate(TableReference targetSideReference, TableReference keySideReference, SqlAstCreationState creationState)
- Specified by:
generateJoinPredicate
in interfaceForeignKeyDescriptor
-
isSimpleJoinPredicate
public boolean isSimpleJoinPredicate(Predicate predicate)
- Specified by:
isSimpleJoinPredicate
in interfaceForeignKeyDescriptor
-
getSelectable
public SelectableMapping getSelectable(int columnIndex)
Description copied from interface:SelectableMappings
Get the selectable at the given position- Specified by:
getSelectable
in interfaceForeignKeyDescriptor
- Specified by:
getSelectable
in interfaceSelectableMappings
-
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
-
getMappedType
public MappingType getMappedType()
Description copied from interface:ValueMapping
Descriptor for the type of this mapping- Specified by:
getMappedType
in interfaceValueMapping
-
getPartMappingType
public MappingType getPartMappingType()
Description copied from interface:ModelPart
The type for this part.- Specified by:
getPartMappingType
in interfaceModelPart
-
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()
-
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:ModelPart
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 valuesX
andY
to the consumer. Returns the amount of jdbc types that have been visited.- Specified by:
breakDownJdbcValues
in interfaceModelPart
-
getAssociationKeyFromSide
public Object getAssociationKeyFromSide(Object targetObject, ForeignKeyDescriptor.Side side, SharedSessionContractImplementor session)
- Specified by:
getAssociationKeyFromSide
in interfaceForeignKeyDescriptor
-
findContainingEntityMapping
public EntityMappingType findContainingEntityMapping()
- Specified by:
findContainingEntityMapping
in interfaceModelPart
-
getJdbcMapping
public JdbcMapping getJdbcMapping(int index)
- Specified by:
getJdbcMapping
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 interfaceJdbcMappingContainer
-
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:Bindable
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)
.- Specified by:
forEachDisassembledJdbcValue
in interfaceBindable
-
disassemble
public Object disassemble(Object value, SharedSessionContractImplementor session)
Description copied from interface:Bindable
Breaks down a value ofJ
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 theBindable
for thePerson
entity to disassemble. Given aPerson
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.
- Specified by:
disassemble
in interfaceBindable
- See Also:
EntityEntry
-
addToCacheKey
public void addToCacheKey(MutableCacheKeyBuilder cacheKey, Object value, SharedSessionContractImplementor session)
Description copied from interface:Bindable
Add to the MutableCacheKey the values obtained disassembling the value and the hasCode generated from the disassembled value.- Specified by:
addToCacheKey
in interfaceBindable
- Specified by:
addToCacheKey
in interfaceJavaTypedExpressible
- Parameters:
cacheKey
- the MutableCacheKey used to add the disassembled value and the hashCodevalue
- the value to disassemblesession
- the SharedSessionContractImplementor
-
hasPartitionedSelectionMapping
public boolean hasPartitionedSelectionMapping()
- Specified by:
hasPartitionedSelectionMapping
in interfaceModelPart
-
isEmbedded
public boolean isEmbedded()
- Specified by:
isEmbedded
in interfaceForeignKeyDescriptor
-
-