Package org.hibernate.query.sqm.function
Class SqmFunctionRegistry
- java.lang.Object
-
- org.hibernate.query.sqm.function.SqmFunctionRegistry
-
public class SqmFunctionRegistry extends Object
Defines a registry forSqmFunctionDescriptor
instances.The
SqmFunctionRegistry
may be configured by aFunctionContributor
.- See Also:
FunctionContributor
,FunctionContributions
-
-
Constructor Summary
Constructors Constructor Description SqmFunctionRegistry()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
SqmFunctionDescriptor
findFunctionDescriptor(String functionName)
Find a SqmFunctionTemplate by name.Stream<Map.Entry<String,SqmFunctionDescriptor>>
getFunctionsByName()
Useful for diagnostics - not efficient: do not use in production code.Set<String>
getValidFunctionKeys()
NamedFunctionDescriptorBuilder
namedAggregateDescriptorBuilder(String name)
Get a builder for creating and registering a name-based aggregate function descriptor using the passed name as both the registration key and underlying SQL function nameNamedFunctionDescriptorBuilder
namedAggregateDescriptorBuilder(String registrationKey, String name)
Get a builder for creating and registering a name-based aggregate function descriptor.NamedFunctionDescriptorBuilder
namedDescriptorBuilder(String name)
Get a builder for creating and registering a name-based function descriptor using the passed name as both the registration key and underlying SQL function nameNamedFunctionDescriptorBuilder
namedDescriptorBuilder(String registrationKey, String name)
Get a builder for creating and registering a name-based function descriptor.NamedFunctionDescriptorBuilder
namedOrderedSetAggregateDescriptorBuilder(String name)
Get a builder for creating and registering a name-based ordered set-aggregate function descriptor using the passed name as both the registration key and underlying SQL function nameNamedFunctionDescriptorBuilder
namedOrderedSetAggregateDescriptorBuilder(String registrationKey, String name)
Get a builder for creating and registering a name-based ordered set-aggregate function descriptor.NamedFunctionDescriptorBuilder
namedWindowDescriptorBuilder(String name)
Get a builder for creating and registering a name-based window function descriptor using the passed name as both the registration key and underlying SQL function nameNamedFunctionDescriptorBuilder
namedWindowDescriptorBuilder(String registrationKey, String name)
Get a builder for creating and registering a name-based window function descriptor.NamedFunctionDescriptorBuilder
noArgsBuilder(String name)
NamedFunctionDescriptorBuilder
noArgsBuilder(String registrationKey, String name)
void
overlay(SqmFunctionRegistry registryToOverly)
Overlay the functions registered here on top of the incoming registry, potentially overriding its registrationsPatternFunctionDescriptorBuilder
patternAggregateDescriptorBuilder(String registrationKey, String pattern)
Get a builder for creating and registering a pattern-based aggregate function descriptor.PatternFunctionDescriptorBuilder
patternDescriptorBuilder(String registrationKey, String pattern)
Get a builder for creating and registering a pattern-based function descriptor.SqmFunctionDescriptor
register(String registrationKey, SqmFunctionDescriptor function)
Register a function descriptor by namevoid
registerAlternateKey(String alternateKey, String mappedKey)
MultipatternSqmFunctionDescriptor
registerBinaryTernaryPattern(String name, BasicType<?> type, String pattern2, String pattern3, FunctionParameterType parameterType1, FunctionParameterType parameterType2, FunctionParameterType parameterType3, TypeConfiguration typeConfiguration)
Register a binary/ternary function.SqmFunctionDescriptor
registerNamed(String name)
Register a named descriptor by name.SqmFunctionDescriptor
registerNamed(String name, BasicType returnType)
Register a named descriptor by name and invariant return type.SqmFunctionDescriptor
registerNoArgs(String name)
Specialized registration method for registering a named descriptor for functions expecting zero arguments.SqmFunctionDescriptor
registerNoArgs(String registrationKey, String name)
SqmFunctionDescriptor
registerNoArgs(String registrationKey, String name, BasicType returnType)
SqmFunctionDescriptor
registerNoArgs(String name, BasicType returnType)
MultipatternSqmFunctionDescriptor
registerNullaryUnaryPattern(String name, BasicType type, String pattern0, String pattern1, FunctionParameterType parameterType, TypeConfiguration typeConfiguration)
Register a nullary/unary function.SqmFunctionDescriptor
registerPattern(String name, String pattern)
Register a pattern-based descriptor by name.SqmFunctionDescriptor
registerPattern(String name, String pattern, BasicType returnType)
Register a pattern-based descriptor by name and invariant return type.MultipatternSqmFunctionDescriptor
registerTernaryQuaternaryPattern(String name, BasicType<?> type, String pattern3, String pattern4, FunctionParameterType parameterType1, FunctionParameterType parameterType2, FunctionParameterType parameterType3, FunctionParameterType parameterType4, TypeConfiguration typeConfiguration)
Register a ternary/quaternary function.MultipatternSqmFunctionDescriptor
registerUnaryBinaryPattern(String name, String pattern1, String pattern2, FunctionParameterType parameterType1, FunctionParameterType parameterType2, TypeConfiguration typeConfiguration)
Register a unary/binary function.MultipatternSqmFunctionDescriptor
registerUnaryBinaryPattern(String name, BasicType<?> type, String pattern1, String pattern2, FunctionParameterType parameterType1, FunctionParameterType parameterType2, TypeConfiguration typeConfiguration)
Register a unary/binary function.SqmFunctionDescriptor
wrapInJdbcEscape(String name, SqmFunctionDescriptor wrapped)
-
-
-
Method Detail
-
getFunctionsByName
public Stream<Map.Entry<String,SqmFunctionDescriptor>> getFunctionsByName()
Useful for diagnostics - not efficient: do not use in production code.- Returns:
-
findFunctionDescriptor
public SqmFunctionDescriptor findFunctionDescriptor(String functionName)
Find a SqmFunctionTemplate by name. Returnsnull
if no such function is found.
-
register
public SqmFunctionDescriptor register(String registrationKey, SqmFunctionDescriptor function)
Register a function descriptor by name
-
registerPattern
public SqmFunctionDescriptor registerPattern(String name, String pattern)
Register a pattern-based descriptor by name. Shortcut for building the descriptor viapatternDescriptorBuilder(java.lang.String, java.lang.String)
accepting its defaults.
-
registerPattern
public SqmFunctionDescriptor registerPattern(String name, String pattern, BasicType returnType)
Register a pattern-based descriptor by name and invariant return type. Shortcut for building the descriptor viapatternDescriptorBuilder(java.lang.String, java.lang.String)
accepting its defaults.
-
patternDescriptorBuilder
public PatternFunctionDescriptorBuilder patternDescriptorBuilder(String registrationKey, String pattern)
Get a builder for creating and registering a pattern-based function descriptor.- Parameters:
registrationKey
- The name under which the descriptor will get registeredpattern
- The pattern defining the underlying function call- Returns:
- The builder
-
patternAggregateDescriptorBuilder
public PatternFunctionDescriptorBuilder patternAggregateDescriptorBuilder(String registrationKey, String pattern)
Get a builder for creating and registering a pattern-based aggregate function descriptor.- Parameters:
registrationKey
- The name under which the descriptor will get registeredpattern
- The pattern defining the underlying function call- Returns:
- The builder
-
registerNamed
public SqmFunctionDescriptor registerNamed(String name)
Register a named descriptor by name. Shortcut for building a descriptor vianamedDescriptorBuilder(java.lang.String)
using the passed name as both the registration key and underlying SQL function name and accepting the builder's defaults.- Parameters:
name
- The function name (and registration key)
-
registerNamed
public SqmFunctionDescriptor registerNamed(String name, BasicType returnType)
Register a named descriptor by name and invariant return type. Shortcut for building a descriptor vianamedDescriptorBuilder(java.lang.String)
using the passed name as both the registration key and underlying SQL function name and accepting the builder's defaults.- Parameters:
name
- The function name (and registration key)
-
namedDescriptorBuilder
public NamedFunctionDescriptorBuilder namedDescriptorBuilder(String name)
Get a builder for creating and registering a name-based function descriptor using the passed name as both the registration key and underlying SQL function name- Parameters:
name
- The function name (and registration key)- Returns:
- The builder
-
namedAggregateDescriptorBuilder
public NamedFunctionDescriptorBuilder namedAggregateDescriptorBuilder(String name)
Get a builder for creating and registering a name-based aggregate function descriptor using the passed name as both the registration key and underlying SQL function name- Parameters:
name
- The function name (and registration key)- Returns:
- The builder
-
namedOrderedSetAggregateDescriptorBuilder
public NamedFunctionDescriptorBuilder namedOrderedSetAggregateDescriptorBuilder(String name)
Get a builder for creating and registering a name-based ordered set-aggregate function descriptor using the passed name as both the registration key and underlying SQL function name- Parameters:
name
- The function name (and registration key)- Returns:
- The builder
-
namedWindowDescriptorBuilder
public NamedFunctionDescriptorBuilder namedWindowDescriptorBuilder(String name)
Get a builder for creating and registering a name-based window function descriptor using the passed name as both the registration key and underlying SQL function name- Parameters:
name
- The function name (and registration key)- Returns:
- The builder
-
namedDescriptorBuilder
public NamedFunctionDescriptorBuilder namedDescriptorBuilder(String registrationKey, String name)
Get a builder for creating and registering a name-based function descriptor.- Parameters:
registrationKey
- The name under which the descriptor will get registeredname
- The underlying SQL function name to use- Returns:
- The builder
-
namedAggregateDescriptorBuilder
public NamedFunctionDescriptorBuilder namedAggregateDescriptorBuilder(String registrationKey, String name)
Get a builder for creating and registering a name-based aggregate function descriptor.- Parameters:
registrationKey
- The name under which the descriptor will get registeredname
- The underlying SQL function name to use- Returns:
- The builder
-
namedOrderedSetAggregateDescriptorBuilder
public NamedFunctionDescriptorBuilder namedOrderedSetAggregateDescriptorBuilder(String registrationKey, String name)
Get a builder for creating and registering a name-based ordered set-aggregate function descriptor.- Parameters:
registrationKey
- The name under which the descriptor will get registeredname
- The underlying SQL function name to use- Returns:
- The builder
-
namedWindowDescriptorBuilder
public NamedFunctionDescriptorBuilder namedWindowDescriptorBuilder(String registrationKey, String name)
Get a builder for creating and registering a name-based window function descriptor.- Parameters:
registrationKey
- The name under which the descriptor will get registeredname
- The underlying SQL function name to use- Returns:
- The builder
-
noArgsBuilder
public NamedFunctionDescriptorBuilder noArgsBuilder(String name)
-
noArgsBuilder
public NamedFunctionDescriptorBuilder noArgsBuilder(String registrationKey, String name)
-
registerNoArgs
public SqmFunctionDescriptor registerNoArgs(String name)
Specialized registration method for registering a named descriptor for functions expecting zero arguments. Short-cut for building a named descriptor vianamedDescriptorBuilder(java.lang.String)
specifying zero arguments and accepting the rest of the builder's defaults.- Parameters:
name
- The function name (and registration key)
-
registerNoArgs
public SqmFunctionDescriptor registerNoArgs(String registrationKey, String name)
-
registerNoArgs
public SqmFunctionDescriptor registerNoArgs(String name, BasicType returnType)
-
registerNoArgs
public SqmFunctionDescriptor registerNoArgs(String registrationKey, String name, BasicType returnType)
-
wrapInJdbcEscape
public SqmFunctionDescriptor wrapInJdbcEscape(String name, SqmFunctionDescriptor wrapped)
-
registerNullaryUnaryPattern
public MultipatternSqmFunctionDescriptor registerNullaryUnaryPattern(String name, BasicType type, String pattern0, String pattern1, FunctionParameterType parameterType, TypeConfiguration typeConfiguration)
Register a nullary/unary function. i.e. a function which accepts 0-1 arguments.
-
registerUnaryBinaryPattern
public MultipatternSqmFunctionDescriptor registerUnaryBinaryPattern(String name, String pattern1, String pattern2, FunctionParameterType parameterType1, FunctionParameterType parameterType2, TypeConfiguration typeConfiguration)
Register a unary/binary function. i.e. a function which accepts 1-2 arguments.
-
registerUnaryBinaryPattern
public MultipatternSqmFunctionDescriptor registerUnaryBinaryPattern(String name, BasicType<?> type, String pattern1, String pattern2, FunctionParameterType parameterType1, FunctionParameterType parameterType2, TypeConfiguration typeConfiguration)
Register a unary/binary function. i.e. a function which accepts 1-2 arguments.
-
registerBinaryTernaryPattern
public MultipatternSqmFunctionDescriptor registerBinaryTernaryPattern(String name, BasicType<?> type, String pattern2, String pattern3, FunctionParameterType parameterType1, FunctionParameterType parameterType2, FunctionParameterType parameterType3, TypeConfiguration typeConfiguration)
Register a binary/ternary function. i.e. a function which accepts 2-3 arguments.
-
registerTernaryQuaternaryPattern
public MultipatternSqmFunctionDescriptor registerTernaryQuaternaryPattern(String name, BasicType<?> type, String pattern3, String pattern4, FunctionParameterType parameterType1, FunctionParameterType parameterType2, FunctionParameterType parameterType3, FunctionParameterType parameterType4, TypeConfiguration typeConfiguration)
Register a ternary/quaternary function. i.e. a function which accepts 3-4 arguments.
-
overlay
public void overlay(SqmFunctionRegistry registryToOverly)
Overlay the functions registered here on top of the incoming registry, potentially overriding its registrations
-
close
public void close()
-
-