public class

VarArgsSQLFunction

extends Object
implements SQLFunction
java.lang.Object
   ↳ org.hibernate.dialect.function.VarArgsSQLFunction

Class Overview

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

Summary

Public Constructors
VarArgsSQLFunction(Type registeredType, String begin, String sep, String end)
Constructs a VarArgsSQLFunction instance with a 'static' return type.
VarArgsSQLFunction(String begin, String sep, String end)
Constructs a VarArgsSQLFunction instance with a 'dynamic' return type.
Public Methods
Type getReturnType(Type firstArgumentType, Mapping mapping)
The return type of the function.
boolean hasArguments()
Does this function have any arguments?

Always returns true here.

boolean hasParenthesesIfNoArguments()
If there are no arguments, are parentheses required?

Always returns true here.

String render(Type firstArgumentType, List arguments, SessionFactoryImplementor factory)
Render the function call as SQL fragment.
Protected Methods
String transformArgument(String argument)
Called from render(Type, List, SessionFactoryImplementor) to allow applying a change or transformation to each individual argument.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.hibernate.dialect.function.SQLFunction

Public Constructors

public VarArgsSQLFunction (Type registeredType, 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
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.

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.

Public Methods

public Type getReturnType (Type firstArgumentType, Mapping mapping)

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 into render(Type, List, SessionFactoryImplementor)

Parameters
firstArgumentType The type of the first argument
mapping The mapping source.
Returns
  • The type to be expected as a return.

public boolean hasArguments ()

Does this function have any arguments?

Always returns true here.

Returns
  • True if the function expects to have parameters; false otherwise.

public boolean hasParenthesesIfNoArguments ()

If there are no arguments, are parentheses required?

Always returns true here.

Returns
  • True if a no-arg call of this function requires parentheses.

public String render (Type firstArgumentType, List arguments, SessionFactoryImplementor factory)

Render the function call as SQL fragment.

Note, the 'firstArgumentType' parameter should match the one passed into getReturnType(Type, Mapping)

Parameters
firstArgumentType The type of the first argument
arguments The function arguments
factory The SessionFactory
Returns
  • The rendered function call

Protected Methods

protected String transformArgument (String argument)

Called from render(Type, 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.