Top Description Inners Fields Constructors Methods
org.eclipse.persistence.platform.database

public Class MySQLPlatform

extends DatabasePlatform
Class Inheritance
Known Direct Subclasses
org.eclipse.persistence.platform.database.MariaDBPlatform
Imports
java.io.IOException, .StringWriter, .Writer, java.lang.reflect.Type, java.sql.Connection, .DatabaseMetaData, .SQLException, .Types, java.util.ArrayList, .Calendar, .Collection, .Hashtable, .List, .Vector, org.eclipse.persistence.exceptions.ValidationException, org.eclipse.persistence.expressions.Expression, .ExpressionOperator, org.eclipse.persistence.internal.expressions.ExtractOperator, .ExpressionJavaPrinter, .ExpressionSQLPrinter, .FunctionExpression, .ParameterExpression, .SQLSelectStatement, org.eclipse.persistence.internal.databaseaccess.DatabaseCall, .DatasourcePlatform, .FieldTypeDefinition, org.eclipse.persistence.internal.helper.ClassConstants, .DatabaseField, .DatabaseTable, .Helper, org.eclipse.persistence.internal.sessions.AbstractRecord, .AbstractSession, .DatabaseSessionImpl, org.eclipse.persistence.queries.DataReadQuery, .StoredProcedureCall, .ValueReadQuery, org.eclipse.persistence.tools.schemaframework.TableDefinition

Purpose: Provides MySQL specific behavior.

Responsibilities:

Since
OracleAS TopLink 10g (10.1.3)

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
isFractionalTimeSupported

Support fractional seconds in time values since MySQL v. 5.6.4.

private static final String
Inherited from org.eclipse.persistence.platform.database.DatabasePlatform:
DEFAULT_VARCHAR_SIZE

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
appendCalendar(Calendar calendar, Writer writer)

Overrides org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.appendCalendar.

Appends an MySQL specific Timestamp, if usesNativeSQL is true otherwise use the ODBC format.
protected void
appendDate(Date date, Writer writer)

Overrides org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.appendDate.

Appends an MySQL specific date if usesNativeSQL is true otherwise use the ODBC format.
protected void
appendTime(Time time, Writer writer)

Overrides org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.appendTime.

Appends an MySQL specific time if usesNativeSQL is true otherwise use the ODBC format.
protected void
appendTimestamp(Timestamp timestamp, Writer writer)

Overrides org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.appendTimestamp.

Appends an MySQL specific Timestamp, if usesNativeSQL is true otherwise use the ODBC format.
protected Hashtable<Class<?>, FieldTypeDefinition>
buildFieldTypes()

Overrides org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.buildFieldTypes.

Return the mapping of class types to database types for the schema framework.
public String
public ValueReadQuery
public boolean
public boolean

Returns:

value of true if given table exists or false otherwise
checkTableExists
(final DatabaseSessionImpl
current database session
session
,
final TableDefinition
database table meta-data
table
,
final boolean
whether to suppress logging during query execution
suppressLogging
)

Overrides org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.checkTableExists.

INTERNAL: Executes and evaluates query to check whether given table exists.
public int
computeMaxRowsForSQL(int firstResultIndex, int maxResults)

Overrides org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.computeMaxRowsForSQL.

INTERNAL: Use the JDBC maxResults and firstResultIndex setting to compute a value to use when limiting the results of a query in SQL.
protected ExpressionOperator
currentDateOperator()

INTERNAL: Create the current date operator for this platform.

public static ExpressionOperator

Returns:

new ExpressionOperator instance with currentTime
currentTime
()

INTERNAL: MySQL specific currentTime operator.

public static ExpressionOperator

Returns:

new ExpressionOperator instance with currentTimeStamp
currentTimeStamp
()

INTERNAL: MySQL specific currentTimeStamp operator.

protected ExpressionOperator
dateToStringOperator()

INTERNAL: Build MySQL equivalent to TO_CHAR.

public String
protected String
getCreateTempTableSqlPrefix()

Overrides org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.getCreateTempTableSqlPrefix.

INTERNAL: MySQL temp table syntax, used for update-all, delete-all queries.
public String
public String
public String
public int
getJDBCType(Class<?> javaType)

Overrides org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.getJDBCType.

Return the JDBC type for the Java type.
public String
public String
public String
public String
public String
public String
protected DataReadQuery

Returns:

query to check whether given table exists
getTableExistsQuery
(final TableDefinition
database table meta-data
table
)

Overrides org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.getTableExistsQuery.

INTERNAL: Returns query to check whether given table exists.
public ValueReadQuery
getTimestampQuery()

Overrides org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform.getTimestampQuery.

Implements org.eclipse.persistence.internal.databaseaccess.Platform.getTimestampQuery.

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

Overrides org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform.getUUIDQuery.

Implements org.eclipse.persistence.internal.databaseaccess.Platform.getUUIDQuery.

INTERNAL: This method returns the query to select the UUID from the server for MySQL.
public void
protected void
public boolean
public boolean
public boolean
protected ExpressionOperator
leftTrim2()

INTERNAL: Build MySQL equivalent to LTRIM(string_exp, character).

public static ExpressionOperator

Returns:

new ExpressionOperator instance with localDateTime
localDateTime
()

INTERNAL: MySQL specific localDateTime operator.

public static ExpressionOperator

Returns:

new ExpressionOperator instance with localTime
localTime
()

INTERNAL: MySQL specific localTime operator.

protected ExpressionOperator
logOperator()

INTERNAL: Create the 10 based log operator for this platform.

private static ExpressionOperator
public void
printFieldIdentityClause(Writer writer)

Overrides org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.printFieldIdentityClause.

INTERNAL: Append the receiver's field 'identity' constraint clause to a writer.
public void
printSQLSelectStatement(DatabaseCall call, ExpressionSQLPrinter printer, SQLSelectStatement statement)

Overrides org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.printSQLSelectStatement.

INTERNAL: Print the SQL representation of the statement on a stream, storing the fields in the DatabaseCall.
public void
printStoredFunctionReturnKeyWord(Writer writer)

Overrides org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.printStoredFunctionReturnKeyWord.

INTERNAL: Prints return keyword for StoredFunctionDefinition: CREATE FUNCTION StoredFunction_In (P_IN BIGINT) RETURN BIGINT The method was introduced because MySQL requires "RETURNS" instead: CREATE FUNCTION StoredFunction_In (P_IN BIGINT) RETURNS BIGINT
public boolean
requiresProcedureBrackets()

Overrides org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.requiresProcedureBrackets.

Used for stored procedure creation: MySQL platforms need brackets around arguments declaration even if no arguments exist.
public boolean
requiresTableInIndexDropDDL()

Overrides org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.requiresTableInIndexDropDDL.

INTERNAL: Return if this database requires the table name when dropping an index.
protected ExpressionOperator
rightTrim2()

INTERNAL: Build MySQL equivalent to RTRIM(string_exp, character).

public boolean
public boolean
public boolean
shouldPrintOutputTokenAtStart()

Overrides org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.shouldPrintOutputTokenAtStart.

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

Overrides org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.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 = ?)
public boolean
shouldUseJDBCOuterJoinSyntax()

Overrides org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.shouldUseJDBCOuterJoinSyntax.

INTERNAL: JDBC defines an outer join syntax which many drivers do not support.
public boolean
supportsAutoConversionToNumericForArithmeticOperations()

Overrides org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.supportsAutoConversionToNumericForArithmeticOperations.

Some db allow VARCHAR db field to be used in arithmetic operations automatically converting them to numeric: UPDATE OL_PHONE SET PHONE_ORDER_VARCHAR = (PHONE_ORDER_VARCHAR + 1) WHERE ...
public boolean
supportsCountDistinctWithMultipleFields()

Overrides org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.supportsCountDistinctWithMultipleFields.

INTERNAL: Indicates whether the platform supports the count distinct function with multiple fields.
public boolean
supportsGlobalTempTables()

Overrides org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.supportsGlobalTempTables.

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

Overrides org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform.supportsIdentity.

INTERNAL: Indicates whether the platform supports identity.
public boolean
supportsIndividualTableLocking()

Overrides org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.supportsIndividualTableLocking.

INTERNAL: Indicates whether locking clause could be selectively applied only to some tables in a ReadQuery.
public boolean
protected ExpressionOperator
toCharOperator()

INTERNAL: Build MySQL equivalent to TO_CHAR.

protected ExpressionOperator
toDateOperator()

INTERNAL: Build MySQL equivalent to TO_DATE.

public static ExpressionOperator

Returns:

new ExpressionOperator instance with today
today
()

INTERNAL: MySQL specific today operator.

protected ExpressionOperator
toNumberOperator()

INTERNAL: Build MySQL equivalent to TO_NUMBER.

public void
writeDeleteFromTargetTableUsingTempTableSql(Writer
for writing the sql
writer
,
DatabaseTable
is original table for which temp table is created.
table
,
DatabaseTable
is a table from which to delete.
targetTable
,
Collection<DatabaseField>
primary key fields for the original table.
pkFields
,
Collection<DatabaseField>
primary key fields for the target table.
targetPkFields
,
DatasourcePlatform platform)

Overrides org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.writeDeleteFromTargetTableUsingTempTableSql.

INTERNAL: Writes MySQL specific SQL for accessing temp tables for delete-all queries.
public void
public void
writeUpdateOriginalFromTempTableSql(Writer
for writing the sql
writer
,
DatabaseTable
is original table for which temp table is created.
table
,
Collection<DatabaseField>
primary key fields for the original table.
pkFields
,
Collection<DatabaseField>
fields to be assigned a new value.
assignedFields
)

Overrides org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.writeUpdateOriginalFromTempTableSql.

INTERNAL: Writes MySQL specific SQL for accessing temp tables for update-all queries.