Class SybaseDialect

All Implemented Interfaces:
FunctionContributor, TypeContributor, ConversionContext
Direct Known Subclasses:
SybaseASEDialect

public class SybaseDialect extends AbstractTransactSQLDialect
Superclass for all Sybase dialects.
  • Field Details

    • jtdsDriver

      @Deprecated(forRemoval=true) protected final boolean jtdsDriver
      Deprecated, for removal: This API element is subject to removal in a future version.
  • Constructor Details

  • Method Details

    • 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 Dialect
    • getDriverKind

      public SybaseDriverKind getDriverKind()
    • 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 AbstractTransactSQLDialect
      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
    • resolveSqlTypeLength

      public int resolveSqlTypeLength(String columnTypeName, int jdbcTypeCode, int precision, int scale, int displaySize)
      Description copied from class: Dialect
      Determine the length/precision of a column based on information in the JDBC ResultSetMetaData. Note that what JDBC reports as a "precision" might actually be the column length.
      Overrides:
      resolveSqlTypeLength in class Dialect
      Parameters:
      columnTypeName - the name of the column type
      jdbcTypeCode - the JDBC type code of the column type
      precision - the (numeric) precision or (character) length of the column
      scale - the scale of a numeric column
      displaySize - the display size of the column
      Returns:
      the precision or length of the column
    • getSqmTranslatorFactory

      public SqmTranslatorFactory getSqmTranslatorFactory()
      Description copied from class: Dialect
      Return a SqmTranslatorFactory specific to this dialect, or null to use the standard translator.

      Note that QueryEngineOptions.getCustomSqmTranslatorFactory() has higher precedence since it comes directly from the user config.

      Overrides:
      getSqmTranslatorFactory in class Dialect
      See Also:
    • 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 Dialect
      See Also:
    • supportsNullPrecedence

      public boolean supportsNullPrecedence()
      Description copied from class: Dialect
      Does this dialect support nulls first and nulls last?
      Overrides:
      supportsNullPrecedence in class Dialect
    • getInExpressionCountLimit

      public int getInExpressionCountLimit()
      Description copied from class: Dialect
      Return the limit that the underlying database places on the number of elements in an IN predicate. If the database defines no such limits, simply return zero or a number smaller than zero.
      Overrides:
      getInExpressionCountLimit in class Dialect
      Returns:
      The limit, or a non-positive integer to indicate no limit.
    • getParameterCountLimit

      public int getParameterCountLimit()
      Description copied from class: Dialect
      Return the limit that the underlying database places on the number of parameters that can be defined for a PreparedStatement. If the database defines no such limits, simply return zero or a number smaller than zero. By default, Dialect returns the same value as Dialect.getInExpressionCountLimit().
      Overrides:
      getParameterCountLimit in class Dialect
      Returns:
      The limit, or a non-positive integer to indicate no limit.
    • 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 Dialect
      Parameters:
      typeContributions - Callback to contribute the types
      serviceRegistry - The service registry
    • 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
    • stripsTrailingSpacesFromChar

      public boolean stripsTrailingSpacesFromChar()
      Description copied from class: Dialect
      Does this dialect strip trailing spaces from values stored in columns of type char(n)? MySQL and Sybase are the main offenders here.
      Overrides:
      stripsTrailingSpacesFromChar 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 AbstractTransactSQLDialect
    • getNullColumnString

      public String getNullColumnString()
      Description copied from class: Dialect
      The keyword used to specify a nullable column, usually "", but sometimes " null".
      Overrides:
      getNullColumnString in class Dialect
    • canCreateSchema

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

      public String getCurrentSchemaCommand()
      Description copied from class: Dialect
      Get the SQL command used to retrieve the current schema name.

      Works in conjunction with Dialect.getSchemaNameResolver(), unless the resulting SchemaNameResolver does not need this information. For example, a custom implementation might make use of the Java 1.7 Connection.getSchema() method.

      Overrides:
      getCurrentSchemaCommand in class Dialect
      Returns:
      The current schema retrieval SQL
    • getMaxIdentifierLength

      public int getMaxIdentifierLength()
      Description copied from class: Dialect
      What is the maximum identifier length supported by this dialect?
      Overrides:
      getMaxIdentifierLength in class Dialect
      Returns:
      The maximum length.
    • 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 Dialect
      Parameters:
      from - a CastType indicating the type of the value argument
      to - a CastType indicating the type the value argument is cast to
    • appendDateTimeLiteral

      public void appendDateTimeLiteral(SqlAppender appender, TemporalAccessor temporalAccessor, TemporalType precision, TimeZone jdbcTimeZone)
      Description copied from class: Dialect
      Append a datetime literal representing the given java.time value to the given SqlAppender.
      Overrides:
      appendDateTimeLiteral in class Dialect
    • appendDateTimeLiteral

      public void appendDateTimeLiteral(SqlAppender appender, Date date, TemporalType precision, TimeZone jdbcTimeZone)
      Description copied from class: Dialect
      Append a datetime literal representing the given Date value to the given SqlAppender.
      Overrides:
      appendDateTimeLiteral in class Dialect
    • appendDateTimeLiteral

      public void appendDateTimeLiteral(SqlAppender appender, Calendar calendar, TemporalType precision, TimeZone jdbcTimeZone)
      Description copied from class: Dialect
      Append a datetime literal representing the given Calendar value to the given SqlAppender.
      Overrides:
      appendDateTimeLiteral in class Dialect
    • translateExtractField

      public String translateExtractField(TemporalUnit unit)
      Description copied from class: Dialect
      Return the name used to identify the given field as an argument to the extract() function, or of this dialect's equivalent function.

      This method does not need to handle TemporalUnit.NANOSECOND, TemporalUnit.NATIVE, TemporalUnit.OFFSET, TemporalUnit.DATE, TemporalUnit.TIME, TemporalUnit.WEEK_OF_YEAR, nor TemporalUnit.WEEK_OF_MONTH, which are already desugared by ExtractFunction.

      Overrides:
      translateExtractField in class Dialect
    • extractPattern

      public String extractPattern(TemporalUnit unit)
      Description copied from class: Dialect
      Obtain a pattern for the SQL equivalent to an extract() function call. The resulting pattern must contain ?1 and ?2 placeholders for the arguments.

      This method does not need to handle TemporalUnit.NANOSECOND, TemporalUnit.NATIVE, TemporalUnit.OFFSET, TemporalUnit.DATE, TemporalUnit.TIME, TemporalUnit.WEEK_OF_YEAR, or TemporalUnit.WEEK_OF_MONTH, which are already desugared by ExtractFunction.

      Overrides:
      extractPattern in class Dialect
      Parameters:
      unit - the first argument
    • supportsFractionalTimestampArithmetic

      public boolean supportsFractionalTimestampArithmetic()
      Description copied from class: Dialect
      Whether the database supports adding a fractional interval to a timestamp, for example timestamp + 0.5 second.
      Overrides:
      supportsFractionalTimestampArithmetic in class Dialect
    • timestampaddPattern

      public String timestampaddPattern(TemporalUnit unit, TemporalType temporalType, IntervalType intervalType)
      Description copied from class: Dialect
      Obtain a pattern for the SQL equivalent to a timestampadd() function call. The resulting pattern must contain ?1, ?2, and ?3 placeholders for the arguments.
      Overrides:
      timestampaddPattern in class Dialect
      Parameters:
      unit - The unit to add to the temporal
      temporalType - The type of the temporal
      intervalType - The type of interval to add or null if it's not a native interval
    • timestampdiffPattern

      public String timestampdiffPattern(TemporalUnit unit, TemporalType fromTemporalType, TemporalType toTemporalType)
      Description copied from class: Dialect
      Obtain a pattern for the SQL equivalent to a timestampdiff() function call. The resulting pattern must contain ?1, ?2, and ?3 placeholders for the arguments.
      Overrides:
      timestampdiffPattern in class Dialect
      Parameters:
      unit - the first argument
      fromTemporalType - true if the first argument is a timestamp, false if a date
      toTemporalType - true if the second argument is
    • appendDatetimeFormat

      public void appendDatetimeFormat(SqlAppender appender, String format)
      Description copied from class: Dialect
      Translate the given datetime format string from the pattern language defined by Java's DateTimeFormatter to whatever pattern language is understood by the native datetime formatting function for this database (often the to_char() function).

      Since it's never possible to translate every pattern letter sequences understood by DateTimeFormatter, only the following subset of pattern letters is accepted by Hibernate:

      • G: era
      • y: year of era
      • Y: year of week-based year
      • M: month of year
      • w: week of week-based year (ISO week number)
      • W: week of month
      • E: day of week (name)
      • e: day of week (number)
      • d: day of month
      • D: day of year
      • a: AM/PM
      • H: hour of day (24 hour time)
      • h: hour of AM/PM (12 hour time)
      • m: minutes
      • s: seconds
      • z,Z,x: timezone offset

      In addition, punctuation characters and single-quoted literal strings are accepted.

      Appends a pattern accepted by the function that formats dates and times in this dialect to a SQL fragment that is being constructed.

      Overrides:
      appendDatetimeFormat in class Dialect
    • supportsStandardCurrentTimestampFunction

      public boolean supportsStandardCurrentTimestampFunction()
      Description copied from class: Dialect
      Does this dialect have an ANSI SQL current_timestamp function?
      Overrides:
      supportsStandardCurrentTimestampFunction in class Dialect
    • 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 Dialect
      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:
    • getNameQualifierSupport

      public NameQualifierSupport getNameQualifierSupport()
      Description copied from class: Dialect
      The support for qualified identifiers.

      By default, decide based on DatabaseMetaData.

      Overrides:
      getNameQualifierSupport in class Dialect
      Returns:
      The NameQualifierSupport, or null to use DatabaseMetaData.
    • getUniqueDelegate

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

      public CallableStatementSupport getCallableStatementSupport()
      Description copied from class: Dialect
      The CallableStatementSupport for this database. Does this database support returning cursors?
      Overrides:
      getCallableStatementSupport in class Dialect
    • supportsNamedParameters

      public boolean supportsNamedParameters(DatabaseMetaData databaseMetaData) throws SQLException
      Description copied from class: Dialect
      Overrides:
      supportsNamedParameters in class Dialect
      Throws:
      SQLException - Accessing the DatabaseMetaData cause an exception. Just rethrow and Hibernate will handle it.
    • getAlterColumnTypeString

      public String getAlterColumnTypeString(String columnName, String columnType, String columnDefinition)
      Description copied from class: Dialect
      The fragment of an alter table command which modifies a column type, or null if column types cannot be modified. Often alter column col_name set data type col_type.
      Overrides:
      getAlterColumnTypeString in class Dialect
      Parameters:
      columnName - the name of the column
      columnType - the new type of the column
      columnDefinition - the full column definition
      Returns:
      a fragment to be appended to alter table
    • supportsAlterColumnType

      public boolean supportsAlterColumnType()
      Description copied from class: Dialect
      Does this dialect support modifying the type of an existing column?
      Overrides:
      supportsAlterColumnType in class Dialect
    • getIdentityColumnSupport

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

      public DmlTargetColumnQualifierSupport getDmlTargetColumnQualifierSupport()
      Description copied from class: Dialect
      Get the minimum DmlTargetColumnQualifierSupport required by this dialect.
      Overrides:
      getDmlTargetColumnQualifierSupport in class Dialect
      Returns:
      the column qualifier support required by this dialect
    • supportsFromClauseInUpdate

      public boolean supportsFromClauseInUpdate()
      Description copied from class: Dialect
      Does this dialect support the from clause for update statements?
      Overrides:
      supportsFromClauseInUpdate in class Dialect
      Returns:
      true if from clause is supported