Package org.hibernate.dialect
Class DB2iDialect
- java.lang.Object
-
- org.hibernate.dialect.Dialect
-
- org.hibernate.dialect.DB2Dialect
-
- org.hibernate.dialect.DB2iDialect
-
- All Implemented Interfaces:
FunctionContributor
,TypeContributor
,ConversionContext
public class DB2iDialect extends DB2Dialect
A SQL dialect for DB2 for IBM i version 7.1 and above, previously known as "DB2/400".
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.hibernate.dialect.Dialect
Dialect.SizeStrategy, Dialect.SizeStrategyImpl
-
-
Field Summary
-
Fields inherited from class org.hibernate.dialect.Dialect
CLOSED_QUOTE, FALSE_STRING_VALUES, LEGACY_LOB_MERGE_STRATEGY, LOG_BASE2OF10, NEW_LOCATOR_LOB_MERGE_STRATEGY, QUOTE, STANDARD_MULTI_KEY_LOAD_SIZING_STRATEGY, STREAM_XFER_LOB_MERGE_STRATEGY, TRUE_STRING_VALUES
-
-
Constructor Summary
Constructors Constructor Description DB2iDialect()
DB2iDialect(DatabaseVersion version)
DB2iDialect(DialectResolutionInfo info)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getCreateIndexString(boolean unique)
The command used to create an index, usuallycreate index
orcreate unique index
.String
getCreateIndexTail(boolean unique, List<Column> columns)
A string to be appended to the end of thecreate index
command, usually to specify thatnull
values are to be considered distinct.DatabaseVersion
getDB2Version()
DB2 LUW VersionString
getForUpdateSkipLockedString()
Retrieves theFOR UPDATE SKIP LOCKED
syntax specific to this dialect.String
getForUpdateSkipLockedString(String aliases)
Get theFOR UPDATE OF column_list SKIP LOCKED
fragment appropriate for this dialect, given the aliases of the columns to be write locked.String
getForUpdateString()
Get the string to append toSELECT
statements to acquire pessimistic UPGRADE locks for this dialect.IdentityColumnSupport
getIdentityColumnSupport()
Get the appropriateIdentityColumnSupport
for this dialect.LimitHandler
getLimitHandler()
Obtain aLimitHandler
that implements pagination support forQuery.setMaxResults(int)
andQuery.setFirstResult(int)
.protected DatabaseVersion
getMinimumSupportedVersion()
Get the version of the SQL dialect that is the minimum supported by this implementation.String
getQuerySequencesString()
Get theselect
command used retrieve the names of all sequences.String
getReadLockString(int timeout)
Get the string to append toSELECT
statements to acquire READ locks for this dialect.String
getRowIdColumnString(String rowId)
If this dialect requires that therowid
column be declared explicitly, return the DDL column definition.SequenceSupport
getSequenceSupport()
No support for sequences.SqlAstTranslatorFactory
getSqlAstTranslatorFactory()
String
getWriteLockString(int timeout)
Get the string to append toSELECT
statements to acquire pessimistic WRITE locks for this dialect.void
initializeFunctionRegistry(FunctionContributions functionContributions)
Initialize the given registry with any dialect-specific functions.String
rowId(String rowId)
The more "standard" syntax isrid_bit(alias)
but here we usealias.rowid
.int
rowIdSqlType()
The JDBC type code of therowid
-like pseudo-column which acts as a high-performance row locator.boolean
supportsDistinctFromPredicate()
Does this dialect support some kind ofdistinct from
predicate?boolean
supportsIfExistsBeforeTableName()
For dropping a table, can the phraseif exists
be applied before the table name?boolean
supportsSkipLocked()
Does this dialect supportSKIP_LOCKED
timeout.boolean
supportsUpdateReturning()
Does this dialect fully support returning arbitrary generated column values after execution of anupdate
statement, using native SQL syntax?-
Methods inherited from class org.hibernate.dialect.DB2Dialect
appendBinaryLiteral, appendBooleanValueString, appendDatetimeFormat, appendDateTimeLiteral, appendDateTimeLiteral, appendDateTimeLiteral, buildIdentifierHelper, buildSQLExceptionConversionDelegate, canDisableConstraints, castPattern, columnType, contributeTypes, createUniqueDelegate, doesReadCommittedCauseWritersToBlockReaders, doesRoundTemporalOnOverflow, dropConstraints, extractPattern, generatedAs, getAggregateSupport, getAlterColumnTypeString, getCallableStatementSupport, getCreateUserDefinedTypeExtensionsString, getCurrentTimestampSelectString, getDefaultDecimalPrecision, getDefaultStatementBatchSize, getDisableConstraintStatement, getDmlTargetColumnQualifierSupport, getDropSchemaCommand, getDual, getEnableConstraintStatement, getFallbackSqmInsertStrategy, getFallbackSqmMutationStrategy, getFractionalSecondPrecisionInNanos, getFromDualForSelectOnly, getInExpressionCountLimit, getMaxIdentifierLength, getMaxVarcharLength, getResultSet, getResultSet, getResultSet, getSelectClauseNullString, getSequenceInformationExtractor, getTruncateTableStatement, getUniqueDelegate, getViolatedConstraintNameExtractor, isCurrentTimestampSelectStringCallable, registerColumnTypes, registerDefaultKeywords, registerResultSetOutParameter, registerResultSetOutParameter, requiresCastForConcatenatingNonStrings, selectNullString, supportsAlterColumnType, supportsCommentOn, supportsCurrentTimestampSelection, supportsExistsInSelect, supportsFromClauseInUpdate, supportsInsertReturning, supportsInsertReturningRowId, supportsIsTrue, supportsLateral, supportsLobValueChangePropagation, supportsLockTimeouts, supportsNonQueryWithCTE, supportsNullPrecedence, supportsOffsetInSubquery, supportsOuterJoinForUpdate, supportsPartitionBy, supportsPredicateAsExpression, supportsRecursiveCTE, supportsRefCursors, supportsResultSetPositionQueryMethodsOnForwardOnlyCursor, supportsTupleDistinctCounts, supportsValuesList, supportsWindowFunctions, timestampaddPattern, timestampdiffPattern, timestampdiffPatternV10, translateExtractField
-
Methods inherited from class org.hibernate.dialect.Dialect
addSqlHintOrComment, appendArrayLiteral, appendIntervalLiteral, appendLiteral, appendLockHint, appendUUIDLiteral, applyLocksToSql, augmentPhysicalTableTypes, augmentRecognizedTableTypes, buildStringToBooleanCast, buildStringToBooleanCastDecode, buildStringToBooleanDecode, canBatchTruncate, canCreateCatalog, canCreateSchema, castType, checkVersion, closeQuote, contribute, contributeFunctions, createOptionalTableUpdateOperation, currentDate, currentLocalTime, currentLocalTimestamp, currentTime, currentTimestamp, currentTimestampWithTimeZone, defaultScrollMode, doesRepeatableReadCauseReadersToBlockWriters, equivalentTypes, escapeComment, forceLobAsLastValue, getAddColumnString, getAddColumnSuffixString, getAddForeignKeyConstraintString, getAddForeignKeyConstraintString, getAddPrimaryKeyConstraintString, getAlterTableString, getArrayTypeName, getAuxiliaryDatabaseObjectExporter, getBatchLoadSizingStrategy, getBeforeDropStatement, getCascadeConstraintsString, getCaseInsensitiveLike, getCheckCondition, getCheckCondition, getCheckCondition, getCheckCondition, getCheckCondition, getColumnAliasExtractor, getColumnComment, getCreateCatalogCommand, getCreateEnumTypeCommand, getCreateEnumTypeCommand, getCreateMultisetTableString, getCreateSchemaCommand, getCreateTableString, getCreateTemporaryTableColumnAnnotation, getCreateUserDefinedTypeKindString, getCrossReferenceParentTableFilter, getCurrentSchemaCommand, getDefaultIntervalSecondScale, getDefaultLobLength, getDefaultNonContextualLobCreation, getDefaultProperties, getDefaultTimestampPrecision, getDefaultUseGetGeneratedKeys, getDisableConstraintsStatement, getDoublePrecision, getDropCatalogCommand, getDropEnumTypeCommand, getDropEnumTypeCommand, getDropForeignKeyString, getDropTableString, getDropUniqueKeyString, getEnableConstraintsStatement, getEnumTypeDeclaration, getEnumTypeDeclaration, getFallbackSchemaManagementTool, getFloatPrecision, getForeignKeyExporter, getForUpdateNowaitString, getForUpdateNowaitString, getForUpdateString, getForUpdateString, getForUpdateString, getForUpdateString, getFunctionalDependencyAnalysisSupport, getGroupBySelectItemReferenceStrategy, getHqlTranslator, getIndexExporter, getKeywords, getLobMergeStrategy, getLockingStrategy, getLockRowIdentifier, getLowercaseFunction, getMaxAliasLength, getMaxNVarcharCapacity, getMaxNVarcharLength, getMaxVarbinaryCapacity, getMaxVarbinaryLength, getMaxVarcharCapacity, getMultiKeyLoadSizingStrategy, getNameQualifierSupport, getNationalizationSupport, getNativeIdentifierGeneratorStrategy, getNativeParameterMarkerStrategy, getNoColumnsInsertString, getNullColumnString, getNullColumnString, getNullOrdering, getParameterCountLimit, getPreferredSqlTypeCodeForArray, getPreferredSqlTypeCodeForBoolean, getQueryHintString, getQueryHintString, getReadLockString, getReadRowLockStrategy, getSchemaNameResolver, getSelectGUIDString, getSequenceExporter, getSizeStrategy, getSqmTranslatorFactory, getSupportedTemporaryTableKind, getTableCleaner, getTableComment, getTableExporter, getTableMigrator, getTableTypeString, getTemporaryTableAfterUseAction, getTemporaryTableBeforeUseAction, getTemporaryTableCreateCommand, getTemporaryTableCreateOptions, getTemporaryTableDdlTransactionHandling, getTemporaryTableDropCommand, getTemporaryTableExporter, getTemporaryTableTruncateCommand, getTimeoutInSeconds, getTimeZoneSupport, getTruncateTableStatements, getUniqueKeyExporter, getUserDefinedTypeComment, getUserDefinedTypeExporter, getVersion, getWriteLockString, getWriteRowLockStrategy, hasAlterTable, hasDataTypeBeforeGeneratedAs, hasSelfReferentialForeignKeyBug, initDefaultProperties, inlineLiteral, isAnsiNullOn, isEmptyStringTreatedAsNull, isJdbcLogWarningsEnabledByDefault, isLob, isLockTimeoutParameterized, openQuote, ordinal, prependComment, qualifyIndexName, quote, quoteCollation, registerKeyword, registerKeywords, requiresFloatCastingOfIntegerDivision, requiresParensForTupleCounts, requiresParensForTupleDistinctCounts, resolveSqlTypeCode, resolveSqlTypeCode, resolveSqlTypeDescriptor, resolveSqlTypeLength, supportsBatchUpdates, supportsBindAsCallableArgument, supportsBitType, supportsCascadeDelete, supportsCaseInsensitiveLike, supportsCircularCascadeDeleteConstraints, supportsColumnCheck, supportsConflictClauseForInsertCTE, supportsExpectedLobUsagePattern, supportsFetchClause, supportsFractionalTimestampArithmetic, supportsIfExistsAfterAlterTable, supportsIfExistsAfterConstraintName, supportsIfExistsAfterTableName, supportsIfExistsAfterTypeName, supportsIfExistsBeforeConstraintName, supportsIfExistsBeforeTypeName, supportsInsertReturningGeneratedKeys, supportsJdbcConnectionLobCreation, supportsMaterializedLobAccess, supportsNamedParameters, supportsNationalizedMethods, supportsNoColumnsInsert, supportsNoWait, supportsOrderByInSubquery, supportsOrdinalSelectItemReference, supportsParametersInInsertSelect, supportsStandardArrays, supportsStandardCurrentTimestampFunction, supportsSubqueryInSelect, supportsSubqueryOnMutatingTable, supportsSubselectAsInPredicateLHS, supportsTableCheck, supportsTemporalLiteralOffset, supportsTemporaryTablePrimaryKey, supportsTemporaryTables, supportsTruncateWithCast, supportsTupleCounts, supportsUnboundedLobLocatorMaterialization, supportsUnionAll, supportsUnionInSubquery, supportsValuesListForInsert, supportsWait, toBooleanValueString, toQuotedIdentifier, toString, transformSelectString, translateDurationField, trimPattern, trimPattern, unquoteGetGeneratedKeys, useArrayForMultiValuedParameters, useConnectionToCreateLob, useCrossReferenceForeignKeys, useFollowOnLocking, useInputStreamToInsertBlob, useMaterializedLobWhenCapacityExceeded
-
-
-
-
Constructor Detail
-
DB2iDialect
public DB2iDialect(DialectResolutionInfo info)
-
DB2iDialect
public DB2iDialect()
-
DB2iDialect
public DB2iDialect(DatabaseVersion version)
-
-
Method Detail
-
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 classDB2Dialect
-
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
-
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])
java.time
types:-
local date
-
local time
-
local datetime
-
offset datetime
-
instant
-
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)
extract()
, 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)
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 classDB2Dialect
-
-
getDB2Version
public DatabaseVersion getDB2Version()
Description copied from class:DB2Dialect
DB2 LUW Version- Overrides:
getDB2Version
in classDB2Dialect
-
getCreateIndexString
public String getCreateIndexString(boolean unique)
Description copied from class:Dialect
The command used to create an index, usuallycreate index
orcreate unique index
.- Overrides:
getCreateIndexString
in classDialect
- Parameters:
unique
-true
if the index is a unique index- Returns:
- The command used to create an index.
-
getCreateIndexTail
public String getCreateIndexTail(boolean unique, List<Column> columns)
Description copied from class:Dialect
A string to be appended to the end of thecreate index
command, usually to specify thatnull
values are to be considered distinct.- Overrides:
getCreateIndexTail
in classDB2Dialect
-
supportsIfExistsBeforeTableName
public boolean supportsIfExistsBeforeTableName()
Description copied from class:Dialect
For dropping a table, can the phraseif exists
be applied before the table name?- Overrides:
supportsIfExistsBeforeTableName
in classDB2Dialect
- Returns:
true
ifif exists
can be applied before the table name
-
supportsDistinctFromPredicate
public boolean supportsDistinctFromPredicate()
Description copied from class:Dialect
Does this dialect support some kind ofdistinct from
predicate?That is, does it support syntax like:
... where FIRST_NAME IS DISTINCT FROM LAST_NAME
- Overrides:
supportsDistinctFromPredicate
in classDB2Dialect
- Returns:
- True if this SQL dialect is known to support some kind of
distinct from
predicate; false otherwise
-
supportsUpdateReturning
public boolean supportsUpdateReturning()
Description copied from class:Dialect
Does this dialect fully support returning arbitrary generated column values after execution of anupdate
statement, using native SQL syntax?Defaults to the value of
Dialect.supportsInsertReturning()
but can be overridden to explicitly disable this for updates.- Overrides:
supportsUpdateReturning
in classDialect
- See Also:
Dialect.supportsInsertReturning()
-
getSequenceSupport
public SequenceSupport getSequenceSupport()
No support for sequences.- Overrides:
getSequenceSupport
in classDB2Dialect
-
getQuerySequencesString
public String getQuerySequencesString()
Description copied from class:Dialect
Get theselect
command used retrieve the names of all sequences.- Overrides:
getQuerySequencesString
in classDB2Dialect
- Returns:
- The select command; or null if sequences are not supported.
-
getLimitHandler
public LimitHandler getLimitHandler()
Description copied from class:Dialect
Obtain aLimitHandler
that implements pagination support forQuery.setMaxResults(int)
andQuery.setFirstResult(int)
.- Overrides:
getLimitHandler
in classDB2Dialect
-
getIdentityColumnSupport
public IdentityColumnSupport getIdentityColumnSupport()
Description copied from class:Dialect
Get the appropriateIdentityColumnSupport
for this dialect.- Overrides:
getIdentityColumnSupport
in classDB2Dialect
- Returns:
- the IdentityColumnSupport
-
supportsSkipLocked
public boolean supportsSkipLocked()
Description copied from class:Dialect
Does this dialect supportSKIP_LOCKED
timeout.- Overrides:
supportsSkipLocked
in classDB2Dialect
- Returns:
true
if SKIP_LOCKED is supported
-
getSqlAstTranslatorFactory
public SqlAstTranslatorFactory getSqlAstTranslatorFactory()
Description copied from class:Dialect
- Overrides:
getSqlAstTranslatorFactory
in classDB2Dialect
- See Also:
StandardSqlAstTranslatorFactory
,JdbcEnvironment.getSqlAstTranslatorFactory()
-
rowId
public String rowId(String rowId)
Description copied from class:DB2Dialect
The more "standard" syntax isrid_bit(alias)
but here we usealias.rowid
.There is also an alternative
rid()
of typebigint
, but it cannot be used with partitioning.- Overrides:
rowId
in classDB2Dialect
- Parameters:
rowId
- the name specified byRowId.value()
, which is ignored ifDialect.getRowIdColumnString(java.lang.String)
is not overridden
-
rowIdSqlType
public int rowIdSqlType()
Description copied from class:Dialect
The JDBC type code of therowid
-like pseudo-column which acts as a high-performance row locator.- Overrides:
rowIdSqlType
in classDB2Dialect
- Returns:
Types.ROWID
by default
-
getRowIdColumnString
public String getRowIdColumnString(String rowId)
Description copied from class:Dialect
If this dialect requires that therowid
column be declared explicitly, return the DDL column definition.- Overrides:
getRowIdColumnString
in classDialect
- Returns:
- the DDL column definition, or
null
if therowid
is an implicit pseudo-column
-
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 classDB2Dialect
- Returns:
- The appropriate
FOR UPDATE
clause string.
-
getForUpdateSkipLockedString
public String getForUpdateSkipLockedString()
Description copied from class:Dialect
Retrieves theFOR UPDATE SKIP LOCKED
syntax specific to this dialect.- Overrides:
getForUpdateSkipLockedString
in classDB2Dialect
- Returns:
- The appropriate
FOR UPDATE SKIP LOCKED
clause string.
-
getForUpdateSkipLockedString
public String getForUpdateSkipLockedString(String aliases)
Description copied from class:Dialect
Get theFOR UPDATE OF column_list SKIP LOCKED
fragment appropriate for this dialect, given the aliases of the columns to be write locked.- Overrides:
getForUpdateSkipLockedString
in classDB2Dialect
- Parameters:
aliases
- The columns to be write locked.- Returns:
- The appropriate
FOR UPDATE colunm_list SKIP LOCKED
clause string.
-
getWriteLockString
public String getWriteLockString(int timeout)
Description copied from class:Dialect
Get the string to append toSELECT
statements to acquire pessimistic WRITE locks for this dialect.Location of the returned string is treated the same as
Dialect.getForUpdateString()
.- Overrides:
getWriteLockString
in classDB2Dialect
- Parameters:
timeout
- in milliseconds, -1 for indefinite wait and 0 for no wait.- Returns:
- The appropriate
LOCK
clause string.
-
getReadLockString
public String getReadLockString(int timeout)
Description copied from class:Dialect
Get the string to append toSELECT
statements to acquire READ locks for this dialect.Location of the returned string is treated the same as
Dialect.getForUpdateString()
.- Overrides:
getReadLockString
in classDB2Dialect
- Parameters:
timeout
- in milliseconds, -1 for indefinite wait and 0 for no wait.- Returns:
- The appropriate
LOCK
clause string.
-
-