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

public class DatasourcePlatform extends Object implements Platform
DatasourcePlatform is private to TopLink. It encapsulates behavior specific to a datasource platform (eg. Oracle, Sybase, DB2, Attunity, MQSeries), and provides protocol for TopLink to access this behavior.
Since:
OracleAS TopLink 10g (10.0.3)
See Also:
  • Field Details

    • tableQualifier

      protected String tableQualifier
      Supporting name scopes in database by prefixing the table names with the table qualifier/creator.
    • conversionManager

      protected transient ConversionManager conversionManager
      Allow for conversion to be customized in the platform.
    • timestampQuery

      protected ValueReadQuery timestampQuery
      Store the query use to query the current server time.
    • uuidQuery

      protected ValueReadQuery uuidQuery
      Store the query use to query the current server UUID.
    • platformOperators

      protected transient Map<Integer,ExpressionOperator> platformOperators
      Operators specific to this platform
    • dataTypesConvertedFromAClass

      protected Hashtable<Class<?>,List<Class<?>>> dataTypesConvertedFromAClass
      Store the list of Classes that can be converted to from the key.
    • dataTypesConvertedToAClass

      protected Hashtable<Class<?>,List<Class<?>>> dataTypesConvertedToAClass
      Store the list of Classes that can be converted from to the key.
    • defaultSequence

      protected Sequence defaultSequence
      Store default sequence
    • sequences

      protected Map<String,Sequence> sequences
      Store map of sequence names to sequences
    • startDelimiter

      protected String startDelimiter
      Delimiter to use for fields and tables using spaces or other special values
    • endDelimiter

      protected String endDelimiter
    • sequencesLock

      protected Object sequencesLock
      Ensures that only one thread at a time can add/remove sequences
    • defaultNativeSequenceToTable

      protected boolean defaultNativeSequenceToTable
      If the native sequence type is not supported, if table sequencing should be used.
    • defaultSeqenceAtNextValue

      protected boolean defaultSeqenceAtNextValue
      If sequences should start at Next Value
    • supportsReturnGeneratedKeys

      protected boolean supportsReturnGeneratedKeys
      This property configures if the database platform will use Statement.getGeneratedKeys(), or a separate query, in order to obtain javax.persistence.GenerationType.IDENTITY generated values.

      Allowed Values:

      See:

  • Constructor Details

    • DatasourcePlatform

      public DatasourcePlatform()
  • Method Details

    • getDefaultNativeSequenceToTable

      public boolean getDefaultNativeSequenceToTable()
      Return if the native sequence type is not supported, if table sequencing should be used.
    • setDefaultNativeSequenceToTable

      public void setDefaultNativeSequenceToTable(boolean defaultNativeSequenceToTable)
      Set if the native sequence type is not supported, if table sequencing should be used.
    • getDefaultSeqenceAtNextValue

      public boolean getDefaultSeqenceAtNextValue()
      Return if the sequence generation should start at next value.
    • setDefaultSeqenceAtNextValue

      public void setDefaultSeqenceAtNextValue(boolean defaultSeqenceAtNextValue)
      Set if the sequence generation should start at next value.
    • addOperator

      protected void addOperator(ExpressionOperator operator)
    • appendParameter

      public void appendParameter(Call call, Writer writer, Object parameter)
      Add the parameter. Convert the parameter to a string and write it.
      Specified by:
      appendParameter in interface Platform
    • getCustomModifyValueForCall

      public Object getCustomModifyValueForCall(Call call, Object value, DatabaseField field, boolean shouldBind)
      Allow for the platform to handle the representation of parameters specially.
      Specified by:
      getCustomModifyValueForCall in interface Platform
    • shouldUseCustomModifyForCall

      public boolean shouldUseCustomModifyForCall(DatabaseField field)
      Used by SQLCall.appendModify(..) If the field should be passed to customModifyInDatabaseCall, retun true, otherwise false. Methods shouldCustomModifyInDatabaseCall and customModifyInDatabaseCall should be kept in sync: shouldCustomModifyInDatabaseCall should return true if and only if the field is handled by customModifyInDatabaseCall.
      Specified by:
      shouldUseCustomModifyForCall in interface Platform
    • clone

      public Object clone()
      Specified by:
      clone in interface Platform
      Overrides:
      clone in class Object
    • sequencesAfterCloneCleanup

      protected void sequencesAfterCloneCleanup()
    • convertObject

      public <T> T convertObject(Object sourceObject, Class<T> javaClass) throws ConversionException
      Convert the object to the appropriate type by invoking the appropriate ConversionManager method
      Specified by:
      convertObject in interface CorePlatform<ConversionManager>
      Specified by:
      convertObject in interface Platform
      Parameters:
      sourceObject - the object that must be converted
      javaClass - the class that the object must be converted to
      Returns:
      the newly converted object
      Throws:
      ConversionException - all exceptions will be thrown as this type.
    • copyInto

      public void copyInto(Platform platform)
      Copy the state into the new platform.
      Specified by:
      copyInto in interface Platform
    • getConversionManager

      public ConversionManager getConversionManager()
      The platform hold its own instance of conversion manager to allow customization.
      Specified by:
      getConversionManager in interface CorePlatform<ConversionManager>
      Specified by:
      getConversionManager in interface Platform
    • setConversionManager

      public void setConversionManager(ConversionManager conversionManager)
      The platform hold its own instance of conversion manager to allow customization.
      Specified by:
      setConversionManager in interface Platform
    • getDriverVersion

      public String getDriverVersion()
      Return the driver version.
      Specified by:
      getDriverVersion in interface Platform
    • getEndDelimiter

      public String getEndDelimiter()
      Delimiter to use for fields and tables using spaces or other special values. Some databases use different delimiters for the beginning and end of the value. This delimiter indicates the end of the value.
      Specified by:
      getEndDelimiter in interface Platform
    • setEndDelimiter

      public void setEndDelimiter(String endDelimiter)
      Delimiter to use for fields and tables using spaces or other special values. Some databases use different delimiters for the beginning and end of the value. This delimiter indicates the end of the value.
    • getOperator

      public ExpressionOperator getOperator(int selector)
      Return the operator for the operator constant defined in ExpressionOperator.
    • getPlatformOperators

      public Map<Integer,ExpressionOperator> getPlatformOperators()
      Return any platform-specific operators
    • getSelectSequenceQuery

      public ValueReadQuery getSelectSequenceQuery()
      OBSOLETE: This method lazy initializes the select sequence number query. It allows for other queries to be used instead of the default one.
    • getSequencePreallocationSize

      public int getSequencePreallocationSize()
    • getStartDelimiter

      public String getStartDelimiter()
      Delimiter to use for fields and tables using spaces or other special values. Some databases use different delimiters for the beginning and end of the value. This delimiter indicates the start of the value.
      Specified by:
      getStartDelimiter in interface Platform
    • setStartDelimiter

      public void setStartDelimiter(String startDelimiter)
      Delimiter to use for fields and tables using spaces or other special values. Some databases use different delimiters for the beginning and end of the value. This delimiter indicates the start of the value.
    • getTableQualifier

      public String getTableQualifier()
      Return the qualifier for the table. Required by some databases such as Oracle and DB2
      Specified by:
      getTableQualifier in interface Platform
    • getTimestampFromServer

      public Timestamp getTimestampFromServer(AbstractSession session, String sessionName)
      Answer the timestamp from the server.
      Specified by:
      getTimestampFromServer in interface Platform
    • getTimestampQuery

      public ValueReadQuery getTimestampQuery()
      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
    • getUUIDQuery

      public ValueReadQuery getUUIDQuery()
      This method can be overridden by subclasses to return a query that will return the UUID from the server. return null if UUID can't be generated by platform.
      Specified by:
      getUUIDQuery in interface Platform
    • getUpdateSequenceQuery

      public DataModifyQuery getUpdateSequenceQuery()
      OBSOLETE: This method lazy initializes the update sequence number query. It allows for other queries to be used instead of the default one.
    • initializePlatformOperators

      protected void initializePlatformOperators()
      Initialize any platform-specific operators
    • initializeDefaultQueries

      public void initializeDefaultQueries(DescriptorQueryManager queryManager, AbstractSession session)
      INTERNAL: Allow the platform to initialize the CRUD queries to defaults. This is mainly used by EIS platforms, but could be used by relational ones for special behavior.
    • isAccess

      public boolean isAccess()
      Specified by:
      isAccess in interface Platform
    • isAttunity

      public boolean isAttunity()
      Specified by:
      isAttunity in interface Platform
    • isCloudscape

      public boolean isCloudscape()
      Specified by:
      isCloudscape in interface Platform
    • isDerby

      public boolean isDerby()
      Specified by:
      isDerby in interface Platform
    • isDB2

      public boolean isDB2()
      Specified by:
      isDB2 in interface Platform
    • isDB2Z

      public boolean isDB2Z()
      Specified by:
      isDB2Z in interface Platform
    • isHANA

      public boolean isHANA()
      Specified by:
      isHANA in interface Platform
    • isH2

      public boolean isH2()
      Specified by:
      isH2 in interface Platform
    • isDBase

      public boolean isDBase()
      Specified by:
      isDBase in interface Platform
    • isHSQL

      public boolean isHSQL()
      Specified by:
      isHSQL in interface Platform
    • isInformix

      public boolean isInformix()
      Specified by:
      isInformix in interface Platform
    • isMariaDB

      public boolean isMariaDB()
      Specified by:
      isMariaDB in interface Platform
    • isMySQL

      public boolean isMySQL()
      Specified by:
      isMySQL in interface Platform
    • isODBC

      public boolean isODBC()
      Specified by:
      isODBC in interface Platform
    • isOracle

      public boolean isOracle()
      Specified by:
      isOracle in interface Platform
    • isOracle9

      public boolean isOracle9()
      Specified by:
      isOracle9 in interface Platform
    • isOracle12

      public boolean isOracle12()
      Specified by:
      isOracle12 in interface Platform
    • isOracle23

      public boolean isOracle23()
      Specified by:
      isOracle23 in interface Platform
    • isPervasive

      public boolean isPervasive()
    • isPostgreSQL

      public boolean isPostgreSQL()
      Specified by:
      isPostgreSQL in interface Platform
    • isPointBase

      public boolean isPointBase()
      Specified by:
      isPointBase in interface Platform
    • isSQLAnywhere

      public boolean isSQLAnywhere()
      Specified by:
      isSQLAnywhere in interface Platform
    • isFirebird

      public boolean isFirebird()
    • isSQLServer

      public boolean isSQLServer()
      Specified by:
      isSQLServer in interface Platform
    • isSybase

      public boolean isSybase()
      Specified by:
      isSybase in interface Platform
    • isSymfoware

      public boolean isSymfoware()
      Specified by:
      isSymfoware in interface Platform
    • isTimesTen

      public boolean isTimesTen()
      Specified by:
      isTimesTen in interface Platform
    • isTimesTen7

      public boolean isTimesTen7()
      Specified by:
      isTimesTen7 in interface Platform
    • isMaxDB

      public boolean isMaxDB()
      Specified by:
      isMaxDB in interface Platform
    • initialize

      public void initialize()
      Allow the platform to initialize itself after login/init.
      Specified by:
      initialize in interface Platform
    • setSelectSequenceNumberQuery

      public void setSelectSequenceNumberQuery(ValueReadQuery seqQuery)
      OBSOLETE: Can override the default query for returning the sequence numbers. This query must be a valid query that has one parameter which is the sequence name.
    • setSequencePreallocationSize

      public void setSequencePreallocationSize(int size)
      Set the number of sequence values to preallocate. Preallocating sequence values can greatly improve insert performance.
    • setTableQualifier

      public void setTableQualifier(String qualifier)
      Set the qualifier for the table. Required by some databases such as Oracle and DB2
      Specified by:
      setTableQualifier in interface Platform
    • setTimestampQuery

      public void setTimestampQuery(ValueReadQuery tsQuery)
      Can override the default query for returning a timestamp from the server. See: getTimestampFromServer
      Specified by:
      setTimestampQuery in interface Platform
    • setUUIDQuery

      public void setUUIDQuery(ValueReadQuery uuidQuery)
      Can override the default query for returning a UUID from the server.
      Specified by:
      setUUIDQuery in interface Platform
    • setUpdateSequenceQuery

      public void setUpdateSequenceQuery(DataModifyQuery updateSequenceNumberQuery)
      This method sets the update sequence number query. It allows for other queries to be used instead of the default one.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getDataTypesConvertedFrom

      public List<Class<?>> getDataTypesConvertedFrom(Class<?> javaClass)
      PUBLIC: Return the list of Classes that can be converted to from the passed in javaClass.
      Parameters:
      javaClass - - the class that is converted from
      Returns:
      - a vector of classes
    • getDataTypesConvertedTo

      public List<Class<?>> getDataTypesConvertedTo(Class<?> javaClass)
      PUBLIC: Return the list of Classes that can be converted from to the passed in javaClass.
      Parameters:
      javaClass - - the class that is converted to
      Returns:
      - a vector of classes
    • getDefaultSequence

      public Sequence getDefaultSequence()
      Get default sequence
      Specified by:
      getDefaultSequence in interface Platform
    • hasDefaultSequence

      public boolean hasDefaultSequence()
      Get default sequence
    • setDefaultSequence

      public void setDefaultSequence(Sequence sequence)
      Set default sequence. In case the passed sequence is of type DefaultSequence - use platformDefaultSequence with name and size of the passed sequence.
      Specified by:
      setDefaultSequence in interface Platform
    • addSequence

      public void addSequence(Sequence sequence)
      Add sequence corresponding to the name
      Specified by:
      addSequence in interface Platform
    • setSupportsReturnGeneratedKeys

      public void setSupportsReturnGeneratedKeys(boolean supportsReturnGeneratedKeys)
      Indicates whether the platform supports the use of Statement.RETURN_GENERATED_KEYS. If supported, IDENTITY values will be obtained through Statement.getGeneratedKeys() and will replace usage of buildSelectQueryForIdentity()
    • addSequence

      public void addSequence(Sequence sequence, boolean isSessionConnected)
      Add sequence corresponding to the name. Use this method with isSessionConnected parameter set to true to add a sequence to connected session. If the session is connected then the sequence is added only if there is no sequence with the same name already in use.
      Specified by:
      addSequence in interface Platform
    • getSequence

      public Sequence getSequence(String seqName)
      Get sequence corresponding to the name
      Specified by:
      getSequence in interface Platform
    • createPlatformDefaultSequence

      protected Sequence createPlatformDefaultSequence()
      INTERNAL: Create platform-default Sequence
    • removeSequence

      public Sequence removeSequence(String seqName)
      Remove sequence corresponding to name. Doesn't remove default sequence.
      Specified by:
      removeSequence in interface Platform
    • removeAllSequences

      public void removeAllSequences()
      Remove all sequences, but the default one.
      Specified by:
      removeAllSequences in interface Platform
    • getSequences

      public Map<String,Sequence> getSequences()
      INTERNAL: Returns a map of sequence names to Sequences (may be null).
      Specified by:
      getSequences in interface Platform
    • getSequencesToWrite

      public Map<String,Sequence> getSequencesToWrite()
      INTERNAL: Used only for writing into XML or Java.
      Specified by:
      getSequencesToWrite in interface Platform
    • getDefaultSequenceToWrite

      public Sequence getDefaultSequenceToWrite()
      INTERNAL: Used only for writing into XML or Java.
      Specified by:
      getDefaultSequenceToWrite in interface Platform
    • setSequences

      public void setSequences(Map<String,Sequence> sequences)
      INTERNAL: Sets sequences - for XML support only
      Specified by:
      setSequences in interface Platform
    • usesPlatformDefaultSequence

      public boolean usesPlatformDefaultSequence()
      INTERNAL: Indicates whether defaultSequence is the same as platform default sequence.
      Specified by:
      usesPlatformDefaultSequence in interface Platform
    • createConnectionCustomizer

      public ConnectionCustomizer createConnectionCustomizer(Accessor accessor, AbstractSession session)
      INTERNAL:
    • shouldPrepare

      public boolean shouldPrepare(DatabaseQuery query)
      Allows query prepare to be disable in the platform. This is required for some EIS platforms, that cannot prepare the call.
    • shouldSelectIncludeOrderBy

      public boolean shouldSelectIncludeOrderBy()
      Return if the database requires the ORDER BY fields to be part of the select clause.
    • shouldSelectDistinctIncludeOrderBy

      public boolean shouldSelectDistinctIncludeOrderBy()
      Return if the database requires the ORDER BY fields to be part of the select clause.
    • shouldNativeSequenceUseTransaction

      public boolean shouldNativeSequenceUseTransaction()
      INTERNAL: Indicates whether a separate transaction is required for NativeSequence. This method is to be used *ONLY* by sequencing classes
    • supportsIdentity

      public boolean supportsIdentity()
      INTERNAL: Indicates whether the platform supports identity. This method is to be used *ONLY* by sequencing classes
    • supportsNativeSequenceNumbers

      public boolean supportsNativeSequenceNumbers()
    • supportsSequenceObjects

      public boolean supportsSequenceObjects()
      INTERNAL: Indicates whether the platform supports sequence objects. This method is to be used *ONLY* by sequencing classes
    • supportsReturnGeneratedKeys

      public boolean supportsReturnGeneratedKeys()
      Indicates whether the platform supports the use of Statement.RETURN_GENERATED_KEYS. If supported, IDENTITY values will be obtained through Statement.getGeneratedKeys() and will replace usage of buildSelectQueryForIdentity()
    • buildSelectQueryForSequenceObject

      public ValueReadQuery buildSelectQueryForSequenceObject()
      INTERNAL: Returns query used to read value generated by sequence object (like Oracle sequence). This method is called when sequence object NativeSequence is connected, the returned query used until the sequence is disconnected. If the platform supportsSequenceObjects then (at least) one of buildSelectQueryForSequenceObject methods should return non-null query.
    • buildSelectQueryForSequenceObject

      public ValueReadQuery buildSelectQueryForSequenceObject(String qualifiedSeqName, Integer size)
      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.
    • buildSelectQueryForIdentity

      public ValueReadQuery buildSelectQueryForIdentity()
      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 supportsReturnGeneratedKeys()

    • buildSelectQueryForIdentity

      public ValueReadQuery buildSelectQueryForIdentity(String seqName, Integer size)
      INTERNAL: Returns query used to read back the value generated by Identity. In case the other version of this method (taking no parameters) returns null, this method is called every time identity NativeSequence reads. If the platform supportsIdentity then (at least) one of buildSelectQueryForIdentity methods should return non-null query.
    • buildNativeCall

      public DatasourceCall buildNativeCall(String queryString)
      INTERNAL: Return the correct call type for the native query string. This allows EIS platforms to use different types of native calls.
    • initIdentitySequences

      public void initIdentitySequences(Session session, String defaultIdentityGenerator)
      INTERNAL: Initialize platform specific identity sequences.
      Specified by:
      initIdentitySequences in interface Platform
      Parameters:
      session - Active database session (in connected state).
      defaultIdentityGenerator - Default identity generator sequence name.
      Since:
      2.7
    • removeIdentitySequences

      public void removeIdentitySequences(Session session, String defaultIdentityGenerator, Set<String> tableNames)
      INTERNAL: Remove platform specific identity sequences for specified tables. Default identity sequences are restored.
      Specified by:
      removeIdentitySequences in interface Platform
      Parameters:
      session - Active database session (in connected state).
      defaultIdentityGenerator - Default identity generator sequence name.
      tableNames - Set of table names to check for identity sequence removal.
      Since:
      2.7
    • createExpressionFor

      public Expression createExpressionFor(DatabaseField field, Expression builder, String fieldClassificationClassName)
      INTERNAL: Override this method if the platform needs to use a custom function based on the DatabaseField
      Returns:
      An expression for the given field set equal to a parameter matching the field
    • getINClauseLimit

      public int getINClauseLimit()
      INTERNAL: Some database platforms have a limit for the number of parameters in an IN clause.