Class MariaDBDialect

All Implemented Interfaces:
FunctionContributor, TypeContributor, ConversionContext

public class MariaDBDialect extends MySQLDialect
A SQL dialect for MariaDB 10.5 and above.
  • Constructor Details

  • Method Details

    • getMySQLVersion

      public DatabaseVersion getMySQLVersion()
      Overrides:
      getMySQLVersion in class MySQLDialect
    • getMinimumSupportedVersion

      protected DatabaseVersion getMinimumSupportedVersion()
      Description copied from class: Dialect
      Get the version of the SQL dialect that is the minimum supported by this implementation.
      Overrides:
      getMinimumSupportedVersion in class MySQLDialect
    • getNationalizationSupport

      public NationalizationSupport getNationalizationSupport()
      Description copied from class: Dialect
      Determines whether this database requires the use of explicitly nationalized character (Unicode) data types.

      That is, whether the use of Types.NCHAR, Types.NVARCHAR, and Types.NCLOB is required for nationalized character data.

      Overrides:
      getNationalizationSupport in class Dialect
    • initializeFunctionRegistry

      public void initializeFunctionRegistry(FunctionContributions functionContributions)
      Description copied from class: Dialect
      Initialize the given registry with any dialect-specific functions.

      Support for certain SQL functions is required, and if the database does not support a required function, then the dialect must define a way to emulate it.

      These required functions include the functions defined by the JPA query language specification:

      • avg(arg) - aggregate function
      • count([distinct ]arg) - aggregate function
      • max(arg) - aggregate function
      • min(arg) - aggregate function
      • sum(arg) - aggregate function
      • coalesce(arg0, arg1, ...)
      • nullif(arg0, arg1)
      • lower(arg)
      • upper(arg)
      • length(arg)
      • concat(arg0, arg1, ...)
      • locate(pattern, string[, start])
      • substring(string, start[, length])
      • trim([[spec ][character ]from] string)
      • abs(arg)
      • mod(arg0, arg1)
      • sqrt(arg)
      • current date
      • current time
      • current timestamp
      Along with an additional set of functions defined by ANSI SQL:
      • any(arg) - aggregate function
      • every(arg) - aggregate function
      • var_samp(arg) - aggregate function
      • var_pop(arg) - aggregate function
      • stddev_samp(arg) - aggregate function
      • stddev_pop(arg) - aggregate function
      • cast(arg as Type)
      • extract(field from arg)
      • ln(arg)
      • exp(arg)
      • power(arg0, arg1)
      • floor(arg)
      • ceiling(arg)
      • position(pattern in string)
      • substring(string from start[ for length])
      • overlay(string placing replacement from start[ for length])
      And the following functions for working with java.time types:
      • local date
      • local time
      • local datetime
      • offset datetime
      • instant
      And a number of additional "standard" functions:
      • left(string, length)
      • right(string, length)
      • replace(string, pattern, replacement)
      • pad(string with length spec[ character])
      • repeat(string, times)
      • pi
      • log10(arg)
      • log(base, arg)
      • sign(arg)
      • sin(arg)
      • cos(arg)
      • tan(arg)
      • asin(arg)
      • acos(arg)
      • atan(arg)
      • atan2(arg0, arg1)
      • round(arg0[, arg1])
      • truncate(arg0[, arg1])
      • sinh(arg)
      • tanh(arg)
      • cosh(arg)
      • least(arg0, arg1, ...)
      • greatest(arg0, arg1, ...)
      • degrees(arg)
      • radians(arg)
      • bitand(arg1, arg1)
      • bitor(arg1, arg1)
      • bitxor(arg1, arg1)
      • format(datetime as pattern)
      • collate(string as collation)
      • str(arg) - synonym of cast(a as String)
      • ifnull(arg0, arg1) - synonym of coalesce(a, b)
      Finally, the following functions are defined as abbreviations for extract(), and desugared by the parser:
      • second(arg) - synonym of extract(second from a)
      • minute(arg) - synonym of extract(minute from a)
      • hour(arg) - synonym of extract(hour from a)
      • day(arg) - synonym of extract(day from a)
      • month(arg) - synonym of extract(month from a)
      • year(arg) - synonym of extract(year from a)
      Note that according to this definition, the second() function returns a floating point value, contrary to the integer type returned by the native function with this name on many databases. Thus, we don't just naively map these HQL functions to the native SQL functions with the same names.
      Overrides:
      initializeFunctionRegistry in class MySQLDialect
    • registerColumnTypes

      protected void registerColumnTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry)
      Description copied from class: Dialect
      Register ANSI-standard column types using the length limits defined by Dialect.getMaxVarcharLength(), Dialect.getMaxNVarcharLength(), and Dialect.getMaxVarbinaryLength().

      This method is always called when a Dialect is instantiated.

      Overrides:
      registerColumnTypes in class MySQLDialect
    • getAggregateSupport

      public AggregateSupport getAggregateSupport()
      Description copied from class: Dialect
      How does this dialect support aggregate types like SqlTypes.STRUCT.
      Overrides:
      getAggregateSupport in class MySQLDialect
    • registerKeyword

      protected void registerKeyword(String word)
      Description copied from class: Dialect
      Register a keyword.
      Overrides:
      registerKeyword in class Dialect
      Parameters:
      word - a reserved word in this SQL dialect
    • resolveSqlTypeDescriptor

      public JdbcType resolveSqlTypeDescriptor(String columnTypeName, int jdbcTypeCode, int precision, int scale, JdbcTypeRegistry jdbcTypeRegistry)
      Description copied from class: Dialect
      Assigns an appropriate JdbcType to a column of a JDBC result set based on the column type name, JDBC type code, precision, and scale.
      Overrides:
      resolveSqlTypeDescriptor in class MySQLDialect
      Parameters:
      columnTypeName - the column type name
      jdbcTypeCode - the type code
      precision - the precision or 0
      scale - the scale or 0
      Returns:
      an appropriate instance of JdbcType
    • contributeTypes

      public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry)
      Description copied from class: Dialect
      A callback which allows the Dialect to contribute types.
      Overrides:
      contributeTypes in class MySQLDialect
      Parameters:
      typeContributions - Callback to contribute the types
      serviceRegistry - The service registry
    • castPattern

      public String castPattern(CastType from, CastType to)
      Description copied from class: Dialect
      Obtain a pattern for the SQL equivalent to a cast() function call. The resulting pattern must contain ?1 and ?2 placeholders for the arguments.
      Overrides:
      castPattern in class MySQLDialect
      Parameters:
      from - a CastType indicating the type of the value argument
      to - a CastType indicating the type the value argument is cast to
    • getSqlAstTranslatorFactory

      public SqlAstTranslatorFactory getSqlAstTranslatorFactory()
      Description copied from class: Dialect
      Return a SqlAstTranslatorFactory specific to this dialect, or null to use the standard translator.
      Overrides:
      getSqlAstTranslatorFactory in class MySQLDialect
      See Also:
    • supportsWindowFunctions

      public boolean supportsWindowFunctions()
      Description copied from class: Dialect
      Does this dialect support window functions like row_number() over (..)?
      Overrides:
      supportsWindowFunctions in class MySQLDialect
      Returns:
      true if the underlying database supports window functions, false otherwise. The default is false.
    • supportsLateral

      public boolean supportsLateral()
      Description copied from class: Dialect
      Does this dialect support the SQL lateral keyword or a proprietary alternative?
      Overrides:
      supportsLateral in class MySQLDialect
      Returns:
      true if the underlying database supports lateral, false otherwise. The default is false.
    • supportsRecursiveCTE

      public boolean supportsRecursiveCTE()
      Description copied from class: Dialect
      Does this dialect/database support recursive CTEs?
      Overrides:
      supportsRecursiveCTE in class MySQLDialect
      Returns:
      true if recursive CTEs are supported
    • supportsColumnCheck

      public boolean supportsColumnCheck()
      Description copied from class: Dialect
      Does this dialect support column-level check constraints?
      Overrides:
      supportsColumnCheck in class MySQLDialect
      Returns:
      True if column-level check constraints are supported; false otherwise.
    • doesRoundTemporalOnOverflow

      public boolean doesRoundTemporalOnOverflow()
      Description copied from class: Dialect
      Does this dialect round a temporal when converting from a precision higher to a lower one?
      Overrides:
      doesRoundTemporalOnOverflow in class Dialect
      Returns:
      true if rounding is applied, false if truncation is applied
    • supportsIfExistsBeforeConstraintName

      public boolean supportsIfExistsBeforeConstraintName()
      Description copied from class: Dialect
      For dropping a constraint with an alter table statement, can the phrase if exists be applied before the constraint name?
      Overrides:
      supportsIfExistsBeforeConstraintName in class Dialect
      Returns:
      true if if exists can be applied before the constraint name
    • supportsIfExistsAfterAlterTable

      public boolean supportsIfExistsAfterAlterTable()
      Description copied from class: Dialect
      For an alter table, can the phrase if exists be applied?
      Overrides:
      supportsIfExistsAfterAlterTable in class Dialect
      Returns:
      true if if exists can be applied after alter table
    • getSequenceSupport

      public SequenceSupport getSequenceSupport()
      Description copied from class: MySQLDialect
      No support for sequences.
      Overrides:
      getSequenceSupport in class MySQLDialect
    • getQuerySequencesString

      public String getQuerySequencesString()
      Description copied from class: Dialect
      Get the select command used retrieve the names of all sequences.
      Overrides:
      getQuerySequencesString in class Dialect
      Returns:
      The select command; or null if sequences are not supported.
    • getSequenceInformationExtractor

      public SequenceInformationExtractor getSequenceInformationExtractor()
      Description copied from class: Dialect
      A SequenceInformationExtractor which is able to extract SequenceInformation from the JDBC result set returned when Dialect.getQuerySequencesString() is executed.
      Overrides:
      getSequenceInformationExtractor in class Dialect
    • supportsSkipLocked

      public boolean supportsSkipLocked()
      Description copied from class: Dialect
      Does this dialect support SKIP_LOCKED timeout.
      Overrides:
      supportsSkipLocked in class MySQLDialect
      Returns:
      true if SKIP_LOCKED is supported
    • supportsNoWait

      public boolean supportsNoWait()
      Description copied from class: Dialect
      Does this dialect support NO_WAIT timeout.
      Overrides:
      supportsNoWait in class MySQLDialect
      Returns:
      true if NO_WAIT is supported
    • supportsWait

      public boolean supportsWait()
      Description copied from class: Dialect
      Does this dialect support WAIT timeout.
      Overrides:
      supportsWait in class MySQLDialect
      Returns:
      true if WAIT is supported
    • supportsInsertReturning

      public boolean supportsInsertReturning()
      Description copied from class: Dialect
      Does this dialect fully support returning arbitrary generated column values after execution of an insert statement, using native SQL syntax?

      Support for identity columns is insufficient here, we require something like:

      1. insert ... returning ..., or
      2. select from final table (insert ... ).
      Overrides:
      supportsInsertReturning in class Dialect
      Returns:
      true for 10.5 and above because Maria supports insert ... returning even though MySQL does not
      See Also:
    • supportsUpdateReturning

      public boolean supportsUpdateReturning()
      Description copied from class: Dialect
      Does this dialect fully support returning arbitrary generated column values after execution of an update statement, using native SQL syntax?

      Defaults to the value of Dialect.supportsInsertReturning() but can be overridden to explicitly disable this for updates.

      Overrides:
      supportsUpdateReturning in class Dialect
      See Also:
    • getIdentityColumnSupport

      public IdentityColumnSupport getIdentityColumnSupport()
      Description copied from class: Dialect
      Get the appropriate IdentityColumnSupport for this dialect.
      Overrides:
      getIdentityColumnSupport in class MySQLDialect
      Returns:
      the IdentityColumnSupport
    • getFunctionalDependencyAnalysisSupport

      public FunctionalDependencyAnalysisSupport getFunctionalDependencyAnalysisSupport()
      Description copied from class: Dialect
      Get this dialect's level of support for primary key functional dependency analysis within GROUP BY and ORDER BY clauses.
      Overrides:
      getFunctionalDependencyAnalysisSupport in class MySQLDialect
    • buildIdentifierHelper

      public IdentifierHelper buildIdentifierHelper(IdentifierHelperBuilder builder, DatabaseMetaData dbMetaData) throws SQLException
      Description copied from class: Dialect
      The IdentifierHelper indicated by this dialect for handling identifier conversions. Returning null is allowed and indicates that Hibernate should fall back to building a "standard" helper. In the fallback path, any changes made to the IdentifierHelperBuilder during this call will still be incorporated into the built IdentifierHelper.

      The incoming builder will have the following set:

      By default, Hibernate will do the following:

      Overrides:
      buildIdentifierHelper in class MySQLDialect
      Parameters:
      builder - A partially-configured IdentifierHelperBuilder.
      dbMetaData - Access to the metadata returned from the driver if needed and if available. WARNING: it may be null.
      Returns:
      The IdentifierHelper instance to use, or null to indicate Hibernate should use its fallback path
      Throws:
      SQLException - Accessing the DatabaseMetaData can throw it. Just rethrow and Hibernate will handle it.
      See Also:
    • getDual

      public String getDual()
      Description copied from class: Dialect
      Returns a table expression that has one row.
      Overrides:
      getDual in class MySQLDialect
      Returns:
      the SQL equivalent to Oracle's dual.
    • equivalentTypes

      public boolean equivalentTypes(int typeCode1, int typeCode2)
      Description copied from class: Dialect
      Do the given JDBC type codes, as defined in Types represent essentially the same type in this dialect of SQL?

      The default implementation treats NUMERIC and DECIMAL as the same type, and FLOAT, REAL, and DOUBLE as essentially the same type, since the ANSI SQL specification fails to meaningfully distinguish them.

      The default implementation also treats VARCHAR, NVARCHAR, LONGVARCHAR, and LONGNVARCHAR as the same type, and BINARY and LONGVARBINARY as the same type, since Hibernate doesn't really differentiate these types.

      On the other hand, integral types are not treated as equivalent, instead, Dialect.isCompatibleIntegralType(int, int) is responsible for determining if the types are compatible.

      Overrides:
      equivalentTypes in class Dialect
      Parameters:
      typeCode1 - the first column type info
      typeCode2 - the second column type info
      Returns:
      true if the two type codes are equivalent