Package org.hibernate.dialect
Class AbstractTransactSQLDialect
- java.lang.Object
-
- org.hibernate.dialect.Dialect
-
- org.hibernate.dialect.AbstractTransactSQLDialect
-
- All Implemented Interfaces:
ConversionContext
- Direct Known Subclasses:
SQLServerDialect
,SybaseDialect
public abstract class AbstractTransactSQLDialect extends Dialect
An abstract base class for Sybase and MS SQL Server dialects.
-
-
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, LEGACY_LOB_MERGE_STRATEGY, LOG_BASE2OF10, NEW_LOCATOR_LOB_MERGE_STRATEGY, QUOTE, STANDARD_DEFAULT_BATCH_LOAD_SIZING_STRATEGY, STREAM_XFER_LOB_MERGE_STRATEGY
-
-
Constructor Summary
Constructors Constructor Description AbstractTransactSQLDialect(DatabaseVersion version)
AbstractTransactSQLDialect(DialectResolutionInfo info)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
appendBinaryLiteral(SqlAppender appender, byte[] bytes)
String
appendLockHint(LockOptions lockOptions, String tableName)
Some dialects support an alternative means toSELECT FOR UPDATE
, whereby a "lock hint" is appended to the table name in the from clause.String
applyLocksToSql(String sql, LockOptions aliasedLockOptions, Map<String,String[]> keyColumnNames)
Modifies the given SQL by applying the appropriate updates for the specified lock modes and key columns.protected String
columnType(int sqlTypeCode)
boolean
doesReadCommittedCauseWritersToBlockReaders()
For the underlying database, is READ_COMMITTED isolation implemented by forcing readers to wait for write locks to be released?boolean
doesRepeatableReadCauseReadersToBlockWriters()
For the underlying database, is REPEATABLE_READ isolation implemented by forcing writers to wait for read locks to be released?String
getAddColumnString()
The syntax used to add a column to a table (optional).String
getCurrentTimestampSelectString()
Retrieve the command used to retrieve the current timestamp from the database.int
getDefaultStatementBatchSize()
The default value to use for the configuration property "hibernate.jdbc.batch_size".SqmMultiTableInsertStrategy
getFallbackSqmInsertStrategy(EntityMappingType entityDescriptor, RuntimeModelCreationContext runtimeModelCreationContext)
SqmMultiTableMutationStrategy
getFallbackSqmMutationStrategy(EntityMappingType entityDescriptor, RuntimeModelCreationContext runtimeModelCreationContext)
String
getForUpdateString()
Get the string to append to SELECT statements to acquire locks for this dialect.IdentityColumnSupport
getIdentityColumnSupport()
Get the appropriateIdentityColumnSupport
NullOrdering
getNullOrdering()
Returns the ordering of null.int
getPreferredSqlTypeCodeForBoolean()
The JDBCtype code
to use for mapping properties of Java typeboolean
.ResultSet
getResultSet(CallableStatement ps)
Given a callable statement previously processed byDialect.registerResultSetOutParameter(java.sql.CallableStatement, int)
, extract theResultSet
from the OUT parameter.String
getSelectGUIDString()
Get the command used to select a GUID from the underlying database.TemporaryTableKind
getSupportedTemporaryTableKind()
AfterUseAction
getTemporaryTableAfterUseAction()
BeforeUseAction
getTemporaryTableBeforeUseAction()
String
getTemporaryTableCreateCommand()
RowLockStrategy
getWriteRowLockStrategy()
The row lock strategy to use for write locks.void
initializeFunctionRegistry(QueryEngine queryEngine)
Initialize the given registry with any dialect-specific functions.boolean
isCurrentTimestampSelectStringCallable()
Should the value returned byDialect.getCurrentTimestampSelectString()
be treated as callable.boolean
qualifyIndexName()
Do we need to qualify index names with the schema name?int
registerResultSetOutParameter(CallableStatement statement, int col)
Registers a parameter (either OUT, or the new REF_CURSOR param type available in Java 8) capable of returningResultSet
*by position*.static String
replaceLtrimRtrim(TrimSpec specification, char character)
JdbcType
resolveSqlTypeDescriptor(String columnTypeName, int jdbcTypeCode, int precision, int scale, JdbcTypeRegistry jdbcTypeRegistry)
boolean
supportsCurrentTimestampSelection()
Does this dialect support a way to retrieve the database's current timestamp value?boolean
supportsExistsInSelect()
Does the dialect support an exists statement in the select clause?boolean
supportsPartitionBy()
Does the underlying database support partition by?boolean
supportsTupleDistinctCounts()
Does this dialect support `count(distinct a,b)`?String
trimPattern(TrimSpec specification, char character)
Obtain a pattern for the SQL equivalent to atrim()
function call.-
Methods inherited from class org.hibernate.dialect.Dialect
addSqlHintOrComment, appendArrayLiteral, appendBooleanValueString, appendDatetimeFormat, appendDateTimeLiteral, appendDateTimeLiteral, appendDateTimeLiteral, appendIntervalLiteral, appendLiteral, appendUUIDLiteral, augmentPhysicalTableTypes, augmentRecognizedTableTypes, buildIdentifierHelper, buildSQLExceptionConversionDelegate, canCreateCatalog, canCreateSchema, castPattern, castType, checkVersion, closeQuote, contributeTypes, currentDate, currentLocalTime, currentLocalTimestamp, currentTime, currentTimestamp, currentTimestampWithTimeZone, defaultScrollMode, dropConstraints, equivalentTypes, escapeComment, extractPattern, forceLobAsLastValue, generatedAs, getAddColumnSuffixString, getAddForeignKeyConstraintString, getAddForeignKeyConstraintString, getAddPrimaryKeyConstraintString, getAlterTableString, getArrayTypeName, getAuxiliaryDatabaseObjectExporter, getBooleanCheckCondition, getCallableStatementSupport, getCascadeConstraintsString, getCaseInsensitiveLike, getColumnAliasExtractor, getColumnComment, getCreateCatalogCommand, getCreateMultisetTableString, getCreateSchemaCommand, getCreateTableString, getCreateTemporaryTableColumnAnnotation, getCurrentSchemaCommand, getDefaultBatchLoadSizingStrategy, getDefaultDecimalPrecision, getDefaultLobLength, getDefaultNonContextualLobCreation, getDefaultProperties, getDefaultTimestampPrecision, getDefaultUseGetGeneratedKeys, getDoublePrecision, getDropCatalogCommand, getDropForeignKeyString, getDropSchemaCommand, getDropTableString, getEnumCheckCondition, getFloatPrecision, getForeignKeyExporter, getForUpdateNowaitString, getForUpdateNowaitString, getForUpdateSkipLockedString, getForUpdateSkipLockedString, getForUpdateString, getForUpdateString, getForUpdateString, getForUpdateString, getFractionalSecondPrecisionInNanos, getGroupBySelectItemReferenceStrategy, getHqlTranslator, getIndexExporter, getInExpressionCountLimit, getKeywords, getLimitHandler, getLobMergeStrategy, getLockingStrategy, getLockRowIdentifier, getLowercaseFunction, getMaxAliasLength, getMaxIdentifierLength, getMaxNVarcharLength, getMaxVarbinaryLength, getMaxVarcharLength, getMinimumSupportedVersion, getNameQualifierSupport, getNationalizationSupport, getNativeIdentifierGeneratorStrategy, getNoColumnsInsertString, getNullColumnString, getNullColumnString, getPreferredSqlTypeCodeForArray, getQueryHintString, getQueryHintString, getQuerySequencesString, getReadLockString, getReadLockString, getReadRowLockStrategy, getResultSet, getResultSet, getSchemaNameResolver, getSelectClauseNullString, getSequenceExporter, getSequenceInformationExtractor, getSequenceSupport, getSizeStrategy, getSqlAstTranslatorFactory, getSqmTranslatorFactory, getTableComment, getTableExporter, getTableTypeString, getTemporaryTableCreateOptions, getTemporaryTableDdlTransactionHandling, getTemporaryTableDropCommand, getTemporaryTableExporter, getTemporaryTableTruncateCommand, getTimeZoneSupport, getUniqueDelegate, getUniqueKeyExporter, getVersion, getViolatedConstraintNameExtractor, getWriteLockString, getWriteLockString, hasAlterTable, hasDataTypeBeforeGeneratedAs, hasSelfReferentialForeignKeyBug, initDefaultProperties, inlineLiteral, isAnsiNullOn, isEmptyStringTreatedAsNull, isJdbcLogWarningsEnabledByDefault, isLockTimeoutParameterized, openQuote, prependComment, quote, registerColumnTypes, registerDefaultKeywords, registerKeyword, registerKeywords, registerResultSetOutParameter, requiresFloatCastingOfIntegerDivision, requiresParensForTupleCounts, requiresParensForTupleDistinctCounts, resolveSqlTypeCode, resolveSqlTypeCode, resolveSqlTypeLength, supportsBindAsCallableArgument, supportsBitType, supportsCascadeDelete, supportsCaseInsensitiveLike, supportsCircularCascadeDeleteConstraints, supportsColumnCheck, supportsCommentOn, supportsDistinctFromPredicate, supportsExpectedLobUsagePattern, supportsFetchClause, supportsFractionalTimestampArithmetic, supportsIfExistsAfterAlterTable, supportsIfExistsAfterConstraintName, supportsIfExistsAfterTableName, supportsIfExistsBeforeConstraintName, supportsIfExistsBeforeTableName, supportsJdbcConnectionLobCreation, supportsLateral, supportsLobValueChangePropagation, supportsLockTimeouts, supportsNamedParameters, supportsNoColumnsInsert, supportsNonQueryWithCTE, supportsNoWait, supportsNullPrecedence, supportsOffsetInSubquery, supportsOrderByInSubquery, supportsOrdinalSelectItemReference, supportsOuterJoinForUpdate, supportsParametersInInsertSelect, supportsResultSetPositionQueryMethodsOnForwardOnlyCursor, supportsSkipLocked, supportsStandardArrays, supportsSubqueryInSelect, supportsSubqueryOnMutatingTable, supportsSubselectAsInPredicateLHS, supportsTableCheck, supportsTemporalLiteralOffset, supportsTemporaryTablePrimaryKey, supportsTemporaryTables, supportsTruncateWithCast, supportsTupleCounts, supportsUnboundedLobLocatorMaterialization, supportsUnionAll, supportsUnionInSubquery, supportsValuesList, supportsValuesListForInsert, supportsWait, supportsWindowFunctions, timestampaddPattern, timestampdiffPattern, toBooleanValueString, toQuotedIdentifier, toString, transformSelectString, translateDurationField, translateExtractField, useFollowOnLocking, useInputStreamToInsertBlob
-
-
-
-
Constructor Detail
-
AbstractTransactSQLDialect
public AbstractTransactSQLDialect(DatabaseVersion version)
-
AbstractTransactSQLDialect
public AbstractTransactSQLDialect(DialectResolutionInfo info)
-
-
Method Detail
-
columnType
protected String columnType(int sqlTypeCode)
Description copied from class:Dialect
The column type name for a given JDBC type code defined inTypes
orSqlTypes
. This default implementation returns the ANSI-standard type name.This method may be overridden by concrete
Dialect
s as an alternative toDialect.registerColumnTypes(TypeContributions, ServiceRegistry)
for simple registrations.- Overrides:
columnType
in classDialect
- Parameters:
sqlTypeCode
- a SQL type code- Returns:
- a column type name, with $l, $p, $s placeholders for length, precision, scale
- See Also:
SqlTypes
-
getDefaultStatementBatchSize
public int getDefaultStatementBatchSize()
Description copied from class:Dialect
The default value to use for the configuration property "hibernate.jdbc.batch_size".- Overrides:
getDefaultStatementBatchSize
in classDialect
-
resolveSqlTypeDescriptor
public JdbcType resolveSqlTypeDescriptor(String columnTypeName, int jdbcTypeCode, int precision, int scale, JdbcTypeRegistry jdbcTypeRegistry)
- Overrides:
resolveSqlTypeDescriptor
in classDialect
-
getPreferredSqlTypeCodeForBoolean
public int getPreferredSqlTypeCodeForBoolean()
Description copied from class:Dialect
The JDBCtype code
to use for mapping properties of Java typeboolean
.Usually
Types.BOOLEAN
orTypes.BIT
.- Overrides:
getPreferredSqlTypeCodeForBoolean
in classDialect
- Returns:
- one of the type codes defined by
Types
.
-
initializeFunctionRegistry
public void initializeFunctionRegistry(QueryEngine queryEngine)
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
- 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])
- 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])
- log10(arg)
- sign(arg)
- sin(arg)
- cos(arg)
- tan(arg)
- asin(arg)
- acos(arg)
- atan(arg)
- atan2(arg0, arg1)
- round(arg0, arg1)
- least(arg0, arg1, ...)
- greatest(arg0, arg1, ...)
- format(datetime as pattern)
- collate(string as collation)
- str(arg) - synonym of cast(a as String)
- ifnull(arg0, arg1) - synonym of coalesce(a, b)
- 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)
- Overrides:
initializeFunctionRegistry
in classDialect
-
trimPattern
public String trimPattern(TrimSpec specification, char character)
Description copied from class:Dialect
Obtain a pattern for the SQL equivalent to atrim()
function call. The resulting pattern must contain a ?1 placeholder for the argument of typeString
.- Overrides:
trimPattern
in classDialect
- Parameters:
specification
-leading
ortrailing
character
- the character to trim
-
getAddColumnString
public String getAddColumnString()
Description copied from class:Dialect
The syntax used to add a column to a table (optional).- Overrides:
getAddColumnString
in classDialect
- Returns:
- The "add column" fragment.
-
qualifyIndexName
public boolean qualifyIndexName()
Description copied from class:Dialect
Do we need to qualify index names with the schema name?- Overrides:
qualifyIndexName
in classDialect
- Returns:
- boolean
-
getForUpdateString
public String getForUpdateString()
Description copied from class:Dialect
Get the string to append to SELECT statements to acquire locks for this dialect.- Overrides:
getForUpdateString
in classDialect
- Returns:
- The appropriate
FOR UPDATE
clause string.
-
getWriteRowLockStrategy
public RowLockStrategy getWriteRowLockStrategy()
Description copied from class:Dialect
The row lock strategy to use for write locks.- Overrides:
getWriteRowLockStrategy
in classDialect
-
appendLockHint
public String appendLockHint(LockOptions lockOptions, String tableName)
Description copied from class:Dialect
Some dialects support an alternative means toSELECT FOR UPDATE
, whereby a "lock hint" is appended to the table name in the from clause. contributed by Helge Schulz- Overrides:
appendLockHint
in classDialect
- Parameters:
lockOptions
- The lock options to applytableName
- The name of the table to which to apply the lock hint.- Returns:
- The table with any required lock hints.
-
applyLocksToSql
public String applyLocksToSql(String sql, LockOptions aliasedLockOptions, Map<String,String[]> keyColumnNames)
Description copied from class:Dialect
Modifies the given SQL by applying the appropriate updates for the specified lock modes and key columns. The behavior here is that of an ANSI SQLSELECT FOR UPDATE
. This method is really intended to allow dialects which do not supportSELECT FOR UPDATE
to achieve this in their own fashion.- Overrides:
applyLocksToSql
in classDialect
- Parameters:
sql
- the SQL string to modifyaliasedLockOptions
- lock options indexed by aliased table names.keyColumnNames
- a map of key columns indexed by aliased table names.- Returns:
- the modified SQL string.
-
registerResultSetOutParameter
public int registerResultSetOutParameter(CallableStatement statement, int col) throws SQLException
Description copied from class:Dialect
Registers a parameter (either OUT, or the new REF_CURSOR param type available in Java 8) capable of returningResultSet
*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.- Overrides:
registerResultSetOutParameter
in classDialect
- Parameters:
statement
- The callable statement.col
- The bind position at which to register the output param.- Returns:
- The number of (contiguous) bind positions used.
- Throws:
SQLException
- Indicates problems registering the param.
-
getResultSet
public ResultSet getResultSet(CallableStatement ps) throws SQLException
Description copied from class:Dialect
Given a callable statement previously processed byDialect.registerResultSetOutParameter(java.sql.CallableStatement, int)
, extract theResultSet
from the OUT parameter.- Overrides:
getResultSet
in classDialect
- Parameters:
ps
- The callable statement.- Returns:
- The extracted result set.
- Throws:
SQLException
- Indicates problems extracting the result set.
-
supportsCurrentTimestampSelection
public boolean supportsCurrentTimestampSelection()
Description copied from class:Dialect
Does this dialect support a way to retrieve the database's current timestamp value?- Overrides:
supportsCurrentTimestampSelection
in classDialect
- Returns:
- True if the current timestamp can be retrieved; false otherwise.
-
isCurrentTimestampSelectStringCallable
public boolean isCurrentTimestampSelectStringCallable()
Description copied from class:Dialect
Should the value returned byDialect.getCurrentTimestampSelectString()
be treated as callable. Typically this indicates that JDBC escape syntax is being used...- Overrides:
isCurrentTimestampSelectStringCallable
in classDialect
- Returns:
- True if the
Dialect.getCurrentTimestampSelectString()
return is callable; false otherwise.
-
getCurrentTimestampSelectString
public String getCurrentTimestampSelectString()
Description copied from class:Dialect
Retrieve the command used to retrieve the current timestamp from the database.- Overrides:
getCurrentTimestampSelectString
in classDialect
- Returns:
- The command.
-
getNullOrdering
public NullOrdering getNullOrdering()
Description copied from class:Dialect
Returns the ordering of null.- Overrides:
getNullOrdering
in classDialect
-
getFallbackSqmMutationStrategy
public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy(EntityMappingType entityDescriptor, RuntimeModelCreationContext runtimeModelCreationContext)
- Overrides:
getFallbackSqmMutationStrategy
in classDialect
-
getFallbackSqmInsertStrategy
public SqmMultiTableInsertStrategy getFallbackSqmInsertStrategy(EntityMappingType entityDescriptor, RuntimeModelCreationContext runtimeModelCreationContext)
- Overrides:
getFallbackSqmInsertStrategy
in classDialect
-
getSupportedTemporaryTableKind
public TemporaryTableKind getSupportedTemporaryTableKind()
- Overrides:
getSupportedTemporaryTableKind
in classDialect
-
getTemporaryTableCreateCommand
public String getTemporaryTableCreateCommand()
- Overrides:
getTemporaryTableCreateCommand
in classDialect
-
getTemporaryTableAfterUseAction
public AfterUseAction getTemporaryTableAfterUseAction()
- Overrides:
getTemporaryTableAfterUseAction
in classDialect
-
getTemporaryTableBeforeUseAction
public BeforeUseAction getTemporaryTableBeforeUseAction()
- Overrides:
getTemporaryTableBeforeUseAction
in classDialect
-
getSelectGUIDString
public String getSelectGUIDString()
Description copied from class:Dialect
Get the command used to select a GUID from the underlying database. Optional operation.- Overrides:
getSelectGUIDString
in classDialect
- Returns:
- The appropriate command.
-
supportsExistsInSelect
public boolean supportsExistsInSelect()
Description copied from class:Dialect
Does the dialect support an exists statement in the select clause?- Overrides:
supportsExistsInSelect
in classDialect
- Returns:
- True if exists checks are allowed in the select clause; false otherwise.
-
doesReadCommittedCauseWritersToBlockReaders
public boolean doesReadCommittedCauseWritersToBlockReaders()
Description copied from class:Dialect
For the underlying database, is READ_COMMITTED isolation implemented by forcing readers to wait for write locks to be released?- Overrides:
doesReadCommittedCauseWritersToBlockReaders
in classDialect
- Returns:
- True if writers block readers to achieve READ_COMMITTED; false otherwise.
-
doesRepeatableReadCauseReadersToBlockWriters
public boolean doesRepeatableReadCauseReadersToBlockWriters()
Description copied from class:Dialect
For the underlying database, is REPEATABLE_READ isolation implemented by forcing writers to wait for read locks to be released?- Overrides:
doesRepeatableReadCauseReadersToBlockWriters
in classDialect
- Returns:
- True if readers block writers to achieve REPEATABLE_READ; false otherwise.
-
supportsTupleDistinctCounts
public boolean supportsTupleDistinctCounts()
Description copied from class:Dialect
Does this dialect support `count(distinct a,b)`?- Overrides:
supportsTupleDistinctCounts
in classDialect
- Returns:
- True if the database supports counting distinct tuples; false otherwise.
-
getIdentityColumnSupport
public IdentityColumnSupport getIdentityColumnSupport()
Description copied from class:Dialect
Get the appropriateIdentityColumnSupport
- Overrides:
getIdentityColumnSupport
in classDialect
- Returns:
- the IdentityColumnSupport
-
supportsPartitionBy
public boolean supportsPartitionBy()
Description copied from class:Dialect
Does the underlying database support partition by?- Overrides:
supportsPartitionBy
in classDialect
-
appendBinaryLiteral
public void appendBinaryLiteral(SqlAppender appender, byte[] bytes)
- Overrides:
appendBinaryLiteral
in classDialect
-
-