Package org.hibernate.dialect.function
Class VarArgsSQLFunction
java.lang.Object
org.hibernate.dialect.function.VarArgsSQLFunction
- All Implemented Interfaces:
SQLFunction
Support for slightly more general templating than
StandardSQLFunction, with an unlimited number of arguments.-
Constructor Summary
ConstructorsConstructorDescriptionVarArgsSQLFunction(String begin, String sep, String end) Constructs a VarArgsSQLFunction instance with a 'dynamic' return type.VarArgsSQLFunction(Type registeredType, String begin, String sep, String end) Constructs a VarArgsSQLFunction instance with a 'static' return type. -
Method Summary
Modifier and TypeMethodDescriptiongetReturnType(Type firstArgumentType, Mapping mapping) The return type of the function.booleanDoes this function have any arguments?booleanIf there are no arguments, are parentheses required?render(Type firstArgumentType, List arguments, SessionFactoryImplementor factory) Render the function call as SQL fragment.protected StringtransformArgument(String argument) Called fromrender(org.hibernate.type.Type, java.util.List, org.hibernate.engine.SessionFactoryImplementor)to allow applying a change or transformation to each individual argument.
-
Constructor Details
-
VarArgsSQLFunction
Constructs a VarArgsSQLFunction instance with a 'static' return type. An example of a 'static' return type would be something like an UPPER function which is always returning a SQL VARCHAR and thus a string type.- Parameters:
registeredType- The return type.begin- The beginning of the function templating.sep- The separator for each individual function argument.end- The end of the function templating.
-
VarArgsSQLFunction
Constructs a VarArgsSQLFunction instance with a 'dynamic' return type. For a dynamic return type, the type of the arguments are used to resolve the type. An example of a function with a 'dynamic' return would be MAX or MIN which return a double or an integer etc based on the types of the arguments.- Parameters:
begin- The beginning of the function templating.sep- The separator for each individual function argument.end- The end of the function templating.- See Also:
-
-
Method Details
-
hasArguments
public boolean hasArguments()Does this function have any arguments? Always returns true here.- Specified by:
hasArgumentsin interfaceSQLFunction- Returns:
- True if the function expects to have parameters; false otherwise.
-
hasParenthesesIfNoArguments
public boolean hasParenthesesIfNoArguments()If there are no arguments, are parentheses required? Always returns true here.- Specified by:
hasParenthesesIfNoArgumentsin interfaceSQLFunction- Returns:
- True if a no-arg call of this function requires parentheses.
-
getReturnType
The return type of the function. May be either a concrete type which is preset, or variable depending upon the type of the first function argument. Note, the 'firstArgumentType' parameter should match the one passed intoSQLFunction.render(org.hibernate.type.Type, java.util.List, org.hibernate.engine.SessionFactoryImplementor)- Specified by:
getReturnTypein interfaceSQLFunction- Parameters:
firstArgumentType- The type of the first argumentmapping- The mapping source.- Returns:
- The type to be expected as a return.
- Throws:
QueryException- Indicates an issue resolving the return type.
-
render
Description copied from interface:SQLFunctionRender the function call as SQL fragment. Note, the 'firstArgumentType' parameter should match the one passed intoSQLFunction.getReturnType(org.hibernate.type.Type, org.hibernate.engine.Mapping)- Specified by:
renderin interfaceSQLFunction- Parameters:
firstArgumentType- The type of the first argumentarguments- The function argumentsfactory- The SessionFactory- Returns:
- The rendered function call
-
transformArgument
Called fromrender(org.hibernate.type.Type, java.util.List, org.hibernate.engine.SessionFactoryImplementor)to allow applying a change or transformation to each individual argument.- Parameters:
argument- The argument being processed.- Returns:
- The transformed argument; may be the same, though should never be null.
-