Package org.hibernate.dialect.function
Class VarArgsSQLFunction
- java.lang.Object
-
- org.hibernate.dialect.function.VarArgsSQLFunction
-
- All Implemented Interfaces:
SQLFunction
public class VarArgsSQLFunction extends java.lang.Object implements SQLFunction
Support for slightly more general templating thanStandardSQLFunction
, with an unlimited number of arguments.
-
-
Constructor Summary
Constructors Constructor Description VarArgsSQLFunction(java.lang.String begin, java.lang.String sep, java.lang.String end)
Constructs a VarArgsSQLFunction instance with a 'dynamic' return type.VarArgsSQLFunction(Type registeredType, java.lang.String begin, java.lang.String sep, java.lang.String end)
Constructs a VarArgsSQLFunction instance with a 'static' return type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Type
getReturnType(Type firstArgumentType, Mapping mapping)
The return type of the function.boolean
hasArguments()
Does this function have any arguments?boolean
hasParenthesesIfNoArguments()
If there are no arguments, are parentheses required?java.lang.String
render(Type firstArgumentType, java.util.List arguments, SessionFactoryImplementor factory)
Render the function call as SQL fragment.protected java.lang.String
transformArgument(java.lang.String argument)
Called fromrender(org.hibernate.type.Type, java.util.List, org.hibernate.engine.spi.SessionFactoryImplementor)
to allow applying a change or transformation to each individual argument.
-
-
-
Constructor Detail
-
VarArgsSQLFunction
public VarArgsSQLFunction(Type registeredType, java.lang.String begin, java.lang.String sep, java.lang.String end)
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
public VarArgsSQLFunction(java.lang.String begin, java.lang.String sep, java.lang.String end)
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:
Specifically, the 'firstArgumentType' argument is the 'dynamic' type.
-
-
Method Detail
-
hasArguments
public boolean hasArguments()
Description copied from interface:SQLFunction
Does this function have any arguments?- Specified by:
hasArguments
in interfaceSQLFunction
- Returns:
- True if the function expects to have parameters; false otherwise.
-
hasParenthesesIfNoArguments
public boolean hasParenthesesIfNoArguments()
Description copied from interface:SQLFunction
If there are no arguments, are parentheses required?- Specified by:
hasParenthesesIfNoArguments
in interfaceSQLFunction
- Returns:
- True if a no-arg call of this function requires parentheses.
-
getReturnType
public Type getReturnType(Type firstArgumentType, Mapping mapping) throws QueryException
Description copied from interface:SQLFunction
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.spi.SessionFactoryImplementor)
- Specified by:
getReturnType
in 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
public java.lang.String render(Type firstArgumentType, java.util.List arguments, SessionFactoryImplementor factory)
Description copied from interface:SQLFunction
Render the function call as SQL fragment. Note, the 'firstArgumentType' parameter should match the one passed intoSQLFunction.getReturnType(org.hibernate.type.Type, org.hibernate.engine.spi.Mapping)
- Specified by:
render
in interfaceSQLFunction
- Parameters:
firstArgumentType
- The type of the first argumentarguments
- The function argumentsfactory
- The SessionFactory- Returns:
- The rendered function call
-
transformArgument
protected java.lang.String transformArgument(java.lang.String argument)
Called fromrender(org.hibernate.type.Type, java.util.List, org.hibernate.engine.spi.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.
-
-