Top Description Inners Fields Constructors Methods
org.hibernate.dialect.function

public Class TimestampdiffFunction

extends AbstractSqmSelfRenderingFunctionDescriptor
Class Inheritance
Imports
java.util.List, java.util.function.Supplier, org.hibernate.dialect.Dialect, org.hibernate.metamodel.mapping.BasicValuedMapping, .JdbcMappingContainer, .MappingModelExpressible, org.hibernate.query.ReturnableType, org.hibernate.query.sqm.TemporalUnit, org.hibernate.query.sqm.function.AbstractSqmSelfRenderingFunctionDescriptor, .SelfRenderingFunctionSqlAstExpression, org.hibernate.query.sqm.produce.function.ArgumentTypesValidator, .FunctionReturnTypeResolver, .StandardArgumentsValidators, .StandardFunctionArgumentTypeResolvers, .StandardFunctionReturnTypeResolvers, org.hibernate.query.sqm.produce.function.internal.PatternRenderer, org.hibernate.query.sqm.tree.SqmTypedNode, org.hibernate.query.sqm.tree.expression.SqmDurationUnit, org.hibernate.sql.ast.SqlAstTranslator, org.hibernate.sql.ast.spi.SqlAppender, org.hibernate.sql.ast.tree.SqlAstNode, org.hibernate.sql.ast.tree.expression.DurationUnit, .Expression, org.hibernate.type.BasicType, .StandardBasicTypes, org.hibernate.type.spi.TypeConfiguration, jakarta.persistence.TemporalType

Deprecated

as a consequence of AbstractSqmSelfRenderingFunctionDescriptor being deprecated. See corresponding docs for further information.

The timestampdiff() or datediff() function has a funny syntax which accepts a TemporalUnit as the first argument, and the actual set of accepted units varies widely. This class uses Dialect#timestampdiffPattern(TemporalUnit, TemporalType, TemporalType) to abstract these differences.
Author
Gavin King

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
TimestampdiffFunction.TimestampdiffFunctionReturnTypeResolver

A special resolver that resolves to DOUBLE for TemporalUnit#SECOND and otherwise to LONG.

Field Summary

Modifier and TypeField and Description
private final Dialect

Constructor Summary

AccessConstructor and Description
public
TimestampdiffFunction(Dialect dialect, TypeConfiguration typeConfiguration)

Method Summary

Modifier and TypeMethod and Description
public SelfRenderingFunctionSqlAstExpression
expression(ReturnableType<?> impliedResultType, SqlAstNode... sqlAstArguments)

public String
private PatternRenderer
public void
Inherited from org.hibernate.query.sqm.function.AbstractSqmSelfRenderingFunctionDescriptor:
generateSqmAggregateFunctionExpressiongenerateSqmFunctionExpressiongenerateSqmOrderedSetAggregateFunctionExpressiongenerateSqmWindowFunctionExpressiongetFunctionKind

Field Detail

dialectback to summary
private final Dialect dialect

Constructor Detail

TimestampdiffFunctionback to summary
public TimestampdiffFunction(Dialect dialect, TypeConfiguration typeConfiguration)

Method Detail

expressionback to summary
public SelfRenderingFunctionSqlAstExpression expression(ReturnableType<?> impliedResultType, SqlAstNode... sqlAstArguments)
getArgumentListSignatureback to summary
public String getArgumentListSignature()

Overrides org.hibernate.query.sqm.function.AbstractSqmFunctionDescriptor.getArgumentListSignature.

Annotations
@Override
patternRendererback to summary
private PatternRenderer patternRenderer(TemporalUnit unit, Expression from, Expression to)
renderback to summary
public void render(SqlAppender sqlAppender, List<? extends SqlAstNode> arguments, ReturnableType<?> returnType, SqlAstTranslator<?> walker)

Overrides org.hibernate.query.sqm.function.AbstractSqmSelfRenderingFunctionDescriptor.render.

Implements org.hibernate.query.sqm.function.FunctionRenderer.render.

Annotations
@Override
org.hibernate.dialect.function back to summary

private Class TimestampdiffFunction.TimestampdiffFunctionReturnTypeResolver

extends Object
implements FunctionReturnTypeResolver
Class Inheritance
  • java.lang.Object
  • org.hibernate.dialect.function.TimestampdiffFunction.TimestampdiffFunctionReturnTypeResolver
All Implemented Interfaces
org.hibernate.query.sqm.produce.function.FunctionReturnTypeResolver

A special resolver that resolves to DOUBLE for TemporalUnit#SECOND and otherwise to LONG.

Field Summary

Modifier and TypeField and Description
private final BasicType<Double>
private final BasicType<Long>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
getReturnType()

Overrides default org.hibernate.query.sqm.produce.function.FunctionReturnTypeResolver.getReturnType.

The return type in a format suitable for display to the user.
public ReturnableType<?>
resolveFunctionReturnType(ReturnableType<?> impliedType, List<? extends SqmTypedNode<?>> arguments, TypeConfiguration typeConfiguration)

Overrides default org.hibernate.query.sqm.produce.function.FunctionReturnTypeResolver.resolveFunctionReturnType.

Resolve the return type for a function given its context-implied type and the arguments to this call.
public ReturnableType<?>
resolveFunctionReturnType(ReturnableType<?> impliedType, Supplier<MappingModelExpressible<?>> inferredTypeSupplier, List<? extends SqmTypedNode<?>> arguments, TypeConfiguration typeConfiguration)

Overrides default org.hibernate.query.sqm.produce.function.FunctionReturnTypeResolver.resolveFunctionReturnType.

Resolve the return type for a function given its context-implied type and the arguments to this call.
public BasicValuedMapping
resolveFunctionReturnType(Supplier<BasicValuedMapping> impliedTypeAccess, List<? extends SqlAstNode> arguments)

Implements org.hibernate.query.sqm.produce.function.FunctionReturnTypeResolver.resolveFunctionReturnType.

Resolve the return type for a function given its context-implied type and the arguments to this call.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

doubleTypeback to summary
private final BasicType<Double> doubleType
longTypeback to summary
private final BasicType<Long> longType

Constructor Detail

TimestampdiffFunctionReturnTypeResolverback to summary
public TimestampdiffFunctionReturnTypeResolver(BasicType<Long> longType, BasicType<Double> doubleType)

Method Detail

getReturnTypeback to summary
public String getReturnType()

Overrides default org.hibernate.query.sqm.produce.function.FunctionReturnTypeResolver.getReturnType.

Doc from org.hibernate.query.sqm.produce.function.FunctionReturnTypeResolver.getReturnType.

The return type in a format suitable for display to the user.

Annotations
@Override
resolveFunctionReturnTypeback to summary
public ReturnableType<?> resolveFunctionReturnType(ReturnableType<?> impliedType, List<? extends SqmTypedNode<?>> arguments, TypeConfiguration typeConfiguration)

Overrides default org.hibernate.query.sqm.produce.function.FunctionReturnTypeResolver.resolveFunctionReturnType.

Doc from org.hibernate.query.sqm.produce.function.FunctionReturnTypeResolver.resolveFunctionReturnType.

Resolve the return type for a function given its context-implied type and the arguments to this call.

The context-implied type is the type implied by where the function occurs in the query. E.g., for an equality predicate (`something = some_function`) the implied type of the return from `some_function` would be defined by the type of `some_function`.

Returns:ReturnableType<?>

The resolved type.

Annotations
@Override
resolveFunctionReturnTypeback to summary
public ReturnableType<?> resolveFunctionReturnType(ReturnableType<?> impliedType, Supplier<MappingModelExpressible<?>> inferredTypeSupplier, List<? extends SqmTypedNode<?>> arguments, TypeConfiguration typeConfiguration)

Overrides default org.hibernate.query.sqm.produce.function.FunctionReturnTypeResolver.resolveFunctionReturnType.

Doc from org.hibernate.query.sqm.produce.function.FunctionReturnTypeResolver.resolveFunctionReturnType.

Resolve the return type for a function given its context-implied type and the arguments to this call.

The context-implied type is the type implied by where the function occurs in the query. E.g., for an equality predicate (`something = some_function`) the implied type of the return from `some_function` would be defined by the type of `some_function`.

Returns:ReturnableType<?>

The resolved type.

Annotations
@Override
resolveFunctionReturnTypeback to summary
public BasicValuedMapping resolveFunctionReturnType(Supplier<BasicValuedMapping> impliedTypeAccess, List<? extends SqlAstNode> arguments)

Implements org.hibernate.query.sqm.produce.function.FunctionReturnTypeResolver.resolveFunctionReturnType.

Doc from org.hibernate.query.sqm.produce.function.FunctionReturnTypeResolver.resolveFunctionReturnType.

Resolve the return type for a function given its context-implied type and the arguments to this call.

The context-implied type is the type implied by where the function occurs in the query. E.g., for an equality predicate (`something = some_function`) the implied type of the return from `some_function` would be defined by the type of `some_function`.

Returns:BasicValuedMapping

The resolved type.

Annotations
@Override