Module eclipselink

Class DerbyPlatform

java.lang.Object
org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform
org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
All Implemented Interfaces:
Serializable, Cloneable, org.eclipse.persistence.internal.core.databaseaccess.CorePlatform<org.eclipse.persistence.internal.helper.ConversionManager>, org.eclipse.persistence.internal.databaseaccess.Platform, DDLPlatform
Direct Known Subclasses:
JavaDBPlatform

public class DerbyPlatform extends DB2Platform

Purpose: Provides Derby DBMS specific behavior.

See Also:
  • Field Details

    • MAX_CLOB

      public static final int MAX_CLOB
      See Also:
    • MAX_BLOB

      public static final int MAX_BLOB
      See Also:
    • isSequenceSupported

      protected boolean isSequenceSupported
      Allow sequence support to be disabled for Derby < 10.6.1.
    • isConnectionDataInitialized

      protected boolean isConnectionDataInitialized
  • Constructor Details

    • DerbyPlatform

      public DerbyPlatform()
  • Method Details

    • appendByteArray

      protected void appendByteArray(byte[] bytes, Writer writer) throws IOException
      INTERNAL: TODO: Need to find out how can byte arrays be inlined in Derby
      Overrides:
      appendByteArray in class DB2Platform
      Throws:
      IOException
    • getTimestampQuery

      public ValueReadQuery getTimestampQuery()
      INTERNAL: This method returns the query to select the timestamp from the server for Derby.
      Specified by:
      getTimestampQuery in interface org.eclipse.persistence.internal.databaseaccess.Platform
      Overrides:
      getTimestampQuery in class DB2Platform
    • getNativeTableInfo

      public Vector getNativeTableInfo(String table, String creator, org.eclipse.persistence.internal.sessions.AbstractSession session)
      INTERNAL: Not currently used.
      Overrides:
      getNativeTableInfo in class DB2Platform
    • isDerby

      public boolean isDerby()
      INTERNAL: Answers whether platform is Derby
      Specified by:
      isDerby in interface org.eclipse.persistence.internal.databaseaccess.Platform
      Overrides:
      isDerby in class org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform
    • isDB2

      public boolean isDB2()
      Specified by:
      isDB2 in interface org.eclipse.persistence.internal.databaseaccess.Platform
      Overrides:
      isDB2 in class DB2Platform
    • shouldBindPartialParameters

      public boolean shouldBindPartialParameters()
      Used to determine if the platform should perform partial parameter binding or not Enabled for DB2 and DB2 for zOS to add support for partial binding
      Overrides:
      shouldBindPartialParameters in class DB2Platform
    • getSelectForUpdateString

      public String getSelectForUpdateString()
      Description copied from class: DB2Platform
      INTERNAL: Used for pessimistic locking in DB2. Without the "WITH RS" the lock is not held.
      Overrides:
      getSelectForUpdateString in class DB2Platform
    • shouldIgnoreException

      public boolean shouldIgnoreException(SQLException exception)
      Allow for the platform to ignore exceptions.
      Overrides:
      shouldIgnoreException in class DB2Platform
    • getCreateTempTableSqlSuffix

      protected String getCreateTempTableSqlSuffix()
      INTERNAL:
      Overrides:
      getCreateTempTableSqlSuffix in class DB2Platform
    • buildSelectQueryForIdentity

      public ValueReadQuery buildSelectQueryForIdentity()
      INTERNAL: Build the identity query for native sequencing.
      Overrides:
      buildSelectQueryForIdentity in class DB2Platform
    • shouldTempTableSpecifyPrimaryKeys

      protected boolean shouldTempTableSpecifyPrimaryKeys()
      INTERNAL: Indicates whether temporary table can specify primary keys (some platforms don't allow that). Used by writeCreateTempTableSql method.
      Overrides:
      shouldTempTableSpecifyPrimaryKeys in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
    • getCreateTempTableSqlBodyForTable

      protected String getCreateTempTableSqlBodyForTable(org.eclipse.persistence.internal.helper.DatabaseTable table)
      INTERNAL:
      Overrides:
      getCreateTempTableSqlBodyForTable in class DB2Platform
      Parameters:
      table - is original table for which temp table is created.
      Returns:
      String
    • writeUpdateOriginalFromTempTableSql

      public void writeUpdateOriginalFromTempTableSql(Writer writer, org.eclipse.persistence.internal.helper.DatabaseTable table, Collection<org.eclipse.persistence.internal.helper.DatabaseField> pkFields, Collection<org.eclipse.persistence.internal.helper.DatabaseField> assignedFields) throws IOException
      INTERNAL: May need to override this method if the platform supports temporary tables and the generated sql doesn't work. Write an sql string for updating the original table from the temporary table. Precondition: supportsTempTables() == true. Precondition: pkFields and assignFields don't intersect.
      Overrides:
      writeUpdateOriginalFromTempTableSql in class org.eclipse.persistence.internal.databaseaccess.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
    • setNullFromDatabaseField

      protected void setNullFromDatabaseField(org.eclipse.persistence.internal.helper.DatabaseField databaseField, PreparedStatement statement, int index) throws SQLException
      Overrides:
      setNullFromDatabaseField in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
      Throws:
      SQLException
    • initializePlatformOperators

      protected void initializePlatformOperators()
      Initialize any platform-specific operators
      Overrides:
      initializePlatformOperators in class DB2Platform
    • avgOperator

      protected ExpressionOperator avgOperator()
      Disable binding support.

      With binding enabled, Derby will throw an error:

      ERROR 42X36: The 'AVG' operator is not allowed to take a ? parameter as an operand.
    • sumOperator

      protected ExpressionOperator sumOperator()
      Disable binding support.

      With binding enabled, Derby will throw an error:

      ERROR 42X36: The 'SUM' operator is not allowed to take a ? parameter as an operand.
    • equalOperator

      protected ExpressionOperator equalOperator()
      Derby requires that at least one argument be a known type

      With binding enabled, Derby will throw an error:

      ERROR 42X35: It is not allowed for both operands of '=' to be ? parameters.
    • notEqualOperator

      protected ExpressionOperator notEqualOperator()
      Derby requires that at least one argument be a known type

      With binding enabled, Derby will throw an error:

      ERROR 42X35: It is not allowed for both operands of '<>' to be ? parameters.
    • greaterThanOperator

      protected ExpressionOperator greaterThanOperator()
      Derby requires that at least one argument be a known type

      With binding enabled, Derby will throw an error:

      ERROR 42X35: It is not allowed for both operands of '>' to be ? parameters.
    • greaterThanEqualOperator

      protected ExpressionOperator greaterThanEqualOperator()
      Derby requires that at least one argument be a known type

      With binding enabled, Derby will throw an error:

      ERROR 42X35: It is not allowed for both operands of '>=' to be ? parameters.
    • lessThanOperator

      protected ExpressionOperator lessThanOperator()
      Derby requires that at least one argument be a known type

      With binding enabled, Derby will throw an error:

      ERROR 42X35: It is not allowed for both operands of '<' to be ? parameters.
    • lessThanEqualOperator

      protected ExpressionOperator lessThanEqualOperator()
      Derby requires that at least one argument be a known type

      With binding enabled, Derby will throw an error:

      ERROR 42X35: It is not allowed for both operands of '<=' to be ? parameters.
    • derbyLeftOperator

      protected static ExpressionOperator derbyLeftOperator()
      INTERNAL: Derby equivalent to LEFT e.g. LEFT(dname, 5) is SUBSTR e.g. SUBSTR(dname, 1, 5).
    • derbyRightOperator

      protected static ExpressionOperator derbyRightOperator()
      INTERNAL: Derby equivalent to RIGHT e.g. RIGHT(dname, 5) is SUBSTR e.g. SUBSTR(dname, LENGTH(dname) +1 - 5, 5).
    • addOperator

      protected ExpressionOperator addOperator()
      Derby requires that at least one argument be a known type

      With binding enabled, Derby will throw an error:

      ERROR 42X35: It is not allowed for both operands of '+' to be ? parameters.
    • subtractOperator

      protected ExpressionOperator subtractOperator()
      Derby requires that at least one argument be a known type

      With binding enabled, Derby will throw an error:

      ERROR 42X35: It is not allowed for both operands of '-' to be ? parameters.
    • multiplyOperator

      protected ExpressionOperator multiplyOperator()
      Set binding support to PARTIAL.

      With binding enabled, Derby will throw an error:

      ERROR 42X35: It is not allowed for both operands of '*' to be ? parameters.
    • divideOperator

      protected ExpressionOperator divideOperator()
      Derby requires that at least one argument be a known type

      With binding enabled, Derby will throw an error:

      ERROR 42X35: It is not allowed for both operands of '/' to be ? parameters.
    • concatOperator

      protected ExpressionOperator concatOperator()
      Derby requires that at least one argument be a known type

      With binding enabled, Derby will throw an error:

      ERROR 42X35: It is not allowed for both operands of '||' to be ? parameters.
      Overrides:
      concatOperator in class DB2Platform
    • trim2

      protected ExpressionOperator trim2()
      Enable binding since DB2 disables it

      With binding enabled, Derby does not throw an exception

      Overrides:
      trim2 in class DB2Platform
    • modOperator

      protected ExpressionOperator modOperator()
      Derby requires that at least one argument be a known type

      With binding enabled, Derby will throw an error:

      ERROR 42X35: It is not allowed for both operands of 'mod' to be ? parameters.
    • ltrim2Operator

      protected ExpressionOperator ltrim2Operator()
      Enable binding since DB2 disables it

      With binding enabled, Derby does not throw an exception

      Overrides:
      ltrim2Operator in class DB2Platform
    • rtrim2Operator

      protected ExpressionOperator rtrim2Operator()
      Enable binding since DB2 disables it

      With binding enabled, Derby does not throw an exception

      Overrides:
      rtrim2Operator in class DB2Platform
    • betweenOperator

      protected ExpressionOperator betweenOperator()
      Derby requires that at least one argument be a known type

      With binding enabled, Derby will throw an error:

      ERROR 42X35: It is not allowed for both operands of 'BETWEEN' to be ? parameters.
    • notBetweenOperator

      protected ExpressionOperator notBetweenOperator()
      Derby requires that at least one argument be a known type

      With binding enabled, Derby will throw an error:

      ERROR 42X35: It is not allowed for both operands of 'BETWEEN' to be ? parameters.
    • inOperator

      protected ExpressionOperator inOperator()
      Derby requires that at least one argument be a known type

      With binding enabled, Derby will throw an error:

      ERROR 42X35: It is not allowed for both operands of 'IN' to be ? parameters.
    • roundOperator

      protected ExpressionOperator roundOperator()
      Emulate ROUND as FLOOR((:x)*1e:n+0.5)/1e:n
      Overrides:
      roundOperator in class DB2Platform
    • 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

      Derby uses case #2 and therefore the maxResults has to be altered based on the firstResultIndex.

      Overrides:
      computeMaxRowsForSQL in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
      See Also:
    • printSQLSelectStatement

      public void printSQLSelectStatement(org.eclipse.persistence.internal.databaseaccess.DatabaseCall call, org.eclipse.persistence.internal.expressions.ExpressionSQLPrinter printer, org.eclipse.persistence.internal.expressions.SQLSelectStatement statement)
      INTERNAL: Print the SQL representation of the statement on a stream, storing the fields in the DatabaseCall.

      Derby supports pagination through its "OFFSET n ROWS FETCH NEXT m ROWS" syntax.

      Overrides:
      printSQLSelectStatement in class DB2Platform
    • supportsSequenceObjects

      public boolean supportsSequenceObjects()
      INTERNAL: Derby supports sequence objects as of 10.6.1.
      Overrides:
      supportsSequenceObjects in class DB2Platform
    • initializeConnectionData

      public void initializeConnectionData(Connection connection) throws SQLException
      INTERNAL:
      Overrides:
      initializeConnectionData in class DB2Platform
      Throws:
      SQLException
    • setParameterValueInDatabaseCall

      public void setParameterValueInDatabaseCall(Object parameter, PreparedStatement statement, int index, org.eclipse.persistence.internal.sessions.AbstractSession session) throws SQLException
      INTERNAL Set the parameter in the JDBC statement at the given index. This support a wide range of different parameter types, and is heavily optimized for common types.
      Overrides:
      setParameterValueInDatabaseCall in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
      Throws:
      SQLException
    • setParameterValueInDatabaseCall

      public void setParameterValueInDatabaseCall(Object parameter, CallableStatement statement, String name, org.eclipse.persistence.internal.sessions.AbstractSession session) throws SQLException
      INTERNAL Set the parameter in the JDBC statement with the given name. This support a wide range of different parameter types, and is heavily optimized for common types.
      Overrides:
      setParameterValueInDatabaseCall in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
      Throws:
      SQLException
    • appendParameterInternal

      public int appendParameterInternal(Call call, Writer writer, Object parameter)
      Returns the number of parameters that used binding. Should only be called in case binding is not used.
      Overrides:
      appendParameterInternal in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
    • buildDatabaseTypes

      protected Map<Class<?>,FieldDefinition.DatabaseType> buildDatabaseTypes()
      Description copied from class: org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
      Return the mapping of class types to database types for the schema framework.
      Overrides:
      buildDatabaseTypes in class DB2Platform
    • buildSequenceObjectDeletionWriter

      public Writer buildSequenceObjectDeletionWriter(Writer writer, String fullSeqName) throws IOException
      INTERNAL: Derby supports sequence objects as of 10.6.1.
      Throws:
      IOException
    • getProcedureEndString

      public String getProcedureEndString()
      Description copied from interface: DDLPlatform
      Used for stored procedure defs.
      Specified by:
      getProcedureEndString in interface DDLPlatform
      Overrides:
      getProcedureEndString in class DB2Platform
    • getProcedureBeginString

      public String getProcedureBeginString()
      Description copied from interface: DDLPlatform
      Used for stored procedure defs.
      Specified by:
      getProcedureBeginString in interface DDLPlatform
      Overrides:
      getProcedureBeginString in class DB2Platform
    • getInOutputProcedureToken

      public String getInOutputProcedureToken()
      Description copied from interface: DDLPlatform
      This method is used to print the output parameter token when stored procedures are called
    • isAlterSequenceObjectSupported

      public boolean isAlterSequenceObjectSupported()
      Description copied from class: DB2Platform
      INTERNAL: DB2 added SEQUENCE support as of (I believe) v8.
      Specified by:
      isAlterSequenceObjectSupported in interface DDLPlatform
      Overrides:
      isAlterSequenceObjectSupported in class DB2Platform
    • printFieldIdentityClause

      public void printFieldIdentityClause(Writer writer) throws ValidationException
      INTERNAL: Append the receiver's field 'identity' constraint clause to a writer.
      Specified by:
      printFieldIdentityClause in interface DDLPlatform
      Overrides:
      printFieldIdentityClause in class DB2Platform
      Parameters:
      writer - the writer to append to
      Throws:
      ValidationException
    • shouldPrintOutputTokenAtStart

      public boolean shouldPrintOutputTokenAtStart()
      Description copied from interface: DDLPlatform
      This is required in the construction of the stored procedures with output parameters
      Specified by:
      shouldPrintOutputTokenAtStart in interface DDLPlatform
      Overrides:
      shouldPrintOutputTokenAtStart in class DB2Platform
    • supportsFractionalTime

      public boolean supportsFractionalTime()
      Description copied from interface: DDLPlatform
      Override this method if the platform supports setting fractional seconds precision in a SQL time or timestamp data type.
      Specified by:
      supportsFractionalTime in interface DDLPlatform
      Overrides:
      supportsFractionalTime in class DB2Platform
      Returns:
      value of true when current database platform supports fractional seconds precision or false otherwise