FileDocCategorySizeDatePackage
Dialect.javaAPI DocHibernate 3.2.557862Thu Jun 07 20:48:54 BST 2007org.hibernate.dialect

Dialect

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

Fields Summary
private static final Log
log
public static final String
DEFAULT_BATCH_SIZE
public static final String
NO_BATCH
public static final String
QUOTE
Characters used for quoting SQL identifiers
public static final String
CLOSED_QUOTE
private static final Map
STANDARD_AGGREGATE_FUNCTIONS
private final TypeNames
typeNames
private final TypeNames
hibernateTypeNames
private final Properties
properties
private final Map
sqlFunctions
private final Set
sqlKeywords
private static final org.hibernate.exception.ViolatedConstraintNameExtracter
EXTRACTER
Constructors Summary
protected Dialect()



	// constructors and factory methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	  
		log.info( "Using dialect: " + this );
		sqlFunctions.putAll( STANDARD_AGGREGATE_FUNCTIONS );

		// standard sql92 functions (can be overridden by subclasses)
		registerFunction( "substring", new SQLFunctionTemplate( Hibernate.STRING, "substring(?1, ?2, ?3)" ) );
		registerFunction( "locate", new SQLFunctionTemplate( Hibernate.INTEGER, "locate(?1, ?2, ?3)" ) );
		registerFunction( "trim", new SQLFunctionTemplate( Hibernate.STRING, "trim(?1 ?2 ?3 ?4)" ) );
		registerFunction( "length", new StandardSQLFunction( "length", Hibernate.INTEGER ) );
		registerFunction( "bit_length", new StandardSQLFunction( "bit_length", Hibernate.INTEGER ) );
		registerFunction( "coalesce", new StandardSQLFunction( "coalesce" ) );
		registerFunction( "nullif", new StandardSQLFunction( "nullif" ) );
		registerFunction( "abs", new StandardSQLFunction( "abs" ) );
		registerFunction( "mod", new StandardSQLFunction( "mod", Hibernate.INTEGER) );
		registerFunction( "sqrt", new StandardSQLFunction( "sqrt", Hibernate.DOUBLE) );
		registerFunction( "upper", new StandardSQLFunction("upper") );
		registerFunction( "lower", new StandardSQLFunction("lower") );
		registerFunction( "cast", new CastFunction() );
		registerFunction( "extract", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(?1 ?2 ?3)") );

		//map second/minute/hour/day/month/year to ANSI extract(), override on subclasses
		registerFunction( "second", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(second from ?1)") );
		registerFunction( "minute", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(minute from ?1)") );
		registerFunction( "hour", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(hour from ?1)") );
		registerFunction( "day", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(day from ?1)") );
		registerFunction( "month", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(month from ?1)") );
		registerFunction( "year", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(year from ?1)") );

		registerFunction( "str", new SQLFunctionTemplate(Hibernate.STRING, "cast(?1 as char)") );

        // register hibernate types for default use in scalar sqlquery type auto detection
		registerHibernateType( Types.BIGINT, Hibernate.BIG_INTEGER.getName() );
		registerHibernateType( Types.BINARY, Hibernate.BINARY.getName() );
		registerHibernateType( Types.BIT, Hibernate.BOOLEAN.getName() );
		registerHibernateType( Types.CHAR, Hibernate.CHARACTER.getName() );
		registerHibernateType( Types.DATE, Hibernate.DATE.getName() );
		registerHibernateType( Types.DOUBLE, Hibernate.DOUBLE.getName() );
		registerHibernateType( Types.FLOAT, Hibernate.FLOAT.getName() );
		registerHibernateType( Types.INTEGER, Hibernate.INTEGER.getName() );
		registerHibernateType( Types.SMALLINT, Hibernate.SHORT.getName() );
		registerHibernateType( Types.TINYINT, Hibernate.BYTE.getName() );
		registerHibernateType( Types.TIME, Hibernate.TIME.getName() );
		registerHibernateType( Types.TIMESTAMP, Hibernate.TIMESTAMP.getName() );
		registerHibernateType( Types.VARCHAR, Hibernate.STRING.getName() );
		registerHibernateType( Types.VARBINARY, Hibernate.BINARY.getName() );
		registerHibernateType( Types.NUMERIC, Hibernate.BIG_DECIMAL.getName() );
		registerHibernateType( Types.DECIMAL, Hibernate.BIG_DECIMAL.getName() );
		registerHibernateType( Types.BLOB, Hibernate.BLOB.getName() );
		registerHibernateType( Types.CLOB, Hibernate.CLOB.getName() );
		registerHibernateType( Types.REAL, Hibernate.FLOAT.getName() );
	
Methods Summary
public java.lang.StringappendIdentitySelectToInsert(java.lang.String insertString)
Provided we {@link #supportsInsertSelectIdentity}, then attch the "select identity" clause to the insert statement.

Note, if {@link #supportsInsertSelectIdentity} == false then the insert-string should be returned without modification.

param
insertString The insert command
return
The insert command with any necessary identity select clause attached.

		return insertString;
	
public java.lang.StringappendLockHint(org.hibernate.LockMode mode, java.lang.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

param
mode The lock mode to apply
param
tableName The name of the table to which to apply the lock hint.
return
The table with any required lock hints.

		return tableName;
	
public java.lang.StringapplyLocksToSql(java.lang.String sql, java.util.Map aliasedLockModes, java.util.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.

param
sql the SQL string to modify
param
aliasedLockModes a map of lock modes indexed by aliased table names.
param
keyColumnNames a map of key columns indexed by aliased table names.
return
the modified SQL string.

		return sql + new ForUpdateFragment( this, aliasedLockModes, keyColumnNames ).toFragmentString();
	
public booleanareStringComparisonsCaseInsensitive()
Are string comparisons implicitly case insensitive.

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

return
True if comparisons are case insensitive.
since
3.2

		return false;
	
public booleanbindLimitParametersFirst()
Does the LIMIT clause come at the start of the SELECT statement, rather than at the end?

return
true if limit parameters should come before other parameters

		return false;
	
public booleanbindLimitParametersInReverseOrder()
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?

return
true if the correct order is limit, offset

		return false;
	
public org.hibernate.exception.SQLExceptionConverterbuildSQLExceptionConverter()
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.

return
The Dialect's preferred SQLExceptionConverter.

		// The default SQLExceptionConverter for all dialects is based on SQLState
		// since SQLErrorCode is extremely vendor-specific.  Specific Dialects
		// may override to return whatever is most appropriate for that vendor.
		return new SQLStateConverter( getViolatedConstraintNameExtracter() );
	
public charcloseQuote()
The character specific to this dialect used to close a quoted identifier.

return
The dialect's specific close quote character.

		return '"";
	
public org.hibernate.sql.CaseFragmentcreateCaseFragment()
Create a {@link org.hibernate.sql.CaseFragment} strategy responsible for handling this dialect's variations in how CASE statements are handled.

return
This dialect's {@link org.hibernate.sql.CaseFragment} strategy.

		return new ANSICaseFragment();
	
public org.hibernate.sql.JoinFragmentcreateOuterJoinFragment()
Create a {@link org.hibernate.sql.JoinFragment} strategy responsible for handling this dialect's variations in how joins are handled.

return
This dialect's {@link org.hibernate.sql.JoinFragment} strategy.

		return new ANSIJoinFragment();
	
public booleandoesReadCommittedCauseWritersToBlockReaders()
For the underlying database, is READ_COMMITTED isolation implemented by forcing readers to wait for write locks to be released?

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

		return false;
	
public booleandoesRepeatableReadCauseReadersToBlockWriters()
For the underlying database, is REPEATABLE_READ isolation implemented by forcing writers to wait for read locks to be released?

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

		return false;
	
public booleandropConstraints()
Do we need to drop constraints before dropping tables in this dialect?

return
True if constraints must be dropped prior to dropping the table; false otherwise.

		return true;
	
public booleandropTemporaryTableAfterUse()
Do we need to drop the temporary table after use?

return
True if the table should be dropped.

		return true;
	
public booleanforUpdateOfColumns()
Is FOR UPDATE OF syntax supported?

return
True if the database supports FOR UPDATE OF syntax; false otherwise.

		// by default we report no support
		return false;
	
public java.lang.StringgenerateTemporaryTableName(java.lang.String baseTableName)
Generate a temporary table name given the bas table.

param
baseTableName The table name from which to base the temp table name.
return
The generated temp table name.

		return "HT_" + baseTableName;
	
public java.lang.StringgetAddColumnString()
The syntax used to add a column to a table (optional).

return
The "add column" fragment.

		throw new UnsupportedOperationException( "No add column syntax supported by Dialect" );
	
public java.lang.StringgetAddForeignKeyConstraintString(java.lang.String constraintName, java.lang.String[] foreignKey, java.lang.String referencedTable, java.lang.String[] primaryKey, boolean referencesPrimaryKey)
The syntax used to add a foreign key constraint to a table.

param
constraintName The FK constraint name.
param
foreignKey The names of the columns comprising the FK
param
referencedTable The table referenced by the FK
param
primaryKey The explicit columns in the referencedTable referenced by this FK.
param
referencesPrimaryKey if false, constraint should be explicit about which column names the constraint refers to
return
the "add FK" fragment

		StringBuffer res = new StringBuffer( 30 );

		res.append( " add constraint " )
				.append( constraintName )
				.append( " foreign key (" )
				.append( StringHelper.join( ", ", foreignKey ) )
				.append( ") references " )
				.append( referencedTable );

		if ( !referencesPrimaryKey ) {
			res.append( " (" )
					.append( StringHelper.join( ", ", primaryKey ) )
					.append( ')" );
		}

		return res.toString();
	
public java.lang.StringgetAddPrimaryKeyConstraintString(java.lang.String constraintName)
The syntax used to add a primary key constraint to a table.

param
constraintName The name of the PK constraint.
return
The "add PK" fragment

		return " add constraint " + constraintName + " primary key ";
	
public java.lang.StringgetCascadeConstraintsString()
Completely optional cascading drop clause

return
String

		return "";
	
public java.lang.StringgetCastTypeName(int code)
Get the name of the database type appropriate for casting operations (via the CAST() SQL function) for the given {@link java.sql.Types} typecode.

param
code The {@link java.sql.Types} typecode
return
The database type name

		return getTypeName( code, Column.DEFAULT_LENGTH, Column.DEFAULT_PRECISION, Column.DEFAULT_SCALE );
	
public java.lang.StringgetColumnComment(java.lang.String comment)

		return "";
	
public java.lang.StringgetCreateMultisetTableString()
Slight variation on {@link #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.

return
The command used to create a multiset table.

		return getCreateTableString();
	
protected java.lang.StringgetCreateSequenceString(java.lang.String sequenceName)
Typically dialects which support sequences can create a sequence with a single command. This is convenience form of {@link #getCreateSequenceStrings} 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 {@link #getCreateSequenceStrings}.

param
sequenceName The name of the sequence
return
The sequence creation command
throws
MappingException If sequences are not supported.

		throw new MappingException( "Dialect does not support sequences" );
	
protected java.lang.StringgetCreateSequenceString(java.lang.String sequenceName, int initialValue, int incrementSize)
Overloaded form of {@link #getCreateSequenceString(String)}, additionally taking the initial value and increment size to be applied to the sequence definition.

The default definition is to suffix {@link #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.

param
sequenceName The name of the sequence
param
initialValue The initial value to apply to 'create sequence' statement
param
incrementSize The increment value to apply to 'create sequence' statement
return
The sequence creation command
throws
MappingException If sequences are not supported.

		if ( supportsPooledSequences() ) {
			return getCreateSequenceString( sequenceName ) + " start with " + initialValue + " increment by " + incrementSize;
		}
		throw new MappingException( "Dialect does not support pooled sequences" );
	
public java.lang.String[]getCreateSequenceStrings(java.lang.String sequenceName)
The multiline script used to create a sequence.

param
sequenceName The name of the sequence
return
The sequence creation commands
throws
MappingException If sequences are not supported.
deprecated
Use {@link #getCreateSequenceString(String, int, int)} instead

		return new String[] { getCreateSequenceString( sequenceName ) };
	
public java.lang.String[]getCreateSequenceStrings(java.lang.String sequenceName, int initialValue, int incrementSize)
An optional multi-line form for databases which {@link #supportsPooledSequences()}.

param
sequenceName The name of the sequence
param
initialValue The initial value to apply to 'create sequence' statement
param
incrementSize The increment value to apply to 'create sequence' statement
return
The sequence creation commands
throws
MappingException If sequences are not supported.

		return new String[] { getCreateSequenceString( sequenceName, initialValue, incrementSize ) };
	
public java.lang.StringgetCreateTableString()
Command used to create a table.

return
The command used to create a table.

		return "create table";
	
public java.lang.StringgetCreateTemporaryTablePostfix()
Get any fragments needing to be postfixed to the command for temporary table creation.

return
Any required postfix.

		return "";
	
public java.lang.StringgetCreateTemporaryTableString()
Command used to create a temporary table.

return
The command used to create a temporary table.

		return "create table";
	
public java.lang.StringgetCurrentTimestampSQLFunctionName()
The name of the database-specific SQL function for retrieving the current timestamp.

return
The function name.

		// the standard SQL function name is current_timestamp...
		return "current_timestamp";
	
public java.lang.StringgetCurrentTimestampSelectString()
Retrieve the command used to retrieve the current timestammp from the database.

return
The command.

		throw new UnsupportedOperationException( "Database not known to define a current timestamp function" );
	
public final java.util.PropertiesgetDefaultProperties()
Retrieve a set of default Hibernate properties for this database.

return
a set of Hibernate properties

		return properties;
	
public static org.hibernate.dialect.DialectgetDialect()
Get an instance of the dialect specified by the current System properties.

return
The specified Dialect
throws
HibernateException If no dialect was specified, or if it could not be instantiated.

		String dialectName = Environment.getProperties().getProperty( Environment.DIALECT );
		return instantiateDialect( dialectName );
	
public static org.hibernate.dialect.DialectgetDialect(java.util.Properties props)
Get an instance of the dialect specified by the given properties or by the current System properties.

param
props The properties to use for finding the dialect class to use.
return
The specified Dialect
throws
HibernateException If no dialect was specified, or if it could not be instantiated.

		String dialectName = props.getProperty( Environment.DIALECT );
		if ( dialectName == null ) {
			return getDialect();
		}
		return instantiateDialect( dialectName );
	
public java.lang.StringgetDropForeignKeyString()

		return " drop constraint ";
	
protected java.lang.StringgetDropSequenceString(java.lang.String sequenceName)
Typically dialects which support sequences can drop a sequence with a single command. This is convenience form of {@link #getDropSequenceStrings} 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 {@link #getDropSequenceStrings}.

param
sequenceName The name of the sequence
return
The sequence drop commands
throws
MappingException If sequences are not supported.

		throw new MappingException( "Dialect does not support sequences" );
	
public java.lang.String[]getDropSequenceStrings(java.lang.String sequenceName)
The multiline script used to drop a sequence.

param
sequenceName The name of the sequence
return
The sequence drop commands
throws
MappingException If sequences are not supported.

		return new String[]{getDropSequenceString( sequenceName )};
	
public java.lang.StringgetForUpdateNowaitString()
Retrieves the FOR UPDATE NOWAIT syntax specific to this dialect.

return
The appropriate FOR UPDATE NOWAIT clause string.

		// by default we report no support for NOWAIT lock semantics
		return getForUpdateString();
	
public java.lang.StringgetForUpdateNowaitString(java.lang.String aliases)
Get the FOR UPDATE OF column_list NOWAIT fragment appropriate for this dialect given the aliases of the columns to be write locked.

param
aliases The columns to be write locked.
return
The appropriate FOR UPDATE colunm_list NOWAIT clause string.

		return getForUpdateString( aliases );
	
public java.lang.StringgetForUpdateString(org.hibernate.LockMode lockMode)
Given a lock mode, determine the appropriate for update fragment to use.

param
lockMode The lock mode to apply.
return
The appropriate for update fragment.

		if ( lockMode==LockMode.UPGRADE ) {
			return getForUpdateString();
		}
		else if ( lockMode==LockMode.UPGRADE_NOWAIT ) {
			return getForUpdateNowaitString();
		}
		else if ( lockMode==LockMode.FORCE ) {
			return getForUpdateNowaitString();
		}
		else {
			return "";
		}
	
public java.lang.StringgetForUpdateString()
Get the string to append to SELECT statements to acquire locks for this dialect.

return
The appropriate FOR UPDATE clause string.

		return " for update";
	
public java.lang.StringgetForUpdateString(java.lang.String aliases)
Get the FOR UPDATE OF column_list fragment appropriate for this dialect given the aliases of the columns to be write locked.

param
aliases The columns to be write locked.
return
The appropriate FOR UPDATE OF column_list clause string.

		// by default we simply return the getForUpdateString() result since
		// the default is to say no support for "FOR UPDATE OF ..."
		return getForUpdateString();
	
public final java.util.MapgetFunctions()
Retrieves a map of the dialect's registered fucntions (functionName => {@link org.hibernate.dialect.function.SQLFunction}).

return
The map of registered functions.

		return sqlFunctions;
	
public java.lang.StringgetHibernateTypeName(int code)
Get the name of the Hibernate {@link org.hibernate.type.Type} associated with th given {@link java.sql.Types} typecode.

param
code The {@link java.sql.Types} typecode
return
The Hibernate {@link org.hibernate.type.Type} name.
throws
HibernateException If no mapping was specified for that type.

		String result = hibernateTypeNames.get( code );
		if ( result == null ) {
			throw new HibernateException( "No Hibernate type mapping for java.sql.Types code: " + code );
		}
		return result;
	
public java.lang.StringgetHibernateTypeName(int code, int length, int precision, int scale)
Get the name of the Hibernate {@link org.hibernate.type.Type} associated with the given {@link java.sql.Types} typecode with the given storage specification parameters.

param
code The {@link java.sql.Types} typecode
param
length The datatype length
param
precision The datatype precision
param
scale The datatype scale
return
The Hibernate {@link org.hibernate.type.Type} name.
throws
HibernateException If no mapping was specified for that type.

		String result = hibernateTypeNames.get( code, length, precision, scale );
		if ( result == null ) {
			throw new HibernateException(
					"No Hibernate type mapping for java.sql.Types code: " +
					code +
					", length: " +
					length
			);
		}
		return result;
	
public java.lang.StringgetIdentityColumnString(int type)
The syntax used during DDL to define a column as being an IDENTITY of a particular type.

param
type The {@link java.sql.Types} type code.
return
The appropriate DDL fragment.
throws
MappingException If IDENTITY generation is not supported.

		return getIdentityColumnString();
	
protected java.lang.StringgetIdentityColumnString()
The syntax used during DDL to define a column as being an IDENTITY.

return
The appropriate DDL fragment.
throws
MappingException If IDENTITY generation is not supported.

		throw new MappingException( "Dialect does not support identity key generation" );
	
public java.lang.StringgetIdentityInsertString()
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.

return
The appropriate keyword.

		return null;
	
public java.lang.StringgetIdentitySelectString(java.lang.String table, java.lang.String column, int type)
Get the select command to use to retrieve the last generated IDENTITY value for a particuar table

param
table The table into which the insert was done
param
column The PK column.
param
type The {@link java.sql.Types} type code.
return
The appropriate select command
throws
MappingException If IDENTITY generation is not supported.

		return getIdentitySelectString();
	
protected java.lang.StringgetIdentitySelectString()
Get the select command to use to retrieve the last generated IDENTITY value.

return
The appropriate select command
throws
MappingException If IDENTITY generation is not supported.

		throw new MappingException( "Dialect does not support identity key generation" );
	
public java.util.SetgetKeywords()

		return sqlKeywords;
	
public java.lang.StringgetLimitString(java.lang.String query, int offset, int limit)
Given a limit and an offset, apply the limit clause to the query.

param
query The query to which to apply the limit.
param
offset The offset of the limit
param
limit The limit of the limit ;)
return
The modified query statement with the limit applied.

		return getLimitString( query, offset > 0 );
	
protected java.lang.StringgetLimitString(java.lang.String query, boolean hasOffset)
Apply s limit clause to the query.

Typically dialects utilize {@link #supportsVariableLimit() 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 {@link #getLimitString(String, int, int)}.

param
query The query to which to apply the limit.
param
hasOffset Is the query requesting an offset?
return
the modified SQL

		throw new UnsupportedOperationException( "paged queries not supported" );
	
public org.hibernate.dialect.lock.LockingStrategygetLockingStrategy(org.hibernate.persister.entity.Lockable lockable, org.hibernate.LockMode lockMode)
Get a strategy instance which knows how to acquire a database-level lock of the specified mode for this dialect.

param
lockable The persister for the entity to be locked.
param
lockMode The type of lock to be acquired.
return
The appropriate locking strategy.
since
3.2

		return new SelectLockingStrategy( lockable, lockMode );
	
public java.lang.StringgetLowercaseFunction()
The name of the SQL function that transforms a string to lowercase

return
The dialect-specific lowercase function.

		return "lower";
	
public intgetMaxAliasLength()
What is the maximum length Hibernate can use for generated aliases?

return
The maximum length.

		return 10;
	
public java.lang.ClassgetNativeIdentifierGeneratorClass()
The class (which implements {@link org.hibernate.id.IdentifierGenerator}) which acts as this dialects native generation strategy.

Comes into play whenever the user specifies the native generator.

return
The native generator class.

		if ( supportsIdentityColumns() ) {
			return IdentityGenerator.class;
		}
		else if ( supportsSequences() ) {
			return SequenceGenerator.class;
		}
		else {
			return TableHiLoGenerator.class;
		}
	
public java.lang.StringgetNoColumnsInsertString()
The fragment used to insert a row without specifying any column values. This is not possible on some databases.

return
The appropriate empty values clause.

		return "values ( )";
	
public java.lang.StringgetNullColumnString()
The keyword used to specify a nullable column.

return
String

		return "";
	
public java.lang.StringgetQuerySequencesString()
Get the select command used retrieve the names of all sequences.

return
The select command; or null if sequences are not supported.
see
org.hibernate.tool.hbm2ddl.SchemaUpdate

		return null;
	
public java.sql.ResultSetgetResultSet(java.sql.CallableStatement statement)
Given a callable statement previously processed by {@link #registerResultSetOutParameter}, extract the {@link java.sql.ResultSet} from the OUT parameter.

param
statement The callable statement.
return
The extracted result set.
throws
SQLException Indicates problems extracting the result set.

		throw new UnsupportedOperationException(
				getClass().getName() +
				" does not support resultsets via stored procedures"
			);
	
public java.lang.StringgetSelectClauseNullString(int sqlType)
Given a {@link java.sql.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.

param
sqlType The {@link java.sql.Types} type code.
return
The appropriate select clause value fragment.

		return "null";
	
public java.lang.StringgetSelectGUIDString()
Get the command used to select a GUID from the underlying database.

Optional operation.

return
The appropriate command.

		throw new UnsupportedOperationException( "dialect does not support GUIDs" );
	
public java.lang.StringgetSelectSequenceNextValString(java.lang.String sequenceName)
Generate the select expression fragment that will retreive the next value of a sequence as part of another (typically DML) statement.

This differs from {@link #getSequenceNextValString(String)} in that this should return an expression usable within another statement.

param
sequenceName the name of the sequence
return
The "nextval" fragment.
throws
MappingException If sequences are not supported.

		throw new MappingException( "Dialect does not support sequences" );
	
public java.lang.StringgetSequenceNextValString(java.lang.String sequenceName)
Generate the appropriate select statement to to retreive the next value of a sequence.

This should be a "stand alone" select statement.

param
sequenceName the name of the sequence
return
String The "nextval" select string.
throws
MappingException If sequences are not supported.

		throw new MappingException( "Dialect does not support sequences" );
	
public java.lang.StringgetTableComment(java.lang.String comment)

		return "";
	
public java.lang.StringgetTableTypeString()

		// grrr... for differentiation of mysql storage engines
		return "";
	
public java.lang.StringgetTypeName(int code)
Get the name of the database type associated with the given {@link java.sql.Types} typecode.

param
code The {@link java.sql.Types} typecode
return
the database type name
throws
HibernateException If no mapping was specified for that type.

		String result = typeNames.get( code );
		if ( result == null ) {
			throw new HibernateException( "No default type mapping for (java.sql.Types) " + code );
		}
		return result;
	
public java.lang.StringgetTypeName(int code, int length, int precision, int scale)
Get the name of the database type associated with the given {@link java.sql.Types} typecode with the given storage specification parameters.

param
code The {@link java.sql.Types} typecode
param
length The datatype length
param
precision The datatype precision
param
scale The datatype scale
return
the database type name
throws
HibernateException If no mapping was specified for that type.

		String result = typeNames.get( code, length, precision, scale );
		if ( result == null ) {
			throw new HibernateException(
					"No type mapping for java.sql.Types code: " +
					code +
					", length: " +
					length
			);
		}
		return result;
	
public org.hibernate.exception.ViolatedConstraintNameExtractergetViolatedConstraintNameExtracter()


	   
		return EXTRACTER;
	
public booleanhasAlterTable()
Does this dialect support the ALTER TABLE syntax?

return
True if we support altering of tables; false otherwise.

		return true;
	
public booleanhasDataTypeInIdentityColumn()
Whether this dialect have an Identity clause added to the data type or a completely seperate identity data type

return
boolean

		return true;
	
public booleanhasSelfReferentialForeignKeyBug()

		return false;
	
private static org.hibernate.dialect.DialectinstantiateDialect(java.lang.String dialectName)

		if ( dialectName == null ) {
			throw new HibernateException( "The dialect was not set. Set the property hibernate.dialect." );
		}
		try {
			return ( Dialect ) ReflectHelper.classForName( dialectName ).newInstance();
		}
		catch ( ClassNotFoundException cnfe ) {
			throw new HibernateException( "Dialect class not found: " + dialectName );
		}
		catch ( Exception e ) {
			throw new HibernateException( "Could not instantiate dialect class", e );
		}
	
public booleanisCurrentTimestampSelectStringCallable()
Should the value returned by {@link #getCurrentTimestampSelectString} be treated as callable. Typically this indicates that JDBC escape sytnax is being used...

return
True if the {@link #getCurrentTimestampSelectString} return is callable; false otherwise.

		throw new UnsupportedOperationException( "Database not known to define a current timestamp function" );
	
public charopenQuote()
The character specific to this dialect used to begin a quoted identifier.

return
The dialect's specific open quote character.

		return '"";
	
public java.lang.BooleanperformTemporaryTableDDLInIsolation()
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 {@link java.sql.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:

  • {@link Boolean#TRUE} - Unequivocally, perform the temporary table DDL in isolation.
  • {@link Boolean#FALSE} - Unequivocally, do not perform the temporary table DDL in isolation.
  • null - defer to the JDBC driver response in regards to {@link java.sql.DatabaseMetaData#dataDefinitionCausesTransactionCommit()}

return
see the result matrix above.

		return null;
	
public booleanqualifyIndexName()
Do we need to qualify index names with the schema name?

return
boolean

		return true;
	
public final java.lang.Stringquote(java.lang.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.

param
column The value to be quoted.
return
The quoted (or unmodified, if not starting with back-tick) value.
see
#openQuote()
see
#closeQuote()

		if ( column.charAt( 0 ) == '`" ) {
			return openQuote() + column.substring( 1, column.length() - 1 ) + closeQuote();
		}
		else {
			return column;
		}
	
protected voidregisterColumnType(int code, int capacity, java.lang.String name)
Subclasses register a type name for the given type code and maximum column length. $l in the type name with be replaced by the column length (if appropriate).

param
code The {@link java.sql.Types} typecode
param
capacity The maximum length of database type
param
name The database type name

		typeNames.put( code, capacity, name );
	
protected voidregisterColumnType(int code, java.lang.String name)
Subclasses register a type name for the given type code. $l in the type name with be replaced by the column length (if appropriate).

param
code The {@link java.sql.Types} typecode
param
name The database type name

		typeNames.put( code, name );
	
protected voidregisterFunction(java.lang.String name, org.hibernate.dialect.function.SQLFunction function)

		sqlFunctions.put( name, function );
	
protected voidregisterHibernateType(int code, int capacity, java.lang.String name)
Registers a Hibernate {@link org.hibernate.type.Type} name for the given {@link java.sql.Types} type code and maximum column length.

param
code The {@link java.sql.Types} typecode
param
capacity The maximum length of database type
param
name The Hibernate {@link org.hibernate.type.Type} name

		hibernateTypeNames.put( code, capacity, name);
	
protected voidregisterHibernateType(int code, java.lang.String name)
Registers a Hibernate {@link org.hibernate.type.Type} name for the given {@link java.sql.Types} type code.

param
code The {@link java.sql.Types} typecode
param
name The Hibernate {@link org.hibernate.type.Type} name

		hibernateTypeNames.put( code, name);
	
protected voidregisterKeyword(java.lang.String word)

		sqlKeywords.add(word);
	
public intregisterResultSetOutParameter(java.sql.CallableStatement statement, int position)
Registers an OUT parameter which will be returing a {@link java.sql.ResultSet}. How this is accomplished varies greatly from DB to DB, hence its inclusion (along with {@link #getResultSet}) here.

param
statement The callable statement.
param
position The bind position at which to register the OUT param.
return
The number of (contiguous) bind positions used.
throws
SQLException Indicates problems registering the OUT param.

		throw new UnsupportedOperationException(
				getClass().getName() +
				" does not support resultsets via stored procedures"
			);
	
public booleansupportsBindAsCallableArgument()
Does this dialect support using a JDBC bind parameter as an argument to a function or procedure call?

return
True if the database supports accepting bind params as args; false otherwise.

		return true;
	
public booleansupportsCascadeDelete()

		return true;
	
public booleansupportsCircularCascadeDeleteConstraints()
Does this dialect support definition of cascade delete constraints which can cause circular chains?

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

		return true;
	
public booleansupportsColumnCheck()
Does this dialect support column-level check constraints?

return
True if column-level CHECK constraints are supported; false otherwise.

		return true;
	
public booleansupportsCommentOn()

		return false;
	
public booleansupportsCurrentTimestampSelection()
Does this dialect support a way to retrieve the database's current timestamp value?

return
True if the current timestamp can be retrieved; false otherwise.

		return false;
	
public booleansupportsEmptyInList()
Does this dialect support empty IN lists?

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

return
True if empty in lists are supported; false otherwise.
since
3.2

		return true;
	
public booleansupportsExistsInSelect()
Does the dialect support an exists statement in the select clause?

return
True if exists checks are allowed in the select clause; false otherwise.

		return true;
	
public booleansupportsExpectedLobUsagePattern()
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...

return
True if normal LOB usage patterns can be used with this driver; false if driver-specific hookiness needs to be applied.
since
3.2

		return true;
	
public booleansupportsIdentityColumns()
Does this dialect support identity column key generation?

return
True if IDENTITY columns are supported; false otherwise.

		return false;
	
public booleansupportsIfExistsAfterTableName()

		return false;
	
public booleansupportsIfExistsBeforeTableName()

		return false;
	
public booleansupportsInsertSelectIdentity()
Does the dialect support some form of inserting and selecting the generated IDENTITY value all in the same statement.

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

		return false;
	
public booleansupportsLimit()
Does this dialect support some form of limiting query results via a SQL clause?

return
True if this dialect supports some form of LIMIT.

		return false;
	
public booleansupportsLimitOffset()
Does this dialect's LIMIT support (if any) additionally support specifying an offset?

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

		return supportsLimit();
	
public booleansupportsLobValueChangePropogation()
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: {@link java.sql.Blob#setBinaryStream}, {@link java.sql.Blob#setBytes(long, byte[])}, {@link java.sql.Blob#setBytes(long, byte[], int, int)}, or {@link java.sql.Blob#truncate(long)}.

For CLOBs, the internal value might be changed by: {@link java.sql.Clob#setAsciiStream(long)}, {@link java.sql.Clob#setCharacterStream(long)}, {@link java.sql.Clob#setString(long, String)}, {@link java.sql.Clob#setString(long, String, int, int)}, or {@link java.sql.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 {@link #supportsExpectedLobUsagePattern}.

return
True if the changes are propogated back to the database; false otherwise.
since
3.2

		return true;
	
public booleansupportsNotNullUnique()

		return true;
	
public booleansupportsOuterJoinForUpdate()
Does this dialect support FOR UPDATE in conjunction with outer joined rows?

return
True if outer joined rows can be locked via FOR UPDATE.

		return true;
	
public booleansupportsParametersInInsertSelect()
Does this dialect support parameters within the select clause of INSERT ... SELECT ... statements?

return
True if this is supported; false otherwise.
since
3.2

		return true;
	
public booleansupportsPooledSequences()
Does this dialect support "pooled" sequences. Not aware of a better name for this. Essentially can we specify the initial and increment values?

return
True if such "pooled" sequences are supported; false otherwise.
see
#getCreateSequenceStrings(String, int, int)
see
#getCreateSequenceString(String, int, int)

		return false;
	
public booleansupportsResultSetPositionQueryMethodsOnForwardOnlyCursor()
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 {@link java.sql.ResultSet#isAfterLast} and {@link java.sql.ResultSet#isBeforeFirst}. Certain drivers do not allow access to these methods for forward only cursors.

NOTE : this is highly driver dependent!

return
True if methods like {@link java.sql.ResultSet#isAfterLast} and {@link java.sql.ResultSet#isBeforeFirst} are supported for forward only cursors; false otherwise.
since
3.2

		return true;
	
public booleansupportsRowValueConstructorSyntax()
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') ...".

return
True if this SQL dialect is known to support "row value constructor" syntax; false otherwise.
since
3.2

		// return false here, as most databases do not properly support this construct...
		return false;
	
public booleansupportsRowValueConstructorSyntaxInInList()
If the dialect supports {@link #supportsRowValueConstructorSyntax() row values}, does it offer such support in IN lists as well?

For example, "... where (FIRST_NAME, LAST_NAME) IN ( (?, ?), (?, ?) ) ..."

return
True if this SQL dialect is known to support "row value constructor" syntax in the IN list; false otherwise.
since
3.2

		return false;
	
public booleansupportsSequences()
Does this dialect support sequences?

return
True if sequences supported; false otherwise.

		return false;
	
public booleansupportsSubqueryOnMutatingTable()
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)

return
True if this dialect allows references the mutating table from a subquery.
since
3.2

		return true;
	
public booleansupportsSubselectAsInPredicateLHS()
Are subselects supported as the left-hand-side (LHS) of IN-predicates.

In other words, is syntax like "... IN (1, 2, 3) ..." supported?

return
True if subselects can appear as the LHS of an in-predicate; false otherwise.
since
3.2

		return true;
	
public booleansupportsTableCheck()
Does this dialect support table-level check constraints?

return
True if table-level CHECK constraints are supported; false otherwise.

		return true;
	
public booleansupportsTemporaryTables()
Does this dialect support temporary tables?

return
True if temp tables are supported; false otherwise.

		return false;
	
public booleansupportsUnboundedLobLocatorMaterialization()
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 {@link #supportsExpectedLobUsagePattern()} also support the ability to materialize a LOB outside the owning transaction...

return
True if unbounded materialization is supported; false otherwise.
since
3.2

		return true;
	
public booleansupportsUnionAll()
Does this dialect support UNION ALL, which is generally a faster variant of UNION?

return
True if UNION ALL is supported; false otherwise.

		return false;
	
public booleansupportsUnique()
Does this dialect support the UNIQUE column syntax?

return
boolean

		return true;
	
public booleansupportsUniqueConstraintInCreateAlterTable()
Does this dialect support adding Unique constraints via create and alter table ?

return
boolean

	    return true;
	
public booleansupportsVariableLimit()
Does this dialect support bind variables (i.e., prepared statememnt parameters) for its limit/offset?

return
True if bind variables can be used; false otherwise.

		return supportsLimit();
	
public java.lang.StringtoBooleanValueString(boolean bool)
The SQL literal value to which this database maps boolean values.

param
bool The boolean value
return
The appropriate SQL literal.

		return bool ? "1" : "0";
	
public java.lang.StringtoString()

		return getClass().getName();
	
public java.lang.StringtransformSelectString(java.lang.String select)
Meant as a means for end users to affect the select strings being sent to the database and perhaps manipulate them in some fashion.

The recommend approach is to instead use {@link org.hibernate.Interceptor#onPrepareStatement(String)}.

param
select The select command
return
The mutated select command, or the same as was passed in.

		return select;
	
public booleanuseInputStreamToInsertBlob()
Should LOBs (both BLOB and CLOB) be bound using stream operations (i.e. {@link java.sql.PreparedStatement#setBinaryStream}).

return
True if BLOBs and CLOBs should be bound using stream operations.
since
3.2

		return true;
	
public booleanuseMaxForLimit()
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?

return
True if limit is relative from offset; false otherwise.

		return false;