org.hibernate.dialect.function

Class VarArgsSQLFunction

Implemented Interfaces:
SQLFunction

public class VarArgsSQLFunction
extends java.lang.Object
implements SQLFunction

Support for slightly more general templating than StandardSQLFunction, with an unlimited number of arguments.
Author:
Gavin King

Constructor Summary

VarArgsSQLFunction(String begin, String sep, String end)
Constructs a VarArgsSQLFunction instance with a 'dynamic' return type.
VarArgsSQLFunction(Type type, String begin, String sep, String end)
Constructs a VarArgsSQLFunction instance with a 'static' return type.

Method Summary

Type
getReturnType(Type columnType, Mapping mapping)
boolean
hasArguments()
Always returns true here.
boolean
hasParenthesesIfNoArguments()
Always returns true here.
String
render(List args, SessionFactoryImplementor factory)
protected String
transformArgument(String argument)
Called from render(List,SessionFactoryImplementor) to allow applying a change or transformation to each individual argument.

Constructor Details

VarArgsSQLFunction

public VarArgsSQLFunction(String begin,
                          String sep,
                          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.

VarArgsSQLFunction

public VarArgsSQLFunction(Type type,
                          String begin,
                          String sep,
                          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:
type - 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.

Method Details

getReturnType

public Type getReturnType(Type columnType,
                          Mapping mapping)
            throws QueryException
Specified by:
getReturnType in interface SQLFunction

hasArguments

public boolean hasArguments()
Always returns true here.
Specified by:
hasArguments in interface SQLFunction

hasParenthesesIfNoArguments

public boolean hasParenthesesIfNoArguments()
Always returns true here.
Specified by:
hasParenthesesIfNoArguments in interface SQLFunction

render

public String render(List args,
                     SessionFactoryImplementor factory)
            throws QueryException
Specified by:
render in interface SQLFunction

transformArgument

protected String transformArgument(String argument)
Called from render(List,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.