Module storm

Class SqlTemplateImpl

java.lang.Object
st.orm.template.impl.SqlTemplateImpl
All Implemented Interfaces:
SqlTemplate

public final class SqlTemplateImpl extends Object implements SqlTemplate
SqlTemplateImpl relies on preview features of the Java platform:
Programs can only use SqlTemplateImpl when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
The sql template implementation that is responsible for generating SQL queries.
  • Constructor Details

    • SqlTemplateImpl

      public SqlTemplateImpl(boolean positionalOnly, boolean expandCollection, boolean supportRecords)
    • SqlTemplateImpl

      public SqlTemplateImpl(boolean positionalOnly, boolean expandCollection, boolean supportRecords, @Nonnull ModelBuilder modelBuilder, @Nonnull TableAliasResolver tableAliasResolver, @Nonnull SqlDialect dialect)
  • Method Details

    • positionalOnly

      public boolean positionalOnly()
      Returns true if the template only support positional parameters, false otherwise.
      Specified by:
      positionalOnly in interface SqlTemplate
      Returns:
      true if the template only support positional parameters, false otherwise.
    • expandCollection

      public boolean expandCollection()
      Returns true if collection parameters must be expanded as multiple (positional) parameters, false otherwise.
      Specified by:
      expandCollection in interface SqlTemplate
      Returns:
      true if the template expands collection parameters, false otherwise.
    • withTableNameResolver

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

      public TableNameResolver tableNameResolver()
      Returns the table name resolver that is used by this template.
      Specified by:
      tableNameResolver in interface SqlTemplate
      Returns:
      the table name resolver that is used by this template.
    • withTableAliasResolver

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

      public TableAliasResolver tableAliasResolver()
      Returns the table alias resolver that is used by this template.
      Specified by:
      tableAliasResolver in interface SqlTemplate
      Returns:
      the table alias resolver that is used by this template.
    • withColumnNameResolver

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

      public ColumnNameResolver columnNameResolver()
      Returns the column name resolver that is used by this template.
      Specified by:
      columnNameResolver in interface SqlTemplate
      Returns:
      the column name resolver that is used by this template.
    • withForeignKeyResolver

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

      public ForeignKeyResolver foreignKeyResolver()
      Returns the foreign key resolver that is used by this template.
      Specified by:
      foreignKeyResolver in interface SqlTemplate
      Returns:
      the foreign key resolver that is used by this template.
    • withDialect

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

      public SqlDialect dialect()
      Returns the SQL dialect that is used by this template.
      Specified by:
      dialect in interface SqlTemplate
      Returns:
      the SQL dialect that is used by this template.
      Since:
      1.2
    • withSupportRecords

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

      public boolean supportRecords()
      Returns true if the template supports tables represented as records, false otherwise.
      Specified by:
      supportRecords in interface SqlTemplate
      Returns:
      true if the template supports records, false otherwise.
    • createBindVars

      public BindVars createBindVars()
      Create a new bind variables instance that can be used to add bind variables to a batch.
      Specified by:
      createBindVars in interface SqlTemplate
      Returns:
      a new bind variables instance.
    • process

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