com.holonplatform.datastore.jdbc.composer

## Interface SQLDialect

- All Superinterfaces:
    Serializable
  All Known Implementing Classes:
    DB2Dialect, DefaultDialect, DerbyDialect, H2Dialect, HANADialect, HSQLDialect, InformixDialect, MariaDBDialect, MySQLDialect, OracleDialect, PostgreSQLDialect, SQLiteDialect, SQLServerDialect

      public interface SQLDialect
      extends Serializable

  Represents a dialect of SQL implemented by a particular database.
  Since:
    5.0.0

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static interface` | `SQLDialect.LimitHandler` Handler to apply limit/offset to SQL query.

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `static SQLDialect` | `db2()` Get the `SQLDialect` for the DB2 database platform.
    `default boolean` | `deleteStatementAliasSupported()` Get whether alias is supported in the DELETE clause.
    `default boolean` | `deleteStatementTargetRequired()` Get whether the DELETE clause target must be specified.
    `static SQLDialect` | `derby()` Get the `SQLDialect` for the Derby database platform.
    `static Optional<SQLDialect>` | `detect(com.holonplatform.jdbc.DatabasePlatform database)` Detect a suitable `SQLDialect` to use with given database platform, if available.
    `boolean` | `generatedKeyAlwaysReturned()` Retrieves whether a generated key will always be returned if the column name(s) or index(es) specified for the auto generated key column(s) are valid and the statement succeeds.
    `default String` | `getColumnName(String columnName)` Get the actual column name for given column name (for example, applying case transformations)
    `default Optional<Class<?>>` | `getJavaType(SQLType sqlType)` Get the Java type which corresponds to given SQL type for this dialect.
    `default Optional<SQLDialect.LimitHandler>` | `getLimitHandler()` Get the `SQLDialect.LimitHandler`
    `default Optional<String>` | `getLockClause(com.holonplatform.core.query.lock.LockMode mode, long timeout)` Get the SQL lock clause for given lock condition.
    `default Optional<String>` | `getLockHint(com.holonplatform.core.query.lock.LockMode mode, long timeout)` Get the SQL lock hint to append to the FROM clause for given lock condition.
    `default Optional<SQLType>` | `getSqlType(Class<?> javaType)` Get the SQL type which corresponds to given Java type for this dialect.
    `default String` | `getTableName(String tableName)` Get the actual table name for given table name (for example, applying case transformations)
    `static SQLDialect` | `h2()` Get the `SQLDialect` for the H2 database platform.
    `static SQLDialect` | `HANA()` Get the `SQLDialect` for the SAP HANA database platform.
    `static SQLDialect` | `hsqldb()` Get the `SQLDialect` for the HSQLDB database platform.
    `static SQLDialect` | `informix()` Get the `SQLDialect` for the Informix database platform.
    `void` | `init(SQLDialectContext context)` Dialect initialization hook at parent datastore initialization.
    `static SQLDialect` | `mariaDB()` Get the `SQLDialect` for the MariaDB database platform.
    `static SQLDialect` | `mySQL()` Get the `SQLDialect` for the MySQL database platform.
    `static SQLDialect` | `oracle()` Get the `SQLDialect` for the Oracle database platform.
    `static SQLDialect` | `postgreSQL()` Get the `SQLDialect` for the PostgreSQL database platform.
    `default Optional<SQLFunction>` | `resolveFunction(com.holonplatform.core.query.QueryFunction<?,?> function)` Resolve given `function` into a dialect-specific `SQLFunction`.
    `static SQLDialect` | `sqlite()` Get the `SQLDialect` for the SQLite database platform.
    `static SQLDialect` | `sqlServer()` Get the `SQLDialect` for the SQL Server database platform.
    `default boolean` | `supportGetGeneratedKeyByName()` Retrieves whether auto-generated keys can be retrieved by name after a statement has been executed.
    `default boolean` | `supportsBinaryStreamParameter()` Get whether binary stream type parameters are supported.
    `boolean` | `supportsGetGeneratedKeys()` Retrieves whether auto-generated keys can be retrieved after a statement has been executed.
    `boolean` | `supportsLikeEscapeClause()` Retrieves whether this database supports specifying a `LIKE` escape clause.
    `default boolean` | `supportsSqlType(int sqlType)` Get whether given SQL type is supported by this dialect.
    `default com.holonplatform.core.exceptions.DataAccessException` | `translateException(SQLException exception)` Translates given `SQLException` into a suitable `DataAccessException`.
    `default boolean` | `updateStatementAliasSupported()` Get whether alias is supported in the UPDATE clause.
    `default boolean` | `updateStatementFromSupported()` Get whether a FROM clause is supported in the UPDATE clause.
    `default boolean` | `updateStatementSetAliasSupported()` Get whether alias is supported in the SET clause of an UPDATE clause.
    `default boolean` | `useOuterInJoins()` Get whether to use the `OUTER` keyword in join serialization.

- - ### Method Detail

    - #### init

          void init(SQLDialectContext context)
             throws SQLException

      Dialect initialization hook at parent datastore initialization.
      Parameters:
        `context` - Dialect context
      Throws:
        `SQLException` - An error occurred during dialect initialization

    - #### resolveFunction

          default Optional<SQLFunction> resolveFunction(com.holonplatform.core.query.QueryFunction<?,?> function)

      Resolve given `function` into a dialect-specific `SQLFunction`.
      Parameters:
        `function` - The function to resolve (not null)
      Returns:
        A dialect-specific function resolution, or empty to fallback to the default function resolution, if available

    - #### useOuterInJoins

          default boolean useOuterInJoins()

      Get whether to use the `OUTER` keyword in join serialization.
      Returns:
        `true` to use the `OUTER` keyword in join serialization

    - #### updateStatementAliasSupported

          default boolean updateStatementAliasSupported()

      Get whether alias is supported in the UPDATE clause.
      Returns:
        `true` if alias is supported in the UPDATE clause

    - #### updateStatementFromSupported

          default boolean updateStatementFromSupported()

      Get whether a FROM clause is supported in the UPDATE clause.
      Returns:
        `true` if a FROM clause is supported in the UPDATE clause

    - #### updateStatementSetAliasSupported

          default boolean updateStatementSetAliasSupported()

      Get whether alias is supported in the SET clause of an UPDATE clause.
      Returns:
        `true` if alias is supported in the SET clause of an UPDATE clause

    - #### deleteStatementAliasSupported

          default boolean deleteStatementAliasSupported()

      Get whether alias is supported in the DELETE clause.
      Returns:
        `true` if alias is supported in the DELETE clause

    - #### deleteStatementTargetRequired

          default boolean deleteStatementTargetRequired()

      Get whether the DELETE clause target must be specified.
      Returns:
        `true` if the DELETE clause target must be specified

    - #### supportsBinaryStreamParameter

          default boolean supportsBinaryStreamParameter()

      Get whether binary stream type parameters are supported.
      Returns:
        `true` if binary stream type parameters are supported

    - #### getTableName

          default String getTableName(String tableName)

      Get the actual table name for given table name (for example, applying case transformations)
      Parameters:
        `tableName` - Table name
      Returns:
        The actual table name

    - #### getColumnName

          default String getColumnName(String columnName)

      Get the actual column name for given column name (for example, applying case transformations)
      Parameters:
        `columnName` - Column name
      Returns:
        The actual column name

    - #### supportsSqlType

          default boolean supportsSqlType(int sqlType)

      Get whether given SQL type is supported by this dialect.
      Parameters:
        `sqlType` - The SQL type id
      Returns:
        `true` if type is supported, `false` otherwise
      See Also:
        `Types`

    - #### getJavaType

          default Optional<Class<?>> getJavaType(SQLType sqlType)

      Get the Java type which corresponds to given SQL type for this dialect.
      Parameters:
        `sqlType` - The sql type (not null)
      Returns:
        Optional Java type, empty to use default

    - #### getSqlType

          default Optional<SQLType> getSqlType(Class<?> javaType)

      Get the SQL type which corresponds to given Java type for this dialect.
      Parameters:
        `javaType` - The sql type (not null)
      Returns:
        Optional SQL type, empty to use default

    - #### supportsLikeEscapeClause

          boolean supportsLikeEscapeClause()

      Retrieves whether this database supports specifying a `LIKE` escape clause.
      Returns:
        `true` if so; `false` otherwise

    - #### supportsGetGeneratedKeys

          boolean supportsGetGeneratedKeys()

      Retrieves whether auto-generated keys can be retrieved after a statement has been executed.
      Returns:
        `true` if auto-generated keys can be retrieved after a statement has executed; `false` otherwise

    - #### generatedKeyAlwaysReturned

          boolean generatedKeyAlwaysReturned()

      Retrieves whether a generated key will always be returned if the column name(s) or index(es) specified for the auto generated key column(s) are valid and the statement succeeds. The key that is returned may or may not be based on the column(s) for the auto generated key.
      Returns:
        `true` if so; `false` otherwise

    - #### supportGetGeneratedKeyByName

          default boolean supportGetGeneratedKeyByName()

      Retrieves whether auto-generated keys can be retrieved by name after a statement has been executed.
      Returns:
        `true` if auto-generated keys can be retrieved by name after a statement has executed

    - #### getLockClause

          default Optional<String> getLockClause(com.holonplatform.core.query.lock.LockMode mode,
                                                 long timeout)

      Get the SQL lock clause for given lock condition.
      Parameters:
        `mode` - Lock mode
        `timeout` - Lock timeout in milliseconds
      Returns:
        Optional SQL lock clause

    - #### getLockHint

          default Optional<String> getLockHint(com.holonplatform.core.query.lock.LockMode mode,
                                               long timeout)

      Get the SQL lock hint to append to the FROM clause for given lock condition.
      Parameters:
        `mode` - Lock mode
        `timeout` - Lock timeout in milliseconds
      Returns:
        Optional SQL lock hint

    - #### translateException

          default com.holonplatform.core.exceptions.DataAccessException translateException(SQLException exception)

      Translates given `SQLException` into a suitable `DataAccessException`.
      Parameters:
        `exception` - Exception to translate (not null)
      Returns:
        Translated `DataAccessException`

    - #### getLimitHandler

          default Optional<SQLDialect.LimitHandler> getLimitHandler()

      Get the `SQLDialect.LimitHandler`
      Returns:
        Optional limit handler

    - #### detect

          static Optional<SQLDialect> detect(com.holonplatform.jdbc.DatabasePlatform database)

      Detect a suitable `SQLDialect` to use with given database platform, if available.
      Parameters:
        `database` - Database platform
      Returns:
        Optional `SQLDialect` for given database platform

    - #### h2

          static SQLDialect h2()

      Get the `SQLDialect` for the H2 database platform.
      Returns:
        The dialect implementation

    - #### derby

          static SQLDialect derby()

      Get the `SQLDialect` for the Derby database platform.
      Returns:
        The dialect implementation

    - #### hsqldb

          static SQLDialect hsqldb()

      Get the `SQLDialect` for the HSQLDB database platform.
      Returns:
        The dialect implementation

    - #### mySQL

          static SQLDialect mySQL()

      Get the `SQLDialect` for the MySQL database platform.
      Returns:
        The dialect implementation

    - #### mariaDB

          static SQLDialect mariaDB()

      Get the `SQLDialect` for the MariaDB database platform.
      Returns:
        The dialect implementation

    - #### postgreSQL

          static SQLDialect postgreSQL()

      Get the `SQLDialect` for the PostgreSQL database platform.
      Returns:
        The dialect implementation

    - #### oracle

          static SQLDialect oracle()

      Get the `SQLDialect` for the Oracle database platform.
      Returns:
        The dialect implementation

    - #### sqlServer

          static SQLDialect sqlServer()

      Get the `SQLDialect` for the SQL Server database platform.
      Returns:
        The dialect implementation

    - #### db2

          static SQLDialect db2()

      Get the `SQLDialect` for the DB2 database platform.
      Returns:
        The dialect implementation

    - #### informix

          static SQLDialect informix()

      Get the `SQLDialect` for the Informix database platform.
      Returns:
        The dialect implementation

    - #### HANA

          static SQLDialect HANA()

      Get the `SQLDialect` for the SAP HANA database platform.
      Returns:
        The dialect implementation

    - #### sqlite

          static SQLDialect sqlite()

      Get the `SQLDialect` for the SQLite database platform.
      Returns:
        The dialect implementation

Copyright © 2019 The Holon Platform. All rights reserved.