Class SybaseASEDialect

All Implemented Interfaces:
FunctionContributor, TypeContributor, ConversionContext

public class SybaseASEDialect extends SybaseDialect
A SQL dialect for Sybase Adaptive Server Enterprise 16 and above.
  • Field Details

  • Constructor Details

    • SybaseASEDialect

      public SybaseASEDialect()
    • SybaseASEDialect

      public SybaseASEDialect(DatabaseVersion version)
    • SybaseASEDialect

      public SybaseASEDialect(DialectResolutionInfo info)
  • Method Details

    • columnType

      protected String columnType(int sqlTypeCode)
      Description copied from class: Dialect
      The database 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.

      Note that:

      1. Implementations of this method are expected to define a sensible mapping forTypes.NCLOB Types.NCHAR, and Types.NVARCHAR. On some database, these types are simply remapped to CLOB, CHAR, and VARCHAR.
      2. Mappings for Types.TIMESTAMP and Types.TIMESTAMP_WITH_TIMEZONE should support explicit specification of precision if possible.
      3. As specified by DdlTypeRegistry.getDescriptor(int), this method never receives Types.LONGVARCHAR, Types.LONGNVARCHAR, nor Types.LONGVARBINARY, which are considered synonyms for their non-LONG counterparts.
      4. On the other hand, the types SqlTypes.LONG32VARCHAR, SqlTypes.LONG32NVARCHAR, and SqlTypes.LONG32VARBINARY are not synonyms, and implementations of this method must define sensible mappings, for example to database-native TEXT or CLOB types.
      Overrides:
      columnType in class AbstractTransactSQLDialect
      Parameters:
      sqlTypeCode - a SQL type code
      Returns:
      a column type name, with $l, $p, $s placeholders for length, precision, scale
      See Also:
    • 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 Dialect
    • getPreferredSqlTypeCodeForArray

      public int getPreferredSqlTypeCodeForArray()
      Description copied from class: Dialect
      The JDBC type code to use for mapping properties of basic Java array or Collection types.

      Usually SqlTypes.ARRAY or SqlTypes.VARBINARY.

      Overrides:
      getPreferredSqlTypeCodeForArray in class Dialect
      Returns:
      one of the type codes defined by SqlTypes.
    • getMaxVarcharLength

      public int getMaxVarcharLength()
      Description copied from class: Dialect
      The biggest size value that can be supplied as argument to a Types.VARCHAR-like type.

      For longer column lengths, use some sort of text-like type for the column.

      Overrides:
      getMaxVarcharLength 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 SybaseDialect
    • getMaximumSeriesSize

      protected int getMaximumSeriesSize()
      Sybase ASE doesn't support the generate_series function or lateral recursive CTEs, so it has to be emulated with the xmltable and replicate functions.
    • getDefaultLobLength

      public long getDefaultLobLength()
      Description copied from class: Dialect
      This is the default length for a generated column of type BLOB or CLOB mapped to Blob or Clob, if LOB columns have a length in this dialect.
      Overrides:
      getDefaultLobLength in class Dialect
      Returns:
      1048576L by default
      See Also:
    • isAnsiNullOn

      public boolean isAnsiNullOn()
    • getFloatPrecision

      public int getFloatPrecision()
      Description copied from class: Dialect
      This is the default precision for a generated column mapped to a Java Float or float. That is, a value representing "single precision".

      Usually 24 binary digits, at least for databases with a conventional interpretation of the ANSI SQL specification.

      Overrides:
      getFloatPrecision in class Dialect
      Returns:
      a value representing "single precision", usually in binary digits, but sometimes in decimal digits
    • getDoublePrecision

      public int getDoublePrecision()
      Description copied from class: Dialect
      This is the default precision for a generated column mapped to a Java Double or double. That is, a value representing "double precision".

      Usually 53 binary digits, at least for databases with a conventional interpretation of the ANSI SQL specification.

      Overrides:
      getDoublePrecision in class Dialect
      Returns:
      a value representing "double precision", usually in binary digits, but sometimes in decimal digits
    • getSizeStrategy

      public Dialect.SizeStrategy getSizeStrategy()
      Description copied from class: Dialect
      A custom Dialect.SizeStrategy for column types.
      Overrides:
      getSizeStrategy in class Dialect
    • 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 SybaseDialect
      See Also:
    • getAggregateSupport

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

      public boolean supportsBitType()
      The Sybase ASE BIT type does not allow null values, so we don't use it.
      Overrides:
      supportsBitType in class Dialect
      Returns:
      false
    • supportsDistinctFromPredicate

      public boolean supportsDistinctFromPredicate()
      Description copied from class: Dialect
      Does this dialect support some kind of distinct from predicate?

      That is, does it support syntax like:

       ... where FIRST_NAME IS DISTINCT FROM LAST_NAME
       
      Overrides:
      supportsDistinctFromPredicate in class Dialect
      Returns:
      True if this SQL dialect is known to support some kind of distinct from predicate; false otherwise
    • 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 SybaseDialect
      Parameters:
      typeContributions - Callback to contribute the types
      serviceRegistry - The service registry
    • currentDate

      public String currentDate()
      Description copied from class: Dialect
      Translation of the HQL/JPQL current_date function, which maps to the Java type Date, and of the HQL local_date function which maps to the Java type LocalDate.
      Overrides:
      currentDate in class Dialect
    • currentTime

      public String currentTime()
      Description copied from class: Dialect
      Translation of the HQL/JPQL current_time function, which maps to the Java type Time which is a time with no time zone. This contradicts ANSI SQL where current_time has the type TIME WITH TIME ZONE.

      It is recommended to override this in dialects for databases which support localtime or time at local.

      Overrides:
      currentTime in class Dialect
    • currentTimestamp

      public String currentTimestamp()
      Description copied from class: Dialect
      Translation of the HQL/JPQL current_timestamp function, which maps to the Java type Timestamp which is a datetime with no time zone. This contradicts ANSI SQL where current_timestamp has the type TIMESTAMP WITH TIME ZONE.

      It is recommended to override this in dialects for databases which support localtimestamp or timestamp at local.

      Overrides:
      currentTimestamp in class Dialect
    • getFractionalSecondPrecisionInNanos

      public long getFractionalSecondPrecisionInNanos()
      Sybase ASE in principle supports microsecond precision for {code bigdatetime}, but unfortunately its duration arithmetic functions have a nasty habit of overflowing. So to give ourselves a little extra headroom, we will use millisecond as the native unit of precision.
      Overrides:
      getFractionalSecondPrecisionInNanos in class Dialect
      Returns:
      the precision, specified as a quantity of nanoseconds
      See Also:
    • 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 SybaseDialect
      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 SybaseDialect
      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
    • registerDefaultKeywords

      protected void registerDefaultKeywords()
      Description copied from class: Dialect
      Register the reserved words of ANSI-standard SQL as keywords.
      Overrides:
      registerDefaultKeywords in class Dialect
      See Also:
    • supportsCascadeDelete

      public boolean supportsCascadeDelete()
      Description copied from class: Dialect
      Does this dialect support on delete actions in foreign key definitions?
      Overrides:
      supportsCascadeDelete in class Dialect
      Returns:
      true if the dialect does support the on delete clause.
    • getMaxAliasLength

      public int getMaxAliasLength()
      Description copied from class: Dialect
      What is the maximum length Hibernate can use for generated aliases?
      Overrides:
      getMaxAliasLength in class Dialect
      Returns:
      The maximum length.
    • getMaxIdentifierLength

      public int getMaxIdentifierLength()
      Description copied from class: Dialect
      What is the maximum identifier length supported by this dialect?
      Overrides:
      getMaxIdentifierLength in class SybaseDialect
      Returns:
      The maximum length.
    • supportsLockTimeouts

      public boolean supportsLockTimeouts()
      Description copied from class: Dialect
      Does this dialect support specifying timeouts when requesting locks.
      Overrides:
      supportsLockTimeouts in class Dialect
      Returns:
      True is this dialect supports specifying lock timeouts.
    • supportsOrderByInSubquery

      public boolean supportsOrderByInSubquery()
      Description copied from class: Dialect
      Does this dialect support the order by clause in subqueries?

      For example:

       select * from Table1 where col1 in (select col1 from Table2 order by col2 limit 1)
       
      Overrides:
      supportsOrderByInSubquery in class Dialect
      Returns:
      true if it does
    • supportsUnionInSubquery

      public boolean supportsUnionInSubquery()
      Description copied from class: Dialect
      Does this dialect support UNION in a subquery.
      Overrides:
      supportsUnionInSubquery in class Dialect
      Returns:
      True if UNION is supported in a subquery; false otherwise.
    • supportsPartitionBy

      public boolean supportsPartitionBy()
      Description copied from class: Dialect
      Does is dialect support partition by?
      Overrides:
      supportsPartitionBy in class AbstractTransactSQLDialect
    • getTableTypeString

      public String getTableTypeString()
      Description copied from class: Dialect
      An arbitrary fragment appended to the end of the create table statement.
      Overrides:
      getTableTypeString in class Dialect
    • supportsLobValueChangePropagation

      public boolean supportsLobValueChangePropagation()
      Description copied from class: Dialect
      Does the dialect support propagating changes to LOB values back to the database? Talking about mutating the internal value of the locator, as opposed to supplying a new locator instance.
      Overrides:
      supportsLobValueChangePropagation in class Dialect
      Returns:
      True if the changes are propagated back to the database; false otherwise.
    • supportsSkipLocked

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

      public String appendLockHint(LockOptions mode, 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.
      Overrides:
      appendLockHint in class AbstractTransactSQLDialect
      Parameters:
      mode - 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.
    • toQuotedIdentifier

      public String toQuotedIdentifier(String name)
      Description copied from class: Dialect
      Apply dialect-specific quoting.
      Overrides:
      toQuotedIdentifier in class Dialect
      Parameters:
      name - The value to be quoted.
      Returns:
      The quoted value.
      See Also:
    • getViolatedConstraintNameExtractor

      public ViolatedConstraintNameExtractor getViolatedConstraintNameExtractor()
      Description copied from class: Dialect
      A ViolatedConstraintNameExtractor for extracting the name of a violated constraint from a SQLException.
      Specified by:
      getViolatedConstraintNameExtractor in interface ConversionContext
      Overrides:
      getViolatedConstraintNameExtractor in class Dialect
    • buildSQLExceptionConversionDelegate

      public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate()
      Description copied from class: Dialect
      An instance of SQLExceptionConversionDelegate for interpreting dialect-specific error or SQLState codes.

      If this method is overridden to return a non-null value, the default SQLExceptionConverter will use the returned SQLExceptionConversionDelegate in addition to the following standard delegates:

      1. a "static" delegate based on the JDBC4-defined SQLException hierarchy, and
      2. a delegate that interprets SQLState codes as either X/Open or SQL-2003 codes, depending on what is reported by the JDBC driver.

      It is strongly recommended that every Dialect implementation override this method, since interpretation of a SQL error is much more accurate when based on the vendor-specific error code, rather than on the SQLState.

      Overrides:
      buildSQLExceptionConversionDelegate in class Dialect
      Returns:
      The SQLExceptionConversionDelegate for this dialect
    • getLimitHandler

      public LimitHandler getLimitHandler()
      Description copied from class: Dialect
      Obtain a LimitHandler that implements pagination support for Query.setMaxResults(int) and Query.setFirstResult(int).
      Overrides:
      getLimitHandler in class Dialect
    • getDual

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