Module eclipselink

Class SybasePlatform

java.lang.Object
org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform
org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
org.eclipse.persistence.platform.database.DatabasePlatform
org.eclipse.persistence.platform.database.SybasePlatform
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:
SQLAnywherePlatform

public class SybasePlatform extends DatabasePlatform

Purpose: Provides Sybase ASE specific behavior.

Responsibilities:

  • Native SQL for byte[], Date, Time, & Timestamp.
  • Native sequencing using @@IDENTITY.
See Also:
  • Field Details

  • Constructor Details

    • SybasePlatform

      public SybasePlatform()
  • Method Details

    • initializeConnectionData

      public void initializeConnectionData(Connection connection) throws SQLException
      Description copied from class: org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
      INTERNAL: Allow initialization from the connection.
      Overrides:
      initializeConnectionData in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
      Throws:
      SQLException
    • getTypeStrings

      protected Map<Integer,String> getTypeStrings()
    • initializeTypeStrings

      protected void initializeTypeStrings()
    • getJDBCType

      public int getJDBCType(Class<?> javaType)
      Sybase and SQL Anywhere do not support BLOB/CLOB but require LONGVARBINARY/LONGVARCHAR.
      Overrides:
      getJDBCType in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
    • appendByteArray

      protected void appendByteArray(byte[] bytes, Writer writer) throws IOException
      If using native SQL then print a byte[] as '0xFF...'
      Overrides:
      appendByteArray in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
      Throws:
      IOException
    • appendDate

      protected void appendDate(Date date, Writer writer) throws IOException
      Answer a platform correct string representation of a Date, suitable for SQL generation. Native format: 'yyyy-mm-dd
      Overrides:
      appendDate in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
      Throws:
      IOException
    • appendSybaseTimestamp

      protected void appendSybaseTimestamp(Timestamp timestamp, Writer writer) throws IOException
      Write a timestamp in Sybase specific format (yyyy-mm-dd-hh.mm.ss.fff).
      Throws:
      IOException
    • appendTime

      protected void appendTime(Time time, Writer writer) throws IOException
      Answer a platform correct string representation of a Time, suitable for SQL generation. The time is printed in the ODBC platform independent format {t'hh:mm:ss'}.
      Overrides:
      appendTime in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
      Throws:
      IOException
    • appendTimestamp

      protected void appendTimestamp(Timestamp timestamp, Writer writer) throws IOException
      Answer a platform correct string representation of a Timestamp, suitable for SQL generation. The date is printed in the ODBC platform independent format {d'YYYY-MM-DD'}.
      Overrides:
      appendTimestamp in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
      Throws:
      IOException
    • appendCalendar

      protected void appendCalendar(Calendar calendar, Writer writer) throws IOException
      Answer a platform correct string representation of a Calendar, suitable for SQL generation. The date is printed in the ODBC platform independent format {d'YYYY-MM-DD'}.
      Overrides:
      appendCalendar in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
      Throws:
      IOException
    • appendSybaseCalendar

      protected void appendSybaseCalendar(Calendar calendar, Writer writer) throws IOException
      Write a timestamp in Sybase specific format ( yyyy-mm-dd-hh.mm.ss.fff)
      Throws:
      IOException
    • 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 org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
    • buildSelectQueryForIdentity

      public ValueReadQuery buildSelectQueryForIdentity()
      INTERNAL: Build the identity query for native sequencing.
      Overrides:
      buildSelectQueryForIdentity in class org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform
    • shouldPrintLockingClauseAfterWhereClause

      public boolean shouldPrintLockingClauseAfterWhereClause()
      The sybase syntax for obtaining pessimistic lock is "SELECT ADDRESS_ID, ... FROM ADDRESS WITH (HOLDLOCK) WHERE (ADDRESS_ID = ?)" Please note that above only obtains shared lock. Apparently there is no way to obtain exclusive lock on Sybase using only a select statement
      Overrides:
      shouldPrintLockingClauseAfterWhereClause in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
    • getSelectForUpdateString

      public String getSelectForUpdateString()
      Description copied from class: org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
      Most database support a syntax. although don't actually lock the row. Some require the OF some don't like it.
      Overrides:
      getSelectForUpdateString in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
    • getBatchDelimiterString

      public String getBatchDelimiterString()
      Used for batch writing and sp defs.
    • getCreationInOutputProcedureToken

      public String getCreationInOutputProcedureToken()
      Description copied from interface: DDLPlatform
      This method is used to print the required output parameter token for the specific platform. Used when stored procedures are created.
    • getCreationOutputProcedureToken

      public String getCreationOutputProcedureToken()
      Description copied from interface: DDLPlatform
      This method is used to print the required output parameter token for the specific platform. Used when stored procedures are created.
    • getInOutputProcedureToken

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

      public String getJdbcTypeName(int jdbcType)
      INTERNAL: Returns the type name corresponding to the jdbc type
      Overrides:
      getJdbcTypeName in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
    • getMaxFieldNameSize

      public int getMaxFieldNameSize()
      INTERNAL: returns the maximum number of characters that can be used in a field name on this platform.
    • getNativeTableInfo

      public Vector getNativeTableInfo(String table, String creator, org.eclipse.persistence.internal.sessions.AbstractSession session)
      Return the catalog information through using the native SQL catalog selects. This is required because many JDBC driver do not support meta-data. Willcards can be passed as arguments.
    • getOutputProcedureToken

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

      public String getProcedureArgumentString()
      Used for sp defs.
    • getProcedureCallHeader

      public String getProcedureCallHeader()
      Used for sp calls.
      Overrides:
      getProcedureCallHeader in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
    • getProcedureCallTail

      public String getProcedureCallTail()
      Description copied from class: org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
      Used for sp calls.
      Overrides:
      getProcedureCallTail in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
    • useJDBCStoredProcedureSyntax

      public boolean useJDBCStoredProcedureSyntax()
      Return true if this platform is to use the JDBC supported syntax for executing stored procedures. If the driver is known to be the DataDirec driver, and the value is not set, then set to true and return.
    • getStoredProcedureParameterPrefix

      public String getStoredProcedureParameterPrefix()
      Overrides:
      getStoredProcedureParameterPrefix in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
    • getTimestampQuery

      public ValueReadQuery getTimestampQuery()
      PUBLIC: This method returns the query to select the timestamp from the server for Sybase.
      Specified by:
      getTimestampQuery in interface org.eclipse.persistence.internal.databaseaccess.Platform
      Overrides:
      getTimestampQuery in class org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform
    • initializePlatformOperators

      protected void initializePlatformOperators()
      Initialize any platform-specific operators
      Overrides:
      initializePlatformOperators in class org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform
    • modOperator

      protected static ExpressionOperator modOperator()
      Override the default MOD operator.
    • operatorOuterJoin

      protected static ExpressionOperator operatorOuterJoin()
      Create the outer join operator for this platform
    • singleArgumentSubstringOperator

      protected static ExpressionOperator singleArgumentSubstringOperator()
      Override the default SubstringSingleArg operator.
    • sybaseAddMonthsOperator

      protected static ExpressionOperator sybaseAddMonthsOperator()
      INTERNAL: Function, to add months to a date.
    • sybaseInStringOperator

      protected static ExpressionOperator sybaseInStringOperator()
      INTERNAL: Build instring operator
    • sybaseToNumberOperator

      protected static ExpressionOperator sybaseToNumberOperator()
      INTERNAL: Build Sybase equivalent to TO_NUMBER.
    • sybaseToDateToStringOperator

      protected static ExpressionOperator sybaseToDateToStringOperator()
      INTERNAL: Build Sybase equivalent to TO_CHAR.
    • sybaseToDateOperator

      protected static ExpressionOperator sybaseToDateOperator()
      INTERNAL: Build Sybase equivalent to TO_DATE.
    • sybaseToCharOperator

      protected static ExpressionOperator sybaseToCharOperator()
      INTERNAL: Build Sybase equivalent to TO_CHAR.
    • sybaseToCharWithFormatOperator

      protected static ExpressionOperator sybaseToCharWithFormatOperator()
      INTERNAL: Build Sybase equivalent to TO_CHAR.
    • sybaseLocateOperator

      protected static ExpressionOperator sybaseLocateOperator()
      INTERNAL: Build the Sybase equivalent to Locate
    • sybaseLocate2Operator

      protected static ExpressionOperator sybaseLocate2Operator()
      INTERNAL: Build the Sybase equivalent to Locate with a start index. Sybase does not define this, so this gets a little complex...
    • extractOperator

      protected static ExpressionOperator extractOperator()
      INTERNAL: Derby does not support EXTRACT, but does have DATEPART.
    • trimOperator

      protected static ExpressionOperator trimOperator()
      INTERNAL: Use RTRIM(LTRIM(?)) function for trim.
    • trim2Operator

      protected static ExpressionOperator trim2Operator()
      INTERNAL: Build Trim operator.
    • isOutputAllowWithResultSet

      public boolean isOutputAllowWithResultSet()
      INTERNAL: Return true if output parameters can be built with result sets.
      Overrides:
      isOutputAllowWithResultSet in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
    • isSybase

      public boolean isSybase()
      Specified by:
      isSybase in interface org.eclipse.persistence.internal.databaseaccess.Platform
      Overrides:
      isSybase in class org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform
    • maximumNumericValues

      public Map<Class<? extends Number>,? super Number> maximumNumericValues()
      Builds a table of maximum numeric values keyed on java class. This is used for type testing but might also be useful to end users attempting to sanitize values.

      NOTE: BigInteger & BigDecimal maximums are dependent upon their precision & Scale

      Overrides:
      maximumNumericValues in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
    • minimumNumericValues

      public Map<Class<? extends Number>,? super Number> minimumNumericValues()
      Builds a table of minimum numeric values keyed on java class. This is used for type testing but might also be useful to end users attempting to sanitize values.

      NOTE: BigInteger & BigDecimal minimums are dependent upon their precision & Scale

      Overrides:
      minimumNumericValues in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
    • printFieldIdentityClause

      public void printFieldIdentityClause(Writer writer) throws ValidationException
      Append the receiver's field 'identity' constraint clause to a writer.
      Parameters:
      writer - the writer to append to
      Throws:
      ValidationException
    • printFieldNullClause

      public void printFieldNullClause(Writer writer) throws ValidationException
      Append the receiver's field 'NULL' constraint clause to a writer.
      Parameters:
      writer - the writer to append to
      Throws:
      ValidationException
    • registerOutputParameter

      public void registerOutputParameter(CallableStatement statement, int index, int jdbcType) throws SQLException
      This method is used to register output parameter on Callable Statements for Stored Procedures as each database seems to have a different method.
      Overrides:
      registerOutputParameter in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
      Throws:
      SQLException
      See Also:
    • registerOutputParameter

      public void registerOutputParameter(CallableStatement statement, int index, int jdbcType, String typeName) throws SQLException
      Description copied from class: org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
      This method is used to register output parameter on CallableStatements for Stored Procedures as each database seems to have a different method.
      Overrides:
      registerOutputParameter in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
      Throws:
      SQLException
      See Also:
    • requiresProcedureCallBrackets

      public boolean requiresProcedureCallBrackets()
      USed for sp calls.
      Overrides:
      requiresProcedureCallBrackets in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
    • requiresProcedureCallOuputToken

      public boolean requiresProcedureCallOuputToken()
      Used for sp calls. Sybase must print output after output params.
      Overrides:
      requiresProcedureCallOuputToken in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
    • requiresTypeNameToRegisterOutputParameter

      public boolean requiresTypeNameToRegisterOutputParameter()
      INTERNAL: Indicates whether the version of CallableStatement.registerOutputParameter method that takes type name should be used.
      Overrides:
      requiresTypeNameToRegisterOutputParameter in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
    • shouldPrintInOutputTokenBeforeType

      public boolean shouldPrintInOutputTokenBeforeType()
      Description copied from class: org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
      This is required in the construction of the stored procedures with output parameters
      Overrides:
      shouldPrintInOutputTokenBeforeType in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
    • shouldPrintOutputTokenBeforeType

      public boolean shouldPrintOutputTokenBeforeType()
      Description copied from interface: DDLPlatform
      This is required in the construction of the stored procedures with output parameters
    • shouldUseJDBCOuterJoinSyntax

      public boolean shouldUseJDBCOuterJoinSyntax()
      JDBC defines and outer join syntax, many drivers do not support this. So we normally avoid it.
      Overrides:
      shouldUseJDBCOuterJoinSyntax in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
    • supportsIdentity

      public boolean supportsIdentity()
      INTERNAL: Indicates whether the platform supports identity. Sybase does through IDENTITY field types. This method is to be used *ONLY* by sequencing classes
      Overrides:
      supportsIdentity in class org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform
    • supportsDeleteOnCascade

      public boolean supportsDeleteOnCascade()
      Sybase (as of Sybase ASE 15, does not support delete on cascade). Sybase ASA (SQL Anywhere does, so must use different platform).
    • supportsGlobalTempTables

      public boolean supportsGlobalTempTables()
      INTERNAL:
      Overrides:
      supportsGlobalTempTables in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
    • getCreateTempTableSqlPrefix

      protected String getCreateTempTableSqlPrefix()
      INTERNAL:
      Overrides:
      getCreateTempTableSqlPrefix in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
    • getTempTableForTable

      public org.eclipse.persistence.internal.helper.DatabaseTable getTempTableForTable(org.eclipse.persistence.internal.helper.DatabaseTable table)
      INTERNAL:
      Overrides:
      getTempTableForTable in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
      Parameters:
      table - is original table for which temp table is created.
      Returns:
      temporary table
    • 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:
      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