org.hibernate.dialect.function

Class SQLFunctionTemplate

Implemented Interfaces:
SQLFunction

public class SQLFunctionTemplate
extends java.lang.Object
implements SQLFunction

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).
Version:
$Revision: 6608 $
Author:
Alexey Loubyansky

Constructor Summary

SQLFunctionTemplate(Type type, String template)
SQLFunctionTemplate(Type type, String template, boolean hasParenthesesIfNoArgs)

Method Summary

Type
getReturnType(Type columnType, Mapping mapping)
boolean
hasArguments()
boolean
hasParenthesesIfNoArguments()
String
render(List args, SessionFactoryImplementor factory)
Applies the template to passed in arguments.
String
toString()

Constructor Details

SQLFunctionTemplate

public SQLFunctionTemplate(Type type,
                           String template)

SQLFunctionTemplate

public SQLFunctionTemplate(Type type,
                           String template,
                           boolean hasParenthesesIfNoArgs)

Method Details

getReturnType

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

hasArguments

public boolean hasArguments()
Specified by:
hasArguments in interface SQLFunction

hasParenthesesIfNoArguments

public boolean hasParenthesesIfNoArguments()
Specified by:
hasParenthesesIfNoArguments in interface SQLFunction

render

public String render(List args,
                     SessionFactoryImplementor factory)
Applies the template to passed in arguments.
Specified by:
render in interface SQLFunction
Parameters:
args - function arguments
Returns:
generated SQL function call

toString

public String toString()