Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.hibernate.dialect.function
Class SQLFunctionTemplate  view SQLFunctionTemplate download SQLFunctionTemplate.java

java.lang.Object
  extended byorg.hibernate.dialect.function.SQLFunctionTemplate
All 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 $

Field Summary
private  java.lang.String[] chunks
           
private  boolean hasArguments
           
private  boolean hasParenthesesIfNoArgs
           
private  int[] paramIndexes
           
private  java.lang.String template
           
private  org.hibernate.type.Type type
           
 
Constructor Summary
SQLFunctionTemplate(org.hibernate.type.Type type, java.lang.String template)
           
SQLFunctionTemplate(org.hibernate.type.Type type, java.lang.String template, boolean hasParenthesesIfNoArgs)
           
 
Method Summary
 org.hibernate.type.Type getReturnType(org.hibernate.type.Type columnType, org.hibernate.engine.Mapping mapping)
          The function return type
 boolean hasArguments()
          Does this function have any arguments?
 boolean hasParenthesesIfNoArguments()
          If there are no arguments, are parens required?
 java.lang.String render(java.util.List args, org.hibernate.engine.SessionFactoryImplementor factory)
          Applies the template to passed in arguments.
 java.lang.String toString()
          Convert this Object to a human-readable String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

type

private final org.hibernate.type.Type type

hasArguments

private final boolean hasArguments

hasParenthesesIfNoArgs

private final boolean hasParenthesesIfNoArgs

template

private final java.lang.String template

chunks

private final java.lang.String[] chunks

paramIndexes

private final int[] paramIndexes
Constructor Detail

SQLFunctionTemplate

public SQLFunctionTemplate(org.hibernate.type.Type type,
                           java.lang.String template)

SQLFunctionTemplate

public SQLFunctionTemplate(org.hibernate.type.Type type,
                           java.lang.String template,
                           boolean hasParenthesesIfNoArgs)
Method Detail

render

public java.lang.String render(java.util.List args,
                               org.hibernate.engine.SessionFactoryImplementor factory)
Applies the template to passed in arguments.

Specified by:
render in interface SQLFunction

getReturnType

public org.hibernate.type.Type getReturnType(org.hibernate.type.Type columnType,
                                             org.hibernate.engine.Mapping mapping)
                                      throws org.hibernate.QueryException
Description copied from interface: SQLFunction
The function return type

Specified by:
getReturnType in interface SQLFunction

hasArguments

public boolean hasArguments()
Description copied from interface: SQLFunction
Does this function have any arguments?

Specified by:
hasArguments in interface SQLFunction

hasParenthesesIfNoArguments

public boolean hasParenthesesIfNoArguments()
Description copied from interface: SQLFunction
If there are no arguments, are parens required?

Specified by:
hasParenthesesIfNoArguments in interface SQLFunction

toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).