站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Hibernate 3.2.4 正式版 API 英文文档

Dialect (Hibernate API Documentation) - Hibernate 3.2.4 正式版 API 英文文档


org.hibernate.dialect
Class Dialect

java.lang.Object
  extended byorg.hibernate.dialect.Dialect
Direct Known Subclasses:
Cache71Dialect, DB2Dialect, FrontBaseDialect, H2Dialect, HSQLDialect, InformixDialect, IngresDialect, InterbaseDialect, JDataStoreDialect, MckoiDialect, MimerSQLDialect, MySQLDialect, Oracle9Dialect, PointbaseDialect, PostgreSQLDialect, ProgressDialect, RDMSOS2200Dialect, SAPDBDialect, SybaseDialect, TeradataDialect, TimesTenDialect

public abstract class Dialect
extends Object

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.

Author:
Gavin King, David Channon

Field Summary
static String CLOSED_QUOTE
           
static String DEFAULT_BATCH_SIZE
           
static String NO_BATCH
           
static String QUOTE
          Characters used for quoting SQL identifiers
 
Constructor Summary
protected Dialect()
           
 
Method Summary
 String appendIdentitySelectToInsert(String insertString)
          Provided we supportsInsertSelectIdentity(), then attch the "select identity" clause to the insert statement.
 String appendLockHint(LockMode mode, String tableName)
          Some dialects support an alternative means to SELECT FOR UPDATE, whereby a "lock hint" is appends to the table name in the from clause.
 String applyLocksToSql(String sql, Map aliasedLockModes, Map 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.
 boolean bindLimitParametersFirst()
          Does the LIMIT clause come at the start of the SELECT statement, rather than at the end?
 boolean bindLimitParametersInReverseOrder()
          ANSI SQL defines the LIMIT clause to be in the form LIMIT offset, limit.
 SQLExceptionConverter buildSQLExceptionConverter()
          Build an instance of the SQLExceptionConverter preferred by this dialect for converting SQLExceptions into Hibernate's JDBCException hierarchy.
 char closeQuote()
          The character specific to this dialect used to close a quoted identifier.
 CaseFragment createCaseFragment()
          Create a CaseFragment strategy responsible for handling this dialect's variations in how CASE statements are handled.
 JoinFragment createOuterJoinFragment()
          Create a JoinFragment strategy responsible for handling this dialect's variations in how joins are handled.
 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 dropTemporaryTableAfterUse()
          Do we need to drop the temporary table after use?
 boolean forUpdateOfColumns()
          Is FOR UPDATE OF syntax supported?
 String generateTemporaryTableName(String baseTableName)
          Generate a temporary table name given the bas table.
 String getAddColumnString()
          The syntax used to add a column to a table (optional).
 String getAddForeignKeyConstraintString(String constraintName, String[] foreignKey, String referencedTable, String[] primaryKey, boolean referencesPrimaryKey)
          The syntax used to add a foreign key constraint to a table.
 String getAddPrimaryKeyConstraintString(String constraintName)
          The syntax used to add a primary key constraint to a table.
 String getCascadeConstraintsString()
          Completely optional cascading drop clause
 String getCastTypeName(int code)
          Get the name of the database type appropriate for casting operations (via the CAST() SQL function) for the given Types typecode.
 String getColumnComment(String comment)
           
 String getCreateMultisetTableString()
          Slight variation on getCreateTableString().
protected  String getCreateSequenceString(String sequenceName)
          Typically dialects which support sequences can create a sequence with a single command.
protected  String getCreateSequenceString(String sequenceName, int initialValue, int incrementSize)
          Overloaded form of getCreateSequenceString(String), additionally taking the initial value and increment size to be applied to the sequence definition.
 String[] getCreateSequenceStrings(String sequenceName)
          Deprecated. Use getCreateSequenceString(String, int, int) instead
 String[] getCreateSequenceStrings(String sequenceName, int initialValue, int incrementSize)
          An optional multi-line form for databases which supportsPooledSequences().
 String getCreateTableString()
          Command used to create a table.
 String getCreateTemporaryTablePostfix()
          Get any fragments needing to be postfixed to the command for temporary table creation.
 String getCreateTemporaryTableString()
          Command used to create a temporary table.
 String getCurrentTimestampSelectString()
          Retrieve the command used to retrieve the current timestammp from the database.
 String getCurrentTimestampSQLFunctionName()
          The name of the database-specific SQL function for retrieving the current timestamp.
 Properties getDefaultProperties()
          Retrieve a set of default Hibernate properties for this database.
static Dialect getDialect()
          Get an instance of the dialect specified by the current System properties.
static Dialect getDialect(Properties props)
          Get an instance of the dialect specified by the given properties or by the current System properties.
 String getDropForeignKeyString()
           
protected  String getDropSequenceString(String sequenceName)
          Typically dialects which support sequences can drop a sequence with a single command.
 String[] getDropSequenceStrings(String sequenceName)
          The multiline script used to drop a sequence.
 String getForUpdateNowaitString()
          Retrieves the FOR UPDATE NOWAIT syntax specific to this dialect.
 String getForUpdateNowaitString(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.
 String getForUpdateString()
          Get the string to append to SELECT statements to acquire locks for this dialect.
 String getForUpdateString(LockMode lockMode)
          Given a lock mode, determine the appropriate for update fragment to use.
 String getForUpdateString(String aliases)
          Get the FOR UPDATE OF column_list fragment appropriate for this dialect given the aliases of the columns to be write locked.
 Map getFunctions()
          Retrieves a map of the dialect's registered fucntions (functionName => SQLFunction).
 String getHibernateTypeName(int code)
          Get the name of the Hibernate Type associated with th given Types typecode.
 String getHibernateTypeName(int code, int length, int precision, int scale)
          Get the name of the Hibernate Type associated with the given Types typecode with the given storage specification parameters.
protected  String getIdentityColumnString()
          The syntax used during DDL to define a column as being an IDENTITY.
 String getIdentityColumnString(int type)
          The syntax used during DDL to define a column as being an IDENTITY of a particular type.
 String getIdentityInsertString()
          The keyword used to insert a generated value into an identity column (or null).
protected  String getIdentitySelectString()
          Get the select command to use to retrieve the last generated IDENTITY value.
 String getIdentitySelectString(String table, String column, int type)
          Get the select command to use to retrieve the last generated IDENTITY value for a particuar table
 Set getKeywords()
           
protected  String getLimitString(String query, boolean hasOffset)
          Apply s limit clause to the query.
 String getLimitString(String query, int offset, int limit)
          Given a limit and an offset, apply the limit clause to the query.
 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.
 String getLowercaseFunction()
          The name of the SQL function that transforms a string to lowercase
 int getMaxAliasLength()
          What is the maximum length Hibernate can use for generated aliases?
 Class getNativeIdentifierGeneratorClass()
          The class (which implements IdentifierGenerator) which acts as this dialects native generation strategy.
 String getNoColumnsInsertString()
          The fragment used to insert a row without specifying any column values.
 String getNullColumnString()
          The keyword used to specify a nullable column.
 String getQuerySequencesString()
          Get the select command used retrieve the names of all sequences.
 ResultSet getResultSet(CallableStatement statement)
          Given a callable statement previously processed by registerResultSetOutParameter(java.sql.CallableStatement, int), extract the ResultSet from the OUT parameter.
 String getSelectClauseNullString(int sqlType)
          Given a Types type code, determine an appropriate null value to use in a select clause.
 String getSelectGUIDString()
          Get the command used to select a GUID from the underlying database.
 String getSelectSequenceNextValString(String sequenceName)
          Generate the select expression fragment that will retreive the next value of a sequence as part of another (typically DML) statement.
 String getSequenceNextValString(String sequenceName)
          Generate the appropriate select statement to to retreive the next value of a sequence.
 String getTableComment(String comment)
           
 String getTableTypeString()
           
 String getTypeName(int code)
          Get the name of the database type associated with the given Types typecode.
 String getTypeName(int code, int length, int precision, int scale)
          Get the name of the database type associated with the given Types typecode with the given storage specification parameters.
 ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter()
           
 boolean hasAlterTable()
          Does this dialect support the ALTER TABLE syntax?
 boolean hasDataTypeInIdentityColumn()
          Whether this dialect have an Identity clause added to the data type or a completely seperate identity data type
 boolean hasSelfReferentialForeignKeyBug()
           
 boolean isCurrentTimestampSelectStringCallable()
          Should the value returned by getCurrentTimestampSelectString() be treated as callable.
 char openQuote()
          The character specific to this dialect used to begin a quoted identifier.
 Boolean performTemporaryTableDDLInIsolation()
          Does the dialect require that temporary table DDL statements occur in isolation from other statements? This would be the case if the creation would cause any current transaction to get committed implicitly.
 boolean qualifyIndexName()
          Do we need to qualify index names with the schema name?
 String quote(String column)
          Apply dialect-specific quoting.
protected  void registerColumnType(int code, int capacity, String name)
          Subclasses register a type name for the given type code and maximum column length.
protected  void registerColumnType(int code, String name)
          Subclasses register a type name for the given type code.
protected  void registerFunction(String name, SQLFunction function)
           
protected  void registerHibernateType(int code, int capacity, String name)
          Registers a Hibernate Type name for the given Types type code and maximum column length.
protected  void registerHibernateType(int code, String name)
          Registers a Hibernate Type name for the given Types type code.
protected  void registerKeyword(String word)
           
 int registerResultSetOutParameter(CallableStatement statement, int position)
          Registers an OUT parameter which will be returing a ResultSet.
 boolean supportsBindAsCallableArgument()
          Does this dialect support using a JDBC bind parameter as an argument to a function or procedure call?
 boolean supportsCascadeDelete()
           
 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()
           
 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 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 supportsIdentityColumns()
          Does this dialect support identity column key generation?
 boolean supportsIfExistsAfterTableName()
           
 boolean supportsIfExistsBeforeTableName()
           
 boolean supportsInsertSelectIdentity()
          Does the dialect support some form of inserting and selecting the generated IDENTITY value all in the same statement.
 boolean supportsLimit()
          Does this dialect support some form of limiting query results via a SQL clause?
 boolean supportsLimitOffset()
          Does this dialect's LIMIT support (if any) additionally support specifying an offset?
 boolean supportsLobValueChangePropogation()
          Does the dialect support propogating 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 supportsNotNullUnique()
           
 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 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 supports row values, does it offer such support in IN lists as well?

For example, "...

 boolean supportsSequences()
          Does this dialect support sequences?
 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 supportsTemporaryTables()
          Does this dialect support temporary tables?
 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.

 boolean supportsUnionAll()
          Does this dialect support UNION ALL, which is generally a faster variant of UNION?
 boolean supportsUnique()
          Does this dialect support the UNIQUE column syntax?
 boolean supportsUniqueConstraintInCreateAlterTable()
          Does this dialect support adding Unique constraints via create and alter table ?
 boolean supportsVariableLimit()
          Does this dialect support bind variables (i.e., prepared statememnt parameters) for its limit/offset?
 String toBooleanValueString(boolean bool)
          The SQL literal value to which this database maps boolean values.
 String toString()
           
 String transformSelectString(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 useInputStreamToInsertBlob()
          Should LOBs (both BLOB and CLOB) be bound using stream operations (i.e.
 boolean 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.

 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_BATCH_SIZE

public static final String DEFAULT_BATCH_SIZE
See Also:
Constant Field Values

NO_BATCH

public static final String NO_BATCH
See Also:
Constant Field Values

QUOTE

public static final String QUOTE
Characters used for quoting SQL identifiers

See Also:
Constant Field Values

CLOSED_QUOTE

public static final String CLOSED_QUOTE
See Also:
Constant Field Values
Constructor Detail

Dialect

protected Dialect()
Method Detail

getDialect

public static Dialect getDialect()
                          throws HibernateException
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

public static Dialect getDialect(Properties props)
                          throws HibernateException
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 Properties getDefaultProperties()
Retrieve a set of default Hibernate properties for this database.

Returns:
a set of Hibernate properties

toString

public String toString()

getTypeName

public String getTypeName(int code)
                   throws HibernateException
Get the name of the database type associated with the given Types typecode.

Parameters:
code - The Types typecode
Returns:
the database type name
Throws:
HibernateException - If no mapping was specified for that type.

getTypeName

public String getTypeName(int code,
                          int length,
                          int precision,
                          int scale)
                   throws HibernateException
Get the name of the database type associated with the given Types typecode with the given storage specification parameters.

Parameters:
code - The Types typecode
length - The datatype length
precision - The datatype precision
scale - The datatype scale
Returns:
the database type name
Throws:
HibernateException - If no mapping was specified for that type.

getCastTypeName

public String getCastTypeName(int code)
Get the name of the database type appropriate for casting operations (via the CAST() SQL function) for the given Types typecode.

Parameters:
code - The Types typecode
Returns:
The database type name

registerColumnType

protected void registerColumnType(int code,
                                  int capacity,
                                  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 - The Types typecode
capacity - The maximum length of database type
name - The database type name

registerColumnType

protected void registerColumnType(int code,
                                  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 - The Types typecode
name - The database type name

getHibernateTypeName

public String getHibernateTypeName(int code)
                            throws HibernateException
Get the name of the Hibernate Type associated with th given Types typecode.

Parameters:
code - The Types typecode
Returns:
The Hibernate Type name.
Throws:
HibernateException - If no mapping was specified for that type.

getHibernateTypeName

public String getHibernateTypeName(int code,
                                   int length,
                                   int precision,
                                   int scale)
                            throws HibernateException
Get the name of the Hibernate Type associated with the given Types typecode with the given storage specification parameters.

Parameters:
code - The Types typecode
length - The datatype length
precision - The datatype precision
scale - The datatype scale
Returns:
The Hibernate Type name.
Throws:
HibernateException - If no mapping was specified for that type.

registerHibernateType

protected void registerHibernateType(int code,
                                     int capacity,
                                     String name)
Registers a Hibernate Type name for the given Types type code and maximum column length.

Parameters:
code - The Types typecode
capacity - The maximum length of database type
name - The Hibernate Type name

registerHibernateType

protected void registerHibernateType(int code,
                                     String name)
Registers a Hibernate Type name for the given Types type code.

Parameters:
code - The Types typecode
name - The Hibernate Type name

registerFunction

protected void registerFunction(String name,
                                SQLFunction function)

getFunctions

public final Map getFunctions()
Retrieves a map of the dialect's registered fucntions (functionName => SQLFunction).

Returns:
The map of registered functions.

registerKeyword

protected void registerKeyword(String word)

getKeywords

public Set getKeywords()

getNativeIdentifierGeneratorClass

public Class getNativeIdentifierGeneratorClass()
The class (which implements IdentifierGenerator) which acts as this dialects native generation strategy.

Comes into play whenever the user specifies the native generator.

Returns:
The native generator class.

supportsIdentityColumns

public boolean supportsIdentityColumns()
Does this dialect support identity column key generation?

Returns:
True if IDENTITY columns are supported; false otherwise.

supportsInsertSelectIdentity

public boolean supportsInsertSelectIdentity()
Does the dialect support some form of inserting and selecting the generated IDENTITY value all in the same statement.

Returns:
True if the dialect supports selecting the just generated IDENTITY in the insert statement.

hasDataTypeInIdentityColumn

public boolean hasDataTypeInIdentityColumn()
Whether this dialect have an Identity clause added to the data type or a completely seperate identity data type

Returns:
boolean

appendIdentitySelectToInsert

public String appendIdentitySelectToInsert(String insertString)
Provided we supportsInsertSelectIdentity(), then attch the "select identity" clause to the insert statement.

Note, if supportsInsertSelectIdentity() == false then the insert-string should be returned without modification.

Parameters:
insertString - The insert command
Returns:
The insert command with any necessary identity select clause attached.

getIdentitySelectString

public String getIdentitySelectString(String table,
                                      String column,
                                      int type)
                               throws MappingException
Get the select command to use to retrieve the last generated IDENTITY value for a particuar table

Parameters:
table - The table into which the insert was done
column - The PK column.
type - The Types type code.
Returns:
The appropriate select command
Throws:
MappingException - If IDENTITY generation is not supported.

getIdentitySelectString

protected String getIdentitySelectString()
                                  throws MappingException
Get the select command to use to retrieve the last generated IDENTITY value.

Returns:
The appropriate select command
Throws:
MappingException - If IDENTITY generation is not supported.

getIdentityColumnString

public String getIdentityColumnString(int type)
                               throws MappingException
The syntax used during DDL to define a column as being an IDENTITY of a particular type.

Parameters:
type - The Types type code.
Returns:
The appropriate DDL fragment.
Throws:
MappingException - If IDENTITY generation is not supported.

getIdentityColumnString

protected String getIdentityColumnString()
                                  throws MappingException
The syntax used during DDL to define a column as being an IDENTITY.

Returns:
The appropriate DDL fragment.
Throws:
MappingException - If IDENTITY generation is not supported.

getIdentityInsertString

public String getIdentityInsertString()
The keyword used to insert a generated value into an identity column (or null). Need if the dialect does not support inserts that specify no column values.

Returns:
The appropriate keyword.

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 String getSequenceNextValString(String sequenceName)
                                throws MappingException
Generate the appropriate select statement to to retreive 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 String getSelectSequenceNextValString(String sequenceName)
                                      throws MappingException
Generate the select expression fragment that will retreive the next value of a sequence as part of another (typically DML) statement.

This differs from getSequenceNextValString(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

public String[] getCreateSequenceStrings(String sequenceName)
                                  throws MappingException
Deprecated. Use getCreateSequenceString(String, int, int) instead

The 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 String[] getCreateSequenceStrings(String sequenceName,
                                         int initialValue,
                                         int incrementSize)
                                  throws MappingException
An optional multi-line form for databases which supportsPooledSequences().

Parameters:
sequenceName - The name of the sequence
initialValue - The initial value to apply to 'create sequence' statement
incrementSize - The increment value to apply to 'create sequence' statement
Returns:
The sequence creation commands
Throws:
MappingException - If sequences are not supported.

getCreateSequenceString

protected String getCreateSequenceString(String sequenceName)
                                  throws MappingException
Typically dialects which support sequences can create a sequence with a single command. This is convenience form of getCreateSequenceStrings(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 override getCreateSequenceStrings(java.lang.String).

Parameters:
sequenceName - The name of the sequence
Returns:
The sequence creation command
Throws:
MappingException - If sequences are not supported.

getCreateSequenceString

protected String getCreateSequenceString(String sequenceName,
                                         int initialValue,
                                         int incrementSize)
                                  throws MappingException
Overloaded form of getCreateSequenceString(String), additionally taking the initial value and increment size to be applied to the sequence definition.

The default definition is to suffix getCreateSequenceString(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 sequence
initialValue - The initial value to apply to 'create sequence' statement
incrementSize - The increment value to apply to 'create sequence' statement
Returns:
The sequence creation command
Throws:
MappingException - If sequences are not supported.

getDropSequenceStrings

public String[] getDropSequenceStrings(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 String getDropSequenceString(String sequenceName)
                                throws MappingException
Typically dialects which support sequences can drop a sequence with a single command. This is convenience form of getDropSequenceStrings(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 override getDropSequenceStrings(java.lang.String).

Parameters:
sequenceName - The name of the sequence
Returns:
The sequence drop commands
Throws:
MappingException - If sequences are not supported.

getQuerySequencesString

public 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

getSelectGUIDString

public String getSelectGUIDString()
Get the command used to select a GUID from the underlying database.

Optional operation.

Returns:
The appropriate command.

supportsLimit

public boolean supportsLimit()
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

public boolean supportsLimitOffset()
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

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

Returns:
True if bind variables can be used; false otherwise.

bindLimitParametersInReverseOrder

public boolean bindLimitParametersInReverseOrder()
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

public boolean bindLimitParametersFirst()
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

public boolean 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:
True if limit is relative from offset; false otherwise.

getLimitString

public String getLimitString(String query,
                             int offset,
                             int limit)
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 limit
limit - The limit of the limit ;)
Returns:
The modified query statement with the limit applied.

getLimitString

protected String getLimitString(String query,
                                boolean hasOffset)
Apply s limit clause to the query.

Typically dialects utilize variable limit caluses when they support limits. Thus, when building the select command we do not actually need to know the limit or the offest 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 and getLimitString(String, int, int).

Parameters:
query - The query to which to apply the limit.
hasOffset - Is the query requesting an offset?
Returns:
the modified SQL

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 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 String getForUpdateString()
Get the string to append to SELECT statements to acquire locks for this dialect.

Returns:
The appropriate FOR UPDATE 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 String getForUpdateString(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.

getForUpdateNowaitString

public String getForUpdateNowaitString()
Retrieves the FOR UPDATE NOWAIT syntax specific to this dialect.

Returns:
The appropriate FOR UPDATE NOWAIT clause string.

getForUpdateNowaitString

public String getForUpdateNowaitString(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 colunm_list NOWAIT clause string.

appendLockHint

public String appendLockHint(LockMode mode,
                             String tableName)
Some dialects support an alternative means to SELECT FOR UPDATE, whereby a "lock hint" is appends to the table name in the from clause.

contributed by Helge Schulz

Parameters:
mode - The lock mode to apply
tableName - The name of the table to which to apply the lock hint.
Returns:
The table with any required lock hints.

applyLocksToSql

public String applyLocksToSql(String sql,
                              Map aliasedLockModes,
                              Map 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 modify
aliasedLockModes - a map of lock modes indexed by aliased table names.
keyColumnNames - a map of key columns indexed by aliased table names.
Returns:
the modified SQL string.

getCreateTableString

public String getCreateTableString()
Command used to create a table.

Returns:
The command used to create a table.

getCreateMultisetTableString

public String getCreateMultisetTableString()
Slight variation on getCreateTableString(). 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.

supportsTemporaryTables

public boolean supportsTemporaryTables()
Does this dialect support temporary tables?

Returns:
True if temp tables are supported; false otherwise.

generateTemporaryTableName

public String generateTemporaryTableName(String baseTableName)
Generate a temporary table name given the bas table.

Parameters:
baseTableName - The table name from which to base the temp table name.
Returns:
The generated temp table name.

getCreateTemporaryTableString

public String getCreateTemporaryTableString()
Command used to create a temporary table.

Returns:
The command used to create a temporary table.

getCreateTemporaryTablePostfix

public String getCreateTemporaryTablePostfix()
Get any fragments needing to be postfixed to the command for temporary table creation.

Returns:
Any required postfix.

performTemporaryTableDDLInIsolation

public Boolean performTemporaryTableDDLInIsolation()
Does the dialect require that temporary table DDL statements occur in isolation from other statements? This would be the case if the creation would cause any current transaction to get committed implicitly.

JDBC defines a standard way to query for this information via the DatabaseMetaData.dataDefinitionCausesTransactionCommit() method. However, that does not distinguish between temporary table DDL and other forms of DDL; MySQL, for example, reports DDL causing a transaction commit via its driver, even though that is not the case for temporary table DDL.

Possible return values and their meanings:

Returns:
see the result matrix above.

dropTemporaryTableAfterUse

public boolean dropTemporaryTableAfterUse()
Do we need to drop the temporary table after use?

Returns:
True if the table should be dropped.

registerResultSetOutParameter

public int registerResultSetOutParameter(CallableStatement statement,
                                         int position)
                                  throws SQLException
Registers an OUT parameter which will be returing a ResultSet. How this is accomplished varies greatly from DB to DB, hence its inclusion (along with getResultSet(java.sql.CallableStatement)) here.

Parameters:
statement - The callable statement.
position - The bind position at which to register the OUT param.
Returns:
The number of (contiguous) bind positions used.
Throws:
SQLException - Indicates problems registering the OUT param.

getResultSet

public ResultSet getResultSet(CallableStatement statement)
                       throws SQLException
Given a callable statement previously processed by registerResultSetOutParameter(java.sql.CallableStatement, int), extract the ResultSet from the OUT parameter.

Parameters:
statement - The callable statement.
Returns:
The extracted result set.
Throws:
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 by getCurrentTimestampSelectString() be treated as callable. Typically this indicates that JDBC escape sytnax is being used...

Returns:
True if the getCurrentTimestampSelectString() return is callable; false otherwise.

getCurrentTimestampSelectString

public String getCurrentTimestampSelectString()
Retrieve the command used to retrieve the current timestammp from the database.

Returns:
The command.

getCurrentTimestampSQLFunctionName

public String getCurrentTimestampSQLFunctionName()
The name of the database-specific SQL function for retrieving the current timestamp.

Returns:
The function name.

buildSQLExceptionConverter

public SQLExceptionConverter buildSQLExceptionConverter()
Build an instance of the SQLExceptionConverter preferred by this dialect for converting SQLExceptions into Hibernate's JDBCException hierarchy. The default Dialect implementation simply returns a converter based on X/Open SQLState codes.

It is strongly recommended that specific Dialect implementations override this method, since interpretation of a SQL error is much more accurate when based on the ErrorCode rather than the SQLState. Unfortunately, the ErrorCode is a vendor- specific approach.

Returns:
The Dialect's preferred SQLExceptionConverter.

getViolatedConstraintNameExtracter

public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter()

getSelectClauseNullString

public String getSelectClauseNullString(int sqlType)
Given a Types 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 - The Types 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 a JoinFragment strategy responsible for handling this dialect's variations in how joins are handled.

Returns:
This dialect's JoinFragment strategy.

createCaseFragment

public CaseFragment createCaseFragment()
Create a CaseFragment strategy responsible for handling this dialect's variations in how CASE statements are handled.

Returns:
This dialect's CaseFragment strategy.

getNoColumnsInsertString

public 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.

getLowercaseFunction

public String getLowercaseFunction()
The name of the SQL function that transforms a string to lowercase

Returns:
The dialect-specific lowercase function.

transformSelectString

public String transformSelectString(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 use Interceptor.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?

Returns:
The maximum length.

toBooleanValueString

public 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.

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 String quote(String column)
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:
column - The value to be quoted.
Returns:
The quoted (or unmodified, if not starting with back-tick) value.
See Also:
openQuote(), closeQuote()

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

supportsUnique

public boolean supportsUnique()
Does this dialect support the UNIQUE column syntax?

Returns:
boolean

supportsUniqueConstraintInCreateAlterTable

public boolean supportsUniqueConstraintInCreateAlterTable()
Does this dialect support adding Unique constraints via create and alter table ?

Returns:
boolean

getAddColumnString

public String getAddColumnString()
The syntax used to add a column to a table (optional).

Returns:
The "add column" fragment.

getDropForeignKeyString

public String getDropForeignKeyString()

getTableTypeString

public String getTableTypeString()

getAddForeignKeyConstraintString

public String getAddForeignKeyConstraintString(String constraintName,
                                               String[] foreignKey,
                                               String referencedTable,
                                               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 FK
referencedTable - The table referenced by the FK
primaryKey - 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

getAddPrimaryKeyConstraintString

public String getAddPrimaryKeyConstraintString(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()

getNullColumnString

public String getNullColumnString()
The keyword used to specify a nullable column.

Returns:
String

supportsCommentOn

public boolean supportsCommentOn()

getTableComment

public String getTableComment(String comment)

getColumnComment

public String getColumnComment(String comment)

supportsIfExistsBeforeTableName

public boolean supportsIfExistsBeforeTableName()

supportsIfExistsAfterTableName

public boolean supportsIfExistsAfterTableName()

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()

supportsNotNullUnique

public boolean supportsNotNullUnique()

getCascadeConstraintsString

public String getCascadeConstraintsString()
Completely optional cascading drop clause

Returns:
String

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

supportsRowValueConstructorSyntaxInInList

public boolean supportsRowValueConstructorSyntaxInInList()
If the dialect supports row 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

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 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:
True if methods like ResultSet.isAfterLast() and ResultSet.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 "... 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 propogating 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), 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:
True if the changes are propogated 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 which supportsExpectedLobUsagePattern() 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.
Since:
3.2

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:
True if the database supports accepting bind params as args; false otherwise.