Class Ingres

All Implemented Interfaces:
Backend

@Service(Backend.class) public class Ingres extends AbstractSql2003Backend
Backend for Ingres.
Author:
harald
  • Field Details

  • Constructor Details

    • Ingres

      public Ingres()
  • Method Details

    • isMatchingUrl

      public boolean isMatchingUrl(String url)
      Description copied from interface: Backend
      Checks whether the backend belongs to the given jdbc url.
      If multiple backend implementations are provided for the same database type, only one backend should match the URL. The others must be selected via name.
      Parameters:
      url - the jdbc url
      Returns:
      true if matches
    • getName

      public String getName()
      Description copied from interface: Backend
      Gets the name of the backend.
      Returns:
      the name
    • getDriverClassName

      public String getDriverClassName()
      Description copied from interface: Backend
      Gets the JDBC driver class name.
      Returns:
      the class name
    • getBackendId

      public String getBackendId(Connection connection)
      Description copied from interface: Backend
      Determines the unique id or name used by the backend for a given connection.

      Useful to figure out the corresponding ManagedConnection from the backend's logfiles.

      Parameters:
      connection - the jdbc connection
      Returns:
      the backend id, null if none
    • sqlRequiresExtraCommit

      public boolean sqlRequiresExtraCommit()
      Description copied from interface: Backend
      According to the JDBC-specs Connection.setAutoCommit(boolean)(true) should commit, but some backends require an extra Connection.commit().
      Specified by:
      sqlRequiresExtraCommit in interface Backend
      Overrides:
      sqlRequiresExtraCommit in class AbstractBackend
      Returns:
      true if the database needs an extra commit
    • needSetLongWorkaround

      public boolean needSetLongWorkaround()
      Description copied from interface: Backend
      Checks whether we need a workaround for the (Ingres) setLong-Bug.
      Specified by:
      needSetLongWorkaround in interface Backend
      Overrides:
      needSetLongWorkaround in class AbstractBackend
      Returns:
      true if workaround needed
    • 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 FROM... WHERE... ORDER BY....
      It is decorated with a leading SELECT plus optional clauses like for the given parameters.

      Specified by:
      buildSelectSql in interface Backend
      Overrides:
      buildSelectSql in class AbstractSql2003Backend
      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
    • setLeadingSelectParameters

      public int setLeadingSelectParameters(BackendPreparedStatement stmt, int limit, int offset)
      Description copied from interface: Backend
      Sets optional parameters before applying the original parameters.
      Specified by:
      setLeadingSelectParameters in interface Backend
      Overrides:
      setLeadingSelectParameters in class AbstractSql2003Backend
      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.
      Specified by:
      setTrailingSelectParameters in interface Backend
      Overrides:
      setTrailingSelectParameters in class AbstractSql2003Backend
      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
    • getMaxSize

      public int getMaxSize(SqlType sqlType)
      Description copied from interface: Backend
      Returns the maximum size for a given SQL-type.
      Specified by:
      getMaxSize in interface Backend
      Overrides:
      getMaxSize in class AbstractBackend
      Parameters:
      sqlType - the SQL-type
      Returns:
      the maximum size, 0 if unlimited, -1 if type without size
    • sqlTypeToString

      public String sqlTypeToString(SqlType sqlType, int size)
      Description copied from interface: Backend
      Converts the java SQL-type to the database type name.
      Specified by:
      sqlTypeToString in interface Backend
      Overrides:
      sqlTypeToString in class AbstractBackend
      Parameters:
      sqlType - the java sql type
      size - the column's size
      Returns:
      the corresponding type string
    • jdbcTypeToSqlType

      public SqlType[] jdbcTypeToSqlType(int jdbcType, int size, int scale)
      Description copied from interface: Backend
      Converts the JDBC data type integer to a tentackle backend SqlTypes.

      There may be more than one sqltype returned!

      Specified by:
      jdbcTypeToSqlType in interface Backend
      Overrides:
      jdbcTypeToSqlType in class AbstractBackend
      Parameters:
      jdbcType - the jdbc data type
      size - the column size
      scale - the column's scale
      Returns:
      the SqlTypes, empty array if no mapping available or no exact match (not generated by TT)
      See Also:
    • sqlCreateTableComment

      public String sqlCreateTableComment(String tableName, String comment)
      Description copied from interface: Backend
      Generates SQL code to create the comment for a table.
      Specified by:
      sqlCreateTableComment in interface Backend
      Overrides:
      sqlCreateTableComment in class AbstractBackend
      Parameters:
      tableName - the table name
      comment - optional comment, null if none
      Returns:
      the SQL code, empty string if comment is created via Backend.sqlCreateTableIntro(java.lang.String, java.lang.String) or Backend.sqlCreateTableClosing(java.lang.String, java.lang.String)
    • sqlCreateColumnComment

      public String sqlCreateColumnComment(String tableName, String columnName, String comment)
      Description copied from interface: Backend
      Generates SQL code to create the comment for an attribute.
      Specified by:
      sqlCreateColumnComment in interface Backend
      Overrides:
      sqlCreateColumnComment in class AbstractBackend
      Parameters:
      tableName - the table name
      columnName - the column name
      comment - optional comment, null if none
      Returns:
      the SQL code, empty string if comment is created via Backend.sqlCreateColumn(java.lang.String, java.lang.String, org.tentackle.sql.SqlType, int, int, boolean, java.lang.Object, boolean, boolean)
    • extractWhereClause

      protected String extractWhereClause(String sql, int whereOffset)
      Description copied from class: AbstractBackend
      Extracts the where clause from a given sql.
      Overrides:
      extractWhereClause in class AbstractBackend
      Parameters:
      sql - the sql statement
      whereOffset - the location of WHERE in sql
      Returns:
      the where clause without the keyword WHERE
    • isDropIfExistsSupported

      protected boolean isDropIfExistsSupported()
      Description copied from class: AbstractBackend
      Adds "IF EXISTS" to drop clauses, if supported by the backend.
      Makes migration a little more robust in case the same SQL scripts are applied to different databases than those used to generate the migration scripts for.
      Overrides:
      isDropIfExistsSupported in class AbstractBackend
      Returns:
      true if supported