Package org.hibernate.sql
Class Template
java.lang.Object
org.hibernate.sql.Template
Parses SQL fragments specified in mapping documents. The SQL fragment
should be written in the native SQL dialect of the target database,
with the following special exceptions:
- any backtick-quoted identifier, for example
`hello`
, is interpreted as a quoted identifier and re-quoted using the native quoted identifier syntax of the database, and - the literal identifiers
true
andfalse
are interpreted as literal boolean values, and replaced with dialect-specific literal values.
- Implementation Note:
- This is based on a simple scanner-based state machine. It is NOT in any way, shape, nor form, a parser, since we simply cannot recognize the syntax of every dialect of SQL we support.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptioncollectColumnNames
(String template) collectColumnNames
(String sql, Dialect dialect, TypeConfiguration typeConfiguration) static String
renderTransformerReadFragment
(String fragment, String... columnNames) static String
renderWhereStringTemplate
(String sql, String alias, Dialect dialect, TypeConfiguration typeConfiguration) Takes the SQL fragment provided in the mapping attribute and interpolates the given alias, using it to qualify every unqualified column name.static String
renderWhereStringTemplate
(String sql, Dialect dialect, TypeConfiguration typeConfiguration) Takes the SQL fragment provided in the mapping attribute and interpolates the default placeholder value, which is "{@}", using it to qualify every unqualified column name.
-
Field Details
-
TEMPLATE
- See Also:
-
-
Method Details
-
renderTransformerReadFragment
-
renderWhereStringTemplate
public static String renderWhereStringTemplate(String sql, Dialect dialect, TypeConfiguration typeConfiguration) Takes the SQL fragment provided in the mapping attribute and interpolates the default placeholder value, which is "{@}", using it to qualify every unqualified column name.Handles subselects, quoted identifiers, quoted strings, expressions, SQL functions, named parameters, literals.
- Parameters:
sql
- The SQL string into which to interpolate the placeholder valuedialect
- The dialect to apply- Returns:
- The rendered SQL fragment
-
renderWhereStringTemplate
public static String renderWhereStringTemplate(String sql, String alias, Dialect dialect, TypeConfiguration typeConfiguration) Takes the SQL fragment provided in the mapping attribute and interpolates the given alias, using it to qualify every unqualified column name.Handles subselects, quoted identifiers, quoted strings, expressions, SQL functions, named parameters, literals.
- Parameters:
sql
- The SQL string into which to interpolate the alias valuealias
- The alias to be interpolated into the SQLdialect
- The dialect to apply- Returns:
- The rendered SQL fragment
-
collectColumnNames
public static List<String> collectColumnNames(String sql, Dialect dialect, TypeConfiguration typeConfiguration) -
collectColumnNames
-