Top Description Fields Constructors Methods
org.hibernate.dialect.function

public Class VarArgsSQLFunction

extends Object
implements SQLFunction
Class Inheritance
All Implemented Interfaces
org.hibernate.dialect.function.SQLFunction
Imports
java.util.List, org.hibernate.QueryException, org.hibernate.engine.spi.Mapping, .SessionFactoryImplementor, org.hibernate.type.Type

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

Field Summary

Modifier and TypeField and Description
private final String
private final String
private final Type
private final String

Constructor Summary

AccessConstructor and Description
public
VarArgsSQLFunction(Type
The return type.
registeredType
,
String
The beginning of the function templating.
begin
,
String
The separator for each individual function argument.
sep
,
String
The end of the function templating.
end
)

Constructs a VarArgsSQLFunction instance with a 'static' return type.

public
VarArgsSQLFunction(String
The beginning of the function templating.
begin
,
String
The separator for each individual function argument.
sep
,
String
The end of the function templating.
end
)

Constructs a VarArgsSQLFunction instance with a 'dynamic' return type.

Method Summary

Modifier and TypeMethod and Description
public Type
getReturnType(Type
The type of the first argument
firstArgumentType
,
Mapping
The mapping source.
mapping
)

Implements org.hibernate.dialect.function.SQLFunction.getReturnType.

The return type of the function.
public boolean
hasArguments()

Implements org.hibernate.dialect.function.SQLFunction.hasArguments.

Does this function have any arguments?
public boolean
hasParenthesesIfNoArguments()

Implements org.hibernate.dialect.function.SQLFunction.hasParenthesesIfNoArguments.

If there are no arguments, are parentheses required?
public String
render(Type
The type of the first argument
firstArgumentType
,
List<E>
The function arguments
arguments
,
SessionFactoryImplementor
The SessionFactory
factory
)

Implements org.hibernate.dialect.function.SQLFunction.render.

Deprecated as a consequence of SessionFactoryImplementor being deprecated.
Render the function call as SQL fragment.
protected String

Returns:

The transformed argument; may be the same, though should never be null.
transformArgument
(String
The argument being processed.
argument
)

Called from render to allow applying a change or transformation to each individual argument.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

beginback to summary
private final String begin
endback to summary
private final String end
registeredTypeback to summary
private final Type registeredType
sepback to summary
private final String sep

Constructor Detail

VarArgsSQLFunctionback to summary
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:Type

The return type.

begin:String

The beginning of the function templating.

sep:String

The separator for each individual function argument.

end:String

The end of the function templating.

VarArgsSQLFunctionback to summary
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:String

The beginning of the function templating.

sep:String

The separator for each individual function argument.

end:String

The end of the function templating.

See Also
Specifically, the 'firstArgumentType' argument is the 'dynamic' type.

Method Detail

getReturnTypeback to summary
public Type getReturnType(Type firstArgumentType, Mapping mapping) throws QueryException

Implements org.hibernate.dialect.function.SQLFunction.getReturnType.

Doc from org.hibernate.dialect.function.SQLFunction.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 into render

Parameters
firstArgumentType:Type

The type of the first argument

mapping:Mapping

The mapping source.

Returns:Type

The type to be expected as a return.

Annotations
@Override
Exceptions
QueryException:
Indicates an issue resolving the return type.
hasArgumentsback to summary
public boolean hasArguments()

Implements org.hibernate.dialect.function.SQLFunction.hasArguments.

Doc from org.hibernate.dialect.function.SQLFunction.hasArguments.

Does this function have any arguments?

Returns:boolean

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

Annotations
@Override
hasParenthesesIfNoArgumentsback to summary
public boolean hasParenthesesIfNoArguments()

Implements org.hibernate.dialect.function.SQLFunction.hasParenthesesIfNoArguments.

Doc from org.hibernate.dialect.function.SQLFunction.hasParenthesesIfNoArguments.

If there are no arguments, are parentheses required?

Returns:boolean

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

Annotations
@Override
renderback to summary
public String render(Type firstArgumentType, List<E> arguments, SessionFactoryImplementor factory)

Implements org.hibernate.dialect.function.SQLFunction.render.

Doc from org.hibernate.dialect.function.SQLFunction.render.

Deprecated

as a consequence of SessionFactoryImplementor being deprecated. See corresponding docs for further information.

Render the function call as SQL fragment.

Note, the 'firstArgumentType' parameter should match the one passed into getReturnType

Parameters
firstArgumentType:Type

The type of the first argument

arguments:List<E>

The function arguments

factory:SessionFactoryImplementor

The SessionFactory

Returns:String

The rendered function call

Annotations
@Override
transformArgumentback to summary
protected String transformArgument(String argument)

Called from render to allow applying a change or transformation to each individual argument.

Parameters
argument:String

The argument being processed.

Returns:String

The transformed argument; may be the same, though should never be null.