Top Description Fields Constructors Methods
org.hibernate.dialect

public Class MySQLDialect

extends Dialect
Class Inheritance
Known Direct Subclasses
org.hibernate.dialect.MySQLInnoDBDialect, org.hibernate.dialect.MySQLMyISAMDialect, org.hibernate.dialect.MySQL5Dialect
Imports
java.sql.CallableStatement, .ResultSet, .SQLException, .Types, org.hibernate.cfg.Environment, org.hibernate.dialect.function.NoArgSQLFunction, .StandardSQLFunction, org.hibernate.type.StandardBasicTypes, org.hibernate.util.StringHelper

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

Field Summary

Inherited from org.hibernate.dialect.Dialect:
CLOSED_QUOTEDEFAULT_BATCH_SIZENO_BATCHQUOTE

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
public char
closeQuote()

Overrides org.hibernate.dialect.Dialect.closeQuote.

The character specific to this dialect used to close a quoted identifier.
public String
getAddColumnString()

Overrides org.hibernate.dialect.Dialect.getAddColumnString.

The syntax used to add a column to a table (optional).
public String
getAddForeignKeyConstraintString(String
The FK constraint name.
constraintName
,
String[]
The names of the columns comprising the FK
foreignKey
,
String
The table referenced by the FK
referencedTable
,
String[]
The explicit columns in the referencedTable referenced by this FK.
primaryKey
,
boolean
if false, constraint should be explicit about which column names the constraint refers to
referencesPrimaryKey
)

Overrides org.hibernate.dialect.Dialect.getAddForeignKeyConstraintString.

The syntax used to add a foreign key constraint to a table.
public String
getCastTypeName(int
The java.sql.Types typecode
code
)

Overrides org.hibernate.dialect.Dialect.getCastTypeName.

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

Overrides org.hibernate.dialect.Dialect.getCurrentTimestampSelectString.

Retrieve the command used to retrieve the current timestamp from the database.
public String
public String
public String
getForUpdateString()

Overrides org.hibernate.dialect.Dialect.getForUpdateString.

Get the string to append to SELECT statements to acquire locks for this dialect.
public String
getIdentityColumnString()

Overrides org.hibernate.dialect.Dialect.getIdentityColumnString.

The syntax used during DDL to define a column as being an IDENTITY.
public String
getIdentitySelectString()

Overrides org.hibernate.dialect.Dialect.getIdentitySelectString.

Get the select command to use to retrieve the last generated IDENTITY value.
public String
getLimitString(String
The query to which to apply the limit.
sql
,
boolean
Is the query requesting an offset?
hasOffset
)

Overrides org.hibernate.dialect.Dialect.getLimitString.

Apply s limit clause to the query.
public String
getReadLockString(int
in milliseconds, -1 for indefinite wait and 0 for no wait.
timeout
)

Overrides org.hibernate.dialect.Dialect.getReadLockString.

Get the string to append to SELECT statements to acquire WRITE locks for this dialect.
public ResultSet
getResultSet(CallableStatement
The callable statement.
ps
)

Overrides org.hibernate.dialect.Dialect.getResultSet.

Given a callable statement previously processed by registerResultSetOutParameter, extract the java.sql.ResultSet from the OUT parameter.
public String
getSelectGUIDString()

Overrides org.hibernate.dialect.Dialect.getSelectGUIDString.

Get the command used to select a GUID from the underlying database.
public String
public String
getWriteLockString(int
in milliseconds, -1 for indefinite wait and 0 for no wait.
timeout
)

Overrides org.hibernate.dialect.Dialect.getWriteLockString.

Get the string to append to SELECT statements to acquire WRITE locks for this dialect.
public boolean
public char
openQuote()

Overrides org.hibernate.dialect.Dialect.openQuote.

The character specific to this dialect used to begin a quoted identifier.
public Boolean
performTemporaryTableDDLInIsolation()

Overrides org.hibernate.dialect.Dialect.performTemporaryTableDDLInIsolation.

Does the dialect require that temporary table DDL statements occur in isolation from other statements?
public boolean
qualifyIndexName()

Overrides org.hibernate.dialect.Dialect.qualifyIndexName.

Do we need to qualify index names with the schema name?
public int
registerResultSetOutParameter(CallableStatement
The callable statement.
statement
,
int
The bind position at which to register the OUT param.
col
)

Overrides org.hibernate.dialect.Dialect.registerResultSetOutParameter.

Registers an OUT parameter which will be returning a java.sql.ResultSet.
protected void
public boolean
public boolean
supportsCurrentTimestampSelection()

Overrides org.hibernate.dialect.Dialect.supportsCurrentTimestampSelection.

Does this dialect support a way to retrieve the database's current timestamp value?
public boolean
supportsEmptyInList()

Overrides org.hibernate.dialect.Dialect.supportsEmptyInList.

Does this dialect support empty IN lists?
public boolean
supportsIdentityColumns()

Overrides org.hibernate.dialect.Dialect.supportsIdentityColumns.

Does this dialect support identity column key generation?
public boolean
public boolean
supportsLimit()

Overrides org.hibernate.dialect.Dialect.supportsLimit.

Does this dialect support some form of limiting query results via a SQL clause?
public boolean
supportsLobValueChangePropogation()

Overrides org.hibernate.dialect.Dialect.supportsLobValueChangePropogation.

Does the dialect support propagating changes to LOB values back to the database?
public boolean
supportsRowValueConstructorSyntax()

Overrides org.hibernate.dialect.Dialect.supportsRowValueConstructorSyntax.

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

Overrides org.hibernate.dialect.Dialect.supportsSubqueryOnMutatingTable.

Does this dialect support referencing the table being mutated in a subquery.
public boolean
supportsTemporaryTables()

Overrides org.hibernate.dialect.Dialect.supportsTemporaryTables.

Does this dialect support temporary tables?
Inherited from org.hibernate.dialect.Dialect:
addTypeOverrideappendIdentitySelectToInsertappendLockHintapplyLocksToSqlbindLimitParametersFirstbindLimitParametersInReverseOrderbuildSQLExceptionConverterconvertToFirstRowValuecreateCaseFragmentcreateOuterJoinFragmentdoesReadCommittedCauseWritersToBlockReadersdoesRepeatableReadCauseReadersToBlockWritersdropConstraintsdropTemporaryTableAfterUseforceLimitUsageforUpdateOfColumnsgenerateTemporaryTableNamegetAddPrimaryKeyConstraintStringgetCascadeConstraintsStringgetColumnAliasExtractorgetCreateMultisetTableStringgetCreateSequenceStringgetCreateSequenceStringgetCreateSequenceStringsgetCreateSequenceStringsgetCreateTableStringgetCreateTemporaryTablePostfixgetCrossJoinSeparatorgetCurrentTimestampSQLFunctionNamegetDefaultPropertiesgetDialectgetDialectgetDropSequenceStringgetDropSequenceStringsgetForUpdateNowaitStringgetForUpdateNowaitStringgetForUpdateStringgetForUpdateStringgetForUpdateStringgetForUpdateStringgetFunctionsgetHibernateTypeNamegetHibernateTypeNamegetIdentityColumnStringgetIdentityInsertStringgetIdentitySelectStringgetKeywordsgetLimitStringgetLockingStrategygetLowercaseFunctiongetMaxAliasLengthgetNativeIdentifierGeneratorClassgetNoColumnsInsertStringgetNullColumnStringgetQuerySequencesStringgetSelectClauseNullStringgetSelectSequenceNextValStringgetSequenceNextValStringgetTableTypeStringgetTypeNamegetTypeNamegetTypeOverridesgetViolatedConstraintNameExtracterhasAlterTablehasDataTypeInIdentityColumnhasSelfReferentialForeignKeyBugisLockTimeoutParameterizedquoteregisterColumnTyperegisterColumnTyperegisterFunctionregisterHibernateTyperegisterHibernateTyperegisterKeywordreplaceResultVariableInOrderByClauseWithPositionrequiresCastingOfParametersInSelectClausesupportsBindAsCallableArgumentsupportsCircularCascadeDeleteConstraintssupportsColumnChecksupportsCommentOnsupportsExistsInSelectsupportsExpectedLobUsagePatternsupportsIfExistsAfterTableNamesupportsInsertSelectIdentitysupportsLimitOffsetsupportsLockTimeoutssupportsNotNullUniquesupportsOuterJoinForUpdatesupportsParametersInInsertSelectsupportsPooledSequencessupportsResultSetPositionQueryMethodsOnForwardOnlyCursorsupportsRowValueConstructorSyntaxInInListsupportsSequencessupportsSubselectAsInPredicateLHSsupportsTableChecksupportsTupleCountssupportsTupleDistinctCountssupportsUnboundedLobLocatorMaterializationsupportsUnionAllsupportsUniquesupportsUniqueConstraintInCreateAlterTablesupportsVariableLimittoBooleanValueStringtoStringtransformSelectStringuseInputStreamToInsertBlobuseMaxForLimit

Constructor Detail

MySQLDialectback to summary
public MySQLDialect()

Method Detail

areStringComparisonsCaseInsensitiveback to summary
public boolean areStringComparisonsCaseInsensitive()

Overrides org.hibernate.dialect.Dialect.areStringComparisonsCaseInsensitive.

Doc from org.hibernate.dialect.Dialect.areStringComparisonsCaseInsensitive.

Are string comparisons implicitly case insensitive.

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

Returns:boolean

True if comparisons are case insensitive.

closeQuoteback to summary
public char closeQuote()

Overrides org.hibernate.dialect.Dialect.closeQuote.

Doc from org.hibernate.dialect.Dialect.closeQuote.

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

Returns:char

The dialect's specific close quote character.

getAddColumnStringback to summary
public String getAddColumnString()

Overrides org.hibernate.dialect.Dialect.getAddColumnString.

Doc from org.hibernate.dialect.Dialect.getAddColumnString.

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

Returns:String

The "add column" fragment.

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

Overrides org.hibernate.dialect.Dialect.getAddForeignKeyConstraintString.

Doc from org.hibernate.dialect.Dialect.getAddForeignKeyConstraintString.

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

Parameters
constraintName:String

The FK constraint name.

foreignKey:String[]

The names of the columns comprising the FK

referencedTable:String

The table referenced by the FK

primaryKey:String[]

The explicit columns in the referencedTable referenced by this FK.

referencesPrimaryKey:boolean

if false, constraint should be explicit about which column names the constraint refers to

Returns:String

the "add FK" fragment

getCastTypeNameback to summary
public String getCastTypeName(int code)

Overrides org.hibernate.dialect.Dialect.getCastTypeName.

Doc from org.hibernate.dialect.Dialect.getCastTypeName.

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:int

The java.sql.Types typecode

Returns:String

The database type name

getColumnCommentback to summary
public String getColumnComment(String comment)

Overrides org.hibernate.dialect.Dialect.getColumnComment.

getCreateTemporaryTableStringback to summary
public String getCreateTemporaryTableString()

Overrides org.hibernate.dialect.Dialect.getCreateTemporaryTableString.

Doc from org.hibernate.dialect.Dialect.getCreateTemporaryTableString.

Command used to create a temporary table.

Returns:String

The command used to create a temporary table.

getCurrentTimestampSelectStringback to summary
public String getCurrentTimestampSelectString()

Overrides org.hibernate.dialect.Dialect.getCurrentTimestampSelectString.

Doc from org.hibernate.dialect.Dialect.getCurrentTimestampSelectString.

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

Returns:String

The command.

getDropForeignKeyStringback to summary
public String getDropForeignKeyString()

Overrides org.hibernate.dialect.Dialect.getDropForeignKeyString.

getDropTemporaryTableStringback to summary
public String getDropTemporaryTableString()

Overrides org.hibernate.dialect.Dialect.getDropTemporaryTableString.

Doc from org.hibernate.dialect.Dialect.getDropTemporaryTableString.

Command used to drop a temporary table.

Returns:String

The command used to drop a temporary table.

getForUpdateStringback to summary
public String getForUpdateString()

Overrides org.hibernate.dialect.Dialect.getForUpdateString.

Doc from org.hibernate.dialect.Dialect.getForUpdateString.

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

Returns:String

The appropriate FOR UPDATE clause string.

getIdentityColumnStringback to summary
public String getIdentityColumnString()

Overrides org.hibernate.dialect.Dialect.getIdentityColumnString.

Doc from org.hibernate.dialect.Dialect.getIdentityColumnString.

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

Returns:String

The appropriate DDL fragment.

getIdentitySelectStringback to summary
public String getIdentitySelectString()

Overrides org.hibernate.dialect.Dialect.getIdentitySelectString.

Doc from org.hibernate.dialect.Dialect.getIdentitySelectString.

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

Returns:String

The appropriate select command

getLimitStringback to summary
public String getLimitString(String sql, boolean hasOffset)

Overrides org.hibernate.dialect.Dialect.getLimitString.

Doc from org.hibernate.dialect.Dialect.getLimitString.

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:String

The query to which to apply the limit.

hasOffset:boolean

Is the query requesting an offset?

Returns:String

the modified SQL

getReadLockStringback to summary
public String getReadLockString(int timeout)

Overrides org.hibernate.dialect.Dialect.getReadLockString.

Doc from org.hibernate.dialect.Dialect.getReadLockString.

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:int

in milliseconds, -1 for indefinite wait and 0 for no wait.

Returns:String

The appropriate LOCK clause string.

getResultSetback to summary
public ResultSet getResultSet(CallableStatement ps) throws SQLException

Overrides org.hibernate.dialect.Dialect.getResultSet.

Doc from org.hibernate.dialect.Dialect.getResultSet.

Given a callable statement previously processed by registerResultSetOutParameter, extract the java.sql.ResultSet from the OUT parameter.

Parameters
ps:CallableStatement

The callable statement.

Returns:ResultSet

The extracted result set.

Exceptions
SQLException:
Indicates problems extracting the result set.
getSelectGUIDStringback to summary
public String getSelectGUIDString()

Overrides org.hibernate.dialect.Dialect.getSelectGUIDString.

Doc from org.hibernate.dialect.Dialect.getSelectGUIDString.

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

Optional operation.

Returns:String

The appropriate command.

getTableCommentback to summary
public String getTableComment(String comment)

Overrides org.hibernate.dialect.Dialect.getTableComment.

getWriteLockStringback to summary
public String getWriteLockString(int timeout)

Overrides org.hibernate.dialect.Dialect.getWriteLockString.

Doc from org.hibernate.dialect.Dialect.getWriteLockString.

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:int

in milliseconds, -1 for indefinite wait and 0 for no wait.

Returns:String

The appropriate LOCK clause string.

isCurrentTimestampSelectStringCallableback to summary
public boolean isCurrentTimestampSelectStringCallable()

Overrides org.hibernate.dialect.Dialect.isCurrentTimestampSelectStringCallable.

Doc from org.hibernate.dialect.Dialect.isCurrentTimestampSelectStringCallable.

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

Returns:boolean

True if the getCurrentTimestampSelectString return is callable; false otherwise.

openQuoteback to summary
public char openQuote()

Overrides org.hibernate.dialect.Dialect.openQuote.

Doc from org.hibernate.dialect.Dialect.openQuote.

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

Returns:char

The dialect's specific open quote character.

performTemporaryTableDDLInIsolationback to summary
public Boolean performTemporaryTableDDLInIsolation()

Overrides org.hibernate.dialect.Dialect.performTemporaryTableDDLInIsolation.

Doc from org.hibernate.dialect.Dialect.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 java.sql.DatabaseMetaData#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:

Returns:Boolean

see the result matrix above.

qualifyIndexNameback to summary
public boolean qualifyIndexName()

Overrides org.hibernate.dialect.Dialect.qualifyIndexName.

Doc from org.hibernate.dialect.Dialect.qualifyIndexName.

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

Returns:boolean

boolean

registerResultSetOutParameterback to summary
public int registerResultSetOutParameter(CallableStatement statement, int col) throws SQLException

Overrides org.hibernate.dialect.Dialect.registerResultSetOutParameter.

Doc from org.hibernate.dialect.Dialect.registerResultSetOutParameter.

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

Parameters
statement:CallableStatement

The callable statement.

col:int

The bind position at which to register the OUT param.

Returns:int

The number of (contiguous) bind positions used.

Exceptions
SQLException:
Indicates problems registering the OUT param.
registerVarcharTypesback to summary
protected void registerVarcharTypes()
supportsCascadeDeleteback to summary
public boolean supportsCascadeDelete()

Overrides org.hibernate.dialect.Dialect.supportsCascadeDelete.

supportsCurrentTimestampSelectionback to summary
public boolean supportsCurrentTimestampSelection()

Overrides org.hibernate.dialect.Dialect.supportsCurrentTimestampSelection.

Doc from org.hibernate.dialect.Dialect.supportsCurrentTimestampSelection.

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

Returns:boolean

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

supportsEmptyInListback to summary
public boolean supportsEmptyInList()

Overrides org.hibernate.dialect.Dialect.supportsEmptyInList.

Doc from org.hibernate.dialect.Dialect.supportsEmptyInList.

Does this dialect support empty IN lists?

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

Returns:boolean

True if empty in lists are supported; false otherwise.

supportsIdentityColumnsback to summary
public boolean supportsIdentityColumns()

Overrides org.hibernate.dialect.Dialect.supportsIdentityColumns.

Doc from org.hibernate.dialect.Dialect.supportsIdentityColumns.

Does this dialect support identity column key generation?

Returns:boolean

True if IDENTITY columns are supported; false otherwise.

supportsIfExistsBeforeTableNameback to summary
public boolean supportsIfExistsBeforeTableName()

Overrides org.hibernate.dialect.Dialect.supportsIfExistsBeforeTableName.

supportsLimitback to summary
public boolean supportsLimit()

Overrides org.hibernate.dialect.Dialect.supportsLimit.

Doc from org.hibernate.dialect.Dialect.supportsLimit.

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

Returns:boolean

True if this dialect supports some form of LIMIT.

supportsLobValueChangePropogationback to summary
public boolean supportsLobValueChangePropogation()

Overrides org.hibernate.dialect.Dialect.supportsLobValueChangePropogation.

Doc from org.hibernate.dialect.Dialect.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: java.sql.Blob#setBinaryStream, java.sql.Blob#setBytes(long, byte[]), java.sql.Blob#setBytes(long, byte[], int, int), or java.sql.Blob#truncate(long).

For CLOBs, the internal value might be changed by: java.sql.Clob#setAsciiStream(long), java.sql.Clob#setCharacterStream(long), java.sql.Clob#setString(long, String), java.sql.Clob#setString(long, String, int, int), or java.sql.Clob#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:boolean

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

supportsRowValueConstructorSyntaxback to summary
public boolean supportsRowValueConstructorSyntax()

Overrides org.hibernate.dialect.Dialect.supportsRowValueConstructorSyntax.

Doc from org.hibernate.dialect.Dialect.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:boolean

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

supportsSubqueryOnMutatingTableback to summary
public boolean supportsSubqueryOnMutatingTable()

Overrides org.hibernate.dialect.Dialect.supportsSubqueryOnMutatingTable.

Doc from org.hibernate.dialect.Dialect.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:boolean

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

supportsTemporaryTablesback to summary
public boolean supportsTemporaryTables()

Overrides org.hibernate.dialect.Dialect.supportsTemporaryTables.

Doc from org.hibernate.dialect.Dialect.supportsTemporaryTables.

Does this dialect support temporary tables?

Returns:boolean

True if temp tables are supported; false otherwise.