Class AbstractSql92Backend

java.lang.Object
org.tentackle.sql.backends.AbstractBackend
org.tentackle.sql.backends.AbstractSql92Backend
All Implemented Interfaces:
Backend
Direct Known Subclasses:
AbstractSql2003Backend, H2, Informix, MySql, Postgres

public abstract class AbstractSql92Backend extends AbstractBackend
Common to all SQL92 backends.
Author:
harald
  • Field Details

    • SQL_FOR_UPDATE

      public static final String SQL_FOR_UPDATE
      FOR UPDATE string.
      See Also:
    • SQL_COALESCE

      public static final String SQL_COALESCE
      COALESCE keyword.
      See Also:
    • RESERVED_WORDS_SQL92

      public static final String[] RESERVED_WORDS_SQL92
      array of reserved words.
  • Constructor Details

    • AbstractSql92Backend

      public AbstractSql92Backend()
      Parent constructor.
  • Method Details

    • getReservedWords

      public Set<String> getReservedWords()
      Description copied from interface: Backend
      Gets the list of reserved words for this backend.
      Returns:
      the set of reserved words
    • buildSelectSql

      public void buildSelectSql(StringBuilder sqlBuilder, boolean writeLock, int limit, int offset)
      Description copied from interface: Backend
      Creates a select statement string from an inner sql string.

      sqlBuilder is anything as [SELECT] FROM... WHERE... ORDER BY....
      It is decorated with a leading SELECT, if missing, plus optional clauses like for the given parameters.

      Parameters:
      sqlBuilder - the sql builder, initially containing the inner sql without leading SELECT.
      writeLock - true select should write lock
      limit - the limit value, ≤ 0 if no limit clause
      offset - the offset value, ≤ 0 if no offset clause
    • isLeadingSelectMissing

      protected boolean isLeadingSelectMissing(StringBuilder sqlBuilder)
      Determines whether buildSelectSql(StringBuilder, boolean, int, int) must prepend a "SELECT ".
      Parameters:
      sqlBuilder - the sql builder
      Returns:
      true if leading select keyword is missing
    • setLeadingSelectParameters

      public int setLeadingSelectParameters(BackendPreparedStatement stmt, int limit, int offset)
      Description copied from interface: Backend
      Sets optional parameters before applying the original parameters.
      Parameters:
      stmt - the prepared statement
      limit - the limit value, ≤ 0 if no limit clause
      offset - the offset value, ≤ 0 if no offset clause
      Returns:
      the next parameter index
    • setTrailingSelectParameters

      public int setTrailingSelectParameters(BackendPreparedStatement stmt, int index, int limit, int offset)
      Description copied from interface: Backend
      Sets optional parameters after applying the original parameters.
      Parameters:
      stmt - the prepared statement
      index - the first parameter index
      limit - the limit value, ≤ 0 if no limit clause
      offset - the offset value, ≤ 0 if no offset clause
      Returns:
      the next parameter index
    • getCoalesceKeyword

      public String getCoalesceKeyword()
      Description copied from interface: Backend
      Gets the keyword for the COALESCE function.
      Specified by:
      getCoalesceKeyword in interface Backend
      Overrides:
      getCoalesceKeyword in class AbstractBackend
      Returns:
      the keyword
    • sqlCreateForeignKey

      public String sqlCreateForeignKey(String referencingTableName, String referencingColumnName, String referencedTableName, String referencedColumnName, String foreignKeyName, boolean composite)
      Description copied from interface: Backend
      Generates the ALTER TABLE statement to add a foreign key constraint.
      Parameters:
      referencingTableName - the referencing foreign table name
      referencingColumnName - the referencing foreign column name
      referencedTableName - the referenced primary table name
      referencedColumnName - the referenced primary column name
      foreignKeyName - the name of the foreign key
      composite - true if referencing table is a component of the referenced table
      Returns:
      the SQL code
    • sqlDropForeignKey

      public String sqlDropForeignKey(String referencingTableName, String foreignKeyName)
      Description copied from interface: Backend
      Generates the sql statement to drop a foreign key constraint.
      Parameters:
      referencingTableName - the referencing foreign table name
      foreignKeyName - the name of the foreign key
      Returns:
      the SQL code
    • isSequenceSupported

      public boolean isSequenceSupported()
      Description copied from interface: Backend
      True if backend provides locking-free sequences.
      Sequences must not take part in transactions, i.e. no read- or write-locks!
      Returns:
      true if database supports sequences
    • sqlCreateSequence

      public String sqlCreateSequence(String name, Long start, Long increment)
      Description copied from interface: Backend
      Creates the SQL string to create a sequence.
      Parameters:
      name - the sequence name
      start - the optional start value, defaults to 1
      increment - the optional increment, defaults to 1
      Returns:
      the SQL code
    • sqlCreateSequenceComment

      public String sqlCreateSequenceComment(String name, String comment)
      Description copied from interface: Backend
      Creates the SQL string to comment a sequence.
      Parameters:
      name - the sequence name
      comment - the comment
      Returns:
      the SQL code
    • sqlNextFromSequence

      public String sqlNextFromSequence(String name)
      Description copied from interface: Backend
      Creates the SQL string to retrieve the next id from a sequence.
      Parameters:
      name - the name of the sequence
      Returns:
      the SQL code