Top Description Fields Constructors Methods
org.hibernate.dialect

public Class DB2iDialect

extends DB2Dialect
Class Inheritance
Imports
org.hibernate.boot.model.FunctionContributions, org.hibernate.dialect.function.CommonFunctionFactory, org.hibernate.dialect.identity.DB2IdentityColumnSupport, .DB2zIdentityColumnSupport, .IdentityColumnSupport, org.hibernate.dialect.pagination.FetchLimitHandler, .LegacyDB2LimitHandler, .LimitHandler, org.hibernate.dialect.sequence.DB2iSequenceSupport, .NoSequenceSupport, .SequenceSupport, org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo, org.hibernate.engine.spi.SessionFactoryImplementor, org.hibernate.mapping.Column, org.hibernate.sql.ast.SqlAstTranslator, .SqlAstTranslatorFactory, org.hibernate.sql.ast.spi.StandardSqlAstTranslatorFactory, org.hibernate.sql.ast.tree.Statement, org.hibernate.sql.exec.spi.JdbcOperation, java.util.List

A SQL dialect for DB2 for IBM i version 7.1 and above, previously known as "DB2/400".
Authors
Peter DeGregorio (pdegregorio), 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
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 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.
Inherited from org.hibernate.dialect.DB2Dialect:
appendBinaryLiteralappendBooleanValueStringappendDatetimeFormatappendDateTimeLiteralappendDateTimeLiteralappendDateTimeLiteralbuildIdentifierHelperbuildSQLExceptionConversionDelegatecanDisableConstraintscolumnTypecontributeTypescreateUniqueDelegatedoesReadCommittedCauseWritersToBlockReadersdropConstraintsextractPatterngeneratedAsgetAggregateSupportgetAlterColumnTypeStringgetCallableStatementSupportgetCreateUserDefinedTypeExtensionsStringgetCurrentTimestampSelectStringgetDefaultDecimalPrecisiongetDefaultStatementBatchSizegetDisableConstraintStatementgetDropSchemaCommandgetEnableConstraintStatementgetFallbackSqmInsertStrategygetFallbackSqmMutationStrategygetForUpdateSkipLockedStringgetForUpdateSkipLockedStringgetForUpdateStringgetFractionalSecondPrecisionInNanosgetInExpressionCountLimitgetMaxIdentifierLengthgetMaxVarcharLengthgetReadLockStringgetResultSetgetSelectClauseNullStringgetSequenceInformationExtractorgetTruncateTableStatementgetUniqueDelegategetWriteLockStringisCurrentTimestampSelectStringCallableregisterColumnTypesregisterDefaultKeywordsregisterResultSetOutParameterrequiresCastForConcatenatingNonStringsselectNullStringsupportsAlterColumnTypesupportsCommentOnsupportsCurrentTimestampSelectionsupportsExistsInSelectsupportsInsertReturningsupportsIsTruesupportsLobValueChangePropagationsupportsLockTimeoutssupportsNonQueryWithCTEsupportsNullPrecedencesupportsOffsetInSubquerysupportsOuterJoinForUpdatesupportsPartitionBysupportsPredicateAsExpressionsupportsResultSetPositionQueryMethodsOnForwardOnlyCursorsupportsTupleDistinctCountssupportsValuesListsupportsWindowFunctionstimestampaddPatterntimestampdiffPatterntimestampdiffPatternV10translateExtractField

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

DB2iDialectback to summary
public DB2iDialect(DialectResolutionInfo info)
DB2iDialectback to summary
public DB2iDialect()
DB2iDialectback to summary
public DB2iDialect(DatabaseVersion version)

Method Detail

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.

No support for sequences.

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
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