Class AbstractTransactSQLDialect

    • Constructor Detail

      • AbstractTransactSQLDialect

        public AbstractTransactSQLDialect​(DatabaseVersion version)
    • Method Detail

      • columnType

        protected String columnType​(int sqlTypeCode)
        Description copied from class: Dialect
        The column type name for a given JDBC type code defined in Types or SqlTypes. This default implementation returns the ANSI-standard type name.

        This method may be overridden by concrete Dialects as an alternative to Dialect.registerColumnTypes(TypeContributions, ServiceRegistry) for simple registrations.

        columnType in class Dialect
        sqlTypeCode - a SQL type code
        a column type name, with $l, $p, $s placeholders for length, precision, scale
        See Also:
      • initializeFunctionRegistry

        public void initializeFunctionRegistry​(QueryEngine queryEngine)
        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
        • 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])
        • log10(arg)
        • sign(arg)
        • sin(arg)
        • cos(arg)
        • tan(arg)
        • asin(arg)
        • acos(arg)
        • atan(arg)
        • atan2(arg0, arg1)
        • round(arg0, arg1)
        • least(arg0, arg1, ...)
        • greatest(arg0, 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.
        initializeFunctionRegistry in class Dialect
      • trimPattern

        public String trimPattern​(TrimSpec specification,
                                  char character)
        Description copied from class: Dialect
        Obtain a pattern for the SQL equivalent to a trim() function call. The resulting pattern must contain a ?1 placeholder for the argument of type String.
        trimPattern in class Dialect
        specification - leading or trailing
        character - the character to trim
      • replaceLtrimRtrim

        public static String replaceLtrimRtrim​(TrimSpec specification,
                                               char character)
      • getAddColumnString

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

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

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

        public String appendLockHint​(LockOptions lockOptions,
                                     String tableName)
        Description copied from class: Dialect
        Some dialects support an alternative means to SELECT FOR UPDATE, whereby a "lock hint" is appended to the table name in the from clause.

        contributed by Helge Schulz

        appendLockHint in class Dialect
        lockOptions - The lock options to apply
        tableName - The name of the table to which to apply the lock hint.
        The table with any required lock hints.
      • applyLocksToSql

        public String applyLocksToSql​(String sql,
                                      LockOptions aliasedLockOptions,
                                      Map<String,​String[]> keyColumnNames)
        Description copied from class: Dialect
        Modifies the given SQL by applying the appropriate updates for the specified lock modes and key columns.

        The behavior here is that of an ANSI SQL SELECT FOR UPDATE. This method is really intended to allow dialects which do not support SELECT FOR UPDATE to achieve this in their own fashion.

        applyLocksToSql in class Dialect
        sql - the SQL string to modify
        aliasedLockOptions - lock options indexed by aliased table names.
        keyColumnNames - a map of key columns indexed by aliased table names.
        the modified SQL string.
      • registerResultSetOutParameter

        public int registerResultSetOutParameter​(CallableStatement statement,
                                                 int col)
                                          throws 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.
        registerResultSetOutParameter in class Dialect
        statement - The callable statement.
        col - The bind position at which to register the output param.
        The number of (contiguous) bind positions used.
        SQLException - Indicates problems registering the param.
      • supportsCurrentTimestampSelection

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

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

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

        Optional operation.

        getSelectGUIDString in class Dialect
        The appropriate command.
      • supportsExistsInSelect

        public boolean supportsExistsInSelect()
        Description copied from class: Dialect
        Does the dialect support an exists statement in the select clause?
        supportsExistsInSelect in class Dialect
        True if exists checks are allowed in the select clause; false otherwise.
      • doesReadCommittedCauseWritersToBlockReaders

        public boolean doesReadCommittedCauseWritersToBlockReaders()
        Description copied from class: Dialect
        For the underlying database, is READ_COMMITTED isolation implemented by forcing readers to wait for write locks to be released?
        doesReadCommittedCauseWritersToBlockReaders in class Dialect
        True if writers block readers to achieve READ_COMMITTED; false otherwise.
      • doesRepeatableReadCauseReadersToBlockWriters

        public boolean doesRepeatableReadCauseReadersToBlockWriters()
        Description copied from class: Dialect
        For the underlying database, is REPEATABLE_READ isolation implemented by forcing writers to wait for read locks to be released?
        doesRepeatableReadCauseReadersToBlockWriters in class Dialect
        True if readers block writers to achieve REPEATABLE_READ; false otherwise.
      • supportsTupleDistinctCounts

        public boolean supportsTupleDistinctCounts()
        Description copied from class: Dialect
        Does this dialect support `count(distinct a,b)`?
        supportsTupleDistinctCounts in class Dialect
        True if the database supports counting distinct tuples; false otherwise.
      • supportsPartitionBy

        public boolean supportsPartitionBy()
        Description copied from class: Dialect
        Does the underlying database support partition by?
        supportsPartitionBy in class Dialect