public class

MySQLDialect

extends Dialect
java.lang.Object
   ↳ org.hibernate.dialect.Dialect
     ↳ org.hibernate.dialect.MySQLDialect
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

An SQL dialect for MySQL (prior to 5.x).

Summary

[Expand]
Inherited Constants
From class org.hibernate.dialect.Dialect
Public Constructors
MySQLDialect()
Public Methods
boolean areStringComparisonsCaseInsensitive()
Are string comparisons implicitly case insensitive.
char closeQuote()
The character specific to this dialect used to close a quoted identifier.
String getAddColumnString()
The syntax used to add a column to a table (optional).
String getAddForeignKeyConstraintString(String constraintName, String[] foreignKey, String referencedTable, String[] primaryKey, boolean referencesPrimaryKey)
The syntax used to add a foreign key constraint to a table.
String getCastTypeName(int code)
Get the name of the database type appropriate for casting operations (via the CAST() SQL function) for the given java.sql.Types typecode.
String getColumnComment(String comment)
String getCreateTemporaryTableString()
Command used to create a temporary table.
String getCurrentTimestampSelectString()
Retrieve the command used to retrieve the current timestamp from the database.
String getDropForeignKeyString()
String getDropTemporaryTableString()
Command used to drop a temporary table.
String getForUpdateString()
Get the string to append to SELECT statements to acquire locks for this dialect.
String getIdentityColumnString()
The syntax used during DDL to define a column as being an IDENTITY.
String getIdentitySelectString()
Get the select command to use to retrieve the last generated IDENTITY value.
String getLimitString(String sql, boolean hasOffset)
Apply s limit clause to the query.
String getReadLockString(int timeout)
Get the string to append to SELECT statements to acquire WRITE locks for this dialect.
ResultSet getResultSet(CallableStatement ps)
Given a callable statement previously processed by registerResultSetOutParameter(CallableStatement, int), extract the ResultSet from the OUT parameter.
String getSelectGUIDString()
Get the command used to select a GUID from the underlying database.
String getTableComment(String comment)
String getWriteLockString(int timeout)
Get the string to append to SELECT statements to acquire WRITE locks for this dialect.
boolean isCurrentTimestampSelectStringCallable()
Should the value returned by getCurrentTimestampSelectString() be treated as callable.
char openQuote()
The character specific to this dialect used to begin a quoted identifier.
Boolean performTemporaryTableDDLInIsolation()
Does the dialect require that temporary table DDL statements occur in isolation from other statements? This would be the case if the creation would cause any current transaction to get committed implicitly.
boolean qualifyIndexName()
Do we need to qualify index names with the schema name?
int registerResultSetOutParameter(CallableStatement statement, int col)
Registers an OUT parameter which will be returning a ResultSet.
boolean supportsCascadeDelete()
boolean supportsCurrentTimestampSelection()
Does this dialect support a way to retrieve the database's current timestamp value?
boolean supportsEmptyInList()
Does this dialect support empty IN lists?

For example, is [where XYZ in ()] a supported construct?

boolean supportsIdentityColumns()
Does this dialect support identity column key generation?
boolean supportsIfExistsBeforeTableName()
boolean supportsLimit()
Does this dialect support some form of limiting query results via a SQL clause?
boolean supportsLobValueChangePropogation()
Does the dialect support propagating changes to LOB values back to the database? Talking about mutating the internal value of the locator as opposed to supplying a new locator instance...
boolean supportsRowValueConstructorSyntax()
Is this dialect known to support what ANSI-SQL terms "row value constructor" syntax; sometimes called tuple syntax.
boolean supportsSubqueryOnMutatingTable()
Does this dialect support referencing the table being mutated in a subquery.
boolean supportsTemporaryTables()
Does this dialect support temporary tables?
Protected Methods
void registerVarcharTypes()
[Expand]
Inherited Methods
From class org.hibernate.dialect.Dialect
From class java.lang.Object

Public Constructors

public MySQLDialect ()

Public Methods

public boolean areStringComparisonsCaseInsensitive ()

Are string comparisons implicitly case insensitive.

In other words, does [where 'XYZ' = 'xyz'] resolve to true?

Returns
  • True if comparisons are case insensitive.

public char closeQuote ()

The character specific to this dialect used to close a quoted identifier.

Returns
  • The dialect's specific close quote character.

public String getAddColumnString ()

The syntax used to add a column to a table (optional).

Returns
  • The "add column" fragment.

public String getAddForeignKeyConstraintString (String constraintName, String[] foreignKey, String referencedTable, String[] primaryKey, boolean referencesPrimaryKey)

The syntax used to add a foreign key constraint to a table.

Parameters
constraintName The FK constraint name.
foreignKey The names of the columns comprising the FK
referencedTable The table referenced by the FK
primaryKey The explicit columns in the referencedTable referenced by this FK.
referencesPrimaryKey if false, constraint should be explicit about which column names the constraint refers to
Returns
  • the "add FK" fragment

public String getCastTypeName (int code)

Get the name of the database type appropriate for casting operations (via the CAST() SQL function) for the given java.sql.Types typecode.

Parameters
code The java.sql.Types typecode
Returns
  • The database type name

public String getColumnComment (String comment)

public String getCreateTemporaryTableString ()

Command used to create a temporary table.

Returns
  • The command used to create a temporary table.

public String getCurrentTimestampSelectString ()

Retrieve the command used to retrieve the current timestamp from the database.

Returns
  • The command.

public String getDropForeignKeyString ()

public String getDropTemporaryTableString ()

Command used to drop a temporary table.

Returns
  • The command used to drop a temporary table.

public String getForUpdateString ()

Get the string to append to SELECT statements to acquire locks for this dialect.

Returns
  • The appropriate FOR UPDATE clause string.

public String getIdentityColumnString ()

The syntax used during DDL to define a column as being an IDENTITY.

Returns
  • The appropriate DDL fragment.

public String getIdentitySelectString ()

Get the select command to use to retrieve the last generated IDENTITY value.

Returns
  • The appropriate select command

public String getLimitString (String sql, boolean hasOffset)

Apply s limit clause to the query.

Typically dialects utilize variable limit clauses when they support limits. Thus, when building the select command we do not actually need to know the limit or the offest since we will just be using placeholders.

Here we do still pass along whether or not an offset was specified so that dialects not supporting offsets can generate proper exceptions. In general, dialects will override one or the other of this method and getLimitString(String, int, int).

Parameters
sql The query to which to apply the limit.
hasOffset Is the query requesting an offset?
Returns
  • the modified SQL

public String getReadLockString (int timeout)

Get the string to append to SELECT statements to acquire WRITE locks for this dialect. Location of the of the returned string is treated the same as getForUpdateString.

Parameters
timeout in milliseconds, -1 for indefinite wait and 0 for no wait.
Returns
  • The appropriate LOCK clause string.

public ResultSet getResultSet (CallableStatement ps)

Given a callable statement previously processed by registerResultSetOutParameter(CallableStatement, int), extract the ResultSet from the OUT parameter.

Parameters
ps The callable statement.
Returns
  • The extracted result set.
Throws
SQLException

public String getSelectGUIDString ()

Get the command used to select a GUID from the underlying database.

Optional operation.

Returns
  • The appropriate command.

public String getTableComment (String comment)

public String getWriteLockString (int timeout)

Get the string to append to SELECT statements to acquire WRITE locks for this dialect. Location of the of the returned string is treated the same as getForUpdateString.

Parameters
timeout in milliseconds, -1 for indefinite wait and 0 for no wait.
Returns
  • The appropriate LOCK clause string.

public boolean isCurrentTimestampSelectStringCallable ()

Should the value returned by getCurrentTimestampSelectString() be treated as callable. Typically this indicates that JDBC escape syntax is being used...

Returns

public char openQuote ()

The character specific to this dialect used to begin a quoted identifier.

Returns
  • The dialect's specific open quote character.

public Boolean performTemporaryTableDDLInIsolation ()

Does the dialect require that temporary table DDL statements occur in isolation from other statements? This would be the case if the creation would cause any current transaction to get committed implicitly.

JDBC defines a standard way to query for this information via the dataDefinitionCausesTransactionCommit() method. However, that does not distinguish between temporary table DDL and other forms of DDL; MySQL, for example, reports DDL causing a transaction commit via its driver, even though that is not the case for temporary table DDL.

Possible return values and their meanings:

  • TRUE - Unequivocally, perform the temporary table DDL in isolation.
  • FALSE - Unequivocally, do not perform the temporary table DDL in isolation.
  • null - defer to the JDBC driver response in regards to dataDefinitionCausesTransactionCommit()

Returns
  • see the result matrix above.

public boolean qualifyIndexName ()

Do we need to qualify index names with the schema name?

Returns
  • boolean

public int registerResultSetOutParameter (CallableStatement statement, int col)

Registers an OUT parameter which will be returning a ResultSet. How this is accomplished varies greatly from DB to DB, hence its inclusion (along with getResultSet(CallableStatement)) here.

Parameters
statement The callable statement.
col The bind position at which to register the OUT param.
Returns
  • The number of (contiguous) bind positions used.
Throws
SQLException

public boolean supportsCascadeDelete ()

public boolean supportsCurrentTimestampSelection ()

Does this dialect support a way to retrieve the database's current timestamp value?

Returns
  • True if the current timestamp can be retrieved; false otherwise.

public boolean supportsEmptyInList ()

Does this dialect support empty IN lists?

For example, is [where XYZ in ()] a supported construct?

Returns
  • True if empty in lists are supported; false otherwise.

public boolean supportsIdentityColumns ()

Does this dialect support identity column key generation?

Returns
  • True if IDENTITY columns are supported; false otherwise.

public boolean supportsIfExistsBeforeTableName ()

public boolean supportsLimit ()

Does this dialect support some form of limiting query results via a SQL clause?

Returns
  • True if this dialect supports some form of LIMIT.

public boolean supportsLobValueChangePropogation ()

Does the dialect support propagating changes to LOB values back to the database? Talking about mutating the internal value of the locator as opposed to supplying a new locator instance...

For BLOBs, the internal value might be changed by: setBinaryStream(long), setBytes(long, byte[]), setBytes(long, byte[], int, int), or truncate(long).

For CLOBs, the internal value might be changed by: setAsciiStream(long), setCharacterStream(long), setString(long, String), setString(long, String, int, int), or truncate(long).

NOTE : I do not know the correct answer currently for databases which (1) are not part of the cruise control process or (2) do not supportsExpectedLobUsagePattern().

Returns
  • True if the changes are propagated back to the database; false otherwise.

public boolean supportsRowValueConstructorSyntax ()

Is this dialect known to support what ANSI-SQL terms "row value constructor" syntax; sometimes called tuple syntax.

Basically, does it support syntax like "... where (FIRST_NAME, LAST_NAME) = ('Steve', 'Ebersole') ...".

Returns
  • True if this SQL dialect is known to support "row value constructor" syntax; false otherwise.

public boolean supportsSubqueryOnMutatingTable ()

Does this dialect support referencing the table being mutated in a subquery. The "table being mutated" is the table referenced in an UPDATE or a DELETE query. And so can that table then be referenced in a subquery of said UPDATE/DELETE query.

For example, would the following two syntaxes be supported:

  • delete from TABLE_A where ID not in ( select ID from TABLE_A )
  • update TABLE_A set NON_ID = 'something' where ID in ( select ID from TABLE_A)

Returns
  • True if this dialect allows references the mutating table from a subquery.

public boolean supportsTemporaryTables ()

Does this dialect support temporary tables?

Returns
  • True if temp tables are supported; false otherwise.

Protected Methods

protected void registerVarcharTypes ()