Module org.eclipse.persistence.core
Class DatasourcePlatform
java.lang.Object
org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform
- All Implemented Interfaces:
Serializable
,Cloneable
,CorePlatform<ConversionManager>
,Platform
- Direct Known Subclasses:
DatabasePlatform
,EISPlatform
,XMLPlatform
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 Summary
FieldsModifier and TypeFieldDescriptionprotected ConversionManager
Allow for conversion to be customized in the platform.Store the list of Classes that can be converted to from the key.Store the list of Classes that can be converted from to the key.protected boolean
If the native sequence type is not supported, if table sequencing should be used.protected boolean
If sequences should start at Next Valueprotected Sequence
Store default sequenceprotected String
protected Map
<Integer, ExpressionOperator> Operators specific to this platformStore map of sequence names to sequencesprotected Object
Ensures that only one thread at a time can add/remove sequencesprotected String
Delimiter to use for fields and tables using spaces or other special valuesprotected boolean
This property configures if the database platform will useStatement.getGeneratedKeys()
, or a separate query, in order to obtain javax.persistence.GenerationType.IDENTITY generated values.protected String
Supporting name scopes in database by prefixing the table names with the table qualifier/creator.protected ValueReadQuery
Store the query use to query the current server time.protected ValueReadQuery
Store the query use to query the current server UUID. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addOperator
(ExpressionOperator operator) void
addSequence
(Sequence sequence) Add sequence corresponding to the namevoid
addSequence
(Sequence sequence, boolean isSessionConnected) Add sequence corresponding to the name.void
appendParameter
(Call call, Writer writer, Object parameter) Add the parameter.buildNativeCall
(String queryString) INTERNAL: Return the correct call type for the native query string.INTERNAL: Returns query used to read back the value generated by Identity.buildSelectQueryForIdentity
(String seqName, Integer size) INTERNAL: Returns query used to read back the value generated by Identity.INTERNAL: Returns query used to read value generated by sequence object (like Oracle sequence).buildSelectQueryForSequenceObject
(String qualifiedSeqName, Integer size) INTERNAL: Returns query used to read value generated by sequence object (like Oracle sequence).clone()
<T> T
convertObject
(Object sourceObject, Class<T> javaClass) Convert the object to the appropriate type by invoking the appropriate ConversionManager methodvoid
Copy the state into the new platform.createConnectionCustomizer
(Accessor accessor, AbstractSession session) INTERNAL:createExpressionFor
(DatabaseField field, Expression builder, String fieldClassificationClassName) INTERNAL: Override this method if the platform needs to use a custom function based on the DatabaseFieldprotected Sequence
INTERNAL: Create platform-default SequenceThe platform hold its own instance of conversion manager to allow customization.getCustomModifyValueForCall
(Call call, Object value, DatabaseField field, boolean shouldBind) Allow for the platform to handle the representation of parameters specially.getDataTypesConvertedFrom
(Class<?> javaClass) PUBLIC: Return the list of Classes that can be converted to from the passed in javaClass.getDataTypesConvertedTo
(Class<?> javaClass) PUBLIC: Return the list of Classes that can be converted from to the passed in javaClass.boolean
Return if the native sequence type is not supported, if table sequencing should be used.boolean
Return if the sequence generation should start at next value.Get default sequenceINTERNAL: Used only for writing into XML or Java.Return the driver version.Delimiter to use for fields and tables using spaces or other special values.int
INTERNAL: Some database platforms have a limit for the number of parameters in an IN clause.getOperator
(int selector) Return the operator for the operator constant defined in ExpressionOperator.Return any platform-specific operatorsOBSOLETE: This method lazy initializes the select sequence number query.getSequence
(String seqName) Get sequence corresponding to the nameint
INTERNAL: Returns a map of sequence names to Sequences (may be null).INTERNAL: Used only for writing into XML or Java.Delimiter to use for fields and tables using spaces or other special values.Return the qualifier for the table.getTimestampFromServer
(AbstractSession session, String sessionName) Answer the timestamp from the server.This method can be overridden by subclasses to return a query that will return the timestamp from the server.OBSOLETE: This method lazy initializes the update sequence number query.This method can be overridden by subclasses to return a query that will return the UUID from the server.boolean
Get default sequencevoid
Allow the platform to initialize itself after login/init.void
initializeDefaultQueries
(DescriptorQueryManager queryManager, AbstractSession session) INTERNAL: Allow the platform to initialize the CRUD queries to defaults.protected void
Initialize any platform-specific operatorsvoid
initIdentitySequences
(Session session, String defaultIdentityGenerator) INTERNAL: Initialize platform specific identity sequences.boolean
isAccess()
boolean
boolean
boolean
isDB2()
boolean
isDB2Z()
boolean
isDBase()
boolean
isDerby()
boolean
boolean
isH2()
boolean
isHANA()
boolean
isHSQL()
boolean
boolean
boolean
isMaxDB()
boolean
isMySQL()
boolean
isODBC()
boolean
isOracle()
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
isSybase()
boolean
boolean
boolean
void
Remove all sequences, but the default one.void
removeIdentitySequences
(Session session, String defaultIdentityGenerator, Set<String> tableNames) INTERNAL: Remove platform specific identity sequences for specified tables.removeSequence
(String seqName) Remove sequence corresponding to name.protected void
void
setConversionManager
(ConversionManager conversionManager) The platform hold its own instance of conversion manager to allow customization.void
setDefaultNativeSequenceToTable
(boolean defaultNativeSequenceToTable) Set if the native sequence type is not supported, if table sequencing should be used.void
setDefaultSeqenceAtNextValue
(boolean defaultSeqenceAtNextValue) Set if the sequence generation should start at next value.void
setDefaultSequence
(Sequence sequence) Set default sequence.void
setEndDelimiter
(String endDelimiter) Delimiter to use for fields and tables using spaces or other special values.void
setSelectSequenceNumberQuery
(ValueReadQuery seqQuery) OBSOLETE: Can override the default query for returning the sequence numbers.void
setSequencePreallocationSize
(int size) Set the number of sequence values to preallocate.void
setSequences
(Map<String, Sequence> sequences) INTERNAL: Sets sequences - for XML support onlyvoid
setStartDelimiter
(String startDelimiter) Delimiter to use for fields and tables using spaces or other special values.void
setSupportsReturnGeneratedKeys
(boolean supportsReturnGeneratedKeys) Indicates whether the platform supports the use ofStatement.RETURN_GENERATED_KEYS
.void
setTableQualifier
(String qualifier) Set the qualifier for the table.void
setTimestampQuery
(ValueReadQuery tsQuery) Can override the default query for returning a timestamp from the server.void
setUpdateSequenceQuery
(DataModifyQuery updateSequenceNumberQuery) This method sets the update sequence number query.void
setUUIDQuery
(ValueReadQuery uuidQuery) Can override the default query for returning a UUID from the server.boolean
INTERNAL: Indicates whether a separate transaction is required for NativeSequence.boolean
shouldPrepare
(DatabaseQuery query) Allows query prepare to be disable in the platform.boolean
Return if the database requires the ORDER BY fields to be part of the select clause.boolean
Return if the database requires the ORDER BY fields to be part of the select clause.boolean
Used by SQLCall.appendModify(..) If the field should be passed to customModifyInDatabaseCall, retun true, otherwise false.boolean
INTERNAL: Indicates whether the platform supports identity.boolean
boolean
Indicates whether the platform supports the use ofStatement.RETURN_GENERATED_KEYS
.boolean
INTERNAL: Indicates whether the platform supports sequence objects.toString()
boolean
INTERNAL: Indicates whether defaultSequence is the same as platform default sequence.Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.persistence.internal.databaseaccess.Platform
connectionProperties
-
Field Details
-
tableQualifier
Supporting name scopes in database by prefixing the table names with the table qualifier/creator. -
conversionManager
Allow for conversion to be customized in the platform. -
timestampQuery
Store the query use to query the current server time. -
uuidQuery
Store the query use to query the current server UUID. -
platformOperators
Operators specific to this platform -
dataTypesConvertedFromAClass
Store the list of Classes that can be converted to from the key. -
dataTypesConvertedToAClass
Store the list of Classes that can be converted from to the key. -
defaultSequence
Store default sequence -
sequences
Store map of sequence names to sequences -
startDelimiter
Delimiter to use for fields and tables using spaces or other special values -
endDelimiter
-
sequencesLock
Ensures that only one thread at a time can add/remove sequences -
defaultNativeSequenceToTable
protected boolean defaultNativeSequenceToTableIf the native sequence type is not supported, if table sequencing should be used. -
defaultSeqenceAtNextValue
protected boolean defaultSeqenceAtNextValueIf sequences should start at Next Value -
supportsReturnGeneratedKeys
protected boolean supportsReturnGeneratedKeysThis property configures if the database platform will useStatement.getGeneratedKeys()
, or a separate query, in order to obtain javax.persistence.GenerationType.IDENTITY generated values.Allowed Values:
- "
true
" - IDENTITY generated values will be obtained withStatement.getGeneratedKeys()
- "
false
" (DEFAULT) - IDENTITY generated values will be obtained with a separate querybuildSelectQueryForIdentity()
See:
buildSelectQueryForIdentity()
will be disabled if this property is enabled
- "
-
-
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
-
appendParameter
Add the parameter. Convert the parameter to a string and write it.- Specified by:
appendParameter
in interfacePlatform
-
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 interfacePlatform
-
shouldUseCustomModifyForCall
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 interfacePlatform
-
clone
-
sequencesAfterCloneCleanup
protected void sequencesAfterCloneCleanup() -
convertObject
Convert the object to the appropriate type by invoking the appropriate ConversionManager method- Specified by:
convertObject
in interfaceCorePlatform<ConversionManager>
- Specified by:
convertObject
in interfacePlatform
- Parameters:
sourceObject
- the object that must be convertedjavaClass
- 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
Copy the state into the new platform. -
getConversionManager
The platform hold its own instance of conversion manager to allow customization.- Specified by:
getConversionManager
in interfaceCorePlatform<ConversionManager>
- Specified by:
getConversionManager
in interfacePlatform
-
setConversionManager
The platform hold its own instance of conversion manager to allow customization.- Specified by:
setConversionManager
in interfacePlatform
-
getDriverVersion
Return the driver version.- Specified by:
getDriverVersion
in interfacePlatform
-
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 interfacePlatform
-
setEndDelimiter
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
Return the operator for the operator constant defined in ExpressionOperator. -
getPlatformOperators
Return any platform-specific operators -
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
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 interfacePlatform
-
setStartDelimiter
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
Return the qualifier for the table. Required by some databases such as Oracle and DB2- Specified by:
getTableQualifier
in interfacePlatform
-
getTimestampFromServer
Answer the timestamp from the server.- Specified by:
getTimestampFromServer
in interfacePlatform
-
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 interfacePlatform
-
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 interfacePlatform
-
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
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() -
isAttunity
public boolean isAttunity()- Specified by:
isAttunity
in interfacePlatform
-
isCloudscape
public boolean isCloudscape()- Specified by:
isCloudscape
in interfacePlatform
-
isDerby
public boolean isDerby() -
isDB2
public boolean isDB2() -
isDB2Z
public boolean isDB2Z() -
isHANA
public boolean isHANA() -
isH2
public boolean isH2() -
isDBase
public boolean isDBase() -
isHSQL
public boolean isHSQL() -
isInformix
public boolean isInformix()- Specified by:
isInformix
in interfacePlatform
-
isMariaDB
public boolean isMariaDB() -
isMySQL
public boolean isMySQL() -
isODBC
public boolean isODBC() -
isOracle
public boolean isOracle() -
isOracle9
public boolean isOracle9() -
isOracle12
public boolean isOracle12()- Specified by:
isOracle12
in interfacePlatform
-
isOracle23
public boolean isOracle23()- Specified by:
isOracle23
in interfacePlatform
-
isPervasive
public boolean isPervasive() -
isPostgreSQL
public boolean isPostgreSQL()- Specified by:
isPostgreSQL
in interfacePlatform
-
isPointBase
public boolean isPointBase()- Specified by:
isPointBase
in interfacePlatform
-
isSQLAnywhere
public boolean isSQLAnywhere()- Specified by:
isSQLAnywhere
in interfacePlatform
-
isFirebird
public boolean isFirebird() -
isSQLServer
public boolean isSQLServer()- Specified by:
isSQLServer
in interfacePlatform
-
isSybase
public boolean isSybase() -
isSymfoware
public boolean isSymfoware()- Specified by:
isSymfoware
in interfacePlatform
-
isTimesTen
public boolean isTimesTen()- Specified by:
isTimesTen
in interfacePlatform
-
isTimesTen7
public boolean isTimesTen7()- Specified by:
isTimesTen7
in interfacePlatform
-
isMaxDB
public boolean isMaxDB() -
initialize
public void initialize()Allow the platform to initialize itself after login/init.- Specified by:
initialize
in interfacePlatform
-
setSelectSequenceNumberQuery
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
Set the qualifier for the table. Required by some databases such as Oracle and DB2- Specified by:
setTableQualifier
in interfacePlatform
-
setTimestampQuery
Can override the default query for returning a timestamp from the server. See: getTimestampFromServer- Specified by:
setTimestampQuery
in interfacePlatform
-
setUUIDQuery
Can override the default query for returning a UUID from the server.- Specified by:
setUUIDQuery
in interfacePlatform
-
setUpdateSequenceQuery
This method sets the update sequence number query. It allows for other queries to be used instead of the default one. -
toString
-
getDataTypesConvertedFrom
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: 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
Get default sequence- Specified by:
getDefaultSequence
in interfacePlatform
-
hasDefaultSequence
public boolean hasDefaultSequence()Get default sequence -
setDefaultSequence
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 interfacePlatform
-
addSequence
Add sequence corresponding to the name- Specified by:
addSequence
in interfacePlatform
-
setSupportsReturnGeneratedKeys
public void setSupportsReturnGeneratedKeys(boolean supportsReturnGeneratedKeys) Indicates whether the platform supports the use ofStatement.RETURN_GENERATED_KEYS
. If supported, IDENTITY values will be obtained throughStatement.getGeneratedKeys()
and will replace usage ofbuildSelectQueryForIdentity()
-
addSequence
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 interfacePlatform
-
getSequence
Get sequence corresponding to the name- Specified by:
getSequence
in interfacePlatform
-
createPlatformDefaultSequence
INTERNAL: Create platform-default Sequence -
removeSequence
Remove sequence corresponding to name. Doesn't remove default sequence.- Specified by:
removeSequence
in interfacePlatform
-
removeAllSequences
public void removeAllSequences()Remove all sequences, but the default one.- Specified by:
removeAllSequences
in interfacePlatform
-
getSequences
INTERNAL: Returns a map of sequence names to Sequences (may be null).- Specified by:
getSequences
in interfacePlatform
-
getSequencesToWrite
INTERNAL: Used only for writing into XML or Java.- Specified by:
getSequencesToWrite
in interfacePlatform
-
getDefaultSequenceToWrite
INTERNAL: Used only for writing into XML or Java.- Specified by:
getDefaultSequenceToWrite
in interfacePlatform
-
setSequences
INTERNAL: Sets sequences - for XML support only- Specified by:
setSequences
in interfacePlatform
-
usesPlatformDefaultSequence
public boolean usesPlatformDefaultSequence()INTERNAL: Indicates whether defaultSequence is the same as platform default sequence.- Specified by:
usesPlatformDefaultSequence
in interfacePlatform
-
createConnectionCustomizer
INTERNAL: -
shouldPrepare
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 ofStatement.RETURN_GENERATED_KEYS
. If supported, IDENTITY values will be obtained throughStatement.getGeneratedKeys()
and will replace usage ofbuildSelectQueryForIdentity()
-
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
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
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()
, seesupportsReturnGeneratedKeys()
-
buildSelectQueryForIdentity
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
INTERNAL: Return the correct call type for the native query string. This allows EIS platforms to use different types of native calls. -
initIdentitySequences
INTERNAL: Initialize platform specific identity sequences.- Specified by:
initIdentitySequences
in interfacePlatform
- 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 interfacePlatform
- 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.
-