Interface SqmFunctionDescriptor
- All Known Implementing Classes:
AbstractArrayContainsFunction, AbstractArrayFillFunction, AbstractArrayGetFunction, AbstractArrayIncludesFunction, AbstractArrayIntersectsFunction, AbstractArrayPositionFunction, AbstractArrayPositionsFunction, AbstractArrayRemoveFunction, AbstractArrayReverseFunction, AbstractArraySortFunction, AbstractArrayTrimFunction, AbstractJsonArrayAppendFunction, AbstractJsonArrayInsertFunction, AbstractJsonInsertFunction, AbstractJsonMergepatchFunction, AbstractJsonRemoveFunction, AbstractJsonReplaceFunction, AbstractJsonSetFunction, AbstractRegexpLikeFunction, AbstractSqmFunctionDescriptor, AbstractSqmSelfRenderingFunctionDescriptor, ArrayAggFunction, ArrayConcatElementFunction, ArrayConcatFunction, ArrayConstructorFunction, ArrayContainsOperatorFunction, ArrayContainsUnnestFunction, ArrayGetBracketFunction, ArrayGetUnnestFunction, ArrayIncludesOperatorFunction, ArrayIncludesUnnestFunction, ArrayIntersectsOperatorFunction, ArrayIntersectsUnnestFunction, ArrayRemoveIndexUnnestFunction, ArrayReplaceUnnestFunction, ArraySetUnnestFunction, ArraySliceUnnestFunction, ArrayToStringFunction, AvgFunction, CaseLeastGreatestEmulation, CastFunction, CastingConcatFunction, CastStrEmulation, ChrLiteralEmulation, CoalesceIfnullEmulation, CockroachArrayFillFunction, CockroachDBJsonExistsFunction, CockroachDBJsonQueryFunction, CockroachDBJsonRemoveFunction, CockroachDBJsonValueFunction, ConcatPipeFunction, CountFunction, CurrentFunction, DateTruncEmulation, DB2FormatEmulation, DB2JsonArrayAggFunction, DB2JsonArrayFunction, DB2JsonObjectAggFunction, DB2JsonObjectFunction, DB2JsonValueFunction, DB2PositionFunction, DB2SubstringFunction, DynamicDispatchFunction, EveryAnyEmulation, ExtractFunction, FormatFunction, H2ArrayContainsFunction, H2ArrayFillFunction, H2ArrayIncludesFunction, H2ArrayIntersectsFunction, H2ArrayPositionFunction, H2ArrayPositionsFunction, H2ArrayRemoveFunction, H2ArrayRemoveIndexFunction, H2ArrayReplaceFunction, H2ArrayReverseFunction, H2ArraySetFunction, H2ArraySortFunction, H2ArrayToStringFunction, H2JsonArrayAggFunction, H2JsonArrayFunction, H2JsonExistsFunction, H2JsonObjectAggFunction, H2JsonObjectFunction, H2JsonQueryFunction, H2JsonValueFunction, H2XmlConcatFunction, H2XmlElementFunction, H2XmlForestFunction, H2XmlPiFunction, HANAJsonArrayAggFunction, HANAJsonArrayFunction, HANAJsonExistsFunction, HANAJsonObjectAggFunction, HANAJsonObjectFunction, HANAJsonValueFunction, HANARegexpLikeFunction, HANASpatialAggregate, HANASpatialFunction, HSQLArrayConstructorFunction, HSQLArrayFillFunction, HSQLArrayPositionFunction, HSQLArrayPositionsFunction, HSQLArrayRemoveFunction, HSQLArraySetFunction, HSQLArraySortFunction, HSQLArrayToStringFunction, HSQLJsonArrayAggFunction, HSQLJsonArrayFunction, HSQLJsonObjectFunction, HSQLRegexpLikeFunction, HypotheticalSetFunction, HypotheticalSetWindowEmulation, InsertSubstringOverlayEmulation, IntegralTimestampaddFunction, InverseDistributionFunction, InverseDistributionWindowEmulation, JdbcEscapeFunctionDescriptor, JsonArrayAggFunction, JsonArrayFunction, JsonExistsFunction, JsonObjectAggFunction, JsonObjectFunction, JsonQueryFunction, JsonValueFunction, LegacyDB2XmlExistsFunction, LegacyDB2XmlQueryFunction, LengthFunction, ListaggFunction, ListaggGroupConcatEmulation, ListaggStringAggEmulation, LocatePositionEmulation, LpadRpadPadEmulation, MariaDBJsonArrayAggFunction, MariaDBJsonArrayAppendFunction, MariaDBJsonArrayFunction, MariaDBJsonObjectAggFunction, MariaDBJsonQueryFunction, MariaDBJsonValueFunction, MinMaxCaseEveryAnyEmulation, ModeStatsModeEmulation, MultipatternSqmFunctionDescriptor, MySQLJsonArrayAggFunction, MySQLJsonArrayFunction, MySQLJsonExistsFunction, MySQLJsonObjectAggFunction, MySQLJsonObjectFunction, MySQLJsonQueryFunction, MySQLJsonValueFunction, NamedSqmFunctionDescriptor, NvlCoalesceEmulation, OracleArrayAggEmulation, OracleArrayConcatElementFunction, OracleArrayConcatFunction, OracleArrayConstructorFunction, OracleArrayContainsFunction, OracleArrayFillFunction, OracleArrayGetFunction, OracleArrayIncludesFunction, OracleArrayIntersectsFunction, OracleArrayLengthFunction, OracleArrayPositionFunction, OracleArrayPositionsFunction, OracleArrayRemoveFunction, OracleArrayRemoveIndexFunction, OracleArrayReplaceFunction, OracleArrayReverseFunction, OracleArraySetFunction, OracleArraySliceFunction, OracleArraySortFunction, OracleArrayToStringFunction, OracleArrayTrimFunction, OracleExtractFunction, OracleJsonArrayAggFunction, OracleJsonArrayAppendFunction, OracleJsonArrayFunction, OracleJsonArrayInsertFunction, OracleJsonInsertFunction, OracleJsonMergepatchFunction, OracleJsonObjectAggFunction, OracleJsonObjectFunction, OracleJsonRemoveFunction, OracleJsonReplaceFunction, OracleJsonSetFunction, OracleJsonValueFunction, OracleSpatialFunction, OracleSpatialSQLMMFunction, OracleTruncFunction, OrderByFragmentFunction, OrdinalFunction, PatternBasedSqmFunctionDescriptor, PostgreSQLArrayConcatElementFunction, PostgreSQLArrayConcatFunction, PostgreSQLArrayConstructorFunction, PostgreSQLArrayFillFunction, PostgreSQLArrayPositionFunction, PostgreSQLArrayPositionsFunction, PostgreSQLArrayReverseEmulation, PostgreSQLArraySortEmulation, PostgreSQLArrayTrimEmulation, PostgreSQLJsonArrayAggFunction, PostgreSQLJsonArrayAppendFunction, PostgreSQLJsonArrayFunction, PostgreSQLJsonArrayInsertFunction, PostgreSQLJsonExistsFunction, PostgreSQLJsonInsertFunction, PostgreSQLJsonMergepatchFunction, PostgreSQLJsonObjectAggFunction, PostgreSQLJsonObjectFunction, PostgreSQLJsonQueryFunction, PostgreSQLJsonRemoveFunction, PostgreSQLJsonReplaceFunction, PostgreSQLJsonSetFunction, PostgreSQLJsonValueFunction, PostgreSQLMinMaxFunction, PostgreSQLTruncFunction, PostgreSQLTruncRoundFunction, PostgreSQLXmlQueryFunction, RegexpLikeOperatorFunction, RegexpLikePredicateFunction, RegexpPredicateFunction, SDOGetGeometryType, SDOMethodDescriptor, SDORelateFunction, SpannerArrayConcatElementFunction, SpannerConcatFunction, SpannerExtractFunction, SpannerFormatFunction, SpannerJsonQueryFunction, SpannerJsonValueFunction, SpannerPostgreSQLArrayConcatElementFunction, SpannerPostgreSQLArrayRemoveFunction, SpannerPostgreSQLArrayRemoveIndexFunction, SpannerPostgreSQLArrayReplaceFunction, SpannerPostgreSQLArrayTrimEmulation, SpannerPostgreSQLJsonArrayFunction, SpannerPostgreSQLJsonObjectFunction, SpannerPostgreSQLRegexpLikeFunction, SpannerPostgreSQLTruncFunction, SpannerPostgreSQLTruncRoundFunction, SpannerTruncFunction, SqlColumn, SqlFunction, SqlServerConvertTruncFunction, SQLServerEveryAnyEmulation, SQLServerFormatEmulation, SQLServerJsonArrayAggFunction, SQLServerJsonArrayAppendFunction, SQLServerJsonArrayFunction, SQLServerJsonArrayInsertFunction, SQLServerJsonExistsFunction, SQLServerJsonInsertFunction, SQLServerJsonObjectAggFunction, SQLServerJsonObjectFunction, SQLServerJsonQueryFunction, SQLServerJsonRemoveFunction, SQLServerJsonReplaceFunction, SQLServerJsonSetFunction, SQLServerJsonValueFunction, SQLServerXmlAggFunction, SQLServerXmlConcatFunction, SQLServerXmlElementFunction, SQLServerXmlExistsFunction, SQLServerXmlForestFunction, SQLServerXmlPiFunction, SQLServerXmlQueryFunction, StandardSQLFunction, STRelateFunction, StringFunction, SybaseTruncFunction, TimestampaddFunction, TimestampdiffFunction, TransactSQLStrFunction, TrimFunction, TruncFunction, XmlAggFunction, XmlConcatFunction, XmlElementFunction, XmlExistsFunction, XmlForestFunction, XmlPiFunction, XmlQueryFunction
Produces SQM nodes for invocations of a named HQL function.
Hibernate obtains a descriptor from the SqmFunctionRegistry and invokes
generateSqmExpression(List, ReturnableType, QueryEngine) with the SQM arguments and implied result type. A
custom descriptor may desugar the invocation into other SQM nodes or return
a SelfRenderingSqmFunction which owns SQL AST rendering.
Prefer registry builders for simple named or pattern functions. Implement a descriptor when custom validation, SQM generation, type inference, or SQL rendering is required, and register it during function bootstrap. A registered descriptor must be safe for reuse and must not retain the boot-scoped contribution callback or mutable registry.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleanWill a call to the described function always include parentheses?default <T> SelfRenderingSqmFunction<T> generateAggregateSqmExpression(List<? extends SqmTypedNode<?>> arguments, SqmPredicate filter, ReturnableType<T> impliedResultType, QueryEngine queryEngine) LikegenerateSqmExpression(List, ReturnableType, QueryEngine), but also accepts afilterpredicate.default <T> SelfRenderingSqmFunction<T> generateOrderedSetAggregateSqmExpression(List<? extends SqmTypedNode<?>> arguments, SqmPredicate filter, SqmOrderByClause withinGroupClause, ReturnableType<T> impliedResultType, QueryEngine queryEngine) LikegenerateSqmExpression(List, ReturnableType, QueryEngine), but also accepts afilterpredicate and anorder byclause.<T> SelfRenderingSqmFunction<T> generateSqmExpression(List<? extends SqmTypedNode<?>> arguments, ReturnableType<T> impliedResultType, QueryEngine queryEngine) Instantiate this template with the given arguments and expected return type.default <T> SelfRenderingSqmFunction<T> generateSqmExpression(ReturnableType<T> impliedResultType, QueryEngine queryEngine) Convenience for no arguments.default <T> SelfRenderingSqmFunction<T> generateSqmExpression(SqmTypedNode<?> argument, ReturnableType<T> impliedResultType, QueryEngine queryEngine) Convenience for a single argument.default <T> SelfRenderingSqmFunction<T> generateWindowSqmExpression(List<? extends SqmTypedNode<?>> arguments, SqmPredicate filter, Boolean respectNulls, Boolean fromFirst, ReturnableType<T> impliedResultType, QueryEngine queryEngine) LikegenerateSqmExpression(List, ReturnableType, QueryEngine)but also accepts afilterpredicate.The object responsible for validating arguments of the function.default FunctionKindWhat sort of function is this?default StringgetSignature(String name) Used only for pretty-printing the function signature in the LOG.default booleanWhether the function renders as a predicate.
-
Method Details
-
generateSqmExpression
<T> SelfRenderingSqmFunction<T> generateSqmExpression(List<? extends SqmTypedNode<?>> arguments, @Nullable ReturnableType<T> impliedResultType, QueryEngine queryEngine) Instantiate this template with the given arguments and expected return type. This produces a tree of SQM nodes representing a tree of function invocations. This allows a single HQL function to be defined in terms of other predefined (database independent) HQL functions, simplifying the task of writing HQL functions which are portable between databases. -
generateAggregateSqmExpression
default <T> SelfRenderingSqmFunction<T> generateAggregateSqmExpression(List<? extends SqmTypedNode<?>> arguments, SqmPredicate filter, @Nullable ReturnableType<T> impliedResultType, QueryEngine queryEngine) LikegenerateSqmExpression(List, ReturnableType, QueryEngine), but also accepts afilterpredicate.This method is intended for aggregate functions.
-
generateOrderedSetAggregateSqmExpression
default <T> SelfRenderingSqmFunction<T> generateOrderedSetAggregateSqmExpression(List<? extends SqmTypedNode<?>> arguments, SqmPredicate filter, SqmOrderByClause withinGroupClause, @Nullable ReturnableType<T> impliedResultType, QueryEngine queryEngine) LikegenerateSqmExpression(List, ReturnableType, QueryEngine), but also accepts afilterpredicate and anorder byclause.This method is intended for ordered set aggregate functions.
-
generateWindowSqmExpression
default <T> SelfRenderingSqmFunction<T> generateWindowSqmExpression(List<? extends SqmTypedNode<?>> arguments, SqmPredicate filter, @Nullable Boolean respectNulls, @Nullable Boolean fromFirst, @Nullable ReturnableType<T> impliedResultType, QueryEngine queryEngine) LikegenerateSqmExpression(List, ReturnableType, QueryEngine)but also accepts afilterpredicate.This method is intended for window functions.
-
generateSqmExpression
default <T> SelfRenderingSqmFunction<T> generateSqmExpression(SqmTypedNode<?> argument, @Nullable ReturnableType<T> impliedResultType, QueryEngine queryEngine) Convenience for a single argument. -
generateSqmExpression
default <T> SelfRenderingSqmFunction<T> generateSqmExpression(@Nullable ReturnableType<T> impliedResultType, QueryEngine queryEngine) Convenience for no arguments. -
alwaysIncludesParentheses
default boolean alwaysIncludesParentheses()Will a call to the described function always include parentheses?Instances of this interface are usually used for rendering of functions. However, there are cases where Hibernate needs to consume a fragment and decide if a token represents a function name. In cases where the token is followed by an opening parenthesis, we can safely assume the token is a function name. Bur if the next token is not an opening parenthesis, the token might still represent a function if the function has a "no paren" form in the case of no arguments.
For example, many databases do not require parentheses for functions like
current_timestampand friends. This method helps account for those cases.- Returns:
trueby default- API Note:
- The most common case, by far, is that a function call requires the parentheses. So this method returns true by default.
-
getSignature
-
getFunctionKind
What sort of function is this?- Returns:
FunctionKind.NORMALby default
-
getArgumentsValidator
ArgumentsValidator getArgumentsValidator()The object responsible for validating arguments of the function.- Returns:
- an instance of
ArgumentsValidator
-
isPredicate
default boolean isPredicate()Whether the function renders as a predicate.- Since:
- 7.0
-