Top Description Fields Constructors Methods
org.hibernate.dialect

public Class SQLServerDialect

extends AbstractTransactSQLDialect
Class Inheritance
Known Direct Subclasses
org.hibernate.dialect.SQLServer2005Dialect
Annotations
@SuppressWarnings:deprecation
Imports
java.sql.DatabaseMetaData, .SQLException, .Types, java.util.Locale, org.hibernate.LockMode, .LockOptions, org.hibernate.dialect.function.AnsiTrimEmulationFunction, .SQLFunctionTemplate, .StandardSQLFunction, org.hibernate.dialect.identity.IdentityColumnSupport, .SQLServerIdentityColumnSupport, org.hibernate.dialect.pagination.LegacyLimitHandler, .LimitHandler, .TopLimitHandler, org.hibernate.engine.jdbc.env.spi.IdentifierCaseStrategy, .IdentifierHelper, .IdentifierHelperBuilder, .NameQualifierSupport, org.hibernate.type.StandardBasicTypes, .StringType, .Type, org.hibernate.type.descriptor.sql.SmallIntTypeDescriptor, .SqlTypeDescriptor

A dialect for Microsoft SQL Server 2000
Author
Gavin King

Field Summary

Modifier and TypeField and Description
private final LimitHandler
private static final int

Constructor Summary

AccessConstructor and Description
public
SQLServerDialect()

Constructs a SQLServerDialect

Method Summary

Modifier and TypeMethod and Description
public String
appendLockHint(LockOptions
The lock options to apply
lockOptions
,
String
The name of the table to which to apply the lock hint.
tableName
)

Overrides org.hibernate.dialect.AbstractTransactSQLDialect.appendLockHint.

Some dialects support an alternative means to SELECT FOR UPDATE, whereby a "lock hint" is appended to the table name in the from clause.
public boolean
public IdentifierHelper
buildIdentifierHelper(IdentifierHelperBuilder
A semi-configured IdentifierHelper builder.
builder
,
DatabaseMetaData
Access to the metadata returned from the driver if needed and if available.

Warning

may be null

dbMetaData
)

Overrides org.hibernate.dialect.Dialect.buildIdentifierHelper.

Build the IdentifierHelper indicated by this Dialect for handling identifier conversions.
public char
closeQuote()

Overrides org.hibernate.dialect.Dialect.closeQuote.

The character specific to this dialect used to close a quoted identifier.
public boolean
doesReadCommittedCauseWritersToBlockReaders()

Overrides org.hibernate.dialect.AbstractTransactSQLDialect.doesReadCommittedCauseWritersToBlockReaders.

For the underlying database, is READ_COMMITTED isolation implemented by forcing readers to wait for write locks to be released?
public boolean
doesRepeatableReadCauseReadersToBlockWriters()

Overrides org.hibernate.dialect.AbstractTransactSQLDialect.doesRepeatableReadCauseReadersToBlockWriters.

For the underlying database, is REPEATABLE_READ isolation implemented by forcing writers to wait for read locks to be released?
pack-priv static int
public String
getCreateTemporaryTableColumnAnnotation(int
The SQL type code
sqlTypeCode
)

Overrides org.hibernate.dialect.Dialect.getCreateTemporaryTableColumnAnnotation.

Annotation to be appended to the end of each COLUMN clause for temporary tables.
public String
getCurrentSchemaCommand()

Overrides org.hibernate.dialect.Dialect.getCurrentSchemaCommand.

Get the SQL command used to retrieve the current schema name.
public String
getCurrentTimestampSelectString()

Overrides org.hibernate.dialect.AbstractTransactSQLDialect.getCurrentTimestampSelectString.

The current_timestamp is more accurate, but only known to be supported in SQL Server 7.0 and later and Sybase not known to support it at all

Retrieve the command used to retrieve the current timestamp from the database.

protected LimitHandler
public IdentityColumnSupport
public int
getInExpressionCountLimit()

Overrides org.hibernate.dialect.Dialect.getInExpressionCountLimit.

Return the limit that the underlying database places on the number of elements in an IN predicate.
public LimitHandler
getLimitHandler()

Overrides org.hibernate.dialect.Dialect.getLimitHandler.

Returns the delegate managing LIMIT clause.
public String
getLimitString(String
The query to which to apply the limit.
querySelect
,
int
The offset of the limit
offset
,
int
The limit of the limit ;)
limit
)

Overrides org.hibernate.dialect.Dialect.getLimitString.

Given a limit and an offset, apply the limit clause to the query.
public NameQualifierSupport
getNameQualifierSupport()

Overrides org.hibernate.dialect.Dialect.getNameQualifierSupport.

By default interpret this based on DatabaseMetaData.
public String
getNoColumnsInsertString()

Overrides org.hibernate.dialect.Dialect.getNoColumnsInsertString.

The fragment used to insert a row without specifying any column values.
protected SqlTypeDescriptor
getSqlTypeDescriptorOverride(int
A Types constant indicating the SQL column type
sqlCode
)

Overrides org.hibernate.dialect.Dialect.getSqlTypeDescriptorOverride.

Returns the SqlTypeDescriptor that should be used to handle the given JDBC type code.
public char
openQuote()

Overrides org.hibernate.dialect.Dialect.openQuote.

The character specific to this dialect used to begin a quoted identifier.
public boolean
supportsCircularCascadeDeleteConstraints()

Overrides org.hibernate.dialect.Dialect.supportsCircularCascadeDeleteConstraints.

Does this dialect support definition of cascade delete constraints which can cause circular chains?
public boolean
supportsLimit()

Overrides org.hibernate.dialect.Dialect.supportsLimit.

Does this dialect support some form of limiting query results via a SQL clause?
public boolean
supportsLimitOffset()

Overrides org.hibernate.dialect.Dialect.supportsLimitOffset.

Does this dialect's LIMIT support (if any) additionally support specifying an offset?
public boolean
supportsLobValueChangePropogation()

Overrides org.hibernate.dialect.Dialect.supportsLobValueChangePropogation.

Does the dialect support propagating changes to LOB values back to the database?
public boolean
supportsResultSetPositionQueryMethodsOnForwardOnlyCursor()

Overrides org.hibernate.dialect.Dialect.supportsResultSetPositionQueryMethodsOnForwardOnlyCursor.

Does this dialect support asking the result set its positioning information on forward only cursors.
public boolean
supportsVariableLimit()

Overrides org.hibernate.dialect.Dialect.supportsVariableLimit.

Does this dialect support bind variables (i.e., prepared statement parameters) for its limit/offset?
public boolean
useMaxForLimit()

Overrides org.hibernate.dialect.Dialect.useMaxForLimit.

Does the LIMIT clause take a "maximum" row number instead of a total number of returned rows?
Inherited from org.hibernate.dialect.AbstractTransactSQLDialect:
applyLocksToSqlgetAddColumnStringgetDefaultMultiTableBulkIdStrategygetForUpdateStringgetNullColumnStringgetResultSetgetSelectGUIDStringisCurrentTimestampSelectStringCallablequalifyIndexNameregisterResultSetOutParametersupportsCurrentTimestampSelectionsupportsEmptyInListsupportsExistsInSelectsupportsPartitionBysupportsTupleDistinctCountssupportsTuplesInSubqueriessupportsUnionAll

Field Detail

limitHandlerback to summary
private final LimitHandler limitHandler
PARAM_LIST_SIZE_LIMITback to summary
private static final int PARAM_LIST_SIZE_LIMIT

Constructor Detail

SQLServerDialectback to summary
public SQLServerDialect()

Constructs a SQLServerDialect

Method Detail

appendLockHintback to summary
public String appendLockHint(LockOptions lockOptions, String tableName)

Overrides org.hibernate.dialect.AbstractTransactSQLDialect.appendLockHint.

Doc from org.hibernate.dialect.Dialect.appendLockHint.

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:LockOptions

The lock options to apply

tableName:String

The name of the table to which to apply the lock hint.

Returns:String

The table with any required lock hints.

Annotations
@Override
areStringComparisonsCaseInsensitiveback to summary
public boolean areStringComparisonsCaseInsensitive()

Overrides org.hibernate.dialect.Dialect.areStringComparisonsCaseInsensitive.

Doc from org.hibernate.dialect.Dialect.areStringComparisonsCaseInsensitive.

Are string comparisons implicitly case insensitive.

In other words, does [where 'XYZ' = 'xyz'] resolve to true?

Returns:boolean

True if comparisons are case insensitive.

Annotations
@Override
buildIdentifierHelperback to summary
public IdentifierHelper buildIdentifierHelper(IdentifierHelperBuilder builder, DatabaseMetaData dbMetaData) throws SQLException

Overrides org.hibernate.dialect.Dialect.buildIdentifierHelper.

Doc from org.hibernate.dialect.Dialect.buildIdentifierHelper.

Build the IdentifierHelper indicated by this Dialect for handling identifier conversions. Returning null 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:

By default Hibernate will do the following:

Parameters
builder:IdentifierHelperBuilder

A semi-configured IdentifierHelper builder.

dbMetaData:DatabaseMetaData

Access to the metadata returned from the driver if needed and if available.

Warning

may be null

Returns:IdentifierHelper

The IdentifierHelper instance to use, or null to indicate Hibernate should use its fallback path

Annotations
@Override
Exceptions
SQLException:
Accessing the DatabaseMetaData can throw it. Just re-throw and Hibernate will handle.
closeQuoteback to summary
public char closeQuote()

Overrides org.hibernate.dialect.Dialect.closeQuote.

Doc from org.hibernate.dialect.Dialect.closeQuote.

The character specific to this dialect used to close a quoted identifier.

Returns:char

The dialect's specific close quote character.

Annotations
@Override
doesReadCommittedCauseWritersToBlockReadersback to summary
public boolean doesReadCommittedCauseWritersToBlockReaders()

Overrides org.hibernate.dialect.AbstractTransactSQLDialect.doesReadCommittedCauseWritersToBlockReaders.

Doc from org.hibernate.dialect.Dialect.doesReadCommittedCauseWritersToBlockReaders.

For the underlying database, is READ_COMMITTED isolation implemented by forcing readers to wait for write locks to be released?

Returns:boolean

True if writers block readers to achieve READ_COMMITTED; false otherwise.

Annotations
@Override
doesRepeatableReadCauseReadersToBlockWritersback to summary
public boolean doesRepeatableReadCauseReadersToBlockWriters()

Overrides org.hibernate.dialect.AbstractTransactSQLDialect.doesRepeatableReadCauseReadersToBlockWriters.

Doc from org.hibernate.dialect.Dialect.doesRepeatableReadCauseReadersToBlockWriters.

For the underlying database, is REPEATABLE_READ isolation implemented by forcing writers to wait for read locks to be released?

Returns:boolean

True if readers block writers to achieve REPEATABLE_READ; false otherwise.

Annotations
@Override
getAfterSelectInsertPointback to summary
pack-priv static int getAfterSelectInsertPoint(String sql)
getCreateTemporaryTableColumnAnnotationback to summary
public String getCreateTemporaryTableColumnAnnotation(int sqlTypeCode)

Overrides org.hibernate.dialect.Dialect.getCreateTemporaryTableColumnAnnotation.

Doc from org.hibernate.dialect.Dialect.getCreateTemporaryTableColumnAnnotation.

Annotation to be appended to the end of each COLUMN clause for temporary tables.

Parameters
sqlTypeCode:int

The SQL type code

Returns:String

The annotation to be appended (e.g. "COLLATE DATABASE_DEFAULT" in SQLServer SQL)

Annotations
@Override
getCurrentSchemaCommandback to summary
public String getCurrentSchemaCommand()

Overrides org.hibernate.dialect.Dialect.getCurrentSchemaCommand.

Doc from org.hibernate.dialect.Dialect.getCurrentSchemaCommand.

Get the SQL command used to retrieve the current schema name. Works in conjunction with getSchemaNameResolver(), 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 the Connection#getSchema() method

Returns:String

The current schema retrieval SQL

Annotations
@Override
getCurrentTimestampSelectStringback to summary
public String getCurrentTimestampSelectString()

Overrides org.hibernate.dialect.AbstractTransactSQLDialect.getCurrentTimestampSelectString.

Doc from org.hibernate.dialect.Dialect.getCurrentTimestampSelectString.

The current_timestamp is more accurate, but only known to be supported in SQL Server 7.0 and later and Sybase not known to support it at all

Retrieve the command used to retrieve the current timestamp from the database.

Returns:String

The command.

Annotations
@Override
getDefaultLimitHandlerback to summary
protected LimitHandler getDefaultLimitHandler()
getIdentityColumnSupportback to summary
public IdentityColumnSupport getIdentityColumnSupport()

Overrides org.hibernate.dialect.AbstractTransactSQLDialect.getIdentityColumnSupport.

Doc from org.hibernate.dialect.Dialect.getIdentityColumnSupport.

Get the appropriate IdentityColumnSupport

Returns:IdentityColumnSupport

the IdentityColumnSupport

Annotations
@Override
getInExpressionCountLimitback to summary
public int getInExpressionCountLimit()

Overrides org.hibernate.dialect.Dialect.getInExpressionCountLimit.

Doc from org.hibernate.dialect.Dialect.getInExpressionCountLimit.

Return the limit that the underlying database places on the number of elements in an IN predicate. If the database defines no such limits, simply return zero or less-than-zero.

Returns:int

int The limit, or zero-or-less to indicate no limit.

Annotations
@Override
getLimitHandlerback to summary
public LimitHandler getLimitHandler()

Overrides org.hibernate.dialect.Dialect.getLimitHandler.

Doc from org.hibernate.dialect.Dialect.getLimitHandler.

Returns the delegate managing LIMIT clause.

Returns:LimitHandler

LIMIT clause delegate.

Annotations
@Override
getLimitStringback to summary
public String getLimitString(String querySelect, int offset, int limit)

Overrides org.hibernate.dialect.Dialect.getLimitString.

Doc from org.hibernate.dialect.Dialect.getLimitString.

Given a limit and an offset, apply the limit clause to the query.

Parameters
querySelect:String

The query to which to apply the limit.

offset:int

The offset of the limit

limit:int

The limit of the limit ;)

Returns:String

The modified query statement with the limit applied.

Annotations
@Override
getNameQualifierSupportback to summary
public NameQualifierSupport getNameQualifierSupport()

Overrides org.hibernate.dialect.Dialect.getNameQualifierSupport.

Doc from org.hibernate.dialect.Dialect.getNameQualifierSupport.

By default interpret this based on DatabaseMetaData.

Returns:NameQualifierSupport

The NameQualifierSupport.

Annotations
@Override
getNoColumnsInsertStringback to summary
public String getNoColumnsInsertString()

Overrides org.hibernate.dialect.Dialect.getNoColumnsInsertString.

Doc from org.hibernate.dialect.Dialect.getNoColumnsInsertString.

The fragment used to insert a row without specifying any column values. This is not possible on some databases.

Returns:String

The appropriate empty values clause.

Annotations
@Override
getSqlTypeDescriptorOverrideback to summary
protected SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode)

Overrides org.hibernate.dialect.Dialect.getSqlTypeDescriptorOverride.

Doc from org.hibernate.dialect.Dialect.getSqlTypeDescriptorOverride.

Returns the SqlTypeDescriptor that should be used to handle the given JDBC type code. Returns null if there is no override.

Parameters
sqlCode:int

A Types constant indicating the SQL column type

Returns:SqlTypeDescriptor

The SqlTypeDescriptor to use as an override, or null if there is no override.

Annotations
@Override
openQuoteback to summary
public char openQuote()

Overrides org.hibernate.dialect.Dialect.openQuote.

Doc from org.hibernate.dialect.Dialect.openQuote.

The character specific to this dialect used to begin a quoted identifier.

Returns:char

The dialect's specific open quote character.

Annotations
@Override
supportsCircularCascadeDeleteConstraintsback to summary
public boolean supportsCircularCascadeDeleteConstraints()

Overrides org.hibernate.dialect.Dialect.supportsCircularCascadeDeleteConstraints.

Doc from org.hibernate.dialect.Dialect.supportsCircularCascadeDeleteConstraints.

Does this dialect support definition of cascade delete constraints which can cause circular chains?

Returns:boolean

True if circular cascade delete constraints are supported; false otherwise.

Annotations
@Override
supportsLimitback to summary
public boolean supportsLimit()

Overrides org.hibernate.dialect.Dialect.supportsLimit.

Doc from org.hibernate.dialect.Dialect.supportsLimit.

Does this dialect support some form of limiting query results via a SQL clause?

Returns:boolean

True if this dialect supports some form of LIMIT.

Annotations
@Override
supportsLimitOffsetback to summary
public boolean supportsLimitOffset()

Overrides org.hibernate.dialect.Dialect.supportsLimitOffset.

Doc from org.hibernate.dialect.Dialect.supportsLimitOffset.

Does this dialect's LIMIT support (if any) additionally support specifying an offset?

Returns:boolean

True if the dialect supports an offset within the limit support.

Annotations
@Override
supportsLobValueChangePropogationback to summary
public boolean supportsLobValueChangePropogation()

Overrides org.hibernate.dialect.Dialect.supportsLobValueChangePropogation.

Doc from org.hibernate.dialect.Dialect.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, Blob#setBytes(long, byte[]), Blob#setBytes(long, byte[], int, int), or Blob#truncate(long).

For CLOBs, the internal value might be changed by: Clob#setAsciiStream(long), Clob#setCharacterStream(long), Clob#setString(long, String), Clob#setString(long, String, int, int), or Clob#truncate(long).

NOTE : I do not know the correct answer currently for databases which (1) are not part of the cruise control process or (2) do not supportsExpectedLobUsagePattern.

Returns:boolean

True if the changes are propagated back to the database; false otherwise.

Annotations
@Override
supportsResultSetPositionQueryMethodsOnForwardOnlyCursorback to summary
public boolean supportsResultSetPositionQueryMethodsOnForwardOnlyCursor()

Overrides org.hibernate.dialect.Dialect.supportsResultSetPositionQueryMethodsOnForwardOnlyCursor.

Doc from org.hibernate.dialect.Dialect.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 use ResultSet#isAfterLast and ResultSet#isBeforeFirst. Certain drivers do not allow access to these methods for forward only cursors.

NOTE : this is highly driver dependent!

Returns:boolean

True if methods like ResultSet#isAfterLast and ResultSet#isBeforeFirst are supported for forward only cursors; false otherwise.

Annotations
@Override
supportsVariableLimitback to summary
public boolean supportsVariableLimit()

Overrides org.hibernate.dialect.Dialect.supportsVariableLimit.

Doc from org.hibernate.dialect.Dialect.supportsVariableLimit.

Does this dialect support bind variables (i.e., prepared statement parameters) for its limit/offset?

Returns:boolean

True if bind variables can be used; false otherwise.

Annotations
@Override
useMaxForLimitback to summary
public boolean useMaxForLimit()

Overrides org.hibernate.dialect.Dialect.useMaxForLimit.

Doc from org.hibernate.dialect.Dialect.useMaxForLimit.

Does the LIMIT clause take a "maximum" row number instead of a total number of returned rows?

This is easiest understood via an example. 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:boolean

True if limit is relative from offset; false otherwise.

Annotations
@Override