Package org.apache.torque.templates.platform

# Interface Platform

All Known Implementing Classes:
  `PlatformDefaultImpl`, `PlatformDerbyImpl`, `PlatformHsqldbImpl`, `PlatformMssqlImpl`, `PlatformMysqlImpl`, `PlatformOracleImpl`, `PlatformPostgresqlImpl`

public interface Platform
Interface for RDBMS platform specific behaviour. Which platform actually is used, is determined here: `PlatformFactory.getPlatformFor(String)`.

Version:
  $Id: Platform.java 1917240 2024-04-21 13:22:54Z tv $
Author:
  Martin Poeschl

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `createNotNullBeforeAutoincrement()`
  Returns whether the "not null part" of the definition of a column should be generated before the "autoincrement part" in a "create table" statement.
  `String`
  `getAutoIncrement()`
  `String`
  `getDateString(Date date)`
  Formats the given date as date string which is parseable by the database.
  `String`
  `getNullString(boolean notNull)`
  `String`
  `getSizeSuffix(String sqlType)`
  Returns a possible SQL suffix for column definitions of certain SQL Types, e.g. for Oracle VARCHAR2 columns, it typically makes sense to use 'XXX CHAR' instead of 'XXX' as size.
  `SqlType`
  `getSqlTypeForSchemaType(SchemaType schemaType)`
  Returns the db specific SQL type for a Torque type.
  `String`
  `getTimestampString(Date date)`
  Formats the given date as timestamp string which is parseable by the database.
  `String`
  `getTimeString(Date date)`
  Formats the given date as time string which is parseable by the database.
  `boolean`
  `hasScale(String sqlType)`
  Returns if the RDBMS-specific SQL type has a scale attribute.
  `boolean`
  `hasSize(String sqlType)`
  Returns if the RDBMS-specific SQL type has a size attribute.
  `boolean`
  `hasUniqueConstraintSize()`
  Returns whether the database has schema support unique constraint for columns with size
  `String`
  `quoteAndEscape(String value)`
  Quotes and escapes a string such that it can be used as literal String value in SQL.
  `boolean`
  `usesStandaloneSchema()`
  Returns whether the database has schema support where a schema is not tied to a user (oracle) or database (mysql), but can be created separately.

- ## Method Details

  - ### getSqlTypeForSchemaType

    SqlType getSqlTypeForSchemaType(SchemaType schemaType)
    Returns the db specific SQL type for a Torque type.
    Parameters:
      `schemaType` - the Torque type, not null.
    Returns:
      the db specific SQL type, or null if no SQL type is defined for the given Torque type.

  - ### getNullString

    String getNullString(boolean notNull)
    Parameters:
      `notNull` - flag for not null
    Returns:
      The RDBMS-specific SQL fragment for `NULL` or `NOT NULL`.

  - ### getAutoIncrement

    String getAutoIncrement()
    Returns:
      The RDBMS-specific SQL fragment for autoincrement.

  - ### hasSize

    boolean hasSize(String sqlType)
    Returns if the RDBMS-specific SQL type has a size attribute.
    Parameters:
      `sqlType` - the SQL type
    Returns:
      true if the type has a size attribute

  - ### hasScale

    boolean hasScale(String sqlType)
    Returns if the RDBMS-specific SQL type has a scale attribute.
    Parameters:
      `sqlType` - the SQL type
    Returns:
      true if the type has a scale attribute

  - ### getSizeSuffix

    String getSizeSuffix(String sqlType)
    Returns a possible SQL suffix for column definitions of certain SQL Types, e.g. for Oracle VARCHAR2 columns, it typically makes sense to use 'XXX CHAR' instead of 'XXX' as size.
    Parameters:
      `sqlType` - the SQL type to determine the suffix for.
    Returns:
      the size suffix, not null, may be empty.

  - ### createNotNullBeforeAutoincrement

    boolean createNotNullBeforeAutoincrement()
    Returns whether the "not null part" of the definition of a column should be generated before the "autoincrement part" in a "create table" statement.
    Returns:
      true if the "not null part" should be first, false if the "autoincrement part" should be first in a "create table" statement.

  - ### quoteAndEscape

    String quoteAndEscape(String value)
    Quotes and escapes a string such that it can be used as literal String value in SQL.
    Parameters:
      `value` - The string to escape, or null.
    Returns:
      the escaped String, not null.

  - ### getDateString

    String getDateString(Date date)
    Formats the given date as date string which is parseable by the database.
    Parameters:
      `date` - the date to format.
    Returns:
      the date string, inclusive string escaping.

  - ### getTimeString

    String getTimeString(Date date)
    Formats the given date as time string which is parseable by the database.
    Parameters:
      `date` - the date to format.
    Returns:
      the time string, inclusive string escaping.

  - ### getTimestampString

    String getTimestampString(Date date)
    Formats the given date as timestamp string which is parseable by the database.
    Parameters:
      `date` - the date to format.
    Returns:
      the timestamp string, inclusive string escaping.

  - ### usesStandaloneSchema

    boolean usesStandaloneSchema()
    Returns whether the database has schema support where a schema is not tied to a user (oracle) or database (mysql), but can be created separately.
    Returns:
      true if separate schema creation is possible, false if not.

  - ### hasUniqueConstraintSize

    boolean hasUniqueConstraintSize()
    Returns whether the database has schema support unique constraint for columns with size
    Returns:
      true if unique column constraint has size