org.hibernate.dialect.function
Class StandardSQLFunction

java.lang.Object
  extended by org.hibernate.dialect.function.StandardSQLFunction
All Implemented Interfaces:
SQLFunction
Direct Known Subclasses:
ClassicAvgFunction, ClassicCountFunction, ClassicSumFunction, ConditionalParenthesisFunction, StandardAnsiSqlAggregationFunctions.AvgFunction, StandardAnsiSqlAggregationFunctions.CountFunction, StandardAnsiSqlAggregationFunctions.MaxFunction, StandardAnsiSqlAggregationFunctions.MinFunction, StandardAnsiSqlAggregationFunctions.SumFunction, StandardJDBCEscapeFunction

public class StandardSQLFunction
extends Object
implements SQLFunction

Provides a standard implementation that supports the majority of the HQL functions that are translated to SQL. The Dialect and its sub-classes use this class to provide details required for processing of the associated function.

Author:
David Channon

Constructor Summary
StandardSQLFunction(String name)
          Construct a standard SQL function definition with a variable return type; the actual return type will depend on the types to which the function is applied.
StandardSQLFunction(String name, Type registeredType)
          Construct a standard SQL function definition with a static return type.
 
Method Summary
 String getName()
          Function name accessor
 Type getReturnType(Type firstArgumentType, Mapping mapping)
          The return type of the function.
 Type getType()
          Function static return type accessor.
 boolean hasArguments()
          Does this function have any arguments?
 boolean hasParenthesesIfNoArguments()
          If there are no arguments, are parentheses required?
 String render(Type firstArgumentType, List arguments, SessionFactoryImplementor sessionFactory)
          Render the function call as SQL fragment.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StandardSQLFunction

public StandardSQLFunction(String name)
Construct a standard SQL function definition with a variable return type; the actual return type will depend on the types to which the function is applied.

Using this form, the return type is considered non-static and assumed to be the type of the first argument.

Parameters:
name - The name of the function.

StandardSQLFunction

public StandardSQLFunction(String name,
                           Type registeredType)
Construct a standard SQL function definition with a static return type.

Parameters:
name - The name of the function.
registeredType - The static return type.
Method Detail

getName

public String getName()
Function name accessor

Returns:
The function name.

getType

public Type getType()
Function static return type accessor.

Returns:
The static function return type; or null if return type is not static.

hasArguments

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

Specified by:
hasArguments in interface SQLFunction
Returns:
True if the function expects to have parameters; false otherwise.

hasParenthesesIfNoArguments

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

Specified by:
hasParenthesesIfNoArguments in interface SQLFunction
Returns:
True if a no-arg call of this function requires parentheses.

getReturnType

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 SQLFunction.render(org.hibernate.type.Type, java.util.List, org.hibernate.engine.SessionFactoryImplementor)

Specified by:
getReturnType in interface SQLFunction
Parameters:
firstArgumentType - The type of the first argument
mapping - The mapping source.
Returns:
The type to be expected as a return.

render

public String render(Type firstArgumentType,
                     List arguments,
                     SessionFactoryImplementor sessionFactory)
Render the function call as SQL fragment.

Note, the 'firstArgumentType' parameter should match the one passed into SQLFunction.getReturnType(org.hibernate.type.Type, org.hibernate.engine.Mapping)

Specified by:
render in interface SQLFunction
Parameters:
firstArgumentType - The type of the first argument
arguments - The function arguments
sessionFactory - The SessionFactory
Returns:
The rendered function call

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2001-2010 Red Hat, Inc. All Rights Reserved.