Top Description Fields Constructors Methods
org.hibernate.dialect

public Class DB2zDialect

extends DB2Dialect
Class Inheritance
Imports
org.hibernate.boot.model.FunctionContributions, org.hibernate.dialect.function.CommonFunctionFactory, org.hibernate.dialect.identity.DB2zIdentityColumnSupport, .IdentityColumnSupport, org.hibernate.dialect.pagination.LimitHandler, .OffsetFetchLimitHandler, org.hibernate.dialect.sequence.DB2zSequenceSupport, .SequenceSupport, org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo, org.hibernate.engine.spi.SessionFactoryImplementor, org.hibernate.mapping.Column, org.hibernate.query.sqm.IntervalType, .TemporalUnit, org.hibernate.sql.ast.SqlAstTranslator, .SqlAstTranslatorFactory, org.hibernate.sql.ast.spi.StandardSqlAstTranslatorFactory, org.hibernate.sql.ast.tree.Statement, org.hibernate.sql.exec.spi.JdbcOperation, jakarta.persistence.TemporalType, java.util.List

A SQL dialect for DB2 for z/OS version 12.1 and above, previously known as:
Author
Christian Beikov

Field Summary

Modifier and TypeField and Description
pack-priv static final DatabaseVersion
private static final DatabaseVersion

Constructor Summary

AccessConstructor and Description
public
public
public

Method Summary

Modifier and TypeMethod and Description
protected String
columnType(int
a SQL type code
sqlTypeCode
)

Overrides org.hibernate.dialect.DB2Dialect.columnType.

The database column type name for a given JDBC type code defined in Types or SqlTypes.
public String
getCreateIndexString(boolean
true if the index is a unique index
unique
)

Overrides org.hibernate.dialect.Dialect.getCreateIndexString.

The command used to create an index, usually create index or create unique index.
public String
getCreateIndexTail(boolean unique, List<Column> columns)

Overrides org.hibernate.dialect.DB2Dialect.getCreateIndexTail.

A string to be appended to the end of the create index command, usually to specify that null values are to be considered distinct.
public DatabaseVersion
public IdentityColumnSupport
public LimitHandler
protected DatabaseVersion
getMinimumSupportedVersion()

Overrides org.hibernate.dialect.DB2Dialect.getMinimumSupportedVersion.

Get the version of the SQL dialect that is the minimum supported by this implementation.
public String
getQuerySequencesString()

Overrides org.hibernate.dialect.DB2Dialect.getQuerySequencesString.

Get the select command used retrieve the names of all sequences.
public String
getRowIdColumnString(String rowId)

Overrides org.hibernate.dialect.Dialect.getRowIdColumnString.

If this dialect requires that the rowid column be declared explicitly, return the DDL column definition.
public SequenceSupport
public SqlAstTranslatorFactory
public TimeZoneSupport
public void
initializeFunctionRegistry(FunctionContributions functionContributions)

Overrides org.hibernate.dialect.DB2Dialect.initializeFunctionRegistry.

Initialize the given registry with any dialect-specific functions.
public String
rowId(String
the name specified by org.hibernate.annotations.RowId#value(), which is ignored if getRowIdColumnString is not overridden
rowId
)

Overrides org.hibernate.dialect.DB2Dialect.rowId.

The more "standard" syntax is rid_bit(alias) but here we use alias.rowid.
public int
rowIdSqlType()

Overrides org.hibernate.dialect.DB2Dialect.rowIdSqlType.

The JDBC type code of the rowid-like pseudo-column which acts as a high-performance row locator.
public boolean
supportsDistinctFromPredicate()

Overrides org.hibernate.dialect.DB2Dialect.supportsDistinctFromPredicate.

Does this dialect support some kind of distinct from predicate?
public boolean
supportsLateral()

Overrides org.hibernate.dialect.DB2Dialect.supportsLateral.

Does this dialect support the SQL lateral keyword or a proprietary alternative?
public boolean
supportsRecursiveCTE()

Overrides org.hibernate.dialect.DB2Dialect.supportsRecursiveCTE.

Does this dialect/database support recursive CTEs?
public boolean
supportsSkipLocked()

Overrides org.hibernate.dialect.DB2Dialect.supportsSkipLocked.

Does this dialect support SKIP_LOCKED timeout.
public String
timestampaddPattern(TemporalUnit
The unit to add to the temporal
unit
,
TemporalType
The type of the temporal
temporalType
,
IntervalType
The type of interval to add or null if it's not a native interval
intervalType
)

Overrides org.hibernate.dialect.DB2Dialect.timestampaddPattern.

Obtain a pattern for the SQL equivalent to a timestampadd() function call.
Inherited from org.hibernate.dialect.DB2Dialect:
appendBinaryLiteralappendBooleanValueStringappendDatetimeFormatappendDateTimeLiteralappendDateTimeLiteralappendDateTimeLiteralbuildIdentifierHelperbuildSQLExceptionConversionDelegatecanDisableConstraintscontributeTypescreateUniqueDelegatedoesReadCommittedCauseWritersToBlockReadersdropConstraintsextractPatterngeneratedAsgetAggregateSupportgetAlterColumnTypeStringgetCallableStatementSupportgetCreateUserDefinedTypeExtensionsStringgetCurrentTimestampSelectStringgetDefaultDecimalPrecisiongetDefaultStatementBatchSizegetDisableConstraintStatementgetDropSchemaCommandgetEnableConstraintStatementgetFallbackSqmInsertStrategygetFallbackSqmMutationStrategygetForUpdateSkipLockedStringgetForUpdateSkipLockedStringgetForUpdateStringgetFractionalSecondPrecisionInNanosgetInExpressionCountLimitgetMaxIdentifierLengthgetMaxVarcharLengthgetReadLockStringgetResultSetgetSelectClauseNullStringgetSequenceInformationExtractorgetTruncateTableStatementgetUniqueDelegategetWriteLockStringisCurrentTimestampSelectStringCallableregisterColumnTypesregisterDefaultKeywordsregisterResultSetOutParameterrequiresCastForConcatenatingNonStringsselectNullStringsupportsAlterColumnTypesupportsCommentOnsupportsCurrentTimestampSelectionsupportsExistsInSelectsupportsInsertReturningsupportsIsTruesupportsLobValueChangePropagationsupportsLockTimeoutssupportsNonQueryWithCTEsupportsNullPrecedencesupportsOffsetInSubquerysupportsOuterJoinForUpdatesupportsPartitionBysupportsPredicateAsExpressionsupportsResultSetPositionQueryMethodsOnForwardOnlyCursorsupportsTupleDistinctCountssupportsValuesListsupportsWindowFunctionstimestampdiffPatterntimestampdiffPatternV10translateExtractField

Field Detail

DB2_LUW_VERSIONback to summary
pack-priv static final DatabaseVersion DB2_LUW_VERSION
MINIMUM_VERSIONback to summary
private static final DatabaseVersion MINIMUM_VERSION

Hides org.hibernate.dialect.DB2Dialect.MINIMUM_VERSION.

Constructor Detail

DB2zDialectback to summary
public DB2zDialect(DialectResolutionInfo info)
DB2zDialectback to summary
public DB2zDialect()
DB2zDialectback to summary
public DB2zDialect(DatabaseVersion version)

Method Detail

columnTypeback to summary
protected String columnType(int sqlTypeCode)

Overrides org.hibernate.dialect.DB2Dialect.columnType.

Doc from org.hibernate.dialect.Dialect.columnType.

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 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.
Parameters
sqlTypeCode:int

a SQL type code

Returns:String

a column type name, with $l, $p, $s placeholders for length, precision, scale

Annotations
@Override
getCreateIndexStringback to summary
public String getCreateIndexString(boolean unique)

Overrides org.hibernate.dialect.Dialect.getCreateIndexString.

Doc from org.hibernate.dialect.Dialect.getCreateIndexString.

The command used to create an index, usually create index or create unique index.

Parameters
unique:boolean

true if the index is a unique index

Returns:String

The command used to create an index.

Annotations
@Override
getCreateIndexTailback to summary
public String getCreateIndexTail(boolean unique, List<Column> columns)

Overrides org.hibernate.dialect.DB2Dialect.getCreateIndexTail.

Doc from org.hibernate.dialect.Dialect.getCreateIndexTail.

A string to be appended to the end of the create index command, usually to specify that null values are to be considered distinct.

Annotations
@Override
getDB2Versionback to summary
public DatabaseVersion getDB2Version()

Overrides org.hibernate.dialect.DB2Dialect.getDB2Version.

Doc from org.hibernate.dialect.DB2Dialect.getDB2Version.

DB2 LUW Version

Annotations
@Override
getIdentityColumnSupportback to summary
public IdentityColumnSupport getIdentityColumnSupport()

Overrides org.hibernate.dialect.DB2Dialect.getIdentityColumnSupport.

Doc from org.hibernate.dialect.Dialect.getIdentityColumnSupport.

Get the appropriate IdentityColumnSupport for this dialect.

Returns:IdentityColumnSupport

the IdentityColumnSupport

Annotations
@Override
getLimitHandlerback to summary
public LimitHandler getLimitHandler()

Overrides org.hibernate.dialect.DB2Dialect.getLimitHandler.

Doc from org.hibernate.dialect.Dialect.getLimitHandler.

Obtain a LimitHandler that implements pagination support for Query#setMaxResults(int) and Query#setFirstResult(int).

Annotations
@Override
getMinimumSupportedVersionback to summary
protected DatabaseVersion getMinimumSupportedVersion()

Overrides org.hibernate.dialect.DB2Dialect.getMinimumSupportedVersion.

Doc from org.hibernate.dialect.Dialect.getMinimumSupportedVersion.

Get the version of the SQL dialect that is the minimum supported by this implementation.

Annotations
@Override
getQuerySequencesStringback to summary
public String getQuerySequencesString()

Overrides org.hibernate.dialect.DB2Dialect.getQuerySequencesString.

Doc from org.hibernate.dialect.Dialect.getQuerySequencesString.

Get the select command used retrieve the names of all sequences.

Returns:String

The select command; or null if sequences are not supported.

Annotations
@Override
getRowIdColumnStringback to summary
public String getRowIdColumnString(String rowId)

Overrides org.hibernate.dialect.Dialect.getRowIdColumnString.

Doc from org.hibernate.dialect.Dialect.getRowIdColumnString.

If this dialect requires that the rowid column be declared explicitly, return the DDL column definition.

Returns:String

the DDL column definition, or null if the rowid is an implicit pseudo-column

Annotations
@Override
getSequenceSupportback to summary
public SequenceSupport getSequenceSupport()

Overrides org.hibernate.dialect.DB2Dialect.getSequenceSupport.

Doc from org.hibernate.dialect.Dialect.getSequenceSupport.

Get the appropriate SequenceSupport for this dialect.

Annotations
@Override
getSqlAstTranslatorFactoryback to summary
public SqlAstTranslatorFactory getSqlAstTranslatorFactory()

Overrides org.hibernate.dialect.DB2Dialect.getSqlAstTranslatorFactory.

Doc from org.hibernate.dialect.Dialect.getSqlAstTranslatorFactory.

Return a SqlAstTranslatorFactory specific to this dialect, or null to use the standard translator.

Annotations
@Override
getTimeZoneSupportback to summary
public TimeZoneSupport getTimeZoneSupport()

Overrides org.hibernate.dialect.Dialect.getTimeZoneSupport.

Doc from org.hibernate.dialect.Dialect.getTimeZoneSupport.

How the dialect supports time zone types like Types#TIMESTAMP_WITH_TIMEZONE.

Annotations
@Override
initializeFunctionRegistryback to summary
public void initializeFunctionRegistry(FunctionContributions functionContributions)

Overrides org.hibernate.dialect.DB2Dialect.initializeFunctionRegistry.

Doc from org.hibernate.dialect.Dialect.initializeFunctionRegistry.

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)
  • 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.
Annotations
@Override
rowIdback to summary
public String rowId(String rowId)

Overrides org.hibernate.dialect.DB2Dialect.rowId.

Doc from org.hibernate.dialect.DB2Dialect.rowId.

The more "standard" syntax is rid_bit(alias) but here we use alias.rowid.

There is also an alternative rid() of type bigint, but it cannot be used with partitioning.

Parameters
rowId:String

Doc from org.hibernate.dialect.Dialect.rowId.

the name specified by org.hibernate.annotations.RowId#value(), which is ignored if getRowIdColumnString is not overridden

Annotations
@Override
rowIdSqlTypeback to summary
public int rowIdSqlType()

Overrides org.hibernate.dialect.DB2Dialect.rowIdSqlType.

Doc from org.hibernate.dialect.Dialect.rowIdSqlType.

The JDBC type code of the rowid-like pseudo-column which acts as a high-performance row locator.

Returns:int

Types#ROWID by default

Annotations
@Override
supportsDistinctFromPredicateback to summary
public boolean supportsDistinctFromPredicate()

Overrides org.hibernate.dialect.DB2Dialect.supportsDistinctFromPredicate.

Doc from org.hibernate.dialect.Dialect.supportsDistinctFromPredicate.

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
Returns:boolean

True if this SQL dialect is known to support some kind of distinct from predicate; false otherwise

Annotations
@Override
supportsLateralback to summary
public boolean supportsLateral()

Overrides org.hibernate.dialect.DB2Dialect.supportsLateral.

Doc from org.hibernate.dialect.Dialect.supportsLateral.

Does this dialect support the SQL lateral keyword or a proprietary alternative?

Returns:boolean

true if the underlying database supports lateral, false otherwise. The default is false.

Annotations
@Override
supportsRecursiveCTEback to summary
public boolean supportsRecursiveCTE()

Overrides org.hibernate.dialect.DB2Dialect.supportsRecursiveCTE.

Doc from org.hibernate.dialect.Dialect.supportsRecursiveCTE.

Does this dialect/database support recursive CTEs?

Returns:boolean

true if recursive CTEs are supported

Annotations
@Override
supportsSkipLockedback to summary
public boolean supportsSkipLocked()

Overrides org.hibernate.dialect.DB2Dialect.supportsSkipLocked.

Doc from org.hibernate.dialect.Dialect.supportsSkipLocked.

Does this dialect support SKIP_LOCKED timeout.

Returns:boolean

true if SKIP_LOCKED is supported

Annotations
@Override
timestampaddPatternback to summary
public String timestampaddPattern(TemporalUnit unit, TemporalType temporalType, IntervalType intervalType)

Overrides org.hibernate.dialect.DB2Dialect.timestampaddPattern.

Doc from org.hibernate.dialect.Dialect.timestampaddPattern.

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.

Parameters
unit:TemporalUnit

The unit to add to the temporal

temporalType:TemporalType

The type of the temporal

intervalType:IntervalType

The type of interval to add or null if it's not a native interval

Annotations
@Override