public class DB2Dialect extends Dialect
CLOSED_QUOTE, DEFAULT_BATCH_SIZE, LEGACY_LOB_MERGE_STRATEGY, NEW_LOCATOR_LOB_MERGE_STRATEGY, NO_BATCH, QUOTE, STREAM_XFER_LOB_MERGE_STRATEGY
Constructor and Description |
---|
DB2Dialect()
Constructs a DB2Dialect
|
Modifier and Type | Method and Description |
---|---|
SQLExceptionConversionDelegate |
buildSQLExceptionConversionDelegate()
Build an instance of a
SQLExceptionConversionDelegate for
interpreting dialect-specific error or SQLState codes. |
int |
convertToFirstRowValue(int zeroBasedFirstResult)
Hibernate APIs explicitly state that setFirstResult() should be a zero-based offset.
|
boolean |
doesReadCommittedCauseWritersToBlockReaders()
For the underlying database, is READ_COMMITTED isolation implemented by
forcing readers to wait for write locks to be released?
|
boolean |
dropConstraints()
Do we need to drop constraints before dropping tables in this dialect?
|
String |
generateTemporaryTableName(String baseTableName)
Generate a temporary table name given the base table.
|
String |
getAddColumnString()
The syntax used to add a column to a table (optional).
|
String |
getCreateSequenceString(String sequenceName)
Typically dialects which support sequences can create a sequence
with a single command.
|
String |
getCreateTemporaryTablePostfix()
Get any fragments needing to be postfixed to the command for
temporary table creation.
|
String |
getCreateTemporaryTableString()
Command used to create a temporary table.
|
String |
getCrossJoinSeparator()
Returns the separator to use for defining cross joins when translating HQL queries.
|
String |
getCurrentTimestampSelectString()
Retrieve the command used to retrieve the current timestamp from the
database.
|
String |
getDropSequenceString(String sequenceName)
Typically dialects which support sequences can drop a sequence
with a single command.
|
String |
getForUpdateString()
Get the string to append to SELECT statements to acquire locks
for this dialect.
|
String |
getIdentityColumnString()
The syntax used during DDL to define a column as being an IDENTITY.
|
String |
getIdentityInsertString()
The keyword used to insert a generated value into an identity column (or null).
|
String |
getIdentitySelectString()
Get the select command to use to retrieve the last generated IDENTITY
value.
|
String |
getLimitString(String sql,
int offset,
int limit)
Given a limit and an offset, apply the limit clause to the query.
|
String |
getLowercaseFunction()
The name of the SQL function that transforms a string to
lowercase
|
String |
getNotExpression(String expression)
Negate an expression
|
String |
getQuerySequencesString()
Get the select command used retrieve the names of all sequences.
|
ResultSet |
getResultSet(CallableStatement ps)
Given a callable statement previously processed by
Dialect.registerResultSetOutParameter(java.sql.CallableStatement, int) ,
extract the ResultSet from the OUT parameter. |
String |
getSelectClauseNullString(int sqlType)
Given a
Types type code, determine an appropriate
null value to use in a select clause. |
String |
getSequenceNextValString(String sequenceName)
Generate the appropriate select statement to to retrieve the next value
of a sequence.
|
protected SqlTypeDescriptor |
getSqlTypeDescriptorOverride(int sqlCode)
Returns the
SqlTypeDescriptor that should be used to handle the given JDBC type code. |
UniqueDelegate |
getUniqueDelegate()
Get the UniqueDelegate supported by this dialect
|
boolean |
isCurrentTimestampSelectStringCallable()
Should the value returned by
Dialect.getCurrentTimestampSelectString()
be treated as callable. |
int |
registerResultSetOutParameter(CallableStatement statement,
int col)
Registers a parameter (either OUT, or the new REF_CURSOR param type available in Java 8) capable of
returning
ResultSet *by position*. |
boolean |
requiresCastingOfParametersInSelectClause()
Does this dialect require that parameters appearing in the SELECT clause be wrapped in cast()
calls to tell the db parser the expected type.
|
boolean |
supportsCommentOn()
Does this dialect/database support commenting on tables, columns, etc?
|
boolean |
supportsCurrentTimestampSelection()
Does this dialect support a way to retrieve the database's current
timestamp value?
|
boolean |
supportsEmptyInList()
Does this dialect support empty IN lists?
For example, is [where XYZ in ()] a supported construct?
|
boolean |
supportsExistsInSelect()
Does the dialect support an exists statement in the select clause?
|
boolean |
supportsIdentityColumns()
Does this dialect support identity column key generation?
|
boolean |
supportsLimit()
Does this dialect support some form of limiting query results
via a SQL clause?
|
boolean |
supportsLobValueChangePropogation()
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...
|
boolean |
supportsLockTimeouts()
Informational metadata about whether this dialect is known to support
specifying timeouts for requested lock acquisitions.
|
boolean |
supportsOuterJoinForUpdate()
Does this dialect support FOR UPDATE in conjunction with
outer joined rows?
|
boolean |
supportsParametersInInsertSelect()
Does this dialect support parameters within the SELECT clause of
INSERT ...
|
boolean |
supportsPooledSequences()
Does this dialect support "pooled" sequences.
|
boolean |
supportsResultSetPositionQueryMethodsOnForwardOnlyCursor()
Does this dialect support asking the result set its positioning
information on forward only cursors.
|
boolean |
supportsSequences()
Does this dialect support sequences?
|
boolean |
supportsTemporaryTables()
Does this dialect support temporary tables?
|
boolean |
supportsTupleDistinctCounts()
Does this dialect support `count(distinct a,b)`?
|
boolean |
supportsUnionAll()
Does this dialect support UNION ALL, which is generally a faster
variant of UNION?
|
boolean |
supportsVariableLimit()
Does this dialect support bind variables (i.e., prepared statement
parameters) for its limit/offset?
|
boolean |
useMaxForLimit()
Does the LIMIT clause take a "maximum" row number instead
of a total number of returned rows?
This is easiest understood via an example.
|
appendIdentitySelectToInsert, appendLockHint, appendLockHint, applyLocksToSql, areStringComparisonsCaseInsensitive, bindLimitParametersFirst, bindLimitParametersInReverseOrder, buildLimitHandler, buildSQLExceptionConverter, cast, cast, cast, closeQuote, contributeTypes, createCaseFragment, createOuterJoinFragment, defaultScrollMode, doesRepeatableReadCauseReadersToBlockWriters, dropTemporaryTableAfterUse, forceLimitUsage, forceLobAsLastValue, forUpdateOfColumns, getAddColumnSuffixString, getAddForeignKeyConstraintString, getAddPrimaryKeyConstraintString, getAddUniqueConstraintString, getCallableStatementSupport, getCascadeConstraintsString, getCaseInsensitiveLike, getCastTypeName, getColumnAliasExtractor, getColumnComment, getCreateMultisetTableString, getCreateSchemaCommand, getCreateSequenceString, getCreateSequenceStrings, getCreateSequenceStrings, getCreateTableString, getCurrentTimestampSQLFunctionName, getDefaultProperties, getDialect, getDialect, getDropForeignKeyString, getDropSchemaCommand, getDropSequenceStrings, getDropTableString, getDropTemporaryTableString, getForUpdateNowaitString, getForUpdateNowaitString, getForUpdateSkipLockedString, getForUpdateSkipLockedString, getForUpdateString, getForUpdateString, getForUpdateString, getForUpdateString, getFunctions, getHibernateTypeName, getHibernateTypeName, getIdentityColumnString, getIdentitySelectString, getInExpressionCountLimit, getKeywords, getLimitString, getLobMergeStrategy, getLockingStrategy, getMaxAliasLength, getNativeIdentifierGeneratorClass, getNoColumnsInsertString, getNullColumnString, getQueryHintString, getReadLockString, getResultSet, getResultSet, getSelectGUIDString, getSelectSequenceNextValString, getTableComment, getTableTypeString, getTypeName, getTypeName, getViolatedConstraintNameExtracter, getWriteLockString, hasAlterTable, hasDataTypeInIdentityColumn, hasSelfReferentialForeignKeyBug, isLockTimeoutParameterized, openQuote, performTemporaryTableDDLInIsolation, qualifyIndexName, quote, registerColumnType, registerColumnType, registerFunction, registerHibernateType, registerHibernateType, registerKeyword, registerResultSetOutParameter, remapSqlTypeDescriptor, renderOrderByElement, replaceResultVariableInOrderByClauseWithPosition, requiresParensForTupleDistinctCounts, supportsBindAsCallableArgument, supportsCascadeDelete, supportsCaseInsensitiveLike, supportsCircularCascadeDeleteConstraints, supportsColumnCheck, supportsExpectedLobUsagePattern, supportsIfExistsAfterConstraintName, supportsIfExistsAfterTableName, supportsIfExistsBeforeConstraintName, supportsIfExistsBeforeTableName, supportsInsertSelectIdentity, supportsLimitOffset, supportsNotNullUnique, supportsRowValueConstructorSyntax, supportsRowValueConstructorSyntaxInInList, supportsSubqueryOnMutatingTable, supportsSubselectAsInPredicateLHS, supportsTableCheck, supportsTupleCounts, supportsTuplesInSubqueries, supportsUnboundedLobLocatorMaterialization, supportsUnique, supportsUniqueConstraintInCreateAlterTable, toBooleanValueString, toString, transformSelectString, useFollowOnLocking, useInputStreamToInsertBlob
public String getLowercaseFunction()
Dialect
getLowercaseFunction
in class Dialect
public String getAddColumnString()
Dialect
getAddColumnString
in class Dialect
public boolean dropConstraints()
Dialect
dropConstraints
in class Dialect
public boolean supportsIdentityColumns()
Dialect
supportsIdentityColumns
in class Dialect
public String getIdentitySelectString()
Dialect
getIdentitySelectString
in class Dialect
public String getIdentityColumnString()
Dialect
getIdentityColumnString
in class Dialect
public String getIdentityInsertString()
Dialect
getIdentityInsertString
in class Dialect
public String getSequenceNextValString(String sequenceName)
Dialect
getSequenceNextValString
in class Dialect
sequenceName
- the name of the sequencepublic String getCreateSequenceString(String sequenceName)
Dialect
Dialect.getCreateSequenceStrings(java.lang.String)
to help facilitate that.
Dialects which support sequences and can create a sequence in a
single command need *only* override this method. Dialects
which support sequences but require multiple commands to create
a sequence should instead override Dialect.getCreateSequenceStrings(java.lang.String)
.getCreateSequenceString
in class Dialect
sequenceName
- The name of the sequencepublic String getDropSequenceString(String sequenceName)
Dialect
Dialect.getDropSequenceStrings(java.lang.String)
to help facilitate that.
Dialects which support sequences and can drop a sequence in a
single command need *only* override this method. Dialects
which support sequences but require multiple commands to drop
a sequence should instead override Dialect.getDropSequenceStrings(java.lang.String)
.getDropSequenceString
in class Dialect
sequenceName
- The name of the sequencepublic boolean supportsSequences()
Dialect
supportsSequences
in class Dialect
public boolean supportsPooledSequences()
Dialect
supportsPooledSequences
in class Dialect
Dialect.getCreateSequenceStrings(String, int, int)
,
Dialect.getCreateSequenceString(String, int, int)
public String getQuerySequencesString()
Dialect
getQuerySequencesString
in class Dialect
SchemaUpdate
public boolean supportsLimit()
Dialect
supportsLimit
in class Dialect
public boolean supportsVariableLimit()
Dialect
supportsVariableLimit
in class Dialect
public String getLimitString(String sql, int offset, int limit)
Dialect
getLimitString
in class Dialect
sql
- The query to which to apply the limit.offset
- The offset of the limitlimit
- The limit of the limit ;)public int convertToFirstRowValue(int zeroBasedFirstResult)
Dialect.getLimitString(String,int,int)
is the zero-based offset. Dialects which
do not Dialect.supportsVariableLimit()
should take care to perform any needed first-row-conversion calls prior
to injecting the limit values into the SQL string.
DB2 does have a one-based offset, however this was actually already handled in the limit string building
(the '?+1' bit). To not mess up inheritors, I'll leave that part alone and not touch the offset here.convertToFirstRowValue
in class Dialect
zeroBasedFirstResult
- The user-supplied, zero-based first row offset.Query.setFirstResult(int)
,
Criteria.setFirstResult(int)
public String getForUpdateString()
Dialect
getForUpdateString
in class Dialect
public boolean useMaxForLimit()
Dialect
useMaxForLimit
in class Dialect
public boolean supportsOuterJoinForUpdate()
Dialect
supportsOuterJoinForUpdate
in class Dialect
public boolean supportsExistsInSelect()
Dialect
supportsExistsInSelect
in class Dialect
public boolean supportsLockTimeouts()
Dialect
supportsLockTimeouts
in class Dialect
public String getSelectClauseNullString(int sqlType)
Dialect
Types
type code, determine an appropriate
null value to use in a select clause.
One thing to consider here is that certain databases might
require proper casting for the nulls here since the select here
will be part of a UNION/UNION ALL.getSelectClauseNullString
in class Dialect
sqlType
- The Types
type code.public boolean supportsUnionAll()
Dialect
supportsUnionAll
in class Dialect
public int registerResultSetOutParameter(CallableStatement statement, int col) throws SQLException
Dialect
ResultSet
*by position*. Pre-Java 8, registering such ResultSet-returning
parameters varied greatly across database and drivers; hence its inclusion as part of the Dialect contract.registerResultSetOutParameter
in class Dialect
statement
- The callable statement.col
- The bind position at which to register the output param.SQLException
- Indicates problems registering the param.public ResultSet getResultSet(CallableStatement ps) throws SQLException
Dialect
Dialect.registerResultSetOutParameter(java.sql.CallableStatement, int)
,
extract the ResultSet
from the OUT parameter.getResultSet
in class Dialect
ps
- The callable statement.SQLException
- Indicates problems extracting the result set.public boolean supportsCommentOn()
Dialect
supportsCommentOn
in class Dialect
true
if commenting is supportedpublic boolean supportsTemporaryTables()
Dialect
supportsTemporaryTables
in class Dialect
public String getCreateTemporaryTableString()
Dialect
getCreateTemporaryTableString
in class Dialect
public String getCreateTemporaryTablePostfix()
Dialect
getCreateTemporaryTablePostfix
in class Dialect
public String generateTemporaryTableName(String baseTableName)
Dialect
generateTemporaryTableName
in class Dialect
baseTableName
- The table name from which to base the temp table name.public boolean supportsCurrentTimestampSelection()
Dialect
supportsCurrentTimestampSelection
in class Dialect
public String getCurrentTimestampSelectString()
Dialect
getCurrentTimestampSelectString
in class Dialect
public boolean isCurrentTimestampSelectStringCallable()
Dialect
Dialect.getCurrentTimestampSelectString()
be treated as callable. Typically this indicates that JDBC escape
syntax is being used...isCurrentTimestampSelectStringCallable
in class Dialect
Dialect.getCurrentTimestampSelectString()
return
is callable; false otherwise.public boolean supportsParametersInInsertSelect()
requiresCastingOfParametersInSelectClause()
).supportsParametersInInsertSelect
in class Dialect
public boolean requiresCastingOfParametersInSelectClause()
requiresCastingOfParametersInSelectClause
in class Dialect
public boolean supportsResultSetPositionQueryMethodsOnForwardOnlyCursor()
Dialect
ResultSet.isAfterLast()
and
ResultSet.isBeforeFirst()
. Certain drivers do not
allow access to these methods for forward only cursors.
NOTE : this is highly driver dependent!supportsResultSetPositionQueryMethodsOnForwardOnlyCursor
in class Dialect
ResultSet.isAfterLast()
and
ResultSet.isBeforeFirst()
are supported for forward
only cursors; false otherwise.public String getCrossJoinSeparator()
Dialect
getCrossJoinSeparator
in class Dialect
public boolean supportsEmptyInList()
Dialect
supportsEmptyInList
in class Dialect
public boolean supportsLobValueChangePropogation()
Dialect
Blob.setBinaryStream(long)
,
Blob.setBytes(long, byte[])
,
Blob.setBytes(long, byte[], int, int)
,
or Blob.truncate(long)
.
For CLOBs, the internal value might be changed by:
Clob.setAsciiStream(long)
,
Clob.setCharacterStream(long)
,
Clob.setString(long, String)
,
Clob.setString(long, String, int, int)
,
or Clob.truncate(long)
.
NOTE : I do not know the correct answer currently for
databases which (1) are not part of the cruise control process
or (2) do not Dialect.supportsExpectedLobUsagePattern()
.supportsLobValueChangePropogation
in class Dialect
public boolean doesReadCommittedCauseWritersToBlockReaders()
Dialect
doesReadCommittedCauseWritersToBlockReaders
in class Dialect
public boolean supportsTupleDistinctCounts()
Dialect
supportsTupleDistinctCounts
in class Dialect
protected SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode)
Dialect
SqlTypeDescriptor
that should be used to handle the given JDBC type code. Returns
null
if there is no override.getSqlTypeDescriptorOverride
in class Dialect
sqlCode
- A Types
constant indicating the SQL column typeSqlTypeDescriptor
to use as an override, or null
if there is no override.public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate()
Dialect
SQLExceptionConversionDelegate
for
interpreting dialect-specific error or SQLState codes.
When Dialect.buildSQLExceptionConverter()
returns null, the default
SQLExceptionConverter
is used to interpret SQLState and
error 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:
buildSQLExceptionConversionDelegate
in class Dialect
public UniqueDelegate getUniqueDelegate()
Dialect
getUniqueDelegate
in class Dialect
public String getNotExpression(String expression)
Dialect
getNotExpression
in class Dialect
expression
- The expression to negateCopyright © 2001-2015 Red Hat, Inc. All Rights Reserved.