Class MySqlDialect

java.lang.Object
org.fastnate.generator.dialect.GeneratorDialect
org.fastnate.generator.dialect.MySqlDialect

public class MySqlDialect extends GeneratorDialect
Handles MySQL specific conversions.
Author:
Tobias Liefke
See Also:
  • Constructor Details

    • MySqlDialect

      public MySqlDialect()
  • Method Details

    • createAddDateExpression

      protected String createAddDateExpression(String referenceDate, long value, String unit)
      Description copied from class: GeneratorDialect
      Creates an SQL expression to add a value to a date.
      Overrides:
      createAddDateExpression in class GeneratorDialect
      Parameters:
      referenceDate - the expression for the reference date
      value - the value to add to the date
      unit - the unit of the value
      Returns:
      the SQL expression that adds the value
    • createBlobExpression

      public String createBlobExpression(byte[] blob)
      Create MySQL specific binary expression.
      Overrides:
      createBlobExpression in class GeneratorDialect
      Parameters:
      blob - the bytes to convert
      Returns:
      the expression for the bytes
    • getEmptyValuesExpression

      public Object getEmptyValuesExpression()
      Description copied from class: GeneratorDialect
      The SQL expression to use in an empty insert statement.
      Overrides:
      getEmptyValuesExpression in class GeneratorDialect
      Returns:
      the SQL expression if an insert statement contains no values
    • getOptionalTable

      public String getOptionalTable()
      Description copied from class: GeneratorDialect
      Returns the string to use when no table is required, e.g. for "SELECT 1, 2 FROM DUAL" this would return "FROM DUAL".
      Overrides:
      getOptionalTable in class GeneratorDialect
      Returns:
      the SQL to use in "SELECT x [OPTIONALTABLE] WHERE ..."
    • isEmulatingSequences

      public boolean isEmulatingSequences()
      Description copied from class: GeneratorDialect
      Indicates that tables are used in place of sequences, if GenerationType.SEQUENCE is defined for a GeneratedValue.
      Overrides:
      isEmulatingSequences in class GeneratorDialect
      Returns:
      true if sequences are emulated with tables, false if sequences are supported
    • isFastInTransaction

      public boolean isFastInTransaction()
      Description copied from class: GeneratorDialect
      Indicates that the database usually faster when all statements are executed within an transaction. For example Oracle is approx. 25% faster but H2 is 200% slower compared to auto commit. Only relevant if executed against a running database.
      Overrides:
      isFastInTransaction in class GeneratorDialect
      Returns:
      true if an transaction is faster than auto commit
    • isSchemaSupported

      public boolean isSchemaSupported()
      Description copied from class: GeneratorDialect
      Indicates that this dialect supports the schema naming.
      Overrides:
      isSchemaSupported in class GeneratorDialect
      Returns:
      true if we support the name of schema when referencing a table
    • isSelectFromSameTableInInsertSupported

      public boolean isSelectFromSameTableInInsertSupported()
      Description copied from class: GeneratorDialect
      Indicates that this dialect may select from the same table in an insert statement.
      Overrides:
      isSelectFromSameTableInInsertSupported in class GeneratorDialect
      Returns:
      true if "INSERT INTO MY_TABLE (a) VALUES (SELECT max(a) FROM MY_TABLE)" is supported
    • quoteIdentifier

      public String quoteIdentifier(String name)
      Description copied from class: GeneratorDialect
      Quotes an object name for the current database dialect.
      Overrides:
      quoteIdentifier in class GeneratorDialect
      Parameters:
      name - the plain object name
      Returns:
      the quoted object name
    • quoteString

      public String quoteString(String value)
      Create MySQL specific quoting of the string.
      Overrides:
      quoteString in class GeneratorDialect
      Parameters:
      value - the value to quote
      Returns:
      the quoted string