Class Template

java.lang.Object
org.hibernate.sql.Template

public final class Template extends Object
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:
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 Details

  • Method Details

    • renderTransformerReadFragment

      public static String renderTransformerReadFragment(String fragment, String... columnNames)
    • 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 value
      dialect - 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 value
      alias - The alias to be interpolated into the SQL
      dialect - The dialect to apply
      Returns:
      The rendered SQL fragment
    • collectColumnNames

      public static List<String> collectColumnNames(String sql, Dialect dialect, TypeConfiguration typeConfiguration)
    • collectColumnNames

      public static List<String> collectColumnNames(String template)