Class JdbcLiteral<T>
- java.lang.Object
-
- org.hibernate.sql.ast.tree.expression.JdbcLiteral<T>
-
- All Implemented Interfaces:
Bindable,JdbcMappingContainer,MappingModelExpressible<T>,DomainResultProducer<T>,SqlSelectionProducer,Expression,Literal,SqlAstNode,JdbcParameterBinder,JavaTypedExpressible<T>
public class JdbcLiteral<T> extends Object implements Literal, MappingModelExpressible<T>, DomainResultProducer<T>, JavaTypedExpressible<T>
Represents a literal in the SQL AST. This form accepts aJdbcMappingand acts as its ownMappingModelExpressible.- See Also:
QueryLiteral
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.hibernate.metamodel.mapping.Bindable
Bindable.JdbcValuesBiConsumer<X,Y>, Bindable.JdbcValuesConsumer
-
-
Field Summary
-
Fields inherited from interface org.hibernate.sql.exec.spi.JdbcParameterBinder
NOOP
-
-
Constructor Summary
Constructors Constructor Description JdbcLiteral(T literalValue, JdbcMapping jdbcMapping)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(SqlAstWalker sqlTreeWalker)voidaddToCacheKey(MutableCacheKeyBuilder cacheKey, Object value, SharedSessionContractImplementor session)Add to the MutableCacheKey the values obtained disassembling the value and the hasCode generated from the disassembled value.voidapplySqlSelections(DomainResultCreationState creationState)Used when this producer is a selection in a sub-query.voidbindParameterValue(PreparedStatement statement, int startPosition, JdbcParameterBindings jdbcParameterBindings, ExecutionContext executionContext)Bind the appropriate value in the JDBC statementDomainResult<T>createDomainResult(String resultVariable, DomainResultCreationState creationState)Produce the domain queryObjectdisassemble(Object value, SharedSessionContractImplementor session)Breaks down a value ofJinto its simple pieces.<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).intforEachJdbcType(int offset, IndexedConsumer<JdbcMapping> action)Visit each JdbcMapping starting from the given offset<X,Y>
intforEachJdbcValue(Object value, int offset, X x, Y y, Bindable.JdbcValuesBiConsumer<X,Y> valuesConsumer, SharedSessionContractImplementor session)Visit each constituent JDBC value extracted from the entity instance itself.JavaType<T>getExpressibleJavaType()MappingModelExpressiblegetExpressionType()The type for this expressionJdbcMappinggetJdbcMapping()JdbcMappinggetJdbcMapping(int index)intgetJdbcTypeCount()The number of JDBC mappingsObjectgetLiteralValue()JdbcMappinggetSingleJdbcMapping()-
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
-
Methods inherited from interface org.hibernate.sql.ast.tree.expression.Expression
createDomainResultSqlSelection, createSqlSelection, getColumnReference
-
-
-
-
Constructor Detail
-
JdbcLiteral
public JdbcLiteral(T literalValue, JdbcMapping jdbcMapping)
-
-
Method Detail
-
getLiteralValue
public Object getLiteralValue()
- Specified by:
getLiteralValuein interfaceLiteral
-
getJdbcMapping
public JdbcMapping getJdbcMapping()
- Specified by:
getJdbcMappingin interfaceLiteral
-
accept
public void accept(SqlAstWalker sqlTreeWalker)
- Specified by:
acceptin interfaceSqlAstNode
-
bindParameterValue
public void bindParameterValue(PreparedStatement statement, int startPosition, JdbcParameterBindings jdbcParameterBindings, ExecutionContext executionContext) throws SQLException
Description copied from interface:JdbcParameterBinderBind the appropriate value in the JDBC statement- Specified by:
bindParameterValuein interfaceJdbcParameterBinder- Throws:
SQLException
-
getExpressionType
public MappingModelExpressible getExpressionType()
Description copied from interface:ExpressionThe type for this expression- Specified by:
getExpressionTypein interfaceExpression
-
getJdbcTypeCount
public int getJdbcTypeCount()
Description copied from interface:BindableThe number of JDBC mappings- Specified by:
getJdbcTypeCountin interfaceBindable- Specified by:
getJdbcTypeCountin interfaceJdbcMappingContainer
-
getJdbcMapping
public JdbcMapping getJdbcMapping(int index)
- Specified by:
getJdbcMappingin interfaceJdbcMappingContainer
-
getSingleJdbcMapping
public JdbcMapping getSingleJdbcMapping()
- Specified by:
getSingleJdbcMappingin interfaceJdbcMappingContainer
-
forEachJdbcType
public int forEachJdbcType(int offset, IndexedConsumer<JdbcMapping> action)Description copied from interface:JdbcMappingContainerVisit each JdbcMapping starting from the given offset- Specified by:
forEachJdbcTypein interfaceJdbcMappingContainer
-
disassemble
public Object disassemble(Object value, SharedSessionContractImplementor session)
Description copied from interface:BindableBreaks down a value ofJinto 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
Personvalue, so we'd ask theBindablefor thePersonentity to disassemble. Given aPersonvalue: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:
disassemblein interfaceBindable- See Also:
EntityEntry
-
addToCacheKey
public void addToCacheKey(MutableCacheKeyBuilder cacheKey, Object value, SharedSessionContractImplementor session)
Description copied from interface:BindableAdd to the MutableCacheKey the values obtained disassembling the value and the hasCode generated from the disassembled value.- Specified by:
addToCacheKeyin interfaceBindable- Specified by:
addToCacheKeyin interfaceJavaTypedExpressible<T>- 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:BindableLikeBindable.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:
forEachDisassembledJdbcValuein interfaceBindable
-
forEachJdbcValue
public <X,Y> int forEachJdbcValue(Object value, int offset, X x, Y y, Bindable.JdbcValuesBiConsumer<X,Y> valuesConsumer, SharedSessionContractImplementor session)
Description copied from interface:BindableVisit each constituent JDBC value extracted from the entity instance itself. Short-hand form of callingBindable.disassemble(java.lang.Object, org.hibernate.engine.spi.SharedSessionContractImplementor)and piping its result toBindable.forEachDisassembledJdbcValue(Object, int, JdbcValuesConsumer, SharedSessionContractImplementor)- Specified by:
forEachJdbcValuein interfaceBindable
-
createDomainResult
public DomainResult<T> createDomainResult(String resultVariable, DomainResultCreationState creationState)
Description copied from interface:DomainResultProducerProduce the domain query- Specified by:
createDomainResultin interfaceDomainResultProducer<T>
-
applySqlSelections
public void applySqlSelections(DomainResultCreationState creationState)
Description copied from interface:DomainResultProducerUsed when this producer is a selection in a sub-query. The DomainResult is only needed for root query of a SELECT statement. This default impl assumes this producer is a true (Sql)Expression- Specified by:
applySqlSelectionsin interfaceDomainResultProducer<T>
-
getExpressibleJavaType
public JavaType<T> getExpressibleJavaType()
- Specified by:
getExpressibleJavaTypein interfaceJavaTypedExpressible<T>
-
-