public class H2Dialect extends Dialect
Dialect.SizeStrategy, Dialect.SizeStrategyImpl
CLOSED_QUOTE, DEFAULT_BATCH_SIZE, LEGACY_LOB_MERGE_STRATEGY, NEW_LOCATOR_LOB_MERGE_STRATEGY, NO_BATCH, QUOTE, STANDARD_DEFAULT_BATCH_LOAD_SIZING_STRATEGY, STREAM_XFER_LOB_MERGE_STRATEGY, TWO_SINGLE_QUOTES_REPLACEMENT
Constructor and Description |
---|
H2Dialect() |
H2Dialect(DialectResolutionInfo info) |
H2Dialect(int version) |
H2Dialect(int version,
int buildId) |
Modifier and Type | Method and Description |
---|---|
SQLExceptionConversionDelegate |
buildSQLExceptionConversionDelegate()
Build an instance of a
SQLExceptionConversionDelegate for
interpreting dialect-specific error or SQLState codes. |
String |
currentTime()
Translation of the HQL/JPQL
current_time function, which
maps to the Java type java.sql.Time which is a time with
no time zone. |
String |
currentTimestamp()
Translation of the HQL/JPQL
current_timestamp function,
which maps to the Java type java.sql.Timestamp which is
a datetime with no time zone. |
String |
currentTimestampWithTimeZone()
Translation of the HQL
offset_datetime function, which maps
to the Java type java.time.OffsetDateTime which is a datetime
with a time zone. |
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 |
extractPattern(TemporalUnit unit)
In H2, the extract() function does not return
fractional seconds for the the field
TemporalUnit.SECOND . |
String |
getCascadeConstraintsString()
The keyword that specifies that a
drop table operation
should be cascaded to its constraints, typically
" cascade" where the leading space is required, or
the empty string if there is no such keyword in this dialect. |
String |
getCurrentTimestampSelectString()
Retrieve the command used to retrieve the current timestamp from the
database.
|
SqmMultiTableMutationStrategy |
getFallbackSqmMutationStrategy(EntityMappingType entityDescriptor,
RuntimeModelCreationContext runtimeModelCreationContext) |
String |
getFromDual()
Some databases require a bit of syntactic noise when
there are no tables in the from clause.
|
IdentityColumnSupport |
getIdentityColumnSupport()
Get the appropriate
IdentityColumnSupport |
LimitHandler |
getLimitHandler()
Returns a
LimitHandler that implements support for
Query.setMaxResults(int) and
Query.setFirstResult(int) for
this dialect. |
NullOrdering |
getNullOrdering()
Returns the ordering of null.
|
String |
getQueryHintString(String query,
String hints)
Apply a hint to the query.
|
String |
getQuerySequencesString()
Get the select command used retrieve the names of all sequences.
|
SequenceInformationExtractor |
getSequenceInformationExtractor()
A source of
SequenceInformation . |
SequenceSupport |
getSequenceSupport() |
SqlAstTranslatorFactory |
getSqlAstTranslatorFactory()
Return an SqlAstTranslatorFactory specific for the Dialect.
|
int |
getVersion() |
ViolatedConstraintNameExtractor |
getViolatedConstraintNameExtractor() |
void |
initializeFunctionRegistry(QueryEngine queryEngine)
Initialize the given registry with any dialect-specific functions.
|
boolean |
isCurrentTimestampSelectStringCallable()
Should the value returned by
Dialect.getCurrentTimestampSelectString()
be treated as callable. |
boolean |
requiresParensForTupleDistinctCounts()
If
Dialect.supportsTupleDistinctCounts() is true, does the Dialect require the tuple to be wrapped with parens? |
boolean |
supportsCurrentTimestampSelection()
Does this dialect support a way to retrieve the database's current
timestamp value?
|
boolean |
supportsFetchClause(FetchClauseType type)
Does this dialect support the given fetch clause type.
|
boolean |
supportsIfExistsAfterAlterTable()
For an "alter table", can the phrase "if exists" be applied?
|
boolean |
supportsIfExistsAfterTableName()
For dropping a table, can the phrase "if exists" be applied after the table name?
NOTE : Only one or the other (or neither) of this and
Dialect.supportsIfExistsBeforeTableName() should return true |
boolean |
supportsIfExistsBeforeConstraintName()
For dropping a constraint with an "alter table", can the phrase "if exists" be applied before the constraint name?
NOTE : Only one or the other (or neither) of this and
Dialect.supportsIfExistsAfterConstraintName() should return true |
boolean |
supportsIfExistsBeforeTableName()
For dropping a table, can the phrase "if exists" be applied before the table name?
NOTE : Only one or the other (or neither) of this and
Dialect.supportsIfExistsAfterTableName() should return true |
boolean |
supportsLobValueChangePropagation()
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 |
supportsOffsetInSubquery()
Does this dialect support offset in subqueries? Ex:
select * from Table1 where col1 in (select col1 from Table2 order by col2 limit 1 offset 1)
|
boolean |
supportsSelectAliasInGroupByClause() |
boolean |
supportsTemporalLiteralOffset()
Whether the Dialect supports timezone offset in temporal literals.
|
boolean |
supportsTimezoneTypes()
Whether the Dialect supports timezone types like
Types.TIMESTAMP_WITH_TIMEZONE . |
boolean |
supportsTuplesInSubqueries()
Does this dialect support tuples in subqueries? Ex:
delete from Table1 where (col1, col2) in (select col1, col2 from Table2)
|
String |
timestampaddPattern(TemporalUnit unit,
TemporalType temporalType)
Obtain a pattern for the SQL equivalent to a
timestampadd() function call. |
String |
timestampdiffPattern(TemporalUnit unit,
TemporalType fromTemporalType,
TemporalType toTemporalType)
Obtain a pattern for the SQL equivalent to a
timestampdiff() function call. |
String |
toBooleanValueString(boolean bool)
The SQL literal value to which this database maps boolean values.
|
String |
translateDatetimeFormat(String format)
Translate the given datetime format string from
the pattern language defined by Java's
DateTimeFormatter to
whatever pattern language is understood by the
native datetime formatting function for this
database (often the to_char() function). |
String |
translateExtractField(TemporalUnit unit)
Return the name used to identify the given field
as an argument to the
extract() function,
or of this dialect's equivalent
function. |
addSqlHintOrComment, appendLockHint, appendLockHint, applyLocksToSql, areStringComparisonsCaseInsensitive, augmentRecognizedTableTypes, binaryToDecimalPrecision, bindLimitParametersFirst, bindLimitParametersInReverseOrder, buildIdentifierHelper, buildSQLExceptionConverter, canCreateCatalog, canCreateSchema, castPattern, closeQuote, contributeTypes, convertToFirstRowValue, createCaseFragment, createOuterJoinFragment, currentDate, currentLocalTime, currentLocalTimestamp, defaultScrollMode, doesRepeatableReadCauseReadersToBlockWriters, equivalentTypes, escapeComment, escapeLiteral, forceLimitUsage, forceLobAsLastValue, formatAsTimestamp, formatAsTimestamp, formatAsTimestamp, formatBinaryLiteral, formatDateTimeLiteral, formatDateTimeLiteral, formatDateTimeLiteral, forUpdateOfColumns, getAddColumnString, getAddColumnSuffixString, getAddForeignKeyConstraintString, getAddForeignKeyConstraintString, getAddPrimaryKeyConstraintString, getAddUniqueConstraintString, getAlterTableString, getAuxiliaryDatabaseObjectExporter, getBooleanCheckCondition, getCallableStatementSupport, getCaseInsensitiveLike, getCastTypeName, getColumnAliasExtractor, getColumnComment, getCreateCatalogCommand, getCreateMultisetTableString, getCreateSchemaCommand, getCreateSequenceString, getCreateSequenceString, getCreateSequenceStrings, getCreateTableString, getCreateTemporaryTableColumnAnnotation, getCrossJoinSeparator, getCurrentSchemaCommand, getCurrentTimestampSQLFunctionName, getDefaultBatchLoadSizingStrategy, getDefaultDecimalPrecision, getDefaultLobLength, getDefaultProperties, getDefaultTimestampPrecision, getDialect, getDialect, getDoublePrecision, getDropCatalogCommand, getDropForeignKeyString, getDropSchemaCommand, getDropSequenceString, getDropSequenceStrings, getDropTableString, getEnumCheckCondition, getFloatPrecision, getForeignKeyExporter, getForUpdateNowaitString, getForUpdateNowaitString, getForUpdateSkipLockedString, getForUpdateSkipLockedString, getForUpdateString, getForUpdateString, getForUpdateString, getForUpdateString, getForUpdateString, getFractionalSecondPrecisionInNanos, getGroupByConstantRenderingStrategy, getGroupBySummarizationRenderingStrategy, getHibernateTypeName, getHibernateTypeName, getHqlTranslator, getIndexExporter, getInExpressionCountLimit, getKeywords, getLimitString, getLimitString, getLobMergeStrategy, getLockingStrategy, getLockRowIdentifier, getLowercaseFunction, getMaxAliasLength, getNameQualifierSupport, getNationalizationSupport, getNativeIdentifierGeneratorClass, getNativeIdentifierGeneratorStrategy, getNoColumnsInsertString, getNotExpression, getNullColumnString, getNullColumnString, getPreferredSqlTypeCodeForBoolean, getQueryHintString, getRawTypeName, getRawTypeName, getReadLockString, getReadLockString, getReadRowLockStrategy, getResultSet, getResultSet, getResultSet, getSchemaNameResolver, getSelectClauseNullString, getSelectGUIDString, getSelectSequenceNextValString, getSequenceExporter, getSequenceNextValString, getSequenceNextValString, getSizeStrategy, getSqlTypeDescriptorOverride, getSqmTranslatorFactory, getTableAliasSeparator, getTableComment, getTableExporter, getTableTypeString, getTypeName, getTypeName, getTypeName, getTypeName, getUniqueDelegate, getUniqueKeyExporter, getWriteLockString, getWriteLockString, getWriteRowLockStrategy, hasAlterTable, hasSelfReferentialForeignKeyBug, inlineLiteral, isEmptyStringTreatedAsNull, isJdbcLogWarningsEnabledByDefault, isLockTimeoutParameterized, isTypeNameRegistered, openQuote, prependComment, qualifyIndexName, quote, registerColumnType, registerColumnType, registerHibernateType, registerHibernateType, registerKeyword, registerResultSetOutParameter, registerResultSetOutParameter, remapSqlTypeDescriptor, renderOrderByElement, replaceResultVariableInOrderByClauseWithPosition, requiresCastingOfParametersInSelectClause, requiresFloatCastingOfIntegerDivision, resolveSqlTypeDescriptor, supportsBindAsCallableArgument, supportsBitType, supportsCascadeDelete, supportsCaseInsensitiveLike, supportsCircularCascadeDeleteConstraints, supportsColumnCheck, supportsCommentOn, supportsEmptyInList, supportsExistsInSelect, supportsExpectedLobUsagePattern, supportsFractionalTimestampArithmetic, supportsIfExistsAfterConstraintName, supportsJdbcConnectionLobCreation, supportsLimit, supportsLimitOffset, supportsLockTimeouts, supportsNamedParameters, supportsNationalizedTypes, supportsNoColumnsInsert, supportsNonQueryWithCTE, supportsNotNullUnique, supportsNoWait, supportsNullPrecedence, supportsOrderByInSubquery, supportsOrdinalSelectItemReference, supportsOuterJoinForUpdate, supportsParametersInInsertSelect, supportsPartitionBy, supportsPooledSequences, supportsResultSetPositionQueryMethodsOnForwardOnlyCursor, supportsRowValueConstructorSyntax, supportsRowValueConstructorSyntaxInInList, supportsRowValueConstructorSyntaxInInSubquery, supportsRowValueConstructorSyntaxInQuantifiedPredicates, supportsRowValueConstructorSyntaxInSet, supportsSelectQueryWithoutFromClause, supportsSequences, supportsSkipLocked, supportsSubqueryInSelect, supportsSubqueryOnMutatingTable, supportsSubselectAsInPredicateLHS, supportsTableCheck, supportsTemporaryTables, supportsTruncateWithCast, supportsTupleCounts, supportsTupleDistinctCounts, supportsUnboundedLobLocatorMaterialization, supportsUnionAll, supportsUnionInSubquery, supportsUnique, supportsUniqueConstraintInCreateAlterTable, supportsValuesList, supportsValuesListForInsert, supportsVariableLimit, supportsWait, supportsWindowFunctions, toString, transformSelectString, translateDurationField, trimPattern, useFollowOnLocking, useInputStreamToInsertBlob, useMaxForLimit, wrapDateLiteral, wrapTimeLiteral, wrapTimestampLiteral
public H2Dialect()
public H2Dialect(int version, int buildId)
public H2Dialect(int version)
public H2Dialect(DialectResolutionInfo info)
public int getVersion()
getVersion
in class Dialect
public void initializeFunctionRegistry(QueryEngine queryEngine)
Dialect
initializeFunctionRegistry
in class Dialect
public String currentTime()
Dialect
current_time
function, which
maps to the Java type java.sql.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
.
currentTime
in class Dialect
public String currentTimestamp()
Dialect
current_timestamp
function,
which maps to the Java type java.sql.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
.
currentTimestamp
in class Dialect
public String currentTimestampWithTimeZone()
Dialect
offset_datetime
function, which maps
to the Java type java.time.OffsetDateTime
which is a datetime
with a time zone. This in principle correctly maps to the ANSI SQL
current_timestamp
which has the type
TIMESTAMP WITH TIME ZONE
.currentTimestampWithTimeZone
in class Dialect
public SqlAstTranslatorFactory getSqlAstTranslatorFactory()
Dialect
null
to use Hibernate's standard translator.getSqlAstTranslatorFactory
in class Dialect
StandardSqlAstTranslatorFactory
,
JdbcEnvironment.getSqlAstTranslatorFactory()
public String extractPattern(TemporalUnit unit)
TemporalUnit.SECOND
. We work around
this here with two calls to extract().extractPattern
in class Dialect
unit
- the first argumentpublic String timestampaddPattern(TemporalUnit unit, TemporalType temporalType)
Dialect
timestampadd()
function call. The resulting
pattern must contain ?1, ?2, and ?3 placeholders
for the arguments.timestampaddPattern
in class Dialect
unit
- the first argumenttemporalType
- true if the third argument is apublic String timestampdiffPattern(TemporalUnit unit, TemporalType fromTemporalType, TemporalType toTemporalType)
Dialect
timestampdiff()
function call. The resulting
pattern must contain ?1, ?2, and ?3 placeholders
for the arguments.timestampdiffPattern
in class Dialect
unit
- the first argumentfromTemporalType
- true if the first argument is
a timestamp, false if a datetoTemporalType
- true if the second argument ispublic boolean supportsTemporalLiteralOffset()
Dialect
supportsTemporalLiteralOffset
in class Dialect
public boolean supportsTimezoneTypes()
Dialect
Types.TIMESTAMP_WITH_TIMEZONE
.supportsTimezoneTypes
in class Dialect
public String toBooleanValueString(boolean bool)
Dialect
toBooleanValueString
in class Dialect
bool
- The boolean valuepublic LimitHandler getLimitHandler()
Dialect
LimitHandler
that implements support for
Query.setMaxResults(int)
and
Query.setFirstResult(int)
for
this dialect.getLimitHandler
in class Dialect
public boolean supportsIfExistsAfterTableName()
Dialect
Dialect.supportsIfExistsBeforeTableName()
should return truesupportsIfExistsAfterTableName
in class Dialect
true
if the "if exists" can be applied after the table namepublic boolean supportsIfExistsBeforeTableName()
Dialect
Dialect.supportsIfExistsAfterTableName()
should return truesupportsIfExistsBeforeTableName
in class Dialect
true
if the "if exists" can be applied before the table namepublic boolean supportsIfExistsAfterAlterTable()
Dialect
supportsIfExistsAfterAlterTable
in class Dialect
true
if the "if exists" can be applied after ALTER TABLEpublic boolean supportsIfExistsBeforeConstraintName()
Dialect
Dialect.supportsIfExistsAfterConstraintName()
should return truesupportsIfExistsBeforeConstraintName
in class Dialect
true
if the "if exists" can be applied before the constraint namepublic String getCascadeConstraintsString()
Dialect
drop table
operation
should be cascaded to its constraints, typically
" cascade"
where the leading space is required, or
the empty string if there is no such keyword in this dialect.getCascadeConstraintsString
in class Dialect
public boolean dropConstraints()
Dialect
dropConstraints
in class Dialect
public SequenceSupport getSequenceSupport()
getSequenceSupport
in class Dialect
public String getQuerySequencesString()
Dialect
getQuerySequencesString
in class Dialect
SchemaUpdate
public SequenceInformationExtractor getSequenceInformationExtractor()
Dialect
SequenceInformation
.getSequenceInformationExtractor
in class Dialect
public String getFromDual()
Dialect
getFromDual
in class Dialect
from dual
.public NullOrdering getNullOrdering()
Dialect
getNullOrdering
in class Dialect
public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy(EntityMappingType entityDescriptor, RuntimeModelCreationContext runtimeModelCreationContext)
getFallbackSqmMutationStrategy
in class Dialect
public ViolatedConstraintNameExtractor getViolatedConstraintNameExtractor()
getViolatedConstraintNameExtractor
in interface ConversionContext
getViolatedConstraintNameExtractor
in class Dialect
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 boolean supportsCurrentTimestampSelection()
Dialect
supportsCurrentTimestampSelection
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 String getCurrentTimestampSelectString()
Dialect
getCurrentTimestampSelectString
in class Dialect
public boolean supportsLobValueChangePropagation()
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()
.supportsLobValueChangePropagation
in class Dialect
public boolean requiresParensForTupleDistinctCounts()
Dialect
Dialect.supportsTupleDistinctCounts()
is true, does the Dialect require the tuple to be wrapped with parens?requiresParensForTupleDistinctCounts
in class Dialect
public boolean doesReadCommittedCauseWritersToBlockReaders()
Dialect
doesReadCommittedCauseWritersToBlockReaders
in class Dialect
public boolean supportsTuplesInSubqueries()
Dialect
supportsTuplesInSubqueries
in class Dialect
public boolean supportsSelectAliasInGroupByClause()
supportsSelectAliasInGroupByClause
in class Dialect
public boolean supportsOffsetInSubquery()
Dialect
supportsOffsetInSubquery
in class Dialect
public boolean supportsFetchClause(FetchClauseType type)
Dialect
supportsFetchClause
in class Dialect
type
- The fetch clause typetrue
if the underlying database supports the given fetch clause type,
false
otherwise. The default is false
.public IdentityColumnSupport getIdentityColumnSupport()
Dialect
IdentityColumnSupport
getIdentityColumnSupport
in class Dialect
public String getQueryHintString(String query, String hints)
Dialect
getQueryHintString
in class Dialect
query
- The query to which to apply the hint.hints
- The hints to applypublic String translateDatetimeFormat(String format)
Dialect
DateTimeFormatter
to
whatever pattern language is understood by the
native datetime formatting function for this
database (often the to_char()
function).
Since it's never possible to translate all of
the pattern letter sequences understood by
DateTimeFormatter
, only the following
subset of pattern letters is accepted by
Hibernate:
translateDatetimeFormat
in class Dialect
public String translateExtractField(TemporalUnit unit)
Dialect
extract()
function,
or of this dialect's equivalent
function.
This method does not need to handle
TemporalUnit.NANOSECOND
,
TemporalUnit.NATIVE
,
TemporalUnit.OFFSET
,
TemporalUnit.DATE
,
TemporalUnit.TIME
,
TemporalUnit.WEEK_OF_YEAR
, nor
TemporalUnit.WEEK_OF_MONTH
,
which are already desugared by
ExtractFunction
.
translateExtractField
in class Dialect
Copyright © 2001-2021 Red Hat, Inc. All Rights Reserved.