Class MySQLDialect

    • Field Detail

      • ESCAPE_PATTERN_REPLACEMENT

        public static final java.lang.String ESCAPE_PATTERN_REPLACEMENT
    • Constructor Detail

      • MySQLDialect

        public MySQLDialect()
        Constructs a MySQLDialect
    • Method Detail

      • registerVarcharTypes

        protected void registerVarcharTypes()
      • getAddColumnString

        public java.lang.String getAddColumnString()
        Description copied from class: Dialect
        The syntax used to add a column to a table (optional).
        Overrides:
        getAddColumnString in class Dialect
        Returns:
        The "add column" fragment.
      • qualifyIndexName

        public boolean qualifyIndexName()
        Description copied from class: Dialect
        Do we need to qualify index names with the schema name?
        Overrides:
        qualifyIndexName in class Dialect
        Returns:
        boolean
      • getAddForeignKeyConstraintString

        public java.lang.String getAddForeignKeyConstraintString​(java.lang.String constraintName,
                                                                 java.lang.String[] foreignKey,
                                                                 java.lang.String referencedTable,
                                                                 java.lang.String[] primaryKey,
                                                                 boolean referencesPrimaryKey)
        Description copied from class: Dialect
        The syntax used to add a foreign key constraint to a table.
        Overrides:
        getAddForeignKeyConstraintString in class Dialect
        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
      • supportsLimit

        public boolean supportsLimit()
        Description copied from class: Dialect
        Does this dialect support some form of limiting query results via a SQL clause?
        Overrides:
        supportsLimit in class Dialect
        Returns:
        True if this dialect supports some form of LIMIT.
      • getLimitHandler

        public LimitHandler getLimitHandler()
        Description copied from class: Dialect
        Returns the delegate managing LIMIT clause.
        Overrides:
        getLimitHandler in class Dialect
        Returns:
        LIMIT clause delegate.
      • getLimitString

        public java.lang.String getLimitString​(java.lang.String sql,
                                               boolean hasOffset)
        Description copied from class: Dialect
        Apply a 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 offset 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 Dialect.getLimitString(String, int, int).

        Overrides:
        getLimitString in class Dialect
        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: Dialect
        The character specific to this dialect used to close a quoted identifier.
        Overrides:
        closeQuote in class Dialect
        Returns:
        The dialect's specific close quote character.
      • openQuote

        public char openQuote()
        Description copied from class: Dialect
        The character specific to this dialect used to begin a quoted identifier.
        Overrides:
        openQuote in class Dialect
        Returns:
        The dialect's specific open quote character.
      • canCreateCatalog

        public boolean canCreateCatalog()
        Description copied from class: Dialect
        Does this dialect support catalog creation?
        Overrides:
        canCreateCatalog in class Dialect
        Returns:
        True if the dialect supports catalog creation; false otherwise.
      • getCreateCatalogCommand

        public java.lang.String[] getCreateCatalogCommand​(java.lang.String catalogName)
        Description copied from class: Dialect
        Get the SQL command used to create the named catalog
        Overrides:
        getCreateCatalogCommand in class Dialect
        Parameters:
        catalogName - The name of the catalog to be created.
        Returns:
        The creation commands
      • getDropCatalogCommand

        public java.lang.String[] getDropCatalogCommand​(java.lang.String catalogName)
        Description copied from class: Dialect
        Get the SQL command used to drop the named catalog
        Overrides:
        getDropCatalogCommand in class Dialect
        Parameters:
        catalogName - The name of the catalog to be dropped.
        Returns:
        The drop commands
      • canCreateSchema

        public boolean canCreateSchema()
        Description copied from class: Dialect
        Does this dialect support schema creation?
        Overrides:
        canCreateSchema in class Dialect
        Returns:
        True if the dialect supports schema creation; false otherwise.
      • getCreateSchemaCommand

        public java.lang.String[] getCreateSchemaCommand​(java.lang.String schemaName)
        Description copied from class: Dialect
        Get the SQL command used to create the named schema
        Overrides:
        getCreateSchemaCommand in class Dialect
        Parameters:
        schemaName - The name of the schema to be created.
        Returns:
        The creation commands
      • getDropSchemaCommand

        public java.lang.String[] getDropSchemaCommand​(java.lang.String schemaName)
        Description copied from class: Dialect
        Get the SQL command used to drop the named schema
        Overrides:
        getDropSchemaCommand in class Dialect
        Parameters:
        schemaName - The name of the schema to be dropped.
        Returns:
        The drop commands
      • supportsIfExistsBeforeTableName

        public boolean supportsIfExistsBeforeTableName()
        Description copied from class: Dialect
        For dropping a table, can the phrase "if exists" be applied before the table name?

        NOTE : Only one or the other (or neither) of this and Dialect.supportsIfExistsAfterTableName() should return true

        Overrides:
        supportsIfExistsBeforeTableName in class Dialect
        Returns:
        true if the "if exists" can be applied before the table name
      • getSelectGUIDString

        public java.lang.String getSelectGUIDString()
        Description copied from class: Dialect
        Get the command used to select a GUID from the underlying database.

        Optional operation.

        Overrides:
        getSelectGUIDString in class Dialect
        Returns:
        The appropriate command.
      • getTableComment

        public java.lang.String getTableComment​(java.lang.String comment)
        Description copied from class: Dialect
        Get the comment into a form supported for table definition.
        Overrides:
        getTableComment in class Dialect
        Parameters:
        comment - The comment to apply
        Returns:
        The comment fragment
      • getColumnComment

        public java.lang.String getColumnComment​(java.lang.String comment)
        Description copied from class: Dialect
        Get the comment into a form supported for column definition.
        Overrides:
        getColumnComment in class Dialect
        Parameters:
        comment - The comment to apply
        Returns:
        The comment fragment
      • getCastTypeName

        public java.lang.String getCastTypeName​(int code)
        Description copied from class: Dialect
        Get the name of the database type appropriate for casting operations (via the CAST() SQL function) for the given Types typecode.
        Overrides:
        getCastTypeName in class Dialect
        Parameters:
        code - The Types typecode
        Returns:
        The database type name
      • smallIntegerCastTarget

        protected java.lang.String smallIntegerCastTarget()
        Determine the cast target for Types.INTEGER, Types.BIGINT and Types.SMALLINT
        Returns:
        The proper cast target type.
      • floatingPointNumberCastTarget

        protected java.lang.String floatingPointNumberCastTarget()
        Determine the cast target for Types.FLOAT and Types.REAL (DOUBLE)
        Returns:
        The proper cast target type.
      • fixedPointNumberCastTarget

        protected java.lang.String fixedPointNumberCastTarget()
        Determine the cast target for Types.NUMERIC
        Returns:
        The proper cast target type.
      • supportsCurrentTimestampSelection

        public boolean supportsCurrentTimestampSelection()
        Description copied from class: Dialect
        Does this dialect support a way to retrieve the database's current timestamp value?
        Overrides:
        supportsCurrentTimestampSelection in class Dialect
        Returns:
        True if the current timestamp can be retrieved; false otherwise.
      • getCurrentTimestampSelectString

        public java.lang.String getCurrentTimestampSelectString()
        Description copied from class: Dialect
        Retrieve the command used to retrieve the current timestamp from the database.
        Overrides:
        getCurrentTimestampSelectString in class Dialect
        Returns:
        The command.
      • registerResultSetOutParameter

        public int registerResultSetOutParameter​(java.sql.CallableStatement statement,
                                                 int col)
                                          throws java.sql.SQLException
        Description copied from class: Dialect
        Registers a parameter (either OUT, or the new REF_CURSOR param type available in Java 8) capable of returning ResultSet *by position*. Pre-Java 8, registering such ResultSet-returning parameters varied greatly across database and drivers; hence its inclusion as part of the Dialect contract.
        Overrides:
        registerResultSetOutParameter in class Dialect
        Parameters:
        statement - The callable statement.
        col - The bind position at which to register the output param.
        Returns:
        The number of (contiguous) bind positions used.
        Throws:
        java.sql.SQLException - Indicates problems registering the param.
      • getResultSet

        public java.sql.ResultSet getResultSet​(java.sql.CallableStatement ps)
                                        throws java.sql.SQLException
        Description copied from class: Dialect
        Given a callable statement previously processed by Dialect.registerResultSetOutParameter(java.sql.CallableStatement, int), extract the ResultSet from the OUT parameter.
        Overrides:
        getResultSet in class Dialect
        Parameters:
        ps - The callable statement.
        Returns:
        The extracted result set.
        Throws:
        java.sql.SQLException - Indicates problems extracting the result set.
      • getUniqueDelegate

        public UniqueDelegate getUniqueDelegate()
        Description copied from class: Dialect
        Get the UniqueDelegate supported by this dialect
        Overrides:
        getUniqueDelegate in class Dialect
        Returns:
        The UniqueDelegate
      • supportsRowValueConstructorSyntax

        public boolean supportsRowValueConstructorSyntax()
        Description copied from class: Dialect
        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') ...".

        Overrides:
        supportsRowValueConstructorSyntax in class Dialect
        Returns:
        True if this SQL dialect is known to support "row value constructor" syntax; false otherwise.
      • supportsRowValueConstructorSyntaxInSet

        public boolean supportsRowValueConstructorSyntaxInSet()
        Description copied from class: Dialect
        Is this dialect known to support what ANSI-SQL terms "row value constructor" syntax, sometimes called tuple syntax, in the SET clause;

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

        Overrides:
        supportsRowValueConstructorSyntaxInSet in class Dialect
        Returns:
        True if this SQL dialect is known to support "row value constructor" syntax in the SET clause; false otherwise.
      • renderOrderByElement

        public java.lang.String renderOrderByElement​(java.lang.String expression,
                                                     java.lang.String collation,
                                                     java.lang.String order,
                                                     NullPrecedence nulls)
        Description copied from class: Dialect
        Renders an ordering fragment
        Overrides:
        renderOrderByElement in class Dialect
        Parameters:
        expression - The SQL order expression. In case of @OrderBy annotation user receives property placeholder (e.g. attribute name enclosed in '{' and '}' signs).
        collation - Collation string in format collate IDENTIFIER, or null if expression has not been explicitly specified.
        order - Order direction. Possible values: asc, desc, or null if expression has not been explicitly specified.
        nulls - Nulls precedence. Default value: NullPrecedence.NONE.
        Returns:
        Renders single element of ORDER BY clause.
      • getForUpdateString

        public java.lang.String getForUpdateString()
        Description copied from class: Dialect
        Get the string to append to SELECT statements to acquire locks for this dialect.
        Overrides:
        getForUpdateString in class Dialect
        Returns:
        The appropriate FOR UPDATE clause string.
      • getWriteLockString

        public java.lang.String getWriteLockString​(int timeout)
        Description copied from class: Dialect
        Get the string to append to SELECT statements to acquire WRITE locks for this dialect. Location of the returned string is treated the same as getForUpdateString.
        Overrides:
        getWriteLockString in class Dialect
        Parameters:
        timeout - in milliseconds, -1 for indefinite wait and 0 for no wait.
        Returns:
        The appropriate LOCK clause string.
      • getReadLockString

        public java.lang.String getReadLockString​(int timeout)
        Description copied from class: Dialect
        Get the string to append to SELECT statements to acquire READ locks for this dialect. Location of the returned string is treated the same as getForUpdateString.
        Overrides:
        getReadLockString in class Dialect
        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: Dialect
        Does this dialect support empty IN lists?

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

        Overrides:
        supportsEmptyInList in class Dialect
        Returns:
        True if empty in lists are supported; false otherwise.
      • areStringComparisonsCaseInsensitive

        public boolean areStringComparisonsCaseInsensitive()
        Description copied from class: Dialect
        Are string comparisons implicitly case insensitive.

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

        Overrides:
        areStringComparisonsCaseInsensitive in class Dialect
        Returns:
        True if comparisons are case insensitive.
      • supportsLobValueChangePropogation

        public boolean supportsLobValueChangePropogation()
        Description copied from class: Dialect
        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: Blob.setBinaryStream(long), Blob.setBytes(long, byte[]), Blob.setBytes(long, byte[], int, int), or Blob.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), or 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 Dialect.supportsExpectedLobUsagePattern().

        Overrides:
        supportsLobValueChangePropogation in class Dialect
        Returns:
        True if the changes are propagated back to the database; false otherwise.
      • supportsSubqueryOnMutatingTable

        public boolean supportsSubqueryOnMutatingTable()
        Description copied from class: Dialect
        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)
        Overrides:
        supportsSubqueryOnMutatingTable in class Dialect
        Returns:
        True if this dialect allows references the mutating table from a subquery.
      • supportsLockTimeouts

        public boolean supportsLockTimeouts()
        Description copied from class: Dialect
        Informational metadata about whether this dialect is known to support specifying timeouts for requested lock acquisitions.
        Overrides:
        supportsLockTimeouts in class Dialect
        Returns:
        True is this dialect supports specifying lock timeouts.
      • buildSQLExceptionConversionDelegate

        public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate()
        Description copied from class: Dialect
        Build an instance of a SQLExceptionConversionDelegate for interpreting dialect-specific error or SQLState codes.

        When Dialect.buildSQLExceptionConverter() returns null, the default SQLExceptionConverter is used to interpret SQLState and error codes. If this method is overridden to return a non-null value, the default SQLExceptionConverter will use the returned SQLExceptionConversionDelegate in addition to the following standard delegates:

        1. a "static" delegate based on the JDBC 4 defined SQLException hierarchy;
        2. a delegate that interprets SQLState codes for either X/Open or SQL-2003 codes, depending on java.sql.DatabaseMetaData#getSQLStateType

        It is strongly recommended that specific Dialect implementations override this method, since interpretation of a SQL error is much more accurate when based on the vendor-specific ErrorCode rather than the SQLState.

        Specific Dialects may override to return whatever is most appropriate for that vendor.

        Overrides:
        buildSQLExceptionConversionDelegate in class Dialect
        Returns:
        The SQLExceptionConversionDelegate for this dialect
      • getNotExpression

        public java.lang.String getNotExpression​(java.lang.String expression)
        Description copied from class: Dialect
        Negate an expression
        Overrides:
        getNotExpression in class Dialect
        Parameters:
        expression - The expression to negate
        Returns:
        The negated expression
      • isJdbcLogWarningsEnabledByDefault

        public boolean isJdbcLogWarningsEnabledByDefault()
        Description copied from class: Dialect
        Does the fetching JDBC statement warning for logging is enabled by default
        Overrides:
        isJdbcLogWarningsEnabledByDefault in class Dialect
        Returns:
        boolean
      • supportsCascadeDelete

        public boolean supportsCascadeDelete()
        Description copied from class: Dialect
        Does this dialect support cascaded delete on foreign key definitions?
        Overrides:
        supportsCascadeDelete in class Dialect
        Returns:
        true indicates that the dialect does support cascaded delete on foreign keys.
      • getEngineKeyword

        protected java.lang.String getEngineKeyword()
      • hasSelfReferentialForeignKeyBug

        public boolean hasSelfReferentialForeignKeyBug()
        Description copied from class: Dialect
        Does the database/driver have bug in deleting rows that refer to other rows being deleted in the same query?
        Overrides:
        hasSelfReferentialForeignKeyBug in class Dialect
        Returns:
        true if the database/driver has this bug
      • dropConstraints

        public boolean dropConstraints()
        Description copied from class: Dialect
        Do we need to drop constraints before dropping tables in this dialect?
        Overrides:
        dropConstraints in class Dialect
        Returns:
        True if constraints must be dropped prior to dropping the table; false otherwise.
      • getDefaultMySQLStorageEngine

        protected MySQLStorageEngine getDefaultMySQLStorageEngine()
      • escapeLiteral

        protected java.lang.String escapeLiteral​(java.lang.String literal)
        Description copied from class: Dialect
        Escape String literal.
        Overrides:
        escapeLiteral in class Dialect
        Returns:
        escaped String