org.hibernate.spatial.dialect.sqlserver
Class SqlServer2008SpatialDialect

java.lang.Object
  extended by org.hibernate.dialect.Dialect
      extended by org.hibernate.dialect.SQLServerDialect
          extended by org.hibernate.dialect.SQLServer2005Dialect
              extended by org.hibernate.dialect.SQLServer2008Dialect
                  extended by org.hibernate.spatial.dialect.sqlserver.SqlServer2008SpatialDialect
All Implemented Interfaces:
java.io.Serializable, org.hibernate.exception.spi.ConversionContext, SpatialDialect

public class SqlServer2008SpatialDialect
extends org.hibernate.dialect.SQLServer2008Dialect
implements SpatialDialect

The SpatialDialect for Microsoft SQL Server (2008).

See Also:
Serialized Form

Field Summary
static java.lang.String COLUMN_TYPE
           
static java.lang.String SHORT_NAME
           
 
Fields inherited from class org.hibernate.dialect.Dialect
CLOSED_QUOTE, DEFAULT_BATCH_SIZE, NO_BATCH, QUOTE
 
Constructor Summary
SqlServer2008SpatialDialect()
           
 
Method Summary
 java.lang.String applyLocksToSql(java.lang.String sql, org.hibernate.LockOptions aliasedLockOptions, java.util.Map keyColumnNames)
          Modifies the given SQL by applying the appropriate updates for the specified lock modes and key columns.
 boolean dropTemporaryTableAfterUse()
          Do we need to drop the temporary table after use?
 java.lang.String generateTemporaryTableName(java.lang.String baseTableName)
          Generate a temporary table name given the base table.
 java.lang.String getAddColumnString()
          The syntax used to add a column to a table (optional).
 java.lang.String getDWithinSQL(java.lang.String columnName)
          Returns the SQL fragment when parsing a DWithinExpression.
 java.lang.String getForUpdateString()
          Get the string to append to SELECT statements to acquire locks for this dialect.
 java.lang.String getHavingSridSQL(java.lang.String columnName)
          Returns the SQL fragment when parsing an HavingSridExpression.
 java.lang.String getIdentityColumnString()
          The syntax used during DDL to define a column as being an IDENTITY.
 java.lang.String getIdentitySelectString()
          Get the select command to use to retrieve the last generated IDENTITY value.
 java.lang.String getIsEmptySQL(java.lang.String columnName, boolean isEmpty)
          Returns the SQL fragment when parsing a IsEmptyExpression or IsNotEmpty expression.
 java.lang.String getNullColumnString()
          The keyword used to specify a nullable column.
 java.sql.ResultSet getResultSet(java.sql.CallableStatement ps)
          Given a callable statement previously processed by Dialect.registerResultSetOutParameter(java.sql.CallableStatement, int), extract the ResultSet from the OUT parameter.
 java.lang.String getSelectGUIDString()
          Get the command used to select a GUID from the underlying database.
 java.lang.String getSpatialAggregateSQL(java.lang.String columnName, int aggregation)
           
 java.lang.String getSpatialFilterExpression(java.lang.String columnName)
          Returns the SQL fragment for the SQL WHERE-expression when parsing org.hibernate.spatial.criterion.SpatialFilterExpressions into prepared statements.
 java.lang.String getSpatialRelateSQL(java.lang.String columnName, int spatialRelation)
          Returns the SQL fragment for the SQL WHERE-clause when parsing org.hibernatespatial.criterion.SpatialRelateExpressions into prepared statements.
 java.lang.String getTypeName(int code, long length, int precision, int scale)
          Get the name of the database type associated with the given Types typecode with the given storage specification parameters.
 boolean isCurrentTimestampSelectStringCallable()
          Should the value returned by Dialect.getCurrentTimestampSelectString() be treated as callable.
 boolean qualifyIndexName()
          Do we need to qualify index names with the schema name?
 int registerResultSetOutParameter(java.sql.CallableStatement statement, int col)
          Registers an OUT parameter which will be returning a ResultSet.
 org.hibernate.type.descriptor.sql.SqlTypeDescriptor remapSqlTypeDescriptor(org.hibernate.type.descriptor.sql.SqlTypeDescriptor sqlTypeDescriptor)
          Allows the dialect to override a SqlTypeDescriptor.
 boolean supports(SpatialFunction function)
          Does this dialect supports the specified SpatialFunction.
 boolean supportsCurrentTimestampSelection()
          Does this dialect support a way to retrieve the database's current timestamp value?
 boolean supportsEmptyInList()
          Does this dialect support empty IN lists?

For example, is [where XYZ in ()] a supported construct?

 boolean supportsExistsInSelect()
          Does the dialect support an exists statement in the select clause?
 boolean supportsFiltering()
          Returns true if this SpatialDialect supports a specific filtering function.
 boolean supportsIdentityColumns()
          Does this dialect support identity column key generation?
 boolean supportsInsertSelectIdentity()
          Does the dialect support some form of inserting and selecting the generated IDENTITY value all in the same statement.
 boolean supportsTemporaryTables()
          Does this dialect support temporary tables?
 boolean supportsTupleDistinctCounts()
          Does this dialect support `count(distinct a,b)`?
 boolean supportsUnionAll()
          Does this dialect support UNION ALL, which is generally a faster variant of UNION?
 
Methods inherited from class org.hibernate.dialect.SQLServer2005Dialect
appendLockHint, buildLimitHandler, buildSQLExceptionConversionDelegate
 
Methods inherited from class org.hibernate.dialect.SQLServerDialect
appendIdentitySelectToInsert, areStringComparisonsCaseInsensitive, closeQuote, doesReadCommittedCauseWritersToBlockReaders, doesRepeatableReadCauseReadersToBlockWriters, getCurrentTimestampSelectString, getInExpressionCountLimit, getLimitString, getNoColumnsInsertString, openQuote, supportsCircularCascadeDeleteConstraints, supportsLimit, supportsLimitOffset, supportsLobValueChangePropogation, supportsResultSetPositionQueryMethodsOnForwardOnlyCursor, supportsVariableLimit, useMaxForLimit
 
Methods inherited from class org.hibernate.dialect.Dialect
appendLockHint, bindLimitParametersFirst, bindLimitParametersInReverseOrder, buildSQLExceptionConverter, cast, cast, cast, convertToFirstRowValue, createCaseFragment, createOuterJoinFragment, dropConstraints, forceLimitUsage, forceLobAsLastValue, forUpdateOfColumns, getAddForeignKeyConstraintString, getAddPrimaryKeyConstraintString, getAddUniqueConstraintString, getCascadeConstraintsString, getCaseInsensitiveLike, getCastTypeName, getColumnAliasExtractor, getColumnComment, getCreateMultisetTableString, getCreateSequenceStrings, getCreateSequenceStrings, getCreateTableString, getCreateTemporaryTablePostfix, getCreateTemporaryTableString, getCrossJoinSeparator, getCurrentTimestampSQLFunctionName, getDefaultProperties, getDialect, getDialect, getDropForeignKeyString, getDropSequenceStrings, getDropTableString, getDropTemporaryTableString, getForUpdateNowaitString, getForUpdateNowaitString, getForUpdateString, getForUpdateString, getForUpdateString, getForUpdateString, getFunctions, getHibernateTypeName, getHibernateTypeName, getIdentityColumnString, getIdentityInsertString, getIdentitySelectString, getKeywords, getLobMergeStrategy, getLockingStrategy, getLowercaseFunction, getMaxAliasLength, getNativeIdentifierGeneratorClass, getNotExpression, getQuerySequencesString, getReadLockString, getSelectClauseNullString, getSelectSequenceNextValString, getSequenceNextValString, getTableComment, getTableTypeString, getTypeName, getViolatedConstraintNameExtracter, getWriteLockString, hasAlterTable, hasDataTypeInIdentityColumn, hasSelfReferentialForeignKeyBug, isLockTimeoutParameterized, performTemporaryTableDDLInIsolation, quote, replaceResultVariableInOrderByClauseWithPosition, requiresCastingOfParametersInSelectClause, supportsBindAsCallableArgument, supportsCascadeDelete, supportsCaseInsensitiveLike, supportsColumnCheck, supportsCommentOn, supportsExpectedLobUsagePattern, supportsIfExistsAfterTableName, supportsIfExistsBeforeTableName, supportsLockTimeouts, supportsNotNullUnique, supportsOuterJoinForUpdate, supportsParametersInInsertSelect, supportsPooledSequences, supportsRowValueConstructorSyntax, supportsRowValueConstructorSyntaxInInList, supportsSequences, supportsSubqueryOnMutatingTable, supportsSubselectAsInPredicateLHS, supportsTableCheck, supportsTupleCounts, supportsUnboundedLobLocatorMaterialization, supportsUnique, supportsUniqueConstraintInCreateAlterTable, toBooleanValueString, toString, transformSelectString, useFollowOnLocking, useInputStreamToInsertBlob
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SHORT_NAME

public static final java.lang.String SHORT_NAME
See Also:
Constant Field Values

COLUMN_TYPE

public static final java.lang.String COLUMN_TYPE
See Also:
Constant Field Values
Constructor Detail

SqlServer2008SpatialDialect

public SqlServer2008SpatialDialect()
Method Detail

getTypeName

public java.lang.String getTypeName(int code,
                                    long length,
                                    int precision,
                                    int scale)
                             throws org.hibernate.HibernateException
Description copied from class: org.hibernate.dialect.Dialect
Get the name of the database type associated with the given Types typecode with the given storage specification parameters.

Overrides:
getTypeName in class org.hibernate.dialect.Dialect
Parameters:
code - The Types typecode
length - The datatype length
precision - The datatype precision
scale - The datatype scale
Returns:
the database type name
Throws:
org.hibernate.HibernateException - If no mapping was specified for that type.

remapSqlTypeDescriptor

public org.hibernate.type.descriptor.sql.SqlTypeDescriptor remapSqlTypeDescriptor(org.hibernate.type.descriptor.sql.SqlTypeDescriptor sqlTypeDescriptor)
Description copied from class: org.hibernate.dialect.Dialect
Allows the dialect to override a SqlTypeDescriptor.

If the passed sqlTypeDescriptor allows itself to be remapped (per SqlTypeDescriptor.canBeRemapped()), then this method uses Dialect.getSqlTypeDescriptorOverride(int) to get an optional override based on the SQL code returned by SqlTypeDescriptor.getSqlType().

If this dialect does not provide an override or if the sqlTypeDescriptor doe not allow itself to be remapped, then this method simply returns the original passed sqlTypeDescriptor

Overrides:
remapSqlTypeDescriptor in class org.hibernate.dialect.Dialect
Parameters:
sqlTypeDescriptor - The SqlTypeDescriptor to override
Returns:
The SqlTypeDescriptor that should be used for this dialect; if there is no override, then original sqlTypeDescriptor is returned.
See Also:
Dialect.getSqlTypeDescriptorOverride(int)

getSpatialRelateSQL

public java.lang.String getSpatialRelateSQL(java.lang.String columnName,
                                            int spatialRelation)
Description copied from interface: SpatialDialect
Returns the SQL fragment for the SQL WHERE-clause when parsing org.hibernatespatial.criterion.SpatialRelateExpressions into prepared statements.

Specified by:
getSpatialRelateSQL in interface SpatialDialect
Parameters:
columnName - The name of the geometry-typed column to which the relation is applied
spatialRelation - The type of spatial relation (as defined in SpatialRelation).
Returns:
SQL fragment for use in the SQL WHERE-clause.

getSpatialFilterExpression

public java.lang.String getSpatialFilterExpression(java.lang.String columnName)
Description copied from interface: SpatialDialect
Returns the SQL fragment for the SQL WHERE-expression when parsing org.hibernate.spatial.criterion.SpatialFilterExpressions into prepared statements.

Specified by:
getSpatialFilterExpression in interface SpatialDialect
Returns:

getSpatialAggregateSQL

public java.lang.String getSpatialAggregateSQL(java.lang.String columnName,
                                               int aggregation)
Specified by:
getSpatialAggregateSQL in interface SpatialDialect
Parameters:
columnName - the name of the Geometry property
aggregation - the type of SpatialAggregate
Returns:
the SQL fragment for the projection

getDWithinSQL

public java.lang.String getDWithinSQL(java.lang.String columnName)
Description copied from interface: SpatialDialect
Returns the SQL fragment when parsing a DWithinExpression.

Specified by:
getDWithinSQL in interface SpatialDialect
Parameters:
columnName - the geometry column to test against
Returns:

getHavingSridSQL

public java.lang.String getHavingSridSQL(java.lang.String columnName)
Description copied from interface: SpatialDialect
Returns the SQL fragment when parsing an HavingSridExpression.

Specified by:
getHavingSridSQL in interface SpatialDialect
Parameters:
columnName - the geometry column to test against
Returns:

getIsEmptySQL

public java.lang.String getIsEmptySQL(java.lang.String columnName,
                                      boolean isEmpty)
Description copied from interface: SpatialDialect
Returns the SQL fragment when parsing a IsEmptyExpression or IsNotEmpty expression.

Specified by:
getIsEmptySQL in interface SpatialDialect
Parameters:
columnName - the geometry column
isEmpty - whether the geometry is tested for empty or non-empty
Returns:

supportsFiltering

public boolean supportsFiltering()
Description copied from interface: SpatialDialect
Returns true if this SpatialDialect supports a specific filtering function.

This is intended to signal DB-support for fast window queries, or MBR-overlap queries

Specified by:
supportsFiltering in interface SpatialDialect

supports

public boolean supports(SpatialFunction function)
Description copied from interface: SpatialDialect
Does this dialect supports the specified SpatialFunction.

Specified by:
supports in interface SpatialDialect
Parameters:
function - SpatialFunction
Returns:
true if this SpatialDialect supports the spatial function specified by the function parameter.

getAddColumnString

public java.lang.String getAddColumnString()
Description copied from class: org.hibernate.dialect.Dialect
The syntax used to add a column to a table (optional).

Overrides:
getAddColumnString in class org.hibernate.dialect.Dialect
Returns:
The "add column" fragment.

getNullColumnString

public java.lang.String getNullColumnString()
Description copied from class: org.hibernate.dialect.Dialect
The keyword used to specify a nullable column.

Overrides:
getNullColumnString in class org.hibernate.dialect.Dialect
Returns:
String

qualifyIndexName

public boolean qualifyIndexName()
Description copied from class: org.hibernate.dialect.Dialect
Do we need to qualify index names with the schema name?

Overrides:
qualifyIndexName in class org.hibernate.dialect.Dialect
Returns:
boolean

getForUpdateString

public java.lang.String getForUpdateString()
Description copied from class: org.hibernate.dialect.Dialect
Get the string to append to SELECT statements to acquire locks for this dialect.

Overrides:
getForUpdateString in class org.hibernate.dialect.Dialect
Returns:
The appropriate FOR UPDATE clause string.

supportsIdentityColumns

public boolean supportsIdentityColumns()
Description copied from class: org.hibernate.dialect.Dialect
Does this dialect support identity column key generation?

Overrides:
supportsIdentityColumns in class org.hibernate.dialect.Dialect
Returns:
True if IDENTITY columns are supported; false otherwise.

getIdentitySelectString

public java.lang.String getIdentitySelectString()
Description copied from class: org.hibernate.dialect.Dialect
Get the select command to use to retrieve the last generated IDENTITY value.

Overrides:
getIdentitySelectString in class org.hibernate.dialect.Dialect
Returns:
The appropriate select command

getIdentityColumnString

public java.lang.String getIdentityColumnString()
Description copied from class: org.hibernate.dialect.Dialect
The syntax used during DDL to define a column as being an IDENTITY.

Overrides:
getIdentityColumnString in class org.hibernate.dialect.Dialect
Returns:
The appropriate DDL fragment.

supportsInsertSelectIdentity

public boolean supportsInsertSelectIdentity()
Description copied from class: org.hibernate.dialect.Dialect
Does the dialect support some form of inserting and selecting the generated IDENTITY value all in the same statement.

Overrides:
supportsInsertSelectIdentity in class org.hibernate.dialect.Dialect
Returns:
True if the dialect supports selecting the just generated IDENTITY in the insert statement.

applyLocksToSql

public java.lang.String applyLocksToSql(java.lang.String sql,
                                        org.hibernate.LockOptions aliasedLockOptions,
                                        java.util.Map keyColumnNames)
Description copied from class: org.hibernate.dialect.Dialect
Modifies the given SQL by applying the appropriate updates for the specified lock modes and key columns.

The behavior here is that of an ANSI 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.

Overrides:
applyLocksToSql in class org.hibernate.dialect.Dialect
Parameters:
sql - the SQL string to modify
aliasedLockOptions - lock options indexed by aliased table names.
keyColumnNames - a map of key columns indexed by aliased table names.
Returns:
the modified SQL string.

registerResultSetOutParameter

public int registerResultSetOutParameter(java.sql.CallableStatement statement,
                                         int col)
                                  throws java.sql.SQLException
Description copied from class: org.hibernate.dialect.Dialect
Registers an OUT parameter which will be returning a ResultSet. How this is accomplished varies greatly from DB to DB, hence its inclusion (along with Dialect.getResultSet(java.sql.CallableStatement)) here.

Overrides:
registerResultSetOutParameter in class org.hibernate.dialect.Dialect
Parameters:
statement - The callable statement.
col - The bind position at which to register the OUT param.
Returns:
The number of (contiguous) bind positions used.
Throws:
java.sql.SQLException - Indicates problems registering the OUT param.

getResultSet

public java.sql.ResultSet getResultSet(java.sql.CallableStatement ps)
                                throws java.sql.SQLException
Description copied from class: org.hibernate.dialect.Dialect
Given a callable statement previously processed by Dialect.registerResultSetOutParameter(java.sql.CallableStatement, int), extract the ResultSet from the OUT parameter.

Overrides:
getResultSet in class org.hibernate.dialect.Dialect
Parameters:
ps - The callable statement.
Returns:
The extracted result set.
Throws:
java.sql.SQLException - Indicates problems extracting the result set.

supportsCurrentTimestampSelection

public boolean supportsCurrentTimestampSelection()
Description copied from class: org.hibernate.dialect.Dialect
Does this dialect support a way to retrieve the database's current timestamp value?

Overrides:
supportsCurrentTimestampSelection in class org.hibernate.dialect.Dialect
Returns:
True if the current timestamp can be retrieved; false otherwise.

isCurrentTimestampSelectStringCallable

public boolean isCurrentTimestampSelectStringCallable()
Description copied from class: org.hibernate.dialect.Dialect
Should the value returned by Dialect.getCurrentTimestampSelectString() be treated as callable. Typically this indicates that JDBC escape syntax is being used...

Overrides:
isCurrentTimestampSelectStringCallable in class org.hibernate.dialect.Dialect
Returns:
True if the Dialect.getCurrentTimestampSelectString() return is callable; false otherwise.

supportsTemporaryTables

public boolean supportsTemporaryTables()
Description copied from class: org.hibernate.dialect.Dialect
Does this dialect support temporary tables?

Overrides:
supportsTemporaryTables in class org.hibernate.dialect.Dialect
Returns:
True if temp tables are supported; false otherwise.

generateTemporaryTableName

public java.lang.String generateTemporaryTableName(java.lang.String baseTableName)
Description copied from class: org.hibernate.dialect.Dialect
Generate a temporary table name given the base table.

Overrides:
generateTemporaryTableName in class org.hibernate.dialect.Dialect
Parameters:
baseTableName - The table name from which to base the temp table name.
Returns:
The generated temp table name.

dropTemporaryTableAfterUse

public boolean dropTemporaryTableAfterUse()
Description copied from class: org.hibernate.dialect.Dialect
Do we need to drop the temporary table after use?

Overrides:
dropTemporaryTableAfterUse in class org.hibernate.dialect.Dialect
Returns:
True if the table should be dropped.

getSelectGUIDString

public java.lang.String getSelectGUIDString()
Description copied from class: org.hibernate.dialect.Dialect
Get the command used to select a GUID from the underlying database.

Optional operation.

Overrides:
getSelectGUIDString in class org.hibernate.dialect.Dialect
Returns:
The appropriate command.

supportsEmptyInList

public boolean supportsEmptyInList()
Description copied from class: org.hibernate.dialect.Dialect
Does this dialect support empty IN lists?

For example, is [where XYZ in ()] a supported construct?

Overrides:
supportsEmptyInList in class org.hibernate.dialect.Dialect
Returns:
True if empty in lists are supported; false otherwise.

supportsUnionAll

public boolean supportsUnionAll()
Description copied from class: org.hibernate.dialect.Dialect
Does this dialect support UNION ALL, which is generally a faster variant of UNION?

Overrides:
supportsUnionAll in class org.hibernate.dialect.Dialect
Returns:
True if UNION ALL is supported; false otherwise.

supportsExistsInSelect

public boolean supportsExistsInSelect()
Description copied from class: org.hibernate.dialect.Dialect
Does the dialect support an exists statement in the select clause?

Overrides:
supportsExistsInSelect in class org.hibernate.dialect.Dialect
Returns:
True if exists checks are allowed in the select clause; false otherwise.

supportsTupleDistinctCounts

public boolean supportsTupleDistinctCounts()
Description copied from class: org.hibernate.dialect.Dialect
Does this dialect support `count(distinct a,b)`?

Overrides:
supportsTupleDistinctCounts in class org.hibernate.dialect.Dialect
Returns:
True if the database supports counting distinct tuples; false otherwise.