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

public Class SQLFunctionTemplate

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

Represents HQL functions that can have different representations in different SQL dialects where that difference can be handled via a template/pattern.

E.g. in HQL we can define function concat(?1, ?2) to concatenate two strings p1 and p2. Dialects would register different versions of this class *using the same name* (concat) but with different templates or patterns; (?1 || ?2) for Oracle, concat(?1, ?2) for MySql, (?1 + ?2) for MS SQL. Each dialect will define a template as a string (exactly like above) marking function parameters with '?' followed by parameter's index (first index is 1).

Author
Alexey Loubyansky

Field Summary

Modifier and TypeField and Description
private final boolean
private final TemplateRenderer
private final Type

Constructor Summary

AccessConstructor and Description
public
SQLFunctionTemplate(Type
The functions return type
type
,
String
The function template
template
)

Constructs a SQLFunctionTemplate

public
SQLFunctionTemplate(Type
The functions return type
type
,
String
The function template
template
,
boolean
If there are no arguments, are parentheses required?
hasParenthesesIfNoArgs
)

Constructs a SQLFunctionTemplate

Method Summary

Modifier and TypeMethod and Description
public Type
getReturnType(Type
The type of the first argument
argumentType
,
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
argumentType
,
List<E>
The function arguments
args
,
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.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

hasParenthesesIfNoArgsback to summary
private final boolean hasParenthesesIfNoArgs
rendererback to summary
private final TemplateRenderer renderer
typeback to summary
private final Type type

Constructor Detail

SQLFunctionTemplateback to summary
public SQLFunctionTemplate(Type type, String template)

Constructs a SQLFunctionTemplate

Parameters
type:Type

The functions return type

template:String

The function template

SQLFunctionTemplateback to summary
public SQLFunctionTemplate(Type type, String template, boolean hasParenthesesIfNoArgs)

Constructs a SQLFunctionTemplate

Parameters
type:Type

The functions return type

template:String

The function template

hasParenthesesIfNoArgs:boolean

If there are no arguments, are parentheses required?

Method Detail

getReturnTypeback to summary
public Type getReturnType(Type argumentType, 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
argumentType: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 argumentType, List<E> args, 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
argumentType:Type

The type of the first argument

args:List<E>

The function arguments

factory:SessionFactoryImplementor

The SessionFactory

Returns:String

The rendered function call

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override