EclipseLink1.0 - 20080707 API Reference

org.eclipse.persistence.platform.database
Class MySQLPlatform

java.lang.Object
  extended by org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform
      extended by org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
          extended by org.eclipse.persistence.platform.database.DatabasePlatform
              extended by org.eclipse.persistence.platform.database.MySQLPlatform
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, org.eclipse.persistence.internal.databaseaccess.Platform

public class MySQLPlatform
extends DatabasePlatform

Purpose: Provides MySQL specific behavior.

Responsibilities:

See Also:
Serialized Form
Since:
OracleAS TopLink 10g (10.1.3)

Field Summary
 
Fields inherited from class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
classTypes, cursorCode, DEFAULT_MAX_BATCH_WRITING_SIZE, DEFAULT_PARAMETERIZED_MAX_BATCH_WRITING_SIZE, fieldTypes, maxBatchWritingSize, pingSQL, shouldBindAllParameters, shouldCacheAllStatements, shouldForceFieldNamesToUpperCase, shouldIgnoreCaseOnFieldComparisons, shouldOptimizeDataConversion, shouldTrimStrings, statementCacheSize, stringBindingSize, structConverters, supportsAutoCommit, transactionIsolation, typeConverters, usesBatchWriting, usesByteArrayBinding, usesJDBCBatchWriting, usesNativeBatchWriting, usesNativeSQL, usesStreamsForBinding, usesStringBinding
 
Fields inherited from class org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform
conversionManager, dataTypesConvertedFromAClass, dataTypesConvertedToAClass, defaultSequence, platformOperators, sequences, tableQualifier, timestampQuery
 
Constructor Summary
MySQLPlatform()
           
 
Method Summary
protected  void appendCalendar(java.util.Calendar calendar, java.io.Writer writer)
          Appends an MySQL specific Timestamp, if usesNativeSQL is true otherwise use the ODBC format.
protected  void appendDate(java.sql.Date date, java.io.Writer writer)
          Appends an MySQL specific date if usesNativeSQL is true otherwise use the ODBC format.
protected  void appendTime(java.sql.Time time, java.io.Writer writer)
          Appends an MySQL specific time if usesNativeSQL is true otherwise use the ODBC format.
protected  void appendTimestamp(java.sql.Timestamp timestamp, java.io.Writer writer)
          Appends an MySQL specific Timestamp, if usesNativeSQL is true otherwise use the ODBC format.
protected  java.util.Hashtable buildFieldTypes()
          Return the mapping of class types to database types for the schema framework.
 java.lang.String buildProcedureCallString(StoredProcedureCall call, org.eclipse.persistence.internal.sessions.AbstractSession session)
          Return the proc syntax for this platform.
 ValueReadQuery buildSelectQueryForIdentity()
          INTERNAL: Build the identity query for native sequencing.
protected  ExpressionOperator currentDateOperator()
          INTERNAL: Create the current date operator for this platform.
protected  ExpressionOperator dateToStringOperator()
          INTERNAL: Build MySQL equivalent to TO_CHAR.
 java.lang.String getConstraintDeletionString()
          INTERNAL: Used for constraint deletion.
protected  java.lang.String getCreateTempTableSqlBodyForTable(org.eclipse.persistence.internal.helper.DatabaseTable table)
          INTERNAL:
protected  java.lang.String getCreateTempTableSqlPrefix()
          INTERNAL: MySQL temp table syntax, used for update-all, delete-all queries.
 java.lang.String getFunctionCallHeader()
          Used for stored function calls.
 java.lang.String getIdentifierQuoteCharacter()
          INTERNAL: MySQL uses ' to allow identifier to have spaces.
 java.lang.String getInOutputProcedureToken()
          INTERNAL: MySQL uses the INOUT keyword for this.
 java.lang.String getProcedureAsString()
          MySQL does not use the AS token.
 java.lang.String getProcedureBeginString()
          INTERNAL: MySQL requires BEGIN.
 java.lang.String getProcedureCallHeader()
          INTERNAL: Used for stored procedure calls.
 java.lang.String getProcedureCallTail()
          Used for sp calls.
 java.lang.String getProcedureEndString()
          INTERNAL: MySQL requires END.
 java.lang.String getSelectForUpdateString()
          INTERNAL: Used for pessimistic locking.
 ValueReadQuery getTimestampQuery()
          INTERNAL: This method returns the query to select the timestamp from the server for MySQL.
protected  void initializePlatformOperators()
          Initialize any platform-specific operators.
 boolean isMySQL()
          Answers whether platform is MySQL.
protected  ExpressionOperator leftTrim2()
          INTERNAL: Build MySQL equivalent to LTRIM(string_exp, character).
protected  ExpressionOperator logOperator()
          INTERNAL: Create the 10 based log operator for this platform.
 void printFieldIdentityClause(java.io.Writer writer)
          INTERNAL: Append the receiver's field 'identity' constraint clause to a writer.
protected  ExpressionOperator rightTrim2()
          INTERNAL: Build MySQL equivalent to RTRIM(string_exp, character).
 boolean shouldAlwaysUseTempStorageForModifyAll()
          INTERNAL: MySQL supports temp tables for update-all, delete-all queries.
 boolean shouldPrintOutputTokenAtStart()
          INTERNAL: MySQL requires the direction at the start of the argument.
 boolean shouldPrintStoredProcedureArgumentNameInCall()
          INTERNAL: MySQL stored procedure calls do not require the argument name be printed in the call string e.g. call MyStoredProc(?)
 boolean shouldUseJDBCOuterJoinSyntax()
          INTERNAL: JDBC defines an outer join syntax which many drivers do not support.
 boolean supportsGlobalTempTables()
          INTERNAL: MySQL supports temp tables for update-all, delete-all queries.
 boolean supportsIdentity()
          INTERNAL: Indicates whether the platform supports identity.
 boolean supportsStoredFunctions()
           
protected  ExpressionOperator toCharOperator()
          INTERNAL: Build MySQL equivalent to TO_CHAR.
protected  ExpressionOperator toDateOperator()
          INTERNAL: Build MySQL equivalent to TO_DATE.
protected  ExpressionOperator toNumberOperator()
          INTERNAL: Build MySQL equivalent to TO_NUMBER.
 void writeDeleteFromTargetTableUsingTempTableSql(java.io.Writer writer, org.eclipse.persistence.internal.helper.DatabaseTable table, org.eclipse.persistence.internal.helper.DatabaseTable targetTable, java.util.Collection pkFields, java.util.Collection targetPkFields)
          INTERNAL: Writes MySQL specific SQL for accessing temp tables for delete-all queries.
 void writeUpdateOriginalFromTempTableSql(java.io.Writer writer, org.eclipse.persistence.internal.helper.DatabaseTable table, java.util.Collection pkFields, java.util.Collection assignedFields)
          INTERNAL: Writes MySQL specific SQL for accessing temp tables for update-all queries.
 
Methods inherited from class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
addBatch, addStructConverter, allowsSizeInProcedureArguments, appendBoolean, appendByteArray, appendLiteralToCall, appendLiteralToCallWithBinding, appendNumber, appendParameter, appendParameterInternal, appendString, autoCommit, beginTransaction, buildCallWithReturning, buildClassTypes, buildSelectQueryForIdentity, buildSelectQueryForSequenceObject, buildSelectQueryForSequenceObject, buildSequenceObjectAlterIncrementWriter, buildSequenceObjectCreationWriter, buildSequenceObjectDeletionWriter, canBuildCallWithReturning, commitTransaction, convertToDatabaseType, copyInto, createArray, createArray, createPlatformDefaultSequence, createStruct, createStruct, dontBindUpdateAllQueryUsingTempTables, executeBatch, executeStoredProcedure, getAssignmentString, getBatchBeginString, getBatchDelimiterString, getBatchEndString, getClassTypes, getConnection, getCreateTempTableSqlSuffix, getCreateViewString, getCreationInOutputProcedureToken, getCreationOutputProcedureToken, getCursorCode, getCustomModifyValueForCall, getFieldTypeDefinition, getFieldTypes, getJDBCOuterJoinString, getJDBCType, getJDBCType, getJdbcTypeName, getMaxBatchWritingSize, getMaxFieldNameSize, getMaxForeignKeyNameSize, getMaxUniqueKeyNameSize, getNoWaitString, getObjectFromResultSet, getOutputProcedureToken, getPingSQL, getProcedureArgumentSetter, getProcedureArgumentString, getQualifiedName, getQualifiedSequenceTableName, getRefValue, getRefValue, getSelectForUpdateNoWaitString, getSelectForUpdateOfString, getSequenceCounterFieldName, getSequenceNameFieldName, getSequencePreallocationSize, getSequenceTableName, getStatementCacheSize, getStoredProcedureParameterPrefix, getStoredProcedureTerminationToken, getStringBindingSize, getStructConverters, getTempTableForTable, getTransactionIsolation, getTypeConverters, isAlterSequenceObjectSupported, isInformixOuterJoin, isNullAllowedInSelectClause, isXDBDocument, maximumNumericValues, minimumNumericValues, prepareBatchStatement, printFieldNotNullClause, printFieldNullClause, printFieldTypeSize, printFieldTypeSize, printFieldUnique, printFieldUnique, printSQLSelectStatement, printValuelist, printValuelist, processResultSet, registerOutputParameter, requiresNamedPrimaryKeyConstraints, requiresProcedureCallBrackets, requiresProcedureCallOuputToken, requiresTypeNameToRegisterOutputParameter, rollbackTransaction, setClassTypes, setCursorCode, setFieldTypes, setMaxBatchWritingSize, setParameterValueInDatabaseCall, setPingSQL, setSequenceCounterFieldName, setSequenceNameFieldName, setSequenceTableName, setShouldBindAllParameters, setShouldCacheAllStatements, setShouldForceFieldNamesToUpperCase, setShouldIgnoreCaseOnFieldComparisons, setShouldOptimizeDataConversion, setShouldTrimStrings, setStatementCacheSize, setStringBindingSize, setSupportsAutoCommit, setTransactionIsolation, setUsesBatchWriting, setUsesByteArrayBinding, setUsesJDBCBatchWriting, setUsesNativeBatchWriting, setUsesNativeSQL, setUsesStreamsForBinding, setUsesStringBinding, shouldBindAllParameters, shouldBindLiterals, shouldCacheAllStatements, shouldForceFieldNamesToUpperCase, shouldIgnoreCaseOnFieldComparisons, shouldIgnoreException, shouldNativeSequenceUseTransaction, shouldOptimizeDataConversion, shouldPrintConstraintNameAfter, shouldPrintFieldIdentityClause, shouldPrintInOutputTokenBeforeType, shouldPrintLockingClauseAfterWhereClause, shouldPrintOuterJoinInWhereClause, shouldPrintOutputTokenBeforeType, shouldTempTableSpecifyPrimaryKeys, shouldTrimStrings, shouldUseCustomModifyForCall, supportsAutoCommit, supportsForeignKeyConstraints, supportsLocalTempTables, supportsNativeSequenceNumbers, supportsPrimaryKeyConstraint, supportsSequenceObjects, supportsTempTables, supportsUniqueKeyConstraints, usesBatchWriting, usesByteArrayBinding, usesJDBCBatchWriting, usesNativeBatchWriting, usesNativeSQL, usesSequenceTable, usesStreamsForBinding, usesStringBinding, wasFailureCommunicationBased, writeAutoAssignmentSetClause, writeAutoJoinWhereClause, writeCleanUpTempTableSql, writeCreateTempTableSql, writeFields, writeFieldsAutoClause, writeFieldsList, writeInsertIntoTableSql, writeJoinWhereClause, writeLOB, writeParameterMarker
 
Methods inherited from class org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform
addOperator, addSequence, clone, convertObject, createConnectionCustomizer, createSequences, getConversionManager, getDataTypesConvertedFrom, getDataTypesConvertedTo, getDefaultSequence, getDefaultSequenceToWrite, getOperator, getPlatformOperators, getSelectSequenceQuery, getSequence, getSequences, getSequencesToWrite, getTableQualifier, getTimestampFromServer, getUpdateSequenceQuery, hasDefaultSequence, isAccess, isAttunity, isCloudscape, isDB2, isDBase, isDerby, isHSQL, isInformix, isODBC, isOracle, isOracle9, isPointBase, isPostgreSQL, isSQLAnywhere, isSQLServer, isSybase, isTimesTen, isTimesTen7, removeAllSequences, removeSequence, sequencesAfterCloneCleanup, setConversionManager, setDefaultSequence, setSelectSequenceNumberQuery, setSequencePreallocationSize, setSequences, setTableQualifier, setTimestampQuery, setUpdateSequenceQuery, toString, usesPlatformDefaultSequence
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MySQLPlatform

public MySQLPlatform()
Method Detail

appendDate

protected void appendDate(java.sql.Date date,
                          java.io.Writer writer)
                   throws java.io.IOException
Appends an MySQL specific date if usesNativeSQL is true otherwise use the ODBC format. Native FORMAT: 'YYYY-MM-DD'

Overrides:
appendDate in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
Throws:
java.io.IOException

appendTime

protected void appendTime(java.sql.Time time,
                          java.io.Writer writer)
                   throws java.io.IOException
Appends an MySQL specific time if usesNativeSQL is true otherwise use the ODBC format. Native FORMAT: 'HH:MM:SS'.

Overrides:
appendTime in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
Throws:
java.io.IOException

appendTimestamp

protected void appendTimestamp(java.sql.Timestamp timestamp,
                               java.io.Writer writer)
                        throws java.io.IOException
Appends an MySQL specific Timestamp, if usesNativeSQL is true otherwise use the ODBC format. Native Format: 'YYYY-MM-DD HH:MM:SS'

Overrides:
appendTimestamp in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
Throws:
java.io.IOException

appendCalendar

protected void appendCalendar(java.util.Calendar calendar,
                              java.io.Writer writer)
                       throws java.io.IOException
Appends an MySQL specific Timestamp, if usesNativeSQL is true otherwise use the ODBC format. Native Format: 'YYYY-MM-DD HH:MM:SS'

Overrides:
appendCalendar in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
Throws:
java.io.IOException

buildFieldTypes

protected java.util.Hashtable buildFieldTypes()
Return the mapping of class types to database types for the schema framework.

Overrides:
buildFieldTypes 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.DatabasePlatform

buildProcedureCallString

public java.lang.String buildProcedureCallString(StoredProcedureCall call,
                                                 org.eclipse.persistence.internal.sessions.AbstractSession session)
Return the proc syntax for this platform.

Overrides:
buildProcedureCallString in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

getConstraintDeletionString

public java.lang.String getConstraintDeletionString()
INTERNAL: Used for constraint deletion.

Overrides:
getConstraintDeletionString in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

getFunctionCallHeader

public java.lang.String getFunctionCallHeader()
Used for stored function calls.

Overrides:
getFunctionCallHeader in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

getProcedureCallTail

public java.lang.String getProcedureCallTail()
Used for sp calls.

Overrides:
getProcedureCallTail in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

getSelectForUpdateString

public java.lang.String getSelectForUpdateString()
INTERNAL: Used for pessimistic locking.

Overrides:
getSelectForUpdateString in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

getTimestampQuery

public ValueReadQuery getTimestampQuery()
INTERNAL: This method returns the query to select the timestamp from the server for MySQL.

Specified by:
getTimestampQuery in interface org.eclipse.persistence.internal.databaseaccess.Platform
Overrides:
getTimestampQuery in class org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform

isMySQL

public boolean isMySQL()
Answers whether platform is MySQL.

Specified by:
isMySQL in interface org.eclipse.persistence.internal.databaseaccess.Platform
Overrides:
isMySQL 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

logOperator

protected ExpressionOperator logOperator()
INTERNAL: Create the 10 based log operator for this platform.


toNumberOperator

protected ExpressionOperator toNumberOperator()
INTERNAL: Build MySQL equivalent to TO_NUMBER.


toDateOperator

protected ExpressionOperator toDateOperator()
INTERNAL: Build MySQL equivalent to TO_DATE.


toCharOperator

protected ExpressionOperator toCharOperator()
INTERNAL: Build MySQL equivalent to TO_CHAR.


dateToStringOperator

protected ExpressionOperator dateToStringOperator()
INTERNAL: Build MySQL equivalent to TO_CHAR.


leftTrim2

protected ExpressionOperator leftTrim2()
INTERNAL: Build MySQL equivalent to LTRIM(string_exp, character). MySQL: TRIM(LEADING character FROM string_exp)


rightTrim2

protected ExpressionOperator rightTrim2()
INTERNAL: Build MySQL equivalent to RTRIM(string_exp, character). MySQL: TRIM(TRAILING character FROM string_exp)


currentDateOperator

protected ExpressionOperator currentDateOperator()
INTERNAL: Create the current date operator for this platform.


printFieldIdentityClause

public void printFieldIdentityClause(java.io.Writer writer)
                              throws ValidationException
INTERNAL: Append the receiver's field 'identity' constraint clause to a writer.

Overrides:
printFieldIdentityClause in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
Throws:
ValidationException

shouldUseJDBCOuterJoinSyntax

public boolean shouldUseJDBCOuterJoinSyntax()
INTERNAL: JDBC defines an outer join syntax which many drivers do not support. 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. MySQL supports native sequencing through AUTO_INCREMENT field types.

Overrides:
supportsIdentity in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

supportsGlobalTempTables

public boolean supportsGlobalTempTables()
INTERNAL: MySQL supports temp tables for update-all, delete-all queries.

Overrides:
supportsGlobalTempTables in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

supportsStoredFunctions

public boolean supportsStoredFunctions()
Overrides:
supportsStoredFunctions in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

getCreateTempTableSqlPrefix

protected java.lang.String getCreateTempTableSqlPrefix()
INTERNAL: MySQL temp table syntax, used for update-all, delete-all queries.

Overrides:
getCreateTempTableSqlPrefix in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

getCreateTempTableSqlBodyForTable

protected java.lang.String getCreateTempTableSqlBodyForTable(org.eclipse.persistence.internal.helper.DatabaseTable table)
INTERNAL:

Overrides:
getCreateTempTableSqlBodyForTable in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

shouldAlwaysUseTempStorageForModifyAll

public boolean shouldAlwaysUseTempStorageForModifyAll()
INTERNAL: MySQL supports temp tables for update-all, delete-all queries.

Overrides:
shouldAlwaysUseTempStorageForModifyAll in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

shouldPrintStoredProcedureArgumentNameInCall

public boolean shouldPrintStoredProcedureArgumentNameInCall()
INTERNAL: MySQL stored procedure calls do not require the argument name be printed in the call string e.g. call MyStoredProc(?) instead of call MyStoredProc(myvariable = ?)

Overrides:
shouldPrintStoredProcedureArgumentNameInCall in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
Returns:

getIdentifierQuoteCharacter

public java.lang.String getIdentifierQuoteCharacter()
INTERNAL: MySQL uses ' to allow identifier to have spaces.

Overrides:
getIdentifierQuoteCharacter in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

getInOutputProcedureToken

public java.lang.String getInOutputProcedureToken()
INTERNAL: MySQL uses the INOUT keyword for this.

Overrides:
getInOutputProcedureToken in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

getProcedureAsString

public java.lang.String getProcedureAsString()
MySQL does not use the AS token.

Overrides:
getProcedureAsString in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

shouldPrintOutputTokenAtStart

public boolean shouldPrintOutputTokenAtStart()
INTERNAL: MySQL requires the direction at the start of the argument.

Overrides:
shouldPrintOutputTokenAtStart in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

getProcedureCallHeader

public java.lang.String getProcedureCallHeader()
INTERNAL: Used for stored procedure calls.

Overrides:
getProcedureCallHeader in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

getProcedureBeginString

public java.lang.String getProcedureBeginString()
INTERNAL: MySQL requires BEGIN.

Overrides:
getProcedureBeginString in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

getProcedureEndString

public java.lang.String getProcedureEndString()
INTERNAL: MySQL requires END.

Overrides:
getProcedureEndString in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

writeUpdateOriginalFromTempTableSql

public void writeUpdateOriginalFromTempTableSql(java.io.Writer writer,
                                                org.eclipse.persistence.internal.helper.DatabaseTable table,
                                                java.util.Collection pkFields,
                                                java.util.Collection assignedFields)
                                         throws java.io.IOException
INTERNAL: Writes MySQL specific SQL for accessing temp tables for update-all queries.

Overrides:
writeUpdateOriginalFromTempTableSql in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
Throws:
java.io.IOException

writeDeleteFromTargetTableUsingTempTableSql

public void writeDeleteFromTargetTableUsingTempTableSql(java.io.Writer writer,
                                                        org.eclipse.persistence.internal.helper.DatabaseTable table,
                                                        org.eclipse.persistence.internal.helper.DatabaseTable targetTable,
                                                        java.util.Collection pkFields,
                                                        java.util.Collection targetPkFields)
                                                 throws java.io.IOException
INTERNAL: Writes MySQL specific SQL for accessing temp tables for delete-all queries.

Overrides:
writeDeleteFromTargetTableUsingTempTableSql in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
Throws:
java.io.IOException

EclipseLink1.0 - 20080707 API Reference