Package org.hibernate.dialect

Class AbstractTransactSQLDialect

    • Constructor Detail

      • AbstractTransactSQLDialect

        public AbstractTransactSQLDialect​(DatabaseVersion version)
    • Method Detail

      • resolveSqlTypeDescriptor

        public JdbcType resolveSqlTypeDescriptor​(String columnTypeName,                                         int jdbcTypeCode,                                         int precision,                                         int scale,JdbcTypeRegistry jdbcTypeRegistry)
        Description copied from class: Dialect
        Assigns an appropriateJdbcType to a column of a JDBC result set based on the column type name, JDBC type code, precision, and scale.
        Overrides:
        resolveSqlTypeDescriptor in class Dialect
        Parameters:
        columnTypeName - the column type name
        jdbcTypeCode - thetype code
        precision - the precision or 0
        scale - the scale or 0
        Returns:
        an appropriate instance ofJdbcType
      • 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 withjava.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 ofcast(a as String)
        • ifnull(arg0, arg1) - synonym ofcoalesce(a, b)
        Finally, the following functions are defined as abbreviations forextract(), and desugared by the parser:
        • second(arg) - synonym ofextract(second from a)
        • minute(arg) - synonym ofextract(minute from a)
        • hour(arg) - synonym ofextract(hour from a)
        • day(arg) - synonym ofextract(day from a)
        • month(arg) - synonym ofextract(month from a)
        • year(arg) - synonym ofextract(year from a)
        Note that according to this definition, thesecond() 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 Dialect
      • trimPattern

        public String trimPattern​(TrimSpec specification,                          boolean isWhitespace)
        Description copied from class: Dialect
        Obtain a pattern for the SQL equivalent to atrim() function call. The resulting pattern must contain a ?1 placeholder for the argument of typeString and a ?2 placeholder for the trim character ifisWhitespace was false.
        Overrides:
        trimPattern in class Dialect
        Parameters:
        specification -leading,trailing orboth
        isWhitespace -true if the trim character is a whitespace and can be omitted,false if it must be explicit and a ?2 placeholder should be included in the pattern
      • replaceLtrimRtrim

        public static String replaceLtrimRtrim​(TrimSpec specification,                                       boolean isWhitespace)
      • getAddColumnString

        public String getAddColumnString()
        Description copied from class: Dialect
        The subcommand of thealter table command used to add a column to a table, usuallyadd column oradd.
        Overrides:
        getAddColumnString in class Dialect
        Returns:
        Theadd 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:
        true if we do
      • getForUpdateString

        public String getForUpdateString()
        Description copied from class: Dialect
        Get the string to append toSELECT statements to acquire pessimistic UPGRADE locks for this dialect.
        Overrides:
        getForUpdateString in class Dialect
        Returns:
        The appropriateFOR UPDATE clause string.
      • appendLockHint

        public String appendLockHint​(LockOptions lockOptions,String tableName)
        Description copied from class: Dialect
        Some dialects support an alternative means toSELECT FOR UPDATE, whereby a "lock hint" is appended to the table name in thefrom clause.
        Overrides:
        appendLockHint in class Dialect
        Parameters:
        lockOptions - The lock options to apply
        tableName - The name of the table to which to apply the lock hint.
        Returns:
        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, applying the appropriate updates for the specified lock modes and key columns.

        This allows emulation ofSELECT FOR UPDATE for dialects which do not support the standard syntax.

        Overrides:
        applyLocksToSql in class Dialect
        Parameters:
        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.
        Returns:
        the modified SQL string.
      • registerResultSetOutParameter

        public int registerResultSetOutParameter​(CallableStatement statement,                                         int col)                                  throwsSQLException
        Description copied from class: Dialect
        Registers a parameter capable of returning aResultSetby position, either anOUT parameter, or aREF_CURSOR parameter as defined in Java 8.
        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:
        SQLException - Indicates problems registering the param.
      • supportsCurrentTimestampSelection

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

        public boolean requiresCastForConcatenatingNonStrings()
        Description copied from class: Dialect
        Does this dialect/database require casting of non-string arguments in theconcat() function?
        Overrides:
        requiresCastForConcatenatingNonStrings in class Dialect
        Returns:
        true if casting usingcast() is required
      • getSelectGUIDString

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

        Optional operation.

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

        public boolean supportsExistsInSelect()
        Description copied from class: Dialect
        Does the dialect support an exists statement in the select clause?
        Overrides:
        supportsExistsInSelect in class Dialect
        Returns:
        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, isREAD_COMMITTED isolation implemented by forcing readers to wait for write locks to be released?
        Overrides:
        doesReadCommittedCauseWritersToBlockReaders in class Dialect
        Returns:
        True if writers block readers to achieveREAD_COMMITTED; false otherwise.
      • doesRepeatableReadCauseReadersToBlockWriters

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

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

        public boolean supportsPartitionBy()
        Description copied from class: Dialect
        Does is dialect supportpartition by?
        Overrides:
        supportsPartitionBy in class Dialect