Module storm

Interface SqlTemplate

All Known Implementing Classes:
SqlTemplateImpl

public interface SqlTemplate
SqlTemplate relies on preview features of the Java platform:
Programs can only use SqlTemplate when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
A template processor for generating SQL queries. While this interface can be used directly, developers are encouraged to leverage the higher-level abstractions provided by the framework, as they are likely more useful and convenient for most use cases.
  • Field Details

    • PS

      static final SqlTemplate PS
      The default SQL template that is optimized for prepared statements.
    • JPA

      static final SqlTemplate JPA
      The default SQL template that is optimized for JPA.
  • Method Details

    • createBindVars

      BindVars createBindVars()
      Create a new bind variables instance that can be used to add bind variables to a batch.
      Returns:
      a new bind variables instance.
    • positionalOnly

      boolean positionalOnly()
      Returns true if the template only support positional parameters, false otherwise.
      Returns:
      true if the template only support positional parameters, false otherwise.
    • expandCollection

      boolean expandCollection()
      Returns true if collection parameters must be expanded as multiple (positional) parameters, false otherwise.
      Returns:
      true if the template expands collection parameters, false otherwise.
    • withSupportRecords

      SqlTemplate withSupportRecords(boolean supportRecords)
      Returns a new SQL template with support for records enabled or disabled.
      Parameters:
      supportRecords - true if the template should support records, false otherwise.
      Returns:
      a new SQL template.
    • supportRecords

      boolean supportRecords()
      Returns true if the template supports tables represented as records, false otherwise.
      Returns:
      true if the template supports records, false otherwise.
    • withTableNameResolver

      SqlTemplate withTableNameResolver(@Nonnull TableNameResolver resolver)
      Returns a new SQL template with the specified table name resolver.
      Parameters:
      resolver - the table name resolver.
      Returns:
      a new SQL template.
    • tableNameResolver

      TableNameResolver tableNameResolver()
      Returns the table name resolver that is used by this template.
      Returns:
      the table name resolver that is used by this template.
    • withTableAliasResolver

      SqlTemplate withTableAliasResolver(@Nonnull TableAliasResolver resolver)
      Returns a new SQL template with the specified table alias resolver.
      Parameters:
      resolver - the table alias resolver.
      Returns:
      a new SQL template.
    • tableAliasResolver

      TableAliasResolver tableAliasResolver()
      Returns the table alias resolver that is used by this template.
      Returns:
      the table alias resolver that is used by this template.
    • withColumnNameResolver

      SqlTemplate withColumnNameResolver(@Nonnull ColumnNameResolver resolver)
      Returns a new SQL template with the specified column name resolver.
      Parameters:
      resolver - the column name resolver.
      Returns:
      a new SQL template.
    • columnNameResolver

      ColumnNameResolver columnNameResolver()
      Returns the column name resolver that is used by this template.
      Returns:
      the column name resolver that is used by this template.
    • withForeignKeyResolver

      SqlTemplate withForeignKeyResolver(@Nonnull ForeignKeyResolver resolver)
      Returns a new SQL template with the specified foreign key resolver.
      Parameters:
      resolver - the foreign key resolver.
      Returns:
      a new SQL template.
    • foreignKeyResolver

      ForeignKeyResolver foreignKeyResolver()
      Returns the foreign key resolver that is used by this template.
      Returns:
      the foreign key resolver that is used by this template.
    • withDialect

      SqlTemplate withDialect(@Nonnull SqlDialect dialect)
      Returns a new SQL template with the specified SQL dialect.
      Parameters:
      dialect - the SQL dialect to use.
      Returns:
      a new SQL template.
    • dialect

      SqlDialect dialect()
      Returns the SQL dialect that is used by this template.
      Returns:
      the SQL dialect that is used by this template.
      Since:
      1.2
    • process

      Sql process(@Nonnull StringTemplatePREVIEW template) throws SqlTemplateException
      Processes the specified template and returns the resulting SQL and parameters.
      Parameters:
      template - the string template to process.
      Returns:
      the resulting SQL and parameters.
      Throws:
      SqlTemplateException - if an error occurs while processing the input.