Top Description Inners Fields Constructors Methods
org.hibernate.sql

public final Class Template

extends Object
Class Inheritance
Imports
java.util.ArrayList, .HashSet, .List, .Set, .StringTokenizer, org.hibernate.HibernateException, org.hibernate.dialect.Dialect, org.hibernate.dialect.function.SQLFunction, .SQLFunctionRegistry, org.hibernate.util.StringHelper, org.hibernate.sql.ordering.antlr.ColumnMapper, .TranslationContext, .OrderByFragmentTranslator, org.hibernate.engine.SessionFactoryImplementor

Parses SQL fragments specified in mapping documents
Author
Gavin King

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
private static class

Field Summary

Modifier and TypeField and Description
private static final Set<String>
private static final Set<String>
private static final Set<String>
public static final String

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static String
extractUntil(StringTokenizer tokens, String delimiter)

private static boolean
isFunction(String lcToken, String nextToken, SQLFunctionRegistry functionRegistry)

private static boolean
isFunctionOrKeyword(String lcToken, String nextToken, Dialect dialect, SQLFunctionRegistry functionRegistry)

private static boolean
isIdentifier(String token, Dialect dialect)

private static boolean
public static String

Returns:

The rendered ORDER BY template.
renderOrderByStringTemplate
(String
The order-by fragment to render.
orderByFragment
,
Dialect
The SQL dialect being used.
dialect
,
SQLFunctionRegistry
The SQL function registry
functionRegistry
)

Performs order-by template rendering without column mapping.
public static String

Returns:

The rendered ORDER BY template.
renderOrderByStringTemplate
(String
The order-by fragment to render.
orderByFragment
,
final ColumnMapper
The column mapping strategy to use.
columnMapper
,
final SessionFactoryImplementor
The session factory.
sessionFactory
,
final Dialect
The SQL dialect being used.
dialect
,
final SQLFunctionRegistry
The SQL function registry
functionRegistry
)

Performs order-by template rendering allowing column mapping.

public static String
renderWhereStringTemplate(String sqlWhereString, Dialect dialect, SQLFunctionRegistry functionRegistry)

public static String
renderWhereStringTemplate(String sqlWhereString, String placeholder, Dialect dialect)

Deprecated Only intended for annotations usage; use renderWhereStringTemplate(String, String, Dialect, SQLFunctionRegistry) instead
Same functionality as renderWhereStringTemplate(String, String, Dialect, SQLFunctionRegistry), except that a SQLFunctionRegistry is not provided (i.e., only the dialect-defined functions are considered).
public static String

Returns:

The rendered sql fragment
renderWhereStringTemplate
(String
The string into which to interpolate the placeholder value
sqlWhereString
,
String
The value to be interpolated into the the sqlWhereString
placeholder
,
Dialect
The dialect to apply
dialect
,
SQLFunctionRegistry
The registry of all sql functions
functionRegistry
)

Takes the where condition provided in the mapping attribute and interpolates the alias.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BEFORE_TABLE_KEYWORDSback to summary
private static final Set<String> BEFORE_TABLE_KEYWORDS
FUNCTION_KEYWORDSback to summary
private static final Set<String> FUNCTION_KEYWORDS
KEYWORDSback to summary
private static final Set<String> KEYWORDS
TEMPLATEback to summary
public static final String TEMPLATE

Constructor Detail

Templateback to summary
private Template()

Method Detail

extractUntilback to summary
private static String extractUntil(StringTokenizer tokens, String delimiter)
isFunctionback to summary
private static boolean isFunction(String lcToken, String nextToken, SQLFunctionRegistry functionRegistry)
isFunctionOrKeywordback to summary
private static boolean isFunctionOrKeyword(String lcToken, String nextToken, Dialect dialect, SQLFunctionRegistry functionRegistry)
isIdentifierback to summary
private static boolean isIdentifier(String token, Dialect dialect)
isNamedParameterback to summary
private static boolean isNamedParameter(String token)
renderOrderByStringTemplateback to summary
public static String renderOrderByStringTemplate(String orderByFragment, Dialect dialect, SQLFunctionRegistry functionRegistry)

Performs order-by template rendering without column mapping. An ORDER BY template has all column references "qualified" with a placeholder identified by Template#TEMPLATE

Parameters
orderByFragment:String

The order-by fragment to render.

dialect:Dialect

The SQL dialect being used.

functionRegistry:SQLFunctionRegistry

The SQL function registry

Returns:String

The rendered ORDER BY template.

renderOrderByStringTemplateback to summary
public static String renderOrderByStringTemplate(String orderByFragment, final ColumnMapper columnMapper, final SessionFactoryImplementor sessionFactory, final Dialect dialect, final SQLFunctionRegistry functionRegistry)

Performs order-by template rendering allowing column mapping. An ORDER BY template has all column references "qualified" with a placeholder identified by Template#TEMPLATE which can later be used to easily inject the SQL alias.

Parameters
orderByFragment:String

The order-by fragment to render.

columnMapper:ColumnMapper

The column mapping strategy to use.

sessionFactory:SessionFactoryImplementor

The session factory.

dialect:Dialect

The SQL dialect being used.

functionRegistry:SQLFunctionRegistry

The SQL function registry

Returns:String

The rendered ORDER BY template.

renderWhereStringTemplateback to summary
public static String renderWhereStringTemplate(String sqlWhereString, Dialect dialect, SQLFunctionRegistry functionRegistry)
renderWhereStringTemplateback to summary
public static String renderWhereStringTemplate(String sqlWhereString, String placeholder, Dialect dialect)

Deprecated

Only intended for annotations usage; use renderWhereStringTemplate(String, String, Dialect, SQLFunctionRegistry) instead

Same functionality as renderWhereStringTemplate(String, String, Dialect, SQLFunctionRegistry), except that a SQLFunctionRegistry is not provided (i.e., only the dialect-defined functions are considered). This is only intended for use by the annotations project until the many-to-many/map-key-from-target-table feature is pulled into core.

Annotations
@SuppressWarnings:JavaDoc
renderWhereStringTemplateback to summary
public static String renderWhereStringTemplate(String sqlWhereString, String placeholder, Dialect dialect, SQLFunctionRegistry functionRegistry)

Takes the where condition provided in the mapping attribute and interpolates the alias. Handles sub-selects, quoted identifiers, quoted strings, expressions, SQL functions, named parameters.

Parameters
sqlWhereString:String

The string into which to interpolate the placeholder value

placeholder:String

The value to be interpolated into the the sqlWhereString

dialect:Dialect

The dialect to apply

functionRegistry:SQLFunctionRegistry

The registry of all sql functions

Returns:String

The rendered sql fragment

org.hibernate.sql back to summary

public Class Template.NoOpColumnMapper

extends Object
implements ColumnMapper
Class Inheritance
All Implemented Interfaces
org.hibernate.sql.ordering.antlr.ColumnMapper

Field Summary

Modifier and TypeField and Description
public static final Template.NoOpColumnMapper

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String[]
map(String
The property reference name.
reference
)

Implements org.hibernate.sql.ordering.antlr.ColumnMapper.map.

Resolve the property reference to its underlying columns.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INSTANCEback to summary
public static final Template.NoOpColumnMapper INSTANCE

Constructor Detail

NoOpColumnMapperback to summary
public NoOpColumnMapper()

Method Detail

mapback to summary
public String[] map(String reference)

Implements org.hibernate.sql.ordering.antlr.ColumnMapper.map.

Doc from org.hibernate.sql.ordering.antlr.ColumnMapper.map.

Resolve the property reference to its underlying columns.

Parameters
reference:String

The property reference name.

Returns:String[]

The underlying columns, or null if the property reference is unknown.

org.hibernate.sql back to summary

private Class Template.TrimOperands

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final String
private final String
private final String
private final String

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fromback to summary
private final String from
trimCharback to summary
private final String trimChar
trimSourceback to summary
private final String trimSource
trimSpecback to summary
private final String trimSpec

Constructor Detail

TrimOperandsback to summary
private TrimOperands(List<String> operands)