Class AnyDiscriminatorPart
- java.lang.Object
-
- org.hibernate.metamodel.mapping.internal.AnyDiscriminatorPart
-
- All Implemented Interfaces:
BasicValuedMapping
,BasicValuedModelPart
,Bindable
,DiscriminatorMapping
,JdbcMappingContainer
,MappingModelExpressible
,ModelPart
,SelectableMapping
,SelectableMappings
,SqlExpressible
,SqlTypedMapping
,ValuedModelPart
,ValueMapping
,VirtualModelPart
,Fetchable
,FetchOptions
,FetchStyleAccess
,FetchTimingAccess
,JavaTypedExpressible
public class AnyDiscriminatorPart extends Object implements DiscriminatorMapping, FetchOptions
Acts as a ModelPart for the discriminator portion of an any-valued mapping
-
-
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.ModelPart
ModelPart.JdbcValueBiConsumer<X,Y>, ModelPart.JdbcValueConsumer
-
-
Constructor Summary
Constructors Constructor Description AnyDiscriminatorPart(NavigableRole partRole, DiscriminatedAssociationModelPart declaringType, String table, String column, String columnDefinition, Long length, Integer precision, Integer scale, boolean insertable, boolean updateable, boolean partitioned, BasicType<?> underlyingJdbcMapping, Map<Object,String> valueToEntityNameMap, SessionFactoryImplementor sessionFactory)
-
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.<T> DomainResult<T>
createDomainResult(NavigablePath navigablePath, TableGroup tableGroup, String resultVariable, DomainResultCreationState creationState)
Create a DomainResult for a specific reference to this ModelPart.Object
disassemble(Object value, SharedSessionContractImplementor session)
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 offsetint
forEachSelectable(int offset, SelectableConsumer consumer)
Visits each selectable mapping with the selectable index offset by the given value.int
forEachSelectable(SelectableConsumer consumer)
A short hand form ofModelPart.forEachSelectable(int, SelectableConsumer)
, that passes 0 as offset.Fetch
generateFetch(FetchParent fetchParent, NavigablePath fetchablePath, FetchTiming fetchTiming, boolean selected, String resultVariable, DomainResultCreationState creationState)
Generates a Fetch of this fetchableString
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.Long
getLength()
FetchOptions
getMappedFetchOptions()
The configured fetch timing and styleMappingType
getMappedType()
Descriptor for the type of this mappingNavigableRole
getNavigableRole()
String
getPartName()
The local part name, which is generally the unqualified role nameInteger
getPrecision()
Integer
getScale()
String
getSelectionExpression()
The selection's expression.FetchStyle
getStyle()
FetchTiming
getTiming()
JdbcMapping
getUnderlyingJdbcMapping()
DiscriminatorConverter<?,?>
getValueConverter()
Information about the value mappingsboolean
isFormula()
Is the mapping a formula instead of a physical column?boolean
isInsertable()
boolean
isNullable()
Is the mapping considered nullable?boolean
isPartitioned()
boolean
isUpdateable()
JdbcMapping
jdbcMapping()
Expression
resolveSqlExpression(NavigablePath navigablePath, JdbcMapping jdbcMappingToUse, TableGroup tableGroup, SqlAstCreationState creationState)
Create the appropriate SQL expression for this discriminator-
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.BasicValuedModelPart
asBasicValuedModelPart, getJdbcMapping, getJdbcMappings, getJdbcTypeCount, getPartMappingType, getSelectable, getSingleJdbcMapping, hasPartitionedSelectionMapping
-
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.DiscriminatorMapping
getDomainJavaType, getRelationalJavaType
-
Methods inherited from interface org.hibernate.sql.results.graph.Fetchable
asAttributeMapping, incrementFetchDepth, isSelectable, resolveCircularFetch
-
Methods inherited from interface org.hibernate.metamodel.mapping.ModelPart
areEqual, asEntityMappingType, breakDownJdbcValues, decompose, decompose, isEntityIdentifierMapping
-
Methods inherited from interface org.hibernate.metamodel.mapping.SelectableMapping
getSelectableName, getSelectablePath, getWriteExpression
-
Methods inherited from interface org.hibernate.metamodel.mapping.SqlTypedMapping
isLob
-
Methods inherited from interface org.hibernate.metamodel.mapping.ValuedModelPart
forEachInsertable, forEachNonFormula, forEachUpdatable
-
Methods inherited from interface org.hibernate.metamodel.mapping.ValueMapping
getExpressibleJavaType, treatAs
-
Methods inherited from interface org.hibernate.metamodel.mapping.VirtualModelPart
isVirtual
-
-
-
-
Field Detail
-
ROLE_NAME
public static final String ROLE_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AnyDiscriminatorPart
public AnyDiscriminatorPart(NavigableRole partRole, DiscriminatedAssociationModelPart declaringType, String table, String column, String columnDefinition, Long length, Integer precision, Integer scale, boolean insertable, boolean updateable, boolean partitioned, BasicType<?> underlyingJdbcMapping, Map<Object,String> valueToEntityNameMap, SessionFactoryImplementor sessionFactory)
-
-
Method Detail
-
getValueConverter
public DiscriminatorConverter<?,?> getValueConverter()
Description copied from interface:DiscriminatorMapping
Information about the value mappings- Specified by:
getValueConverter
in interfaceDiscriminatorMapping
-
jdbcMapping
public JdbcMapping jdbcMapping()
-
getContainingTableExpression
public String getContainingTableExpression()
Description copied from interface:ValuedModelPart
The table which contains the columns mapped by this value- 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
-
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
-
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
-
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
-
getPartName
public String getPartName()
Description copied from interface:ModelPart
The local part name, which is generally the unqualified role name- Specified by:
getPartName
in interfaceModelPart
-
getNavigableRole
public NavigableRole getNavigableRole()
- Specified by:
getNavigableRole
in interfaceModelPart
- See Also:
ModelPart.getPartName()
-
getUnderlyingJdbcMapping
public JdbcMapping getUnderlyingJdbcMapping()
- Specified by:
getUnderlyingJdbcMapping
in interfaceDiscriminatorMapping
-
disassemble
public Object disassemble(Object value, SharedSessionContractImplementor session)
- Specified by:
disassemble
in interfaceBasicValuedMapping
- Specified by:
disassemble
in interfaceBindable
- See Also:
As an example, consider the following domain model: ````
-
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 interfaceBasicValuedMapping
- 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
-
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
-
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
-
findContainingEntityMapping
public EntityMappingType findContainingEntityMapping()
- Specified by:
findContainingEntityMapping
in interfaceModelPart
-
getMappedType
public MappingType getMappedType()
Description copied from interface:ValueMapping
Descriptor for the type of this mapping- Specified by:
getMappedType
in interfaceValueMapping
-
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
-
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
-
forEachSelectable
public int forEachSelectable(SelectableConsumer consumer)
Description copied from interface:ModelPart
A short hand form ofModelPart.forEachSelectable(int, SelectableConsumer)
, that passes 0 as offset.- Specified by:
forEachSelectable
in interfaceBasicValuedModelPart
- Specified by:
forEachSelectable
in interfaceModelPart
- Specified by:
forEachSelectable
in interfaceSelectableMappings
- Specified by:
forEachSelectable
in interfaceValuedModelPart
-
forEachSelectable
public int forEachSelectable(int offset, SelectableConsumer consumer)
Description copied from interface:ModelPart
Visits each selectable mapping with the selectable index offset by the given value. Returns the amount of jdbc types that have been visited.- Specified by:
forEachSelectable
in interfaceBasicValuedModelPart
- Specified by:
forEachSelectable
in interfaceModelPart
- Specified by:
forEachSelectable
in interfaceSelectableMappings
- Specified by:
forEachSelectable
in interfaceValuedModelPart
- See Also:
SelectableConsumer.accept(int, SelectableMapping)
-
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
-
getStyle
public FetchStyle getStyle()
- Specified by:
getStyle
in interfaceFetchStyleAccess
-
getTiming
public FetchTiming getTiming()
- Specified by:
getTiming
in interfaceFetchTimingAccess
-
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
-
resolveSqlExpression
public Expression resolveSqlExpression(NavigablePath navigablePath, JdbcMapping jdbcMappingToUse, TableGroup tableGroup, SqlAstCreationState creationState)
Description copied from interface:DiscriminatorMapping
Create the appropriate SQL expression for this discriminator- Specified by:
resolveSqlExpression
in interfaceDiscriminatorMapping
jdbcMappingToUse
- The JDBC mapping to use. This allows opting between the "domain result type" (aka Class) and the "underlying type" (Integer, String, etc)
-
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
-
-