All Implemented Interfaces:
Serializable, Cloneable, CorePlatform<ConversionManager>, Platform

public class H2Platform extends DatabasePlatform
See Also:
  • Constructor Details

    • H2Platform

      public H2Platform()
  • Method Details

    • printSQLSelectStatement

      public void printSQLSelectStatement(DatabaseCall call, ExpressionSQLPrinter printer, SQLSelectStatement statement)
      Print the pagination SQL using H2 syntax " LIMIT <max> OFFSET <first>".
      Overrides:
      printSQLSelectStatement in class DatabasePlatform
    • computeMaxRowsForSQL

      public int computeMaxRowsForSQL(int firstResultIndex, int maxResults)
      INTERNAL: Use the JDBC maxResults and firstResultIndex setting to compute a value to use when limiting the results of a query in SQL. These limits tend to be used in two ways. 1. MaxRows is the index of the last row to be returned (like JDBC maxResults) 2. MaxRows is the number of rows to be returned H2 uses case #2 and therefore the maxResults has to be altered based on the firstResultIndex.
      Overrides:
      computeMaxRowsForSQL in class DatabasePlatform
      See Also:
    • buildFieldTypes

      protected Hashtable<Class<?>,FieldTypeDefinition> buildFieldTypes()
      Description copied from class: DatabasePlatform
      Return the mapping of class types to database types for the schema framework.
      Overrides:
      buildFieldTypes in class DatabasePlatform
    • isAlterSequenceObjectSupported

      public boolean isAlterSequenceObjectSupported()
      Description copied from class: DatabasePlatform
      INTERNAL: Override this method if the platform supports sequence objects and it's possible to alter sequence object's increment in the database.
      Overrides:
      isAlterSequenceObjectSupported in class DatabasePlatform
    • isDynamicSQLRequiredForFunctions

      public boolean isDynamicSQLRequiredForFunctions()
      INTERNAL H2 has some issues with using parameters on certain functions and relations. This allows statements to disable binding only in these cases.
      Overrides:
      isDynamicSQLRequiredForFunctions in class DatabasePlatform
    • allowBindingForSelectClause

      public boolean allowBindingForSelectClause()
      Overrides:
      allowBindingForSelectClause in class DatabasePlatform
    • buildSelectQueryForSequenceObject

      public ValueReadQuery buildSelectQueryForSequenceObject(String seqName, Integer size)
      Description copied from class: DatasourcePlatform
      INTERNAL: Returns query used to read value generated by sequence object (like Oracle sequence). In case the other version of this method (taking no parameters) returns null, this method is called every time sequence object NativeSequence reads. If the platform supportsSequenceObjects then (at least) one of buildSelectQueryForSequenceObject methods should return non-null query.
      Overrides:
      buildSelectQueryForSequenceObject in class DatasourcePlatform
    • supportsIdentity

      public boolean supportsIdentity()
      Description copied from class: DatasourcePlatform
      INTERNAL: Indicates whether the platform supports identity. This method is to be used *ONLY* by sequencing classes
      Overrides:
      supportsIdentity in class DatasourcePlatform
    • supportsSequenceObjects

      public boolean supportsSequenceObjects()
      Description copied from class: DatasourcePlatform
      INTERNAL: Indicates whether the platform supports sequence objects. This method is to be used *ONLY* by sequencing classes
      Overrides:
      supportsSequenceObjects in class DatasourcePlatform
    • buildSelectQueryForIdentity

      public ValueReadQuery buildSelectQueryForIdentity()
      Description copied from class: DatasourcePlatform
      INTERNAL: Returns query used to read back the value generated by Identity. This method is called when identity NativeSequence is connected, the returned query used until the sequence is disconnected. If the platform supportsIdentity then (at least) one of buildSelectQueryForIdentity methods should return non-null query.

      Alternatively, if the platform supports Statement.getGeneratedKeys(), see DatasourcePlatform.supportsReturnGeneratedKeys()

      Overrides:
      buildSelectQueryForIdentity in class DatasourcePlatform
    • printFieldIdentityClause

      public void printFieldIdentityClause(Writer writer) throws ValidationException
      Description copied from class: DatabasePlatform
      Append the receiver's field 'identity' constraint clause to a writer.
      Overrides:
      printFieldIdentityClause in class DatabasePlatform
      Throws:
      ValidationException
    • supportsForeignKeyConstraints

      public boolean supportsForeignKeyConstraints()
      Overrides:
      supportsForeignKeyConstraints in class DatabasePlatform
    • supportsGlobalTempTables

      public boolean supportsGlobalTempTables()
      Description copied from class: DatabasePlatform
      INTERNAL: Indicates whether the platform supports global temporary tables. "Global" means that an attempt to create temporary table with the same name for the second time results in exception. EclipseLink attempts to create global temporary table in the beginning of UpdateAllQuery, execution and assumes that it already exists in case SQLException results. In the end of UpdateAllQuery execution all rows are removed from the temporary table - it is necessary in case the same temporary table will be used by another UpdateAllQuery in the same transaction. Override this method if the platform supports global temporary tables. Note that this method is ignored in case supportsLocalTempTables() returns true.
      Overrides:
      supportsGlobalTempTables in class DatabasePlatform
    • getCreateTempTableSqlPrefix

      protected String getCreateTempTableSqlPrefix()
      Description copied from class: DatabasePlatform
      INTERNAL: Override this method if the platform supports temporary tables. This should contain the beginning of sql string for creating temporary table - the sql statement name, for instance: "CREATE GLOBAL TEMPORARY TABLE ". Don't forget to end it with a space.
      Overrides:
      getCreateTempTableSqlPrefix in class DatabasePlatform
    • writeUpdateOriginalFromTempTableSql

      public void writeUpdateOriginalFromTempTableSql(Writer writer, DatabaseTable table, Collection<DatabaseField> pkFields, Collection<DatabaseField> assignedFields) throws IOException
      H2 does not allow using () in the update if only one field.
      Overrides:
      writeUpdateOriginalFromTempTableSql in class DatabasePlatform
      Parameters:
      writer - for writing the sql
      table - is original table for which temp table is created.
      pkFields - primary key fields for the original table.
      assignedFields - fields to be assigned a new value.
      Throws:
      IOException
    • supportsStoredFunctions

      public boolean supportsStoredFunctions()
      Overrides:
      supportsStoredFunctions in class DatabasePlatform
    • getTimestampQuery

      public ValueReadQuery getTimestampQuery()
      Description copied from class: DatasourcePlatform
      This method can be overridden by subclasses to return a query that will return the timestamp from the server. return null if the time should be the local time.
      Specified by:
      getTimestampQuery in interface Platform
      Overrides:
      getTimestampQuery in class DatasourcePlatform
    • initializePlatformOperators

      protected void initializePlatformOperators()
      Description copied from class: DatasourcePlatform
      Initialize any platform-specific operators
      Overrides:
      initializePlatformOperators in class DatasourcePlatform
    • toNumberOperator

      public static ExpressionOperator toNumberOperator()
      INTERNAL: Use CONVERT function for toNumber.
    • monthsBetweenOperator

      public static ExpressionOperator monthsBetweenOperator()
      INTERNAL: Use MONTH function for MONTH_BETWEEN.
    • isH2

      public boolean isH2()
      Specified by:
      isH2 in interface Platform
      Overrides:
      isH2 in class DatasourcePlatform
    • getProcedureCallHeader

      public String getProcedureCallHeader()
      INTERNAL: Used for stored procedure calls.
      Overrides:
      getProcedureCallHeader in class DatabasePlatform