Package org.hibernate.dialect
Class Dialect
- java.lang.Object
-
- org.hibernate.dialect.Dialect
-
- All Implemented Interfaces:
ConversionContext
- Direct Known Subclasses:
AbstractHANADialect
,Cache71Dialect
,CockroachDB192Dialect
,CUBRIDDialect
,DB2Dialect
,FrontBaseDialect
,H2Dialect
,HSQLDialect
,InformixDialect
,IngresDialect
,InterbaseDialect
,JDataStoreDialect
,MckoiDialect
,MimerSQLDialect
,MySQLDialect
,Oracle8iDialect
,Oracle9Dialect
,PointbaseDialect
,PostgreSQL81Dialect
,ProgressDialect
,RDMSOS2200Dialect
,SAPDBDialect
,SQLServerDialect
,SybaseDialect
,TeradataDialect
,TimesTenDialect
public abstract class Dialect extends java.lang.Object implements ConversionContext
Represents a dialect of SQL implemented by a particular RDBMS. Subclasses implement Hibernate compatibility with different systems. Subclasses should provide a public default constructor that register a set of type mappings and default Hibernate properties. Subclasses should be immutable.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CLOSED_QUOTE
Characters used as closing for quoting SQL identifiersstatic java.lang.String
DEFAULT_BATCH_SIZE
Defines a default batch size constantprotected static LobMergeStrategy
LEGACY_LOB_MERGE_STRATEGY
The legacy behavior of Hibernate.protected static LobMergeStrategy
NEW_LOCATOR_LOB_MERGE_STRATEGY
Merge strategy based on creating a new LOB locator.static java.lang.String
NO_BATCH
Defines a "no batching" batch size constantstatic java.lang.String
QUOTE
Characters used as opening for quoting SQL identifiersprotected BatchLoadSizingStrategy
STANDARD_DEFAULT_BATCH_LOAD_SIZING_STRATEGY
protected static LobMergeStrategy
STREAM_XFER_LOB_MERGE_STRATEGY
Merge strategy based on transferring contents based on streams.static java.lang.String
TWO_SINGLE_QUOTES_REPLACEMENT
-
Constructor Summary
Constructors Modifier Constructor Description protected
Dialect()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.String
addSqlHintOrComment(java.lang.String sql, QueryParameters parameters, boolean commentsEnabled)
Modify the SQL, adding hints or comments, if necessaryjava.lang.String
appendLockHint(LockMode mode, java.lang.String tableName)
Deprecated.useappendLockHint(LockOptions,String)
insteadjava.lang.String
appendLockHint(LockOptions lockOptions, java.lang.String tableName)
Some dialects support an alternative means to SELECT FOR UPDATE, whereby a "lock hint" is appended to the table name in the from clause.java.lang.String
applyLocksToSql(java.lang.String sql, LockOptions aliasedLockOptions, java.util.Map<java.lang.String,java.lang.String[]> keyColumnNames)
Modifies the given SQL by applying the appropriate updates for the specified lock modes and key columns.boolean
areStringComparisonsCaseInsensitive()
Are string comparisons implicitly case insensitive.void
augmentPhysicalTableTypes(java.util.List<java.lang.String> tableTypesList)
void
augmentRecognizedTableTypes(java.util.List<java.lang.String> tableTypesList)
boolean
bindLimitParametersFirst()
Deprecated.getLimitHandler()
should be overridden instead.boolean
bindLimitParametersInReverseOrder()
Deprecated.getLimitHandler()
should be overridden instead.IdentifierHelper
buildIdentifierHelper(IdentifierHelperBuilder builder, java.sql.DatabaseMetaData dbMetaData)
Build the IdentifierHelper indicated by this Dialect for handling identifier conversions.SQLExceptionConversionDelegate
buildSQLExceptionConversionDelegate()
Build an instance of aSQLExceptionConversionDelegate
for interpreting dialect-specific error or SQLState codes.SQLExceptionConverter
buildSQLExceptionConverter()
Deprecated.buildSQLExceptionConversionDelegate()
should be overridden instead.boolean
canCreateCatalog()
Does this dialect support catalog creation?boolean
canCreateSchema()
Does this dialect support schema creation?java.lang.String
cast(java.lang.String value, int jdbcTypeCode, int length)
Return an expression casting the value to the specified type.java.lang.String
cast(java.lang.String value, int jdbcTypeCode, int precision, int scale)
Return an expression casting the value to the specified type.java.lang.String
cast(java.lang.String value, int jdbcTypeCode, int length, int precision, int scale)
Return an expression casting the value to the specified typechar
closeQuote()
The character specific to this dialect used to close a quoted identifier.void
contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry)
Allows the Dialect to contribute additional typesint
convertToFirstRowValue(int zeroBasedFirstResult)
Deprecated.getLimitHandler()
should be overridden instead.CaseFragment
createCaseFragment()
Create aCaseFragment
strategy responsible for handling this dialect's variations in how CASE statements are handled.JoinFragment
createOuterJoinFragment()
Create aJoinFragment
strategy responsible for handling this dialect's variations in how joins are handled.ScrollMode
defaultScrollMode()
Certain dialects support a subset of ScrollModes.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?boolean
dropConstraints()
Do we need to drop constraints before dropping tables in this dialect?boolean
equivalentTypes(int typeCode1, int typeCode2)
Do the given JDBC type codes, as defined inTypes
represent essentially the same type in this dialect of SQL? The default implementation treatsNUMERIC
andDECIMAL
as the same type, andFLOAT
,REAL
, andDOUBLE
as essentially the same type, since the ANSI SQL specification fails to meaningfully distinguish them.static java.lang.String
escapeComment(java.lang.String comment)
protected java.lang.String
escapeLiteral(java.lang.String literal)
Escape String literal.boolean
forceLimitUsage()
Deprecated.getLimitHandler()
should be overridden instead.boolean
forceLobAsLastValue()
HHH-4635 Oracle expects all Lob values to be last in inserts and updates.boolean
forUpdateOfColumns()
Is FOR UPDATE OF syntax supported?java.lang.String
getAddColumnString()
The syntax used to add a column to a table (optional).java.lang.String
getAddColumnSuffixString()
The syntax for the suffix used to add a column to a table (optional).java.lang.String
getAddForeignKeyConstraintString(java.lang.String constraintName, java.lang.String foreignKeyDefinition)
java.lang.String
getAddForeignKeyConstraintString(java.lang.String constraintName, java.lang.String[] foreignKey, java.lang.String referencedTable, java.lang.String[] primaryKey, boolean referencesPrimaryKey)
The syntax used to add a foreign key constraint to a table.java.lang.String
getAddPrimaryKeyConstraintString(java.lang.String constraintName)
The syntax used to add a primary key constraint to a table.java.lang.String
getAddUniqueConstraintString(java.lang.String constraintName)
Deprecated.getUniqueDelegate()
should be overridden instead.java.lang.String
getAlterTableString(java.lang.String tableName)
Command used to alter a table.Exporter<AuxiliaryDatabaseObject>
getAuxiliaryDatabaseObjectExporter()
CallableStatementSupport
getCallableStatementSupport()
java.lang.String
getCascadeConstraintsString()
Completely optional cascading drop clausejava.lang.String
getCaseInsensitiveLike()
The name of the SQL function that can do case insensitive like comparison.java.lang.String
getCastTypeName(int code)
Get the name of the database type appropriate for casting operations (via the CAST() SQL function) for the givenTypes
typecode.ColumnAliasExtractor
getColumnAliasExtractor()
java.lang.String
getColumnComment(java.lang.String comment)
Get the comment into a form supported for column definition.java.lang.String[]
getCreateCatalogCommand(java.lang.String catalogName)
Get the SQL command used to create the named catalogjava.lang.String
getCreateMultisetTableString()
Slight variation ongetCreateTableString()
.java.lang.String[]
getCreateSchemaCommand(java.lang.String schemaName)
Get the SQL command used to create the named schemaprotected java.lang.String
getCreateSequenceString(java.lang.String sequenceName)
Typically dialects which support sequences can create a sequence with a single command.protected java.lang.String
getCreateSequenceString(java.lang.String sequenceName, int initialValue, int incrementSize)
Overloaded form ofgetCreateSequenceString(String)
, additionally taking the initial value and increment size to be applied to the sequence definition.java.lang.String[]
getCreateSequenceStrings(java.lang.String sequenceName)
Deprecated.UsegetCreateSequenceString(String, int, int)
insteadjava.lang.String[]
getCreateSequenceStrings(java.lang.String sequenceName, int initialValue, int incrementSize)
An optional multi-line form for databases whichsupportsPooledSequences()
.java.lang.String
getCreateTableString()
Command used to create a table.java.lang.String
getCreateTemporaryTableColumnAnnotation(int sqlTypeCode)
Annotation to be appended to the end of each COLUMN clause for temporary tables.java.lang.String
getCrossJoinSeparator()
Returns the separator to use for defining cross joins when translating HQL queries.java.lang.String
getCurrentSchemaCommand()
Get the SQL command used to retrieve the current schema name.java.lang.String
getCurrentTimestampSelectString()
Retrieve the command used to retrieve the current timestamp from the database.java.lang.String
getCurrentTimestampSQLFunctionName()
The name of the database-specific SQL function for retrieving the current timestamp.BatchLoadSizingStrategy
getDefaultBatchLoadSizingStrategy()
MultiTableBulkIdStrategy
getDefaultMultiTableBulkIdStrategy()
java.util.Properties
getDefaultProperties()
Retrieve a set of default Hibernate properties for this database.static Dialect
getDialect()
Deprecated.this static method will be removed.static Dialect
getDialect(java.util.Properties props)
Deprecated.this static method will be removed.java.lang.String[]
getDropCatalogCommand(java.lang.String catalogName)
Get the SQL command used to drop the named catalogjava.lang.String
getDropForeignKeyString()
java.lang.String[]
getDropSchemaCommand(java.lang.String schemaName)
Get the SQL command used to drop the named schemaprotected java.lang.String
getDropSequenceString(java.lang.String sequenceName)
Typically dialects which support sequences can drop a sequence with a single command.java.lang.String[]
getDropSequenceStrings(java.lang.String sequenceName)
The multiline script used to drop a sequence.java.lang.String
getDropTableString(java.lang.String tableName)
Generate a DROP TABLE statementExporter<ForeignKey>
getForeignKeyExporter()
java.lang.String
getForUpdateNowaitString()
Retrieves the FOR UPDATE NOWAIT syntax specific to this dialect.java.lang.String
getForUpdateNowaitString(java.lang.String aliases)
Get the FOR UPDATE OF column_list NOWAIT fragment appropriate for this dialect given the aliases of the columns to be write locked.java.lang.String
getForUpdateSkipLockedString()
Retrieves the FOR UPDATE SKIP LOCKED syntax specific to this dialect.java.lang.String
getForUpdateSkipLockedString(java.lang.String aliases)
Get the FOR UPDATE OF column_list SKIP LOCKED fragment appropriate for this dialect given the aliases of the columns to be write locked.java.lang.String
getForUpdateString()
Get the string to append to SELECT statements to acquire locks for this dialect.java.lang.String
getForUpdateString(java.lang.String aliases)
Get the FOR UPDATE OF column_list fragment appropriate for this dialect given the aliases of the columns to be write locked.java.lang.String
getForUpdateString(java.lang.String aliases, LockOptions lockOptions)
Get the FOR UPDATE OF column_list fragment appropriate for this dialect given the aliases of the columns to be write locked.java.lang.String
getForUpdateString(LockMode lockMode)
Given a lock mode, determine the appropriate for update fragment to use.java.lang.String
getForUpdateString(LockOptions lockOptions)
Given LockOptions (lockMode, timeout), determine the appropriate for update fragment to use.java.util.Map<java.lang.String,SQLFunction>
getFunctions()
Retrieves a map of the dialect's registered functions (functionName =>SQLFunction
).java.lang.String
getHibernateTypeName(int code)
Get the name of the HibernateType
associated with the givenTypes
type code.java.lang.String
getHibernateTypeName(int code, int length, int precision, int scale)
Get the name of the HibernateType
associated with the givenTypes
typecode with the given storage specification parameters.IdentityColumnSupport
getIdentityColumnSupport()
Get the appropriateIdentityColumnSupport
Exporter<Index>
getIndexExporter()
int
getInExpressionCountLimit()
Return the limit that the underlying database places on the number of elements in anIN
predicate.java.util.Set<java.lang.String>
getKeywords()
Deprecated.These are only ever used (if at all) from the code that handles identifier quoting.LimitHandler
getLimitHandler()
Returns the delegate managing LIMIT clause.protected java.lang.String
getLimitString(java.lang.String query, boolean hasOffset)
Deprecated.getLimitHandler()
should be overridden instead.java.lang.String
getLimitString(java.lang.String query, int offset, int limit)
Deprecated.getLimitHandler()
should be overridden instead.LobMergeStrategy
getLobMergeStrategy()
LockingStrategy
getLockingStrategy(Lockable lockable, LockMode lockMode)
Get a strategy instance which knows how to acquire a database-level lock of the specified mode for this dialect.java.lang.String
getLowercaseFunction()
The name of the SQL function that transforms a string to lowercaseint
getMaxAliasLength()
What is the maximum length Hibernate can use for generated aliases?NameQualifierSupport
getNameQualifierSupport()
By default interpret this based on DatabaseMetaData.java.lang.Class
getNativeIdentifierGeneratorClass()
Deprecated.usegetNativeIdentifierGeneratorStrategy()
insteadjava.lang.String
getNativeIdentifierGeneratorStrategy()
Resolves the native generation strategy associated to this dialect.java.lang.String
getNoColumnsInsertString()
The fragment used to insert a row without specifying any column values.java.lang.String
getNotExpression(java.lang.String expression)
Negate an expressionjava.lang.String
getNullColumnString()
The keyword used to specify a nullable column.java.lang.String
getQueryHintString(java.lang.String query, java.lang.String hints)
Apply a hint to the query.java.lang.String
getQueryHintString(java.lang.String query, java.util.List<java.lang.String> hintList)
Apply a hint to the query.java.lang.String
getQuerySequencesString()
Get the select command used retrieve the names of all sequences.java.lang.String
getReadLockString(int timeout)
Get the string to append to SELECT statements to acquire READ locks for this dialect.java.lang.String
getReadLockString(java.lang.String aliases, int timeout)
Get the string to append to SELECT statements to acquire READ locks for this dialect given the aliases of the columns to be read locked.java.sql.ResultSet
getResultSet(java.sql.CallableStatement statement)
Given a callable statement previously processed byregisterResultSetOutParameter(java.sql.CallableStatement, int)
, extract theResultSet
from the OUT parameter.java.sql.ResultSet
getResultSet(java.sql.CallableStatement statement, int position)
Given a callable statement previously processed byregisterResultSetOutParameter(java.sql.CallableStatement, int)
, extract theResultSet
.java.sql.ResultSet
getResultSet(java.sql.CallableStatement statement, java.lang.String name)
Given a callable statement previously processed byregisterResultSetOutParameter(java.sql.CallableStatement, int)
, extract theResultSet
from the OUT parameter.SchemaNameResolver
getSchemaNameResolver()
Get the strategy for determining the schema name of a Connectionjava.lang.String
getSelectClauseNullString(int sqlType)
Given aTypes
type code, determine an appropriate null value to use in a select clause.java.lang.String
getSelectGUIDString()
Get the command used to select a GUID from the underlying database.java.lang.String
getSelectSequenceNextValString(java.lang.String sequenceName)
Generate the select expression fragment that will retrieve the next value of a sequence as part of another (typically DML) statement.Exporter<Sequence>
getSequenceExporter()
SequenceInformationExtractor
getSequenceInformationExtractor()
java.lang.String
getSequenceNextValString(java.lang.String sequenceName)
Generate the appropriate select statement to to retrieve the next value of a sequence.protected SqlTypeDescriptor
getSqlTypeDescriptorOverride(int sqlCode)
Returns theSqlTypeDescriptor
that should be used to handle the given JDBC type code.java.lang.String
getTableComment(java.lang.String comment)
Get the comment into a form supported for table definition.Exporter<Table>
getTableExporter()
java.lang.String
getTableTypeString()
java.lang.String
getTypeName(int code)
Get the name of the database type associated with the givenTypes
typecode.java.lang.String
getTypeName(int code, long length, int precision, int scale)
Get the name of the database type associated with the givenTypes
typecode with the given storage specification parameters.UniqueDelegate
getUniqueDelegate()
Get the UniqueDelegate supported by this dialectExporter<Constraint>
getUniqueKeyExporter()
ViolatedConstraintNameExtracter
getViolatedConstraintNameExtracter()
java.lang.String
getWriteLockString(int timeout)
Get the string to append to SELECT statements to acquire WRITE locks for this dialect.java.lang.String
getWriteLockString(java.lang.String aliases, int timeout)
Get the string to append to SELECT statements to acquire WRITE locks for this dialect given the aliases of the columns to be write locked.boolean
hasAlterTable()
Does this dialect support the ALTER TABLE syntax?boolean
hasSelfReferentialForeignKeyBug()
Does the database/driver have bug in deleting rows that refer to other rows being deleted in the same query?java.lang.String
inlineLiteral(java.lang.String literal)
Inline String literal.boolean
isCurrentTimestampSelectStringCallable()
Should the value returned bygetCurrentTimestampSelectString()
be treated as callable.boolean
isJdbcLogWarningsEnabledByDefault()
Does the fetching JDBC statement warning for logging is enabled by defaultboolean
isLegacyLimitHandlerBehaviorEnabled()
boolean
isLockTimeoutParameterized()
If this dialect supports specifying lock timeouts, are those timeouts rendered into the SQL string as parameters.boolean
isTypeNameRegistered(java.lang.String typeName)
Whether or not the given type name has been registered for this dialect (including both hibernate type names and custom-registered type names).char
openQuote()
The character specific to this dialect used to begin a quoted identifier.protected java.lang.String
prependComment(java.lang.String sql, java.lang.String comment)
boolean
qualifyIndexName()
Do we need to qualify index names with the schema name?java.lang.String
quote(java.lang.String name)
Apply dialect-specific quoting.protected void
registerColumnType(int code, long capacity, java.lang.String name)
Subclasses register a type name for the given type code and maximum column length.protected void
registerColumnType(int code, java.lang.String name)
Subclasses register a type name for the given type code.protected void
registerFunction(java.lang.String name, SQLFunction function)
protected void
registerHibernateType(int code, long capacity, java.lang.String name)
Registers a HibernateType
name for the givenTypes
type code and maximum column length.protected void
registerHibernateType(int code, java.lang.String name)
Registers a HibernateType
name for the givenTypes
type code.protected void
registerKeyword(java.lang.String word)
int
registerResultSetOutParameter(java.sql.CallableStatement statement, int position)
Registers a parameter (either OUT, or the new REF_CURSOR param type available in Java 8) capable of returningResultSet
*by position*.int
registerResultSetOutParameter(java.sql.CallableStatement statement, java.lang.String name)
Registers a parameter (either OUT, or the new REF_CURSOR param type available in Java 8) capable of returningResultSet
*by name*.SqlTypeDescriptor
remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor)
Allows the dialect to override aSqlTypeDescriptor
.java.lang.String
renderOrderByElement(java.lang.String expression, java.lang.String collation, java.lang.String order, NullPrecedence nulls)
Renders an ordering fragmentboolean
replaceResultVariableInOrderByClauseWithPosition()
Does this dialect require that references to result variables (i.e, select expression aliases) in an ORDER BY clause be replaced by column positions (1-origin) as defined by the select clause?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
requiresParensForTupleDistinctCounts()
IfsupportsTupleDistinctCounts()
is true, does the Dialect require the tuple to be wrapped with parens?boolean
supportsBindAsCallableArgument()
Does this dialect support using a JDBC bind parameter as an argument to a function or procedure call?boolean
supportsCascadeDelete()
Does this dialect support cascaded delete on foreign key definitions?boolean
supportsCaseInsensitiveLike()
Does this dialect support case insensitive LIKE restrictions?boolean
supportsCircularCascadeDeleteConstraints()
Does this dialect support definition of cascade delete constraints which can cause circular chains?boolean
supportsColumnCheck()
Does this dialect support column-level check constraints?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?boolean
supportsExistsInSelect()
Does the dialect support an exists statement in the select clause?boolean
supportsExpectedLobUsagePattern()
Expected LOB usage pattern is such that I can perform an insert via prepared statement with a parameter binding for a LOB value without crazy casting to JDBC driver implementation-specific classes...boolean
supportsIfExistsAfterAlterTable()
For an "alter table", can the phrase "if exists" be applied?boolean
supportsIfExistsAfterConstraintName()
For dropping a constraint with an "alter table", can the phrase "if exists" be applied after the constraint name?boolean
supportsIfExistsAfterTableName()
For dropping a table, can the phrase "if exists" be applied after the table name?boolean
supportsIfExistsBeforeConstraintName()
For dropping a constraint with an "alter table", can the phrase "if exists" be applied before the constraint name?boolean
supportsIfExistsBeforeTableName()
For dropping a table, can the phrase "if exists" be applied before the table name?boolean
supportsJdbcConnectionLobCreation(java.sql.DatabaseMetaData databaseMetaData)
Check whether the JDBCConnection
supports creating LOBs viaConnection.createBlob()
,Connection.createNClob()
orConnection.createClob()
.boolean
supportsLimit()
Deprecated.getLimitHandler()
should be overridden instead.boolean
supportsLimitOffset()
Deprecated.getLimitHandler()
should be overridden instead.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
supportsNamedParameters(java.sql.DatabaseMetaData databaseMetaData)
Override the DatabaseMetaData#supportsNamedParameters()boolean
supportsNationalizedTypes()
Does this dialect supports Nationalized Typesboolean
supportsNoColumnsInsert()
Check if the INSERT statement is allowed to contain no column.boolean
supportsNonQueryWithCTE()
Does this dialect/database support non-query statements (e.g.boolean
supportsNotNullUnique()
Deprecated.getUniqueDelegate()
should be overridden instead.boolean
supportsNoWait()
Does this dialect/database support NO_WAIT timeout.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
supportsPartitionBy()
Does the underlying database support partition byboolean
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
supportsRowValueConstructorSyntax()
Is this dialect known to support what ANSI-SQL terms "row value constructor" syntax; sometimes called tuple syntax.boolean
supportsRowValueConstructorSyntaxInInList()
If the dialect supportsrow values
, does it offer such support in IN lists as well?boolean
supportsRowValueConstructorSyntaxInSet()
Is this dialect known to support what ANSI-SQL terms "row value constructor" syntax, sometimes called tuple syntax, in the SET clause;boolean
supportsSelectAliasInGroupByClause()
boolean
supportsSequences()
Does this dialect support sequences?boolean
supportsSkipLocked()
Does this dialect/database support SKIP_LOCKED timeout.boolean
supportsSubqueryOnMutatingTable()
Does this dialect support referencing the table being mutated in a subquery.boolean
supportsSubselectAsInPredicateLHS()
Are subselects supported as the left-hand-side (LHS) of IN-predicates.boolean
supportsTableCheck()
Does this dialect support table-level check constraints?boolean
supportsTupleCounts()
Does this dialect support `count(a,b)`?boolean
supportsTupleDistinctCounts()
Does this dialect support `count(distinct a,b)`?boolean
supportsTuplesInSubqueries()
Does this dialect support tuples in subqueries? Ex: delete from Table1 where (col1, col2) in (select col1, col2 from Table2)boolean
supportsUnboundedLobLocatorMaterialization()
Is it supported to materialize a LOB locator outside the transaction in which it was created?boolean
supportsUnionAll()
Does this dialect support UNION ALL, which is generally a faster variant of UNION?boolean
supportsUnique()
Deprecated.getUniqueDelegate()
should be overridden instead.boolean
supportsUniqueConstraintInCreateAlterTable()
Deprecated.getUniqueDelegate()
should be overridden instead.boolean
supportsValuesList()
Does this dialect/database support VALUES list (e.g.boolean
supportsVariableLimit()
Deprecated.getLimitHandler()
should be overridden instead.java.lang.String
toBooleanValueString(boolean bool)
The SQL literal value to which this database maps boolean values.java.lang.String
toString()
java.lang.String
transformSelectString(java.lang.String select)
Meant as a means for end users to affect the select strings being sent to the database and perhaps manipulate them in some fashion.boolean
useFollowOnLocking()
Deprecated.UseuseFollowOnLocking(QueryParameters)
instead.boolean
useFollowOnLocking(QueryParameters parameters)
Some dialects have trouble applying pessimistic locking depending upon what other query options are specified (paging, ordering, etc).boolean
useInputStreamToInsertBlob()
Should LOBs (both BLOB and CLOB) be bound using stream operations (i.e.boolean
useMaxForLimit()
Deprecated.getLimitHandler()
should be overridden instead.
-
-
-
Field Detail
-
DEFAULT_BATCH_SIZE
public static final java.lang.String DEFAULT_BATCH_SIZE
Defines a default batch size constant- See Also:
- Constant Field Values
-
NO_BATCH
public static final java.lang.String NO_BATCH
Defines a "no batching" batch size constant- See Also:
- Constant Field Values
-
QUOTE
public static final java.lang.String QUOTE
Characters used as opening for quoting SQL identifiers- See Also:
- Constant Field Values
-
CLOSED_QUOTE
public static final java.lang.String CLOSED_QUOTE
Characters used as closing for quoting SQL identifiers- See Also:
- Constant Field Values
-
TWO_SINGLE_QUOTES_REPLACEMENT
public static final java.lang.String TWO_SINGLE_QUOTES_REPLACEMENT
-
LEGACY_LOB_MERGE_STRATEGY
protected static final LobMergeStrategy LEGACY_LOB_MERGE_STRATEGY
The legacy behavior of Hibernate. LOBs are not processed by merge
-
STREAM_XFER_LOB_MERGE_STRATEGY
protected static final LobMergeStrategy STREAM_XFER_LOB_MERGE_STRATEGY
Merge strategy based on transferring contents based on streams.
-
NEW_LOCATOR_LOB_MERGE_STRATEGY
protected static final LobMergeStrategy NEW_LOCATOR_LOB_MERGE_STRATEGY
Merge strategy based on creating a new LOB locator.
-
STANDARD_DEFAULT_BATCH_LOAD_SIZING_STRATEGY
protected final BatchLoadSizingStrategy STANDARD_DEFAULT_BATCH_LOAD_SIZING_STRATEGY
-
-
Method Detail
-
equivalentTypes
public boolean equivalentTypes(int typeCode1, int typeCode2)
Do the given JDBC type codes, as defined inTypes
represent essentially the same type in this dialect of SQL? The default implementation treatsNUMERIC
andDECIMAL
as the same type, andFLOAT
,REAL
, andDOUBLE
as essentially the same type, since the ANSI SQL specification fails to meaningfully distinguish them.- Parameters:
typeCode1
- the first JDBC type codetypeCode2
- the second JDBC type code- Returns:
true
if the two type codes are equivalent
-
getDialect
@Deprecated public static Dialect getDialect() throws HibernateException
Deprecated.this static method will be removed.Get an instance of the dialect specified by the current System properties.- Returns:
- The specified Dialect
- Throws:
HibernateException
- If no dialect was specified, or if it could not be instantiated.
-
getDialect
@Deprecated public static Dialect getDialect(java.util.Properties props) throws HibernateException
Deprecated.this static method will be removed.Get an instance of the dialect specified by the given properties or by the current System properties.- Parameters:
props
- The properties to use for finding the dialect class to use.- Returns:
- The specified Dialect
- Throws:
HibernateException
- If no dialect was specified, or if it could not be instantiated.
-
getDefaultProperties
public final java.util.Properties getDefaultProperties()
Retrieve a set of default Hibernate properties for this database.- Returns:
- a set of Hibernate properties
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
contributeTypes
public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry)
Allows the Dialect to contribute additional types- Parameters:
typeContributions
- Callback to contribute the typesserviceRegistry
- The service registry
-
getTypeName
public java.lang.String getTypeName(int code) throws HibernateException
Get the name of the database type associated with the givenTypes
typecode.- Parameters:
code
- TheTypes
typecode- Returns:
- the database type name
- Throws:
HibernateException
- If no mapping was specified for that type.
-
getTypeName
public java.lang.String getTypeName(int code, long length, int precision, int scale) throws HibernateException
Get the name of the database type associated with the givenTypes
typecode with the given storage specification parameters.- Parameters:
code
- TheTypes
typecodelength
- The datatype lengthprecision
- The datatype precisionscale
- The datatype scale- Returns:
- the database type name
- Throws:
HibernateException
- If no mapping was specified for that type.
-
getCastTypeName
public java.lang.String getCastTypeName(int code)
Get the name of the database type appropriate for casting operations (via the CAST() SQL function) for the givenTypes
typecode.- Parameters:
code
- TheTypes
typecode- Returns:
- The database type name
-
cast
public java.lang.String cast(java.lang.String value, int jdbcTypeCode, int length, int precision, int scale)
Return an expression casting the value to the specified type- Parameters:
value
- The value to castjdbcTypeCode
- The JDBC type code to cast tolength
- The type lengthprecision
- The type precisionscale
- The type scale- Returns:
- The cast expression
-
cast
public java.lang.String cast(java.lang.String value, int jdbcTypeCode, int length)
Return an expression casting the value to the specified type. Simply callscast(String, int, int, int, int)
passingColumn.DEFAULT_PRECISION
andColumn.DEFAULT_SCALE
as the precision/scale.- Parameters:
value
- The value to castjdbcTypeCode
- The JDBC type code to cast tolength
- The type length- Returns:
- The cast expression
-
cast
public java.lang.String cast(java.lang.String value, int jdbcTypeCode, int precision, int scale)
Return an expression casting the value to the specified type. Simply callscast(String, int, int, int, int)
passingColumn.DEFAULT_LENGTH
as the length- Parameters:
value
- The value to castjdbcTypeCode
- The JDBC type code to cast toprecision
- The type precisionscale
- The type scale- Returns:
- The cast expression
-
registerColumnType
protected void registerColumnType(int code, long capacity, java.lang.String name)
Subclasses register a type name for the given type code and maximum column length. $l in the type name with be replaced by the column length (if appropriate).- Parameters:
code
- TheTypes
typecodecapacity
- The maximum length of database typename
- The database type name
-
registerColumnType
protected void registerColumnType(int code, java.lang.String name)
Subclasses register a type name for the given type code. $l in the type name with be replaced by the column length (if appropriate).- Parameters:
code
- TheTypes
typecodename
- The database type name
-
remapSqlTypeDescriptor
public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor)
Allows the dialect to override aSqlTypeDescriptor
. If the passedsqlTypeDescriptor
allows itself to be remapped (perSqlTypeDescriptor.canBeRemapped()
), then this method usesgetSqlTypeDescriptorOverride(int)
to get an optional override based on the SQL code returned bySqlTypeDescriptor.getSqlType()
. If this dialect does not provide an override or if thesqlTypeDescriptor
does not allow itself to be remapped, then this method simply returns the original passedsqlTypeDescriptor
- Parameters:
sqlTypeDescriptor
- TheSqlTypeDescriptor
to override- Returns:
- The
SqlTypeDescriptor
that should be used for this dialect; if there is no override, then originalsqlTypeDescriptor
is returned. - Throws:
java.lang.IllegalArgumentException
- ifsqlTypeDescriptor
is null.- See Also:
getSqlTypeDescriptorOverride(int)
-
getSqlTypeDescriptorOverride
protected SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode)
Returns theSqlTypeDescriptor
that should be used to handle the given JDBC type code. Returnsnull
if there is no override.- Parameters:
sqlCode
- ATypes
constant indicating the SQL column type- Returns:
- The
SqlTypeDescriptor
to use as an override, ornull
if there is no override.
-
getLobMergeStrategy
public LobMergeStrategy getLobMergeStrategy()
-
getHibernateTypeName
public java.lang.String getHibernateTypeName(int code) throws HibernateException
Get the name of the HibernateType
associated with the givenTypes
type code.- Parameters:
code
- TheTypes
type code- Returns:
- The Hibernate
Type
name. - Throws:
HibernateException
- If no mapping was specified for that type.
-
isTypeNameRegistered
public boolean isTypeNameRegistered(java.lang.String typeName)
Whether or not the given type name has been registered for this dialect (including both hibernate type names and custom-registered type names).- Parameters:
typeName
- the type name.- Returns:
- true if the given string has been registered either as a hibernate type or as a custom-registered one
-
getHibernateTypeName
public java.lang.String getHibernateTypeName(int code, int length, int precision, int scale) throws HibernateException
Get the name of the HibernateType
associated with the givenTypes
typecode with the given storage specification parameters.- Parameters:
code
- TheTypes
typecodelength
- The datatype lengthprecision
- The datatype precisionscale
- The datatype scale- Returns:
- The Hibernate
Type
name. - Throws:
HibernateException
- If no mapping was specified for that type.
-
registerHibernateType
protected void registerHibernateType(int code, long capacity, java.lang.String name)
Registers a HibernateType
name for the givenTypes
type code and maximum column length.- Parameters:
code
- TheTypes
typecodecapacity
- The maximum length of database typename
- The HibernateType
name
-
registerHibernateType
protected void registerHibernateType(int code, java.lang.String name)
Registers a HibernateType
name for the givenTypes
type code.- Parameters:
code
- TheTypes
typecodename
- The HibernateType
name
-
registerFunction
protected void registerFunction(java.lang.String name, SQLFunction function)
-
getFunctions
public final java.util.Map<java.lang.String,SQLFunction> getFunctions()
Retrieves a map of the dialect's registered functions (functionName =>SQLFunction
).- Returns:
- The map of registered functions.
-
getNativeIdentifierGeneratorClass
@Deprecated public java.lang.Class getNativeIdentifierGeneratorClass()
Deprecated.usegetNativeIdentifierGeneratorStrategy()
insteadThe class (which implementsIdentifierGenerator
) which acts as this dialects native generation strategy. Comes into play whenever the user specifies the native generator.- Returns:
- The native generator class.
-
getNativeIdentifierGeneratorStrategy
public java.lang.String getNativeIdentifierGeneratorStrategy()
Resolves the native generation strategy associated to this dialect. Comes into play whenever the user specifies the native generator.- Returns:
- The native generator strategy.
-
getIdentityColumnSupport
public IdentityColumnSupport getIdentityColumnSupport()
Get the appropriateIdentityColumnSupport
- Returns:
- the IdentityColumnSupport
- Since:
- 5.1
-
supportsSequences
public boolean supportsSequences()
Does this dialect support sequences?- Returns:
- True if sequences supported; false otherwise.
-
supportsPooledSequences
public boolean supportsPooledSequences()
Does this dialect support "pooled" sequences. Not aware of a better name for this. Essentially can we specify the initial and increment values?- Returns:
- True if such "pooled" sequences are supported; false otherwise.
- See Also:
getCreateSequenceStrings(String, int, int)
,getCreateSequenceString(String, int, int)
-
getSequenceNextValString
public java.lang.String getSequenceNextValString(java.lang.String sequenceName) throws MappingException
Generate the appropriate select statement to to retrieve the next value of a sequence. This should be a "stand alone" select statement.- Parameters:
sequenceName
- the name of the sequence- Returns:
- String The "nextval" select string.
- Throws:
MappingException
- If sequences are not supported.
-
getSelectSequenceNextValString
public java.lang.String getSelectSequenceNextValString(java.lang.String sequenceName) throws MappingException
Generate the select expression fragment that will retrieve the next value of a sequence as part of another (typically DML) statement. This differs fromgetSequenceNextValString(String)
in that this should return an expression usable within another statement.- Parameters:
sequenceName
- the name of the sequence- Returns:
- The "nextval" fragment.
- Throws:
MappingException
- If sequences are not supported.
-
getCreateSequenceStrings
@Deprecated public java.lang.String[] getCreateSequenceStrings(java.lang.String sequenceName) throws MappingException
Deprecated.UsegetCreateSequenceString(String, int, int)
insteadThe multiline script used to create a sequence.- Parameters:
sequenceName
- The name of the sequence- Returns:
- The sequence creation commands
- Throws:
MappingException
- If sequences are not supported.
-
getCreateSequenceStrings
public java.lang.String[] getCreateSequenceStrings(java.lang.String sequenceName, int initialValue, int incrementSize) throws MappingException
An optional multi-line form for databases whichsupportsPooledSequences()
.- Parameters:
sequenceName
- The name of the sequenceinitialValue
- The initial value to apply to 'create sequence' statementincrementSize
- The increment value to apply to 'create sequence' statement- Returns:
- The sequence creation commands
- Throws:
MappingException
- If sequences are not supported.
-
getCreateSequenceString
protected java.lang.String getCreateSequenceString(java.lang.String sequenceName) throws MappingException
Typically dialects which support sequences can create a sequence with a single command. This is convenience form ofgetCreateSequenceStrings(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 overridegetCreateSequenceStrings(java.lang.String)
.- Parameters:
sequenceName
- The name of the sequence- Returns:
- The sequence creation command
- Throws:
MappingException
- If sequences are not supported.
-
getCreateSequenceString
protected java.lang.String getCreateSequenceString(java.lang.String sequenceName, int initialValue, int incrementSize) throws MappingException
Overloaded form ofgetCreateSequenceString(String)
, additionally taking the initial value and increment size to be applied to the sequence definition. The default definition is to suffixgetCreateSequenceString(String)
with the string: " start with {initialValue} increment by {incrementSize}" where {initialValue} and {incrementSize} are replacement placeholders. Generally dialects should only need to override this method if different key phrases are used to apply the allocation information.- Parameters:
sequenceName
- The name of the sequenceinitialValue
- The initial value to apply to 'create sequence' statementincrementSize
- The increment value to apply to 'create sequence' statement- Returns:
- The sequence creation command
- Throws:
MappingException
- If sequences are not supported.
-
getDropSequenceStrings
public java.lang.String[] getDropSequenceStrings(java.lang.String sequenceName) throws MappingException
The multiline script used to drop a sequence.- Parameters:
sequenceName
- The name of the sequence- Returns:
- The sequence drop commands
- Throws:
MappingException
- If sequences are not supported.
-
getDropSequenceString
protected java.lang.String getDropSequenceString(java.lang.String sequenceName) throws MappingException
Typically dialects which support sequences can drop a sequence with a single command. This is convenience form ofgetDropSequenceStrings(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 overridegetDropSequenceStrings(java.lang.String)
.- Parameters:
sequenceName
- The name of the sequence- Returns:
- The sequence drop commands
- Throws:
MappingException
- If sequences are not supported.
-
getQuerySequencesString
public java.lang.String getQuerySequencesString()
Get the select command used retrieve the names of all sequences.- Returns:
- The select command; or null if sequences are not supported.
- See Also:
SchemaUpdate
-
getSequenceInformationExtractor
public SequenceInformationExtractor getSequenceInformationExtractor()
-
getSelectGUIDString
public java.lang.String getSelectGUIDString()
Get the command used to select a GUID from the underlying database. Optional operation.- Returns:
- The appropriate command.
-
getLimitHandler
public LimitHandler getLimitHandler()
Returns the delegate managing LIMIT clause.- Returns:
- LIMIT clause delegate.
-
supportsLimit
@Deprecated public boolean supportsLimit()
Deprecated.getLimitHandler()
should be overridden instead.Does this dialect support some form of limiting query results via a SQL clause?- Returns:
- True if this dialect supports some form of LIMIT.
-
supportsLimitOffset
@Deprecated public boolean supportsLimitOffset()
Deprecated.getLimitHandler()
should be overridden instead.Does this dialect's LIMIT support (if any) additionally support specifying an offset?- Returns:
- True if the dialect supports an offset within the limit support.
-
supportsVariableLimit
@Deprecated public boolean supportsVariableLimit()
Deprecated.getLimitHandler()
should be overridden instead.Does this dialect support bind variables (i.e., prepared statement parameters) for its limit/offset?- Returns:
- True if bind variables can be used; false otherwise.
-
bindLimitParametersInReverseOrder
@Deprecated public boolean bindLimitParametersInReverseOrder()
Deprecated.getLimitHandler()
should be overridden instead.ANSI SQL defines the LIMIT clause to be in the form LIMIT offset, limit. Does this dialect require us to bind the parameters in reverse order?- Returns:
- true if the correct order is limit, offset
-
bindLimitParametersFirst
@Deprecated public boolean bindLimitParametersFirst()
Deprecated.getLimitHandler()
should be overridden instead.Does the LIMIT clause come at the start of the SELECT statement, rather than at the end?- Returns:
- true if limit parameters should come before other parameters
-
useMaxForLimit
@Deprecated public boolean useMaxForLimit()
Deprecated.getLimitHandler()
should be overridden instead.Does the LIMIT clause take a "maximum" row number instead of a total number of returned rows? This is easiest understood via an example. Consider you have a table with 20 rows, but you only want to retrieve rows number 11 through 20. Generally, a limit with offset would say that the offset = 11 and the limit = 10 (we only want 10 rows at a time); this is specifying the total number of returned rows. Some dialects require that we instead specify offset = 11 and limit = 20, where 20 is the "last" row we want relative to offset (i.e. total number of rows = 20 - 11 = 9) So essentially, is limit relative from offset? Or is limit absolute?- Returns:
- True if limit is relative from offset; false otherwise.
-
forceLimitUsage
@Deprecated public boolean forceLimitUsage()
Deprecated.getLimitHandler()
should be overridden instead.Generally, if there is no limit applied to a Hibernate query we do not apply any limits to the SQL query. This option forces that the limit be written to the SQL query.- Returns:
- True to force limit into SQL query even if none specified in Hibernate query; false otherwise.
-
getLimitString
@Deprecated public java.lang.String getLimitString(java.lang.String query, int offset, int limit)
Deprecated.getLimitHandler()
should be overridden instead.Given a limit and an offset, apply the limit clause to the query.- Parameters:
query
- The query to which to apply the limit.offset
- The offset of the limitlimit
- The limit of the limit ;)- Returns:
- The modified query statement with the limit applied.
-
getLimitString
@Deprecated protected java.lang.String getLimitString(java.lang.String query, boolean hasOffset)
Deprecated.getLimitHandler()
should be overridden instead.Apply a limit clause to the query. Typically dialects utilizevariable
limit clauses when they support limits. Thus, when building the select command we do not actually need to know the limit or the offset since we will just be using placeholders. Here we do still pass along whether or not an offset was specified so that dialects not supporting offsets can generate proper exceptions. In general, dialects will override one or the other of this method andgetLimitString(String, int, int)
.- Parameters:
query
- The query to which to apply the limit.hasOffset
- Is the query requesting an offset?- Returns:
- the modified SQL
-
convertToFirstRowValue
@Deprecated public int convertToFirstRowValue(int zeroBasedFirstResult)
Deprecated.getLimitHandler()
should be overridden instead.Hibernate APIs explicitly state that setFirstResult() should be a zero-based offset. Here we allow the Dialect a chance to convert that value based on what the underlying db or driver will expect. NOTE: what gets passed intogetLimitString(String,int,int)
is the zero-based offset. Dialects which do notsupportsVariableLimit()
should take care to perform any needed first-row-conversion calls prior to injecting the limit values into the SQL string.- Parameters:
zeroBasedFirstResult
- The user-supplied, zero-based first row offset.- Returns:
- The corresponding db/dialect specific offset.
- See Also:
Query.setFirstResult(int)
,Criteria.setFirstResult(int)
-
supportsLockTimeouts
public boolean supportsLockTimeouts()
Informational metadata about whether this dialect is known to support specifying timeouts for requested lock acquisitions.- Returns:
- True is this dialect supports specifying lock timeouts.
-
isLockTimeoutParameterized
public boolean isLockTimeoutParameterized()
If this dialect supports specifying lock timeouts, are those timeouts rendered into the SQL string as parameters. The implication is that Hibernate will need to bind the timeout value as a parameter in thePreparedStatement
. If true, the param position is always handled as the last parameter; if the dialect specifies the lock timeout elsewhere in the SQL statement then the timeout value should be directly rendered into the statement and this method should return false.- Returns:
- True if the lock timeout is rendered into the SQL string as a parameter; false otherwise.
-
getLockingStrategy
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode)
Get a strategy instance which knows how to acquire a database-level lock of the specified mode for this dialect.- Parameters:
lockable
- The persister for the entity to be locked.lockMode
- The type of lock to be acquired.- Returns:
- The appropriate locking strategy.
- Since:
- 3.2
-
getForUpdateString
public java.lang.String getForUpdateString(LockOptions lockOptions)
Given LockOptions (lockMode, timeout), determine the appropriate for update fragment to use.- Parameters:
lockOptions
- contains the lock mode to apply.- Returns:
- The appropriate for update fragment.
-
getForUpdateString
public java.lang.String getForUpdateString(LockMode lockMode)
Given a lock mode, determine the appropriate for update fragment to use.- Parameters:
lockMode
- The lock mode to apply.- Returns:
- The appropriate for update fragment.
-
getForUpdateString
public java.lang.String getForUpdateString()
Get the string to append to SELECT statements to acquire locks for this dialect.- Returns:
- The appropriate FOR UPDATE clause string.
-
getWriteLockString
public java.lang.String getWriteLockString(int timeout)
Get the string to append to SELECT statements to acquire WRITE locks for this dialect. Location of the returned string is treated the same as getForUpdateString.- Parameters:
timeout
- in milliseconds, -1 for indefinite wait and 0 for no wait.- Returns:
- The appropriate LOCK clause string.
-
getWriteLockString
public java.lang.String getWriteLockString(java.lang.String aliases, int timeout)
Get the string to append to SELECT statements to acquire WRITE locks for this dialect given the aliases of the columns to be write locked. Location of the of the returned string is treated the same as getForUpdateString.- Parameters:
aliases
- The columns to be read locked.timeout
- in milliseconds, -1 for indefinite wait and 0 for no wait.- Returns:
- The appropriate LOCK clause string.
-
getReadLockString
public java.lang.String getReadLockString(int timeout)
Get the string to append to SELECT statements to acquire READ locks for this dialect. Location of the returned string is treated the same as getForUpdateString.- Parameters:
timeout
- in milliseconds, -1 for indefinite wait and 0 for no wait.- Returns:
- The appropriate LOCK clause string.
-
getReadLockString
public java.lang.String getReadLockString(java.lang.String aliases, int timeout)
Get the string to append to SELECT statements to acquire READ locks for this dialect given the aliases of the columns to be read locked. Location of the returned string is treated the same as getForUpdateString.- Parameters:
aliases
- The columns to be read locked.timeout
- in milliseconds, -1 for indefinite wait and 0 for no wait.- Returns:
- The appropriate LOCK clause string.
-
forUpdateOfColumns
public boolean forUpdateOfColumns()
Is FOR UPDATE OF syntax supported?- Returns:
- True if the database supports FOR UPDATE OF syntax; false otherwise.
-
supportsOuterJoinForUpdate
public boolean supportsOuterJoinForUpdate()
Does this dialect support FOR UPDATE in conjunction with outer joined rows?- Returns:
- True if outer joined rows can be locked via FOR UPDATE.
-
getForUpdateString
public java.lang.String getForUpdateString(java.lang.String aliases)
Get the FOR UPDATE OF column_list fragment appropriate for this dialect given the aliases of the columns to be write locked.- Parameters:
aliases
- The columns to be write locked.- Returns:
- The appropriate FOR UPDATE OF column_list clause string.
-
getForUpdateString
public java.lang.String getForUpdateString(java.lang.String aliases, LockOptions lockOptions)
Get the FOR UPDATE OF column_list fragment appropriate for this dialect given the aliases of the columns to be write locked.- Parameters:
aliases
- The columns to be write locked.lockOptions
- the lock options to apply- Returns:
- The appropriate FOR UPDATE OF column_list clause string.
-
getForUpdateNowaitString
public java.lang.String getForUpdateNowaitString()
Retrieves the FOR UPDATE NOWAIT syntax specific to this dialect.- Returns:
- The appropriate FOR UPDATE NOWAIT clause string.
-
getForUpdateSkipLockedString
public java.lang.String getForUpdateSkipLockedString()
Retrieves the FOR UPDATE SKIP LOCKED syntax specific to this dialect.- Returns:
- The appropriate FOR UPDATE SKIP LOCKED clause string.
-
getForUpdateNowaitString
public java.lang.String getForUpdateNowaitString(java.lang.String aliases)
Get the FOR UPDATE OF column_list NOWAIT fragment appropriate for this dialect given the aliases of the columns to be write locked.- Parameters:
aliases
- The columns to be write locked.- Returns:
- The appropriate FOR UPDATE OF colunm_list NOWAIT clause string.
-
getForUpdateSkipLockedString
public java.lang.String getForUpdateSkipLockedString(java.lang.String aliases)
Get the FOR UPDATE OF column_list SKIP LOCKED fragment appropriate for this dialect given the aliases of the columns to be write locked.- Parameters:
aliases
- The columns to be write locked.- Returns:
- The appropriate FOR UPDATE colunm_list SKIP LOCKED clause string.
-
appendLockHint
@Deprecated public java.lang.String appendLockHint(LockMode mode, java.lang.String tableName)
Deprecated.useappendLockHint(LockOptions,String)
insteadSome dialects support an alternative means to SELECT FOR UPDATE, whereby a "lock hint" is appended to the table name in the from clause. contributed by Helge Schulz- Parameters:
mode
- The lock mode to applytableName
- The name of the table to which to apply the lock hint.- Returns:
- The table with any required lock hints.
-
appendLockHint
public java.lang.String appendLockHint(LockOptions lockOptions, java.lang.String tableName)
Some dialects support an alternative means to SELECT FOR UPDATE, whereby a "lock hint" is appended to the table name in the from clause. contributed by Helge Schulz- 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 java.lang.String applyLocksToSql(java.lang.String sql, LockOptions aliasedLockOptions, java.util.Map<java.lang.String,java.lang.String[]> keyColumnNames)
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 SQL SELECT FOR UPDATE. This method is really intended to allow dialects which do not support SELECT FOR UPDATE to achieve this in their own fashion.- 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.
-
getCreateTableString
public java.lang.String getCreateTableString()
Command used to create a table.- Returns:
- The command used to create a table.
-
getAlterTableString
public java.lang.String getAlterTableString(java.lang.String tableName)
Command used to alter a table.- Parameters:
tableName
- The name of the table to alter- Returns:
- The command used to alter a table.
- Since:
- 5.2.11
-
getCreateMultisetTableString
public java.lang.String getCreateMultisetTableString()
Slight variation ongetCreateTableString()
. Here, we have the command used to create a table when there is no primary key and duplicate rows are expected. Most databases do not care about the distinction; originally added for Teradata support which does care.- Returns:
- The command used to create a multiset table.
-
getDefaultMultiTableBulkIdStrategy
public MultiTableBulkIdStrategy getDefaultMultiTableBulkIdStrategy()
-
registerResultSetOutParameter
public int registerResultSetOutParameter(java.sql.CallableStatement statement, int position) throws java.sql.SQLException
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.- Parameters:
statement
- The callable statement.position
- The bind position at which to register the output param.- Returns:
- The number of (contiguous) bind positions used.
- Throws:
java.sql.SQLException
- Indicates problems registering the param.
-
registerResultSetOutParameter
public int registerResultSetOutParameter(java.sql.CallableStatement statement, java.lang.String name) throws java.sql.SQLException
Registers a parameter (either OUT, or the new REF_CURSOR param type available in Java 8) capable of returningResultSet
*by name*. Pre-Java 8, registering such ResultSet-returning parameters varied greatly across database and drivers; hence its inclusion as part of the Dialect contract.- Parameters:
statement
- The callable statement.name
- The parameter name (for drivers which support named parameters).- Returns:
- The number of (contiguous) bind positions used.
- Throws:
java.sql.SQLException
- Indicates problems registering the param.
-
getResultSet
public java.sql.ResultSet getResultSet(java.sql.CallableStatement statement) throws java.sql.SQLException
Given a callable statement previously processed byregisterResultSetOutParameter(java.sql.CallableStatement, int)
, extract theResultSet
from the OUT parameter.- Parameters:
statement
- The callable statement.- Returns:
- The extracted result set.
- Throws:
java.sql.SQLException
- Indicates problems extracting the result set.
-
getResultSet
public java.sql.ResultSet getResultSet(java.sql.CallableStatement statement, int position) throws java.sql.SQLException
Given a callable statement previously processed byregisterResultSetOutParameter(java.sql.CallableStatement, int)
, extract theResultSet
.- Parameters:
statement
- The callable statement.position
- The bind position at which to register the output param.- Returns:
- The extracted result set.
- Throws:
java.sql.SQLException
- Indicates problems extracting the result set.
-
getResultSet
public java.sql.ResultSet getResultSet(java.sql.CallableStatement statement, java.lang.String name) throws java.sql.SQLException
Given a callable statement previously processed byregisterResultSetOutParameter(java.sql.CallableStatement, int)
, extract theResultSet
from the OUT parameter.- Parameters:
statement
- The callable statement.name
- The parameter name (for drivers which support named parameters).- Returns:
- The extracted result set.
- Throws:
java.sql.SQLException
- Indicates problems extracting the result set.
-
supportsCurrentTimestampSelection
public boolean supportsCurrentTimestampSelection()
Does this dialect support a way to retrieve the database's current timestamp value?- Returns:
- True if the current timestamp can be retrieved; false otherwise.
-
isCurrentTimestampSelectStringCallable
public boolean isCurrentTimestampSelectStringCallable()
Should the value returned bygetCurrentTimestampSelectString()
be treated as callable. Typically this indicates that JDBC escape syntax is being used...- Returns:
- True if the
getCurrentTimestampSelectString()
return is callable; false otherwise.
-
getCurrentTimestampSelectString
public java.lang.String getCurrentTimestampSelectString()
Retrieve the command used to retrieve the current timestamp from the database.- Returns:
- The command.
-
getCurrentTimestampSQLFunctionName
public java.lang.String getCurrentTimestampSQLFunctionName()
The name of the database-specific SQL function for retrieving the current timestamp.- Returns:
- The function name.
-
buildSQLExceptionConverter
@Deprecated public SQLExceptionConverter buildSQLExceptionConverter()
Deprecated.buildSQLExceptionConversionDelegate()
should be overridden instead.Build an instance of the SQLExceptionConverter preferred by this dialect for converting SQLExceptions into Hibernate's JDBCException hierarchy. The preferred method is to not override this method; if possible,buildSQLExceptionConversionDelegate()
should be overridden instead. If this method is not overridden, the default SQLExceptionConverter implementation executes 3 SQLException converter delegates:- a "static" delegate based on the JDBC 4 defined SQLException hierarchy;
- the vendor-specific delegate returned by
buildSQLExceptionConversionDelegate()
; (it is strongly recommended that specific Dialect implementations overridebuildSQLExceptionConversionDelegate()
) - a delegate that interprets SQLState codes for either X/Open or SQL-2003 codes, depending on java.sql.DatabaseMetaData#getSQLStateType
SQLExceptionConverter
interpret SQL errors based on vendor-specific error codes rather than the SQLState since the interpretation is more accurate when using vendor-specific ErrorCodes.- Returns:
- The Dialect's preferred SQLExceptionConverter, or null to
indicate that the default
SQLExceptionConverter
should be used. - See Also:
buildSQLExceptionConversionDelegate()
-
buildSQLExceptionConversionDelegate
public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate()
Build an instance of aSQLExceptionConversionDelegate
for interpreting dialect-specific error or SQLState codes. WhenbuildSQLExceptionConverter()
returns null, the defaultSQLExceptionConverter
is used to interpret SQLState and error codes. If this method is overridden to return a non-null value, the defaultSQLExceptionConverter
will use the returnedSQLExceptionConversionDelegate
in addition to the following standard delegates:- a "static" delegate based on the JDBC 4 defined SQLException hierarchy;
- a delegate that interprets SQLState codes for either X/Open or SQL-2003 codes, depending on java.sql.DatabaseMetaData#getSQLStateType
- Returns:
- The SQLExceptionConversionDelegate for this dialect
-
getViolatedConstraintNameExtracter
public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter()
- Specified by:
getViolatedConstraintNameExtracter
in interfaceConversionContext
-
getSelectClauseNullString
public java.lang.String getSelectClauseNullString(int sqlType)
Given aTypes
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.- Parameters:
sqlType
- TheTypes
type code.- Returns:
- The appropriate select clause value fragment.
-
supportsUnionAll
public boolean supportsUnionAll()
Does this dialect support UNION ALL, which is generally a faster variant of UNION?- Returns:
- True if UNION ALL is supported; false otherwise.
-
createOuterJoinFragment
public JoinFragment createOuterJoinFragment()
Create aJoinFragment
strategy responsible for handling this dialect's variations in how joins are handled.- Returns:
- This dialect's
JoinFragment
strategy.
-
createCaseFragment
public CaseFragment createCaseFragment()
Create aCaseFragment
strategy responsible for handling this dialect's variations in how CASE statements are handled.- Returns:
- This dialect's
CaseFragment
strategy.
-
getNoColumnsInsertString
public java.lang.String getNoColumnsInsertString()
The fragment used to insert a row without specifying any column values. This is not possible on some databases.- Returns:
- The appropriate empty values clause.
-
supportsNoColumnsInsert
public boolean supportsNoColumnsInsert()
Check if the INSERT statement is allowed to contain no column.- Returns:
- if the Dialect supports no-column INSERT.
-
getLowercaseFunction
public java.lang.String getLowercaseFunction()
The name of the SQL function that transforms a string to lowercase- Returns:
- The dialect-specific lowercase function.
-
getCaseInsensitiveLike
public java.lang.String getCaseInsensitiveLike()
The name of the SQL function that can do case insensitive like comparison.- Returns:
- The dialect-specific "case insensitive" like function.
-
supportsCaseInsensitiveLike
public boolean supportsCaseInsensitiveLike()
Does this dialect support case insensitive LIKE restrictions?- Returns:
true
if the underlying database supports case insensitive like comparison,false
otherwise. The default isfalse
.
-
transformSelectString
public java.lang.String transformSelectString(java.lang.String select)
Meant as a means for end users to affect the select strings being sent to the database and perhaps manipulate them in some fashion. The recommend approach is to instead useInterceptor.onPrepareStatement(String)
.- Parameters:
select
- The select command- Returns:
- The mutated select command, or the same as was passed in.
-
getMaxAliasLength
public int getMaxAliasLength()
What is the maximum length Hibernate can use for generated aliases? The maximum here should account for the fact that Hibernate often needs to append "uniqueing" information to the end of generated aliases. That "uniqueing" information will be added to the end of a identifier generated to the length specified here; so be sure to leave some room (generally speaking 5 positions will suffice).- Returns:
- The maximum length.
-
toBooleanValueString
public java.lang.String toBooleanValueString(boolean bool)
The SQL literal value to which this database maps boolean values.- Parameters:
bool
- The boolean value- Returns:
- The appropriate SQL literal.
-
registerKeyword
protected void registerKeyword(java.lang.String word)
-
getKeywords
@Deprecated public java.util.Set<java.lang.String> getKeywords()
Deprecated.These are only ever used (if at all) from the code that handles identifier quoting. So seebuildIdentifierHelper(org.hibernate.engine.jdbc.env.spi.IdentifierHelperBuilder, java.sql.DatabaseMetaData)
instead
-
buildIdentifierHelper
public IdentifierHelper buildIdentifierHelper(IdentifierHelperBuilder builder, java.sql.DatabaseMetaData dbMetaData) throws java.sql.SQLException
Build the IdentifierHelper indicated by this Dialect for handling identifier conversions. Returningnull
is allowed and indicates that Hibernate should fallback to building a "standard" helper. In the fallback path, any changes made to the IdentifierHelperBuilder during this call will still be incorporated into the built IdentifierHelper. The incoming builder will have the following set:IdentifierHelperBuilder.isGloballyQuoteIdentifiers()
IdentifierHelperBuilder.getUnquotedCaseStrategy()
- initialized to UPPERIdentifierHelperBuilder.getQuotedCaseStrategy()
- initialized to MIXED
- Call
IdentifierHelperBuilder.applyIdentifierCasing(DatabaseMetaData)
- Call
IdentifierHelperBuilder.applyReservedWords(DatabaseMetaData)
- Applies
AnsiSqlKeywords.sql2003()
as reserved words - Applies the {#link #sqlKeywords} collected here as reserved words
- Applies the Dialect's NameQualifierSupport, if it defines one
- Parameters:
builder
- A semi-configured IdentifierHelper builder.dbMetaData
- Access to the metadata returned from the driver if needed and if available. WARNING: may benull
- Returns:
- The IdentifierHelper instance to use, or
null
to indicate Hibernate should use its fallback path - Throws:
java.sql.SQLException
- Accessing the DatabaseMetaData can throw it. Just re-throw and Hibernate will handle.- See Also:
getNameQualifierSupport()
-
openQuote
public char openQuote()
The character specific to this dialect used to begin a quoted identifier.- Returns:
- The dialect's specific open quote character.
-
closeQuote
public char closeQuote()
The character specific to this dialect used to close a quoted identifier.- Returns:
- The dialect's specific close quote character.
-
quote
public final java.lang.String quote(java.lang.String name)
Apply dialect-specific quoting. By default, the incoming value is checked to see if its first character is the back-tick (`). If so, the dialect specific quoting is applied.- Parameters:
name
- The value to be quoted.- Returns:
- The quoted (or unmodified, if not starting with back-tick) value.
- See Also:
openQuote()
,closeQuote()
-
getForeignKeyExporter
public Exporter<ForeignKey> getForeignKeyExporter()
-
getUniqueKeyExporter
public Exporter<Constraint> getUniqueKeyExporter()
-
getAuxiliaryDatabaseObjectExporter
public Exporter<AuxiliaryDatabaseObject> getAuxiliaryDatabaseObjectExporter()
-
canCreateCatalog
public boolean canCreateCatalog()
Does this dialect support catalog creation?- Returns:
- True if the dialect supports catalog creation; false otherwise.
-
getCreateCatalogCommand
public java.lang.String[] getCreateCatalogCommand(java.lang.String catalogName)
Get the SQL command used to create the named catalog- Parameters:
catalogName
- The name of the catalog to be created.- Returns:
- The creation commands
-
getDropCatalogCommand
public java.lang.String[] getDropCatalogCommand(java.lang.String catalogName)
Get the SQL command used to drop the named catalog- Parameters:
catalogName
- The name of the catalog to be dropped.- Returns:
- The drop commands
-
canCreateSchema
public boolean canCreateSchema()
Does this dialect support schema creation?- Returns:
- True if the dialect supports schema creation; false otherwise.
-
getCreateSchemaCommand
public java.lang.String[] getCreateSchemaCommand(java.lang.String schemaName)
Get the SQL command used to create the named schema- Parameters:
schemaName
- The name of the schema to be created.- Returns:
- The creation commands
-
getDropSchemaCommand
public java.lang.String[] getDropSchemaCommand(java.lang.String schemaName)
Get the SQL command used to drop the named schema- Parameters:
schemaName
- The name of the schema to be dropped.- Returns:
- The drop commands
-
getCurrentSchemaCommand
public java.lang.String getCurrentSchemaCommand()
Get the SQL command used to retrieve the current schema name. Works in conjunction withgetSchemaNameResolver()
, unless the return from there does not need this information. E.g., a custom impl might make use of the Java 1.7 addition of theConnection.getSchema()
method- Returns:
- The current schema retrieval SQL
-
getSchemaNameResolver
public SchemaNameResolver getSchemaNameResolver()
Get the strategy for determining the schema name of a Connection- Returns:
- The schema name resolver strategy
-
hasAlterTable
public boolean hasAlterTable()
Does this dialect support the ALTER TABLE syntax?- Returns:
- True if we support altering of tables; false otherwise.
-
dropConstraints
public boolean dropConstraints()
Do we need to drop constraints before dropping tables in this dialect?- Returns:
- True if constraints must be dropped prior to dropping the table; false otherwise.
-
qualifyIndexName
public boolean qualifyIndexName()
Do we need to qualify index names with the schema name?- Returns:
- boolean
-
getAddColumnString
public java.lang.String getAddColumnString()
The syntax used to add a column to a table (optional).- Returns:
- The "add column" fragment.
-
getAddColumnSuffixString
public java.lang.String getAddColumnSuffixString()
The syntax for the suffix used to add a column to a table (optional).- Returns:
- The suffix "add column" fragment.
-
getDropForeignKeyString
public java.lang.String getDropForeignKeyString()
-
getTableTypeString
public java.lang.String getTableTypeString()
-
getAddForeignKeyConstraintString
public java.lang.String getAddForeignKeyConstraintString(java.lang.String constraintName, java.lang.String[] foreignKey, java.lang.String referencedTable, java.lang.String[] primaryKey, boolean referencesPrimaryKey)
The syntax used to add a foreign key constraint to a table.- Parameters:
constraintName
- The FK constraint name.foreignKey
- The names of the columns comprising the FKreferencedTable
- The table referenced by the FKprimaryKey
- The explicit columns in the referencedTable referenced by this FK.referencesPrimaryKey
- if false, constraint should be explicit about which column names the constraint refers to- Returns:
- the "add FK" fragment
-
getAddForeignKeyConstraintString
public java.lang.String getAddForeignKeyConstraintString(java.lang.String constraintName, java.lang.String foreignKeyDefinition)
-
getAddPrimaryKeyConstraintString
public java.lang.String getAddPrimaryKeyConstraintString(java.lang.String constraintName)
The syntax used to add a primary key constraint to a table.- Parameters:
constraintName
- The name of the PK constraint.- Returns:
- The "add PK" fragment
-
hasSelfReferentialForeignKeyBug
public boolean hasSelfReferentialForeignKeyBug()
Does the database/driver have bug in deleting rows that refer to other rows being deleted in the same query?- Returns:
true
if the database/driver has this bug
-
getNullColumnString
public java.lang.String getNullColumnString()
The keyword used to specify a nullable column.- Returns:
- String
-
supportsCommentOn
public boolean supportsCommentOn()
Does this dialect/database support commenting on tables, columns, etc?- Returns:
true
if commenting is supported
-
getTableComment
public java.lang.String getTableComment(java.lang.String comment)
Get the comment into a form supported for table definition.- Parameters:
comment
- The comment to apply- Returns:
- The comment fragment
-
getColumnComment
public java.lang.String getColumnComment(java.lang.String comment)
Get the comment into a form supported for column definition.- Parameters:
comment
- The comment to apply- Returns:
- The comment fragment
-
supportsIfExistsBeforeTableName
public 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 andsupportsIfExistsAfterTableName()
should return true- Returns:
true
if the "if exists" can be applied before the table name
-
supportsIfExistsAfterTableName
public 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 andsupportsIfExistsBeforeTableName()
should return true- Returns:
true
if the "if exists" can be applied after the table name
-
supportsIfExistsBeforeConstraintName
public 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 andsupportsIfExistsAfterConstraintName()
should return true- Returns:
true
if the "if exists" can be applied before the constraint name
-
supportsIfExistsAfterConstraintName
public boolean supportsIfExistsAfterConstraintName()
For dropping a constraint with an "alter table", can the phrase "if exists" be applied after the constraint name? NOTE : Only one or the other (or neither) of this andsupportsIfExistsBeforeConstraintName()
should return true- Returns:
true
if the "if exists" can be applied after the constraint name
-
supportsIfExistsAfterAlterTable
public boolean supportsIfExistsAfterAlterTable()
For an "alter table", can the phrase "if exists" be applied?- Returns:
true
if the "if exists" can be applied after ALTER TABLE- Since:
- 5.2.11
-
getDropTableString
public java.lang.String getDropTableString(java.lang.String tableName)
Generate a DROP TABLE statement- Parameters:
tableName
- The name of the table to drop- Returns:
- The DROP TABLE command
-
supportsColumnCheck
public boolean supportsColumnCheck()
Does this dialect support column-level check constraints?- Returns:
- True if column-level CHECK constraints are supported; false otherwise.
-
supportsTableCheck
public boolean supportsTableCheck()
Does this dialect support table-level check constraints?- Returns:
- True if table-level CHECK constraints are supported; false otherwise.
-
supportsCascadeDelete
public boolean supportsCascadeDelete()
Does this dialect support cascaded delete on foreign key definitions?- Returns:
true
indicates that the dialect does support cascaded delete on foreign keys.
-
getCascadeConstraintsString
public java.lang.String getCascadeConstraintsString()
Completely optional cascading drop clause- Returns:
- String
-
getCrossJoinSeparator
public java.lang.String getCrossJoinSeparator()
Returns the separator to use for defining cross joins when translating HQL queries. Typically this will be either [ cross join ] or [, ] Note that the spaces are important!- Returns:
- The cross join separator
-
getColumnAliasExtractor
public ColumnAliasExtractor getColumnAliasExtractor()
-
supportsEmptyInList
public boolean supportsEmptyInList()
Does this dialect support empty IN lists? For example, is [where XYZ in ()] a supported construct?- Returns:
- True if empty in lists are supported; false otherwise.
- Since:
- 3.2
-
areStringComparisonsCaseInsensitive
public boolean areStringComparisonsCaseInsensitive()
Are string comparisons implicitly case insensitive. In other words, does [where 'XYZ' = 'xyz'] resolve to true?- Returns:
- True if comparisons are case insensitive.
- Since:
- 3.2
-
supportsRowValueConstructorSyntax
public boolean supportsRowValueConstructorSyntax()
Is this dialect known to support what ANSI-SQL terms "row value constructor" syntax; sometimes called tuple syntax. Basically, does it support syntax like "... where (FIRST_NAME, LAST_NAME) = ('Steve', 'Ebersole') ...".- Returns:
- True if this SQL dialect is known to support "row value constructor" syntax; false otherwise.
- Since:
- 3.2
-
supportsRowValueConstructorSyntaxInSet
public boolean supportsRowValueConstructorSyntaxInSet()
Is this dialect known to support what ANSI-SQL terms "row value constructor" syntax, sometimes called tuple syntax, in the SET clause; Basically, does it support syntax like "... SET (FIRST_NAME, LAST_NAME) = ('Steve', 'Ebersole') ...".- Returns:
- True if this SQL dialect is known to support "row value constructor" syntax in the SET clause; false otherwise.
-
supportsRowValueConstructorSyntaxInInList
public boolean supportsRowValueConstructorSyntaxInInList()
If the dialect supportsrow values
, does it offer such support in IN lists as well? For example, "... where (FIRST_NAME, LAST_NAME) IN ( (?, ?), (?, ?) ) ..."- Returns:
- True if this SQL dialect is known to support "row value constructor" syntax in the IN list; false otherwise.
- Since:
- 3.2
-
useInputStreamToInsertBlob
public boolean useInputStreamToInsertBlob()
Should LOBs (both BLOB and CLOB) be bound using stream operations (i.e.PreparedStatement.setBinaryStream(int, java.io.InputStream, int)
).- Returns:
- True if BLOBs and CLOBs should be bound using stream operations.
- Since:
- 3.2
-
supportsParametersInInsertSelect
public boolean supportsParametersInInsertSelect()
Does this dialect support parameters within the SELECT clause of INSERT ... SELECT ... statements?- Returns:
- True if this is supported; false otherwise.
- Since:
- 3.2
-
replaceResultVariableInOrderByClauseWithPosition
public boolean replaceResultVariableInOrderByClauseWithPosition()
Does this dialect require that references to result variables (i.e, select expression aliases) in an ORDER BY clause be replaced by column positions (1-origin) as defined by the select clause?- Returns:
- true if result variable references in the ORDER BY clause should be replaced by column positions; false otherwise.
-
renderOrderByElement
public java.lang.String renderOrderByElement(java.lang.String expression, java.lang.String collation, java.lang.String order, NullPrecedence nulls)
Renders an ordering fragment- Parameters:
expression
- The SQL order expression. In case of@OrderBy
annotation user receives property placeholder (e.g. attribute name enclosed in '{' and '}' signs).collation
- Collation string in formatcollate IDENTIFIER
, ornull
if expression has not been explicitly specified.order
- Order direction. Possible values:asc
,desc
, ornull
if expression has not been explicitly specified.nulls
- Nulls precedence. Default value:NullPrecedence.NONE
.- Returns:
- Renders single element of
ORDER BY
clause.
-
requiresCastingOfParametersInSelectClause
public 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.- Returns:
- True if select clause parameter must be cast()ed
- Since:
- 3.2
-
supportsResultSetPositionQueryMethodsOnForwardOnlyCursor
public boolean supportsResultSetPositionQueryMethodsOnForwardOnlyCursor()
Does this dialect support asking the result set its positioning information on forward only cursors. Specifically, in the case of scrolling fetches, Hibernate needs to useResultSet.isAfterLast()
andResultSet.isBeforeFirst()
. Certain drivers do not allow access to these methods for forward only cursors. NOTE : this is highly driver dependent!- Returns:
- True if methods like
ResultSet.isAfterLast()
andResultSet.isBeforeFirst()
are supported for forward only cursors; false otherwise. - Since:
- 3.2
-
supportsCircularCascadeDeleteConstraints
public boolean supportsCircularCascadeDeleteConstraints()
Does this dialect support definition of cascade delete constraints which can cause circular chains?- Returns:
- True if circular cascade delete constraints are supported; false otherwise.
- Since:
- 3.2
-
supportsSubselectAsInPredicateLHS
public boolean supportsSubselectAsInPredicateLHS()
Are subselects supported as the left-hand-side (LHS) of IN-predicates. In other words, is syntax like... <subquery> IN (1, 2, 3) ...
supported?- Returns:
- True if subselects can appear as the LHS of an in-predicate; false otherwise.
- Since:
- 3.2
-
supportsExpectedLobUsagePattern
public boolean supportsExpectedLobUsagePattern()
Expected LOB usage pattern is such that I can perform an insert via prepared statement with a parameter binding for a LOB value without crazy casting to JDBC driver implementation-specific classes... Part of the trickiness here is the fact that this is largely driver dependent. For example, Oracle (which is notoriously bad with LOB support in their drivers historically) actually does a pretty good job with LOB support as of the 10.2.x versions of their drivers...- Returns:
- True if normal LOB usage patterns can be used with this driver; false if driver-specific hookiness needs to be applied.
- Since:
- 3.2
-
supportsLobValueChangePropogation
public 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... For BLOBs, the internal value might be changed by:Blob.setBinaryStream(long)
,Blob.setBytes(long, byte[])
,Blob.setBytes(long, byte[], int, int)
, orBlob.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)
, orClob.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 notsupportsExpectedLobUsagePattern()
.- Returns:
- True if the changes are propagated back to the database; false otherwise.
- Since:
- 3.2
-
supportsUnboundedLobLocatorMaterialization
public boolean supportsUnboundedLobLocatorMaterialization()
Is it supported to materialize a LOB locator outside the transaction in which it was created? Again, part of the trickiness here is the fact that this is largely driver dependent. NOTE: all database I have tested whichsupportsExpectedLobUsagePattern()
also support the ability to materialize a LOB outside the owning transaction...- Returns:
- True if unbounded materialization is supported; false otherwise.
- Since:
- 3.2
-
supportsSubqueryOnMutatingTable
public boolean supportsSubqueryOnMutatingTable()
Does this dialect support referencing the table being mutated in a subquery. The "table being mutated" is the table referenced in an UPDATE or a DELETE query. And so can that table then be referenced in a subquery of said UPDATE/DELETE query. For example, would the following two syntaxes be supported:- delete from TABLE_A where ID not in ( select ID from TABLE_A )
- update TABLE_A set NON_ID = 'something' where ID in ( select ID from TABLE_A)
- Returns:
- True if this dialect allows references the mutating table from a subquery.
-
supportsExistsInSelect
public boolean supportsExistsInSelect()
Does the dialect support an exists statement in the select clause?- Returns:
- True if exists checks are allowed in the select clause; false otherwise.
-
doesReadCommittedCauseWritersToBlockReaders
public boolean doesReadCommittedCauseWritersToBlockReaders()
For the underlying database, is READ_COMMITTED isolation implemented by forcing readers to wait for write locks to be released?- Returns:
- True if writers block readers to achieve READ_COMMITTED; false otherwise.
-
doesRepeatableReadCauseReadersToBlockWriters
public boolean doesRepeatableReadCauseReadersToBlockWriters()
For the underlying database, is REPEATABLE_READ isolation implemented by forcing writers to wait for read locks to be released?- Returns:
- True if readers block writers to achieve REPEATABLE_READ; false otherwise.
-
supportsBindAsCallableArgument
public boolean supportsBindAsCallableArgument()
Does this dialect support using a JDBC bind parameter as an argument to a function or procedure call?- Returns:
- Returns
true
if the database supports accepting bind params as args,false
otherwise. The default istrue
.
-
supportsTupleCounts
public boolean supportsTupleCounts()
Does this dialect support `count(a,b)`?- Returns:
- True if the database supports counting tuples; false otherwise.
-
supportsTupleDistinctCounts
public boolean supportsTupleDistinctCounts()
Does this dialect support `count(distinct a,b)`?- Returns:
- True if the database supports counting distinct tuples; false otherwise.
-
requiresParensForTupleDistinctCounts
public boolean requiresParensForTupleDistinctCounts()
IfsupportsTupleDistinctCounts()
is true, does the Dialect require the tuple to be wrapped with parens?- Returns:
- boolean
-
getInExpressionCountLimit
public int getInExpressionCountLimit()
Return the limit that the underlying database places on the number of elements in anIN
predicate. If the database defines no such limits, simply return zero or less-than-zero.- Returns:
- int The limit, or zero-or-less to indicate no limit.
-
forceLobAsLastValue
public boolean forceLobAsLastValue()
HHH-4635 Oracle expects all Lob values to be last in inserts and updates.- Returns:
- boolean True if Lob values should be last, false if it does not matter.
-
useFollowOnLocking
@Deprecated public boolean useFollowOnLocking()
Deprecated.UseuseFollowOnLocking(QueryParameters)
instead.Some dialects have trouble applying pessimistic locking depending upon what other query options are specified (paging, ordering, etc). This method allows these dialects to request that locking be applied by subsequent selects.- Returns:
true
indicates that the dialect requests that locking be applied by subsequent select;false
(the default) indicates that locking should be applied to the main SQL statement..
-
useFollowOnLocking
public boolean useFollowOnLocking(QueryParameters parameters)
Some dialects have trouble applying pessimistic locking depending upon what other query options are specified (paging, ordering, etc). This method allows these dialects to request that locking be applied by subsequent selects.- Parameters:
parameters
- query parameters- Returns:
true
indicates that the dialect requests that locking be applied by subsequent select;false
(the default) indicates that locking should be applied to the main SQL statement..- Since:
- 5.2
-
getNotExpression
public java.lang.String getNotExpression(java.lang.String expression)
Negate an expression- Parameters:
expression
- The expression to negate- Returns:
- The negated expression
-
getUniqueDelegate
public UniqueDelegate getUniqueDelegate()
Get the UniqueDelegate supported by this dialect- Returns:
- The UniqueDelegate
-
supportsUnique
@Deprecated public boolean supportsUnique()
Deprecated.getUniqueDelegate()
should be overridden instead.Does this dialect support the UNIQUE column syntax?- Returns:
- boolean
-
supportsUniqueConstraintInCreateAlterTable
@Deprecated public boolean supportsUniqueConstraintInCreateAlterTable()
Deprecated.getUniqueDelegate()
should be overridden instead.Does this dialect support adding Unique constraints via create and alter table ?- Returns:
- boolean
-
getAddUniqueConstraintString
@Deprecated public java.lang.String getAddUniqueConstraintString(java.lang.String constraintName)
Deprecated.getUniqueDelegate()
should be overridden instead.The syntax used to add a unique constraint to a table.- Parameters:
constraintName
- The name of the unique constraint.- Returns:
- The "add unique" fragment
-
supportsNotNullUnique
@Deprecated public boolean supportsNotNullUnique()
Deprecated.getUniqueDelegate()
should be overridden instead.Is the combination of not-null and unique supported?- Returns:
- deprecated
-
getQueryHintString
public java.lang.String getQueryHintString(java.lang.String query, java.util.List<java.lang.String> hintList)
Apply a hint to the query. The entire query is provided, allowing the Dialect full control over the placement and syntax of the hint. By default, ignore the hint and simply return the query.- Parameters:
query
- The query to which to apply the hint.hintList
- The hints to apply- Returns:
- The modified SQL
-
getQueryHintString
public java.lang.String getQueryHintString(java.lang.String query, java.lang.String hints)
Apply a hint to the query. The entire query is provided, allowing the Dialect full control over the placement and syntax of the hint. By default, ignore the hint and simply return the query.- Parameters:
query
- The query to which to apply the hint.hints
- The hints to apply- Returns:
- The modified SQL
-
defaultScrollMode
public ScrollMode defaultScrollMode()
Certain dialects support a subset of ScrollModes. Provide a default to be used by Criteria and Query.- Returns:
- ScrollMode
-
supportsTuplesInSubqueries
public boolean supportsTuplesInSubqueries()
Does this dialect support tuples in subqueries? Ex: delete from Table1 where (col1, col2) in (select col1, col2 from Table2)- Returns:
- boolean
-
getCallableStatementSupport
public CallableStatementSupport getCallableStatementSupport()
-
getNameQualifierSupport
public NameQualifierSupport getNameQualifierSupport()
By default interpret this based on DatabaseMetaData.- Returns:
- The NameQualifierSupport.
-
getDefaultBatchLoadSizingStrategy
public BatchLoadSizingStrategy getDefaultBatchLoadSizingStrategy()
-
isJdbcLogWarningsEnabledByDefault
public boolean isJdbcLogWarningsEnabledByDefault()
Does the fetching JDBC statement warning for logging is enabled by default- Returns:
- boolean
- Since:
- 5.1
-
augmentPhysicalTableTypes
public void augmentPhysicalTableTypes(java.util.List<java.lang.String> tableTypesList)
-
augmentRecognizedTableTypes
public void augmentRecognizedTableTypes(java.util.List<java.lang.String> tableTypesList)
-
supportsPartitionBy
public boolean supportsPartitionBy()
Does the underlying database support partition by- Returns:
- boolean
- Since:
- 5.2
-
supportsNamedParameters
public boolean supportsNamedParameters(java.sql.DatabaseMetaData databaseMetaData) throws java.sql.SQLException
Override the DatabaseMetaData#supportsNamedParameters()- Returns:
- boolean
- Throws:
java.sql.SQLException
- Accessing the DatabaseMetaData can throw it. Just re-throw and Hibernate will handle.
-
supportsNationalizedTypes
public boolean supportsNationalizedTypes()
Does this dialect supports Nationalized Types- Returns:
- boolean
-
supportsNonQueryWithCTE
public boolean supportsNonQueryWithCTE()
Does this dialect/database support non-query statements (e.g. INSERT, UPDATE, DELETE) with CTE (Common Table Expressions)?- Returns:
true
if non-query statements are supported with CTE
-
supportsValuesList
public boolean supportsValuesList()
Does this dialect/database support VALUES list (e.g. VALUES (1), (2), (3) )- Returns:
true
if VALUES list are supported
-
supportsSkipLocked
public boolean supportsSkipLocked()
Does this dialect/database support SKIP_LOCKED timeout.- Returns:
true
if SKIP_LOCKED is supported
-
supportsNoWait
public boolean supportsNoWait()
Does this dialect/database support NO_WAIT timeout.- Returns:
true
if NO_WAIT is supported
-
isLegacyLimitHandlerBehaviorEnabled
public boolean isLegacyLimitHandlerBehaviorEnabled()
-
inlineLiteral
public java.lang.String inlineLiteral(java.lang.String literal)
Inline String literal.- Returns:
- escaped String
-
supportsJdbcConnectionLobCreation
public boolean supportsJdbcConnectionLobCreation(java.sql.DatabaseMetaData databaseMetaData)
Check whether the JDBCConnection
supports creating LOBs viaConnection.createBlob()
,Connection.createNClob()
orConnection.createClob()
.- Parameters:
databaseMetaData
- JDBCDatabaseMetaData
which can be used if LOB creation is supported only starting from a given Driver version- Returns:
true
if LOBs can be created via the JDBC Connection.
-
escapeLiteral
protected java.lang.String escapeLiteral(java.lang.String literal)
Escape String literal.- Returns:
- escaped String
-
addSqlHintOrComment
public java.lang.String addSqlHintOrComment(java.lang.String sql, QueryParameters parameters, boolean commentsEnabled)
Modify the SQL, adding hints or comments, if necessary- Parameters:
sql
- original sqlparameters
- query parameterscommentsEnabled
- if comments are enabled
-
prependComment
protected java.lang.String prependComment(java.lang.String sql, java.lang.String comment)
-
escapeComment
public static java.lang.String escapeComment(java.lang.String comment)
-
supportsSelectAliasInGroupByClause
public boolean supportsSelectAliasInGroupByClause()
-
getCreateTemporaryTableColumnAnnotation
public java.lang.String getCreateTemporaryTableColumnAnnotation(int sqlTypeCode)
Annotation to be appended to the end of each COLUMN clause for temporary tables.- Parameters:
sqlTypeCode
- The SQL type code- Returns:
- The annotation to be appended (e.g. "COLLATE DATABASE_DEFAULT" in SQLServer SQL)
-
-