org.hibernate.spatial.dialect.h2geodb
Class GeoDBDialect

java.lang.Object
  extended by org.hibernate.dialect.Dialect
      extended by org.hibernate.dialect.H2Dialect
          extended by org.hibernate.spatial.dialect.h2geodb.GeoDBDialect
All Implemented Interfaces:
java.io.Serializable, org.hibernate.exception.spi.ConversionContext, SpatialDialect

public class GeoDBDialect
extends org.hibernate.dialect.H2Dialect
implements SpatialDialect

Extends the H2Dialect by also including information on spatial functions.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.hibernate.dialect.Dialect
CLOSED_QUOTE, DEFAULT_BATCH_SIZE, NO_BATCH, QUOTE
 
Constructor Summary
GeoDBDialect()
          Constructor.
 
Method Summary
 java.lang.String getDbGeometryTypeName()
           
 java.lang.String getDWithinSQL(java.lang.String columnName)
          Returns the SQL fragment when parsing a DWithinExpression.
 java.lang.String getHavingSridSQL(java.lang.String columnName)
          Returns the SQL fragment when parsing an HavingSridExpression.
 java.lang.String getIsEmptySQL(java.lang.String columnName, boolean isEmpty)
          Returns the SQL fragment when parsing a IsEmptyExpression or IsNotEmpty expression.
 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 isTwoPhaseFiltering()
           
 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 supportsFiltering()
          Returns true if this SpatialDialect supports a specific filtering function.
 
Methods inherited from class org.hibernate.dialect.H2Dialect
bindLimitParametersFirst, bindLimitParametersInReverseOrder, buildSQLExceptionConversionDelegate, doesReadCommittedCauseWritersToBlockReaders, dropTemporaryTableAfterUse, getAddColumnString, getCreateSequenceString, getCreateTemporaryTablePostfix, getCreateTemporaryTableString, getCurrentTimestampSelectString, getDropSequenceString, getForUpdateString, getIdentityColumnString, getIdentityInsertString, getIdentitySelectString, getLimitString, getQuerySequencesString, getSelectSequenceNextValString, getSequenceNextValString, getViolatedConstraintNameExtracter, isCurrentTimestampSelectStringCallable, performTemporaryTableDDLInIsolation, supportsCurrentTimestampSelection, supportsIdentityColumns, supportsIfExistsAfterTableName, supportsLimit, supportsLobValueChangePropogation, supportsPooledSequences, supportsSequences, supportsTemporaryTables, supportsTupleDistinctCounts, supportsUnionAll, supportsUnique
 
Methods inherited from class org.hibernate.dialect.Dialect
appendIdentitySelectToInsert, appendLockHint, appendLockHint, applyLocksToSql, areStringComparisonsCaseInsensitive, buildLimitHandler, buildSQLExceptionConverter, cast, cast, cast, closeQuote, convertToFirstRowValue, createCaseFragment, createOuterJoinFragment, doesRepeatableReadCauseReadersToBlockWriters, dropConstraints, forceLimitUsage, forceLobAsLastValue, forUpdateOfColumns, generateTemporaryTableName, getAddForeignKeyConstraintString, getAddPrimaryKeyConstraintString, getAddUniqueConstraintString, getCascadeConstraintsString, getCaseInsensitiveLike, getCastTypeName, getColumnAliasExtractor, getColumnComment, getCreateMultisetTableString, getCreateSequenceStrings, getCreateSequenceStrings, getCreateTableString, getCrossJoinSeparator, getCurrentTimestampSQLFunctionName, getDefaultProperties, getDialect, getDialect, getDropForeignKeyString, getDropSequenceStrings, getDropTableString, getDropTemporaryTableString, getForUpdateNowaitString, getForUpdateNowaitString, getForUpdateString, getForUpdateString, getForUpdateString, getForUpdateString, getFunctions, getHibernateTypeName, getHibernateTypeName, getIdentityColumnString, getIdentitySelectString, getInExpressionCountLimit, getKeywords, getLimitString, getLobMergeStrategy, getLockingStrategy, getLowercaseFunction, getMaxAliasLength, getNativeIdentifierGeneratorClass, getNoColumnsInsertString, getNotExpression, getNullColumnString, getReadLockString, getResultSet, getSelectClauseNullString, getSelectGUIDString, getTableComment, getTableTypeString, getTypeName, getWriteLockString, hasAlterTable, hasDataTypeInIdentityColumn, hasSelfReferentialForeignKeyBug, isLockTimeoutParameterized, openQuote, qualifyIndexName, quote, registerResultSetOutParameter, replaceResultVariableInOrderByClauseWithPosition, requiresCastingOfParametersInSelectClause, supportsBindAsCallableArgument, supportsCascadeDelete, supportsCaseInsensitiveLike, supportsCircularCascadeDeleteConstraints, supportsColumnCheck, supportsCommentOn, supportsEmptyInList, supportsExistsInSelect, supportsExpectedLobUsagePattern, supportsIfExistsBeforeTableName, supportsInsertSelectIdentity, supportsLimitOffset, supportsLockTimeouts, supportsNotNullUnique, supportsOuterJoinForUpdate, supportsParametersInInsertSelect, supportsResultSetPositionQueryMethodsOnForwardOnlyCursor, supportsRowValueConstructorSyntax, supportsRowValueConstructorSyntaxInInList, supportsSubqueryOnMutatingTable, supportsSubselectAsInPredicateLHS, supportsTableCheck, supportsTupleCounts, supportsUnboundedLobLocatorMaterialization, supportsUniqueConstraintInCreateAlterTable, supportsVariableLimit, toBooleanValueString, toString, transformSelectString, useFollowOnLocking, useInputStreamToInsertBlob, useMaxForLimit
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GeoDBDialect

public GeoDBDialect()
Constructor. Registers OGC simple feature functions (see http://portal.opengeospatial.org/files/?artifact_id=829 for details).

Note for the registerfunction method: it registers non-standard database functions: first argument is the internal (OGC standard) function name, second the name as it occurs in the spatial dialect

Method Detail

getTypeName

public java.lang.String getTypeName(int code,
                                    long length,
                                    int precision,
                                    int scale)
                             throws org.hibernate.HibernateException
Get the name of the database type associated with the given Types typecode with the given storage specification parameters. In the case of typecode == 3000, it returns this dialect's spatial type which is GEOMETRY.

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:
Throws:
org.hibernate.HibernateException

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)

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:

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:

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.

getDbGeometryTypeName

public java.lang.String getDbGeometryTypeName()

isTwoPhaseFiltering

public boolean isTwoPhaseFiltering()

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.