Package org.hibernate.dialect
Class MySQLDialect
java.lang.Object
org.hibernate.dialect.Dialect
org.hibernate.dialect.MySQLDialect
- Direct Known Subclasses:
MySQL5Dialect,MySQLInnoDBDialect,MySQLMyISAMDialect
An SQL dialect for MySQL (prior to 5.x).
-
Field Summary
Fields inherited from class org.hibernate.dialect.Dialect
CLOSED_QUOTE, DEFAULT_BATCH_SIZE, NO_BATCH, QUOTE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAre string comparisons implicitly case insensitive.charThe character specific to this dialect used to close a quoted identifier.The syntax used to add a column to a table (optional).getAddForeignKeyConstraintString(String constraintName, String[] foreignKey, String referencedTable, String[] primaryKey, boolean referencesPrimaryKey) The syntax used to add a foreign key constraint to a table.getCastTypeName(int code) Get the name of the database type appropriate for casting operations (via the CAST() SQL function) for the givenTypestypecode.getColumnComment(String comment) Command used to create a temporary table.Retrieve the command used to retrieve the current timestamp from the database.Command used to drop a temporary table.Get the string to append to SELECT statements to acquire locks for this dialect.The syntax used during DDL to define a column as being an IDENTITY.Get the select command to use to retrieve the last generated IDENTITY value.getLimitString(String sql, boolean hasOffset) Apply s limit clause to the query.getReadLockString(int timeout) Get the string to append to SELECT statements to acquire WRITE locks for this dialect.Given a callable statement previously processed byDialect.registerResultSetOutParameter(java.sql.CallableStatement, int), extract theResultSetfrom the OUT parameter.Get the command used to select a GUID from the underlying database.getTableComment(String comment) getWriteLockString(int timeout) Get the string to append to SELECT statements to acquire WRITE locks for this dialect.booleanShould the value returned byDialect.getCurrentTimestampSelectString()be treated as callable.charThe character specific to this dialect used to begin a quoted identifier.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.booleanDo we need to qualify index names with the schema name?intregisterResultSetOutParameter(CallableStatement statement, int col) Registers an OUT parameter which will be returning aResultSet.protected voidbooleanbooleanDoes this dialect support a way to retrieve the database's current timestamp value?booleanDoes this dialect support empty IN lists?booleanDoes this dialect support identity column key generation?booleanbooleanDoes this dialect support some form of limiting query results via a SQL clause?booleanDoes 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...booleanIs this dialect known to support what ANSI-SQL terms "row value constructor" syntax; sometimes called tuple syntax.booleanDoes this dialect support referencing the table being mutated in a subquery.booleanDoes this dialect support temporary tables?Methods inherited from class org.hibernate.dialect.Dialect
addTypeOverride, appendIdentitySelectToInsert, appendLockHint, applyLocksToSql, bindLimitParametersFirst, bindLimitParametersInReverseOrder, buildSQLExceptionConverter, convertToFirstRowValue, createCaseFragment, createOuterJoinFragment, doesReadCommittedCauseWritersToBlockReaders, doesRepeatableReadCauseReadersToBlockWriters, dropConstraints, dropTemporaryTableAfterUse, forceLimitUsage, forUpdateOfColumns, generateTemporaryTableName, getAddPrimaryKeyConstraintString, getCascadeConstraintsString, getColumnAliasExtractor, getCreateMultisetTableString, getCreateSequenceString, getCreateSequenceString, getCreateSequenceStrings, getCreateSequenceStrings, getCreateTableString, getCreateTemporaryTablePostfix, getCrossJoinSeparator, getCurrentTimestampSQLFunctionName, getDefaultProperties, getDialect, getDialect, getDropSequenceString, getDropSequenceStrings, getForUpdateNowaitString, getForUpdateNowaitString, getForUpdateString, getForUpdateString, getForUpdateString, getForUpdateString, getFunctions, getHibernateTypeName, getHibernateTypeName, getIdentityColumnString, getIdentityInsertString, getIdentitySelectString, getKeywords, getLimitString, getLockingStrategy, getLowercaseFunction, getMaxAliasLength, getNativeIdentifierGeneratorClass, getNoColumnsInsertString, getNullColumnString, getQuerySequencesString, getSelectClauseNullString, getSelectSequenceNextValString, getSequenceNextValString, getTableTypeString, getTypeName, getTypeName, getTypeOverrides, getViolatedConstraintNameExtracter, hasAlterTable, hasDataTypeInIdentityColumn, hasSelfReferentialForeignKeyBug, isLockTimeoutParameterized, quote, registerColumnType, registerColumnType, registerFunction, registerHibernateType, registerHibernateType, registerKeyword, replaceResultVariableInOrderByClauseWithPosition, requiresCastingOfParametersInSelectClause, supportsBindAsCallableArgument, supportsCircularCascadeDeleteConstraints, supportsColumnCheck, supportsCommentOn, supportsExistsInSelect, supportsExpectedLobUsagePattern, supportsIfExistsAfterTableName, supportsInsertSelectIdentity, supportsLimitOffset, supportsLockTimeouts, supportsNotNullUnique, supportsOuterJoinForUpdate, supportsParametersInInsertSelect, supportsPooledSequences, supportsResultSetPositionQueryMethodsOnForwardOnlyCursor, supportsRowValueConstructorSyntaxInInList, supportsSequences, supportsSubselectAsInPredicateLHS, supportsTableCheck, supportsTupleCounts, supportsTupleDistinctCounts, supportsUnboundedLobLocatorMaterialization, supportsUnionAll, supportsUnique, supportsUniqueConstraintInCreateAlterTable, supportsVariableLimit, toBooleanValueString, toString, transformSelectString, useInputStreamToInsertBlob, useMaxForLimit
-
Constructor Details
-
MySQLDialect
public MySQLDialect()
-
-
Method Details
-
registerVarcharTypes
protected void registerVarcharTypes() -
getAddColumnString
Description copied from class:DialectThe syntax used to add a column to a table (optional).- Overrides:
getAddColumnStringin classDialect- Returns:
- The "add column" fragment.
-
qualifyIndexName
public boolean qualifyIndexName()Description copied from class:DialectDo we need to qualify index names with the schema name?- Overrides:
qualifyIndexNamein classDialect- Returns:
- boolean
-
supportsIdentityColumns
public boolean supportsIdentityColumns()Description copied from class:DialectDoes this dialect support identity column key generation?- Overrides:
supportsIdentityColumnsin classDialect- Returns:
- True if IDENTITY columns are supported; false otherwise.
-
getIdentitySelectString
Description copied from class:DialectGet the select command to use to retrieve the last generated IDENTITY value.- Overrides:
getIdentitySelectStringin classDialect- Returns:
- The appropriate select command
-
getIdentityColumnString
Description copied from class:DialectThe syntax used during DDL to define a column as being an IDENTITY.- Overrides:
getIdentityColumnStringin classDialect- Returns:
- The appropriate DDL fragment.
-
getAddForeignKeyConstraintString
public String getAddForeignKeyConstraintString(String constraintName, String[] foreignKey, String referencedTable, String[] primaryKey, boolean referencesPrimaryKey) Description copied from class:DialectThe syntax used to add a foreign key constraint to a table.- Overrides:
getAddForeignKeyConstraintStringin classDialect- Parameters:
constraintName- The FK constraint name.foreignKey- The names of the columns comprising the FKreferencedTable- The table referenced by the FKprimaryKey- 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
-
supportsLimit
public boolean supportsLimit()Description copied from class:DialectDoes this dialect support some form of limiting query results via a SQL clause?- Overrides:
supportsLimitin classDialect- Returns:
- True if this dialect supports some form of LIMIT.
-
getDropForeignKeyString
- Overrides:
getDropForeignKeyStringin classDialect
-
getLimitString
Description copied from class:DialectApply s limit clause to the query. Typically dialects utilizevariablelimit 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 andDialect.getLimitString(String, int, int).- Overrides:
getLimitStringin classDialect- Parameters:
sql- The query to which to apply the limit.hasOffset- Is the query requesting an offset?- Returns:
- the modified SQL
-
closeQuote
public char closeQuote()Description copied from class:DialectThe character specific to this dialect used to close a quoted identifier.- Overrides:
closeQuotein classDialect- Returns:
- The dialect's specific close quote character.
-
openQuote
public char openQuote()Description copied from class:DialectThe character specific to this dialect used to begin a quoted identifier. -
supportsIfExistsBeforeTableName
public boolean supportsIfExistsBeforeTableName()- Overrides:
supportsIfExistsBeforeTableNamein classDialect
-
getSelectGUIDString
Description copied from class:DialectGet the command used to select a GUID from the underlying database. Optional operation.- Overrides:
getSelectGUIDStringin classDialect- Returns:
- The appropriate command.
-
supportsCascadeDelete
public boolean supportsCascadeDelete()- Overrides:
supportsCascadeDeletein classDialect
-
getTableComment
- Overrides:
getTableCommentin classDialect
-
getColumnComment
- Overrides:
getColumnCommentin classDialect
-
supportsTemporaryTables
public boolean supportsTemporaryTables()Description copied from class:DialectDoes this dialect support temporary tables?- Overrides:
supportsTemporaryTablesin classDialect- Returns:
- True if temp tables are supported; false otherwise.
-
getCreateTemporaryTableString
Description copied from class:DialectCommand used to create a temporary table.- Overrides:
getCreateTemporaryTableStringin classDialect- Returns:
- The command used to create a temporary table.
-
getDropTemporaryTableString
Description copied from class:DialectCommand used to drop a temporary table.- Overrides:
getDropTemporaryTableStringin classDialect- Returns:
- The command used to drop a temporary table.
-
performTemporaryTableDDLInIsolation
Description copied from class:DialectDoes 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 theDatabaseMetaData.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:Boolean.TRUE- Unequivocally, perform the temporary table DDL in isolation.Boolean.FALSE- Unequivocally, do not perform the temporary table DDL in isolation.- null - defer to the JDBC driver response in regards to
DatabaseMetaData.dataDefinitionCausesTransactionCommit()
- Overrides:
performTemporaryTableDDLInIsolationin classDialect- Returns:
- see the result matrix above.
-
getCastTypeName
Description copied from class:DialectGet the name of the database type appropriate for casting operations (via the CAST() SQL function) for the givenTypestypecode.- Overrides:
getCastTypeNamein classDialect- Parameters:
code- TheTypestypecode- Returns:
- The database type name
-
supportsCurrentTimestampSelection
public boolean supportsCurrentTimestampSelection()Description copied from class:DialectDoes this dialect support a way to retrieve the database's current timestamp value?- Overrides:
supportsCurrentTimestampSelectionin classDialect- Returns:
- True if the current timestamp can be retrieved; false otherwise.
-
isCurrentTimestampSelectStringCallable
public boolean isCurrentTimestampSelectStringCallable()Description copied from class:DialectShould the value returned byDialect.getCurrentTimestampSelectString()be treated as callable. Typically this indicates that JDBC escape syntax is being used...- Overrides:
isCurrentTimestampSelectStringCallablein classDialect- Returns:
- True if the
Dialect.getCurrentTimestampSelectString()return is callable; false otherwise.
-
getCurrentTimestampSelectString
Description copied from class:DialectRetrieve the command used to retrieve the current timestamp from the database.- Overrides:
getCurrentTimestampSelectStringin classDialect- Returns:
- The command.
-
registerResultSetOutParameter
Description copied from class:DialectRegisters an OUT parameter which will be returning aResultSet. How this is accomplished varies greatly from DB to DB, hence its inclusion (along withDialect.getResultSet(java.sql.CallableStatement)) here.- Overrides:
registerResultSetOutParameterin classDialect- 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- Indicates problems registering the OUT param.
-
getResultSet
Description copied from class:DialectGiven a callable statement previously processed byDialect.registerResultSetOutParameter(java.sql.CallableStatement, int), extract theResultSetfrom the OUT parameter.- Overrides:
getResultSetin classDialect- Parameters:
ps- The callable statement.- Returns:
- The extracted result set.
- Throws:
SQLException- Indicates problems extracting the result set.
-
supportsRowValueConstructorSyntax
public boolean supportsRowValueConstructorSyntax()Description copied from class:DialectIs 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') ...".- Overrides:
supportsRowValueConstructorSyntaxin classDialect- Returns:
- True if this SQL dialect is known to support "row value constructor" syntax; false otherwise.
-
getForUpdateString
Description copied from class:DialectGet the string to append to SELECT statements to acquire locks for this dialect.- Overrides:
getForUpdateStringin classDialect- Returns:
- The appropriate FOR UPDATE clause string.
-
getWriteLockString
Description copied from class:DialectGet 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.- Overrides:
getWriteLockStringin classDialect- Parameters:
timeout- in milliseconds, -1 for indefinite wait and 0 for no wait.- Returns:
- The appropriate LOCK clause string.
-
getReadLockString
Description copied from class:DialectGet 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.- Overrides:
getReadLockStringin classDialect- Parameters:
timeout- in milliseconds, -1 for indefinite wait and 0 for no wait.- Returns:
- The appropriate LOCK clause string.
-
supportsEmptyInList
public boolean supportsEmptyInList()Description copied from class:DialectDoes this dialect support empty IN lists? For example, is [where XYZ in ()] a supported construct?- Overrides:
supportsEmptyInListin classDialect- Returns:
- True if empty in lists are supported; false otherwise.
-
areStringComparisonsCaseInsensitive
public boolean areStringComparisonsCaseInsensitive()Description copied from class:DialectAre string comparisons implicitly case insensitive. In other words, does [where 'XYZ' = 'xyz'] resolve to true?- Overrides:
areStringComparisonsCaseInsensitivein classDialect- Returns:
- True if comparisons are case insensitive.
-
supportsLobValueChangePropogation
public boolean supportsLobValueChangePropogation()Description copied from class:DialectDoes 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:Blob.setBinaryStream(long),Blob.setBytes(long, byte[]),Blob.setBytes(long, byte[], int, int), orBlob.truncate(long). For CLOBs, the internal value might be changed by:Clob.setAsciiStream(long),Clob.setCharacterStream(long),Clob.setString(long, String),Clob.setString(long, String, int, int), orClob.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 notDialect.supportsExpectedLobUsagePattern().- Overrides:
supportsLobValueChangePropogationin classDialect- Returns:
- True if the changes are propagated back to the database; false otherwise.
-
supportsSubqueryOnMutatingTable
public boolean supportsSubqueryOnMutatingTable()Description copied from class:DialectDoes 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)
- Overrides:
supportsSubqueryOnMutatingTablein classDialect- Returns:
- True if this dialect allows references the mutating table from a subquery.
-