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
org.hibernate.QueryException, org.hibernate.engine.Mapping, .SessionFactoryImplementor, org.hibernate.type.Type, java.util.List

Represents HQL functions that can have different representations in different SQL dialects. E.g. in HQL we can define function concat(?1, ?2) to concatenate two strings p1 and p2. Target SQL function will be dialect-specific, e.g. (?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
public
SQLFunctionTemplate(Type type, String template, boolean hasParenthesesIfNoArgs)

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.

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)
SQLFunctionTemplateback to summary
public SQLFunctionTemplate(Type type, String template, boolean hasParenthesesIfNoArgs)

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.

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.

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.

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.

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

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.