public class

H2Dialect

extends Dialect
java.lang.Object
   ↳ org.hibernate.dialect.Dialect
     ↳ org.hibernate.dialect.H2Dialect

Class Overview

A dialect compatible with the H2 database.

Summary

[Expand]
Inherited Constants
From class org.hibernate.dialect.Dialect
Public Constructors
H2Dialect()
Public Methods
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.
boolean doesReadCommittedCauseWritersToBlockReaders()
For the underlying database, is READ_COMMITTED isolation implemented by forcing readers to wait for write locks to be released?
boolean dropTemporaryTableAfterUse()
Do we need to drop the temporary table after use?
String getAddColumnString()
The syntax used to add a column to a table (optional).
String getCreateSequenceString(String sequenceName)
Typically dialects which support sequences can create a sequence with a single command.
String getCreateTemporaryTableString()
Command used to create a temporary table.
String getCurrentTimestampSelectString()
Retrieve the command used to retrieve the current timestamp from the database.
String getDropSequenceString(String sequenceName)
Typically dialects which support sequences can drop a sequence with a single command.
String getForUpdateString()
Get the string to append to SELECT statements to acquire locks for this dialect.
String getIdentityColumnString()
The syntax used during DDL to define a column as being an IDENTITY.
String getIdentityInsertString()
The keyword used to insert a generated value into an identity column (or null).
String getIdentitySelectString()
Get the select command to use to retrieve the last generated IDENTITY value.
String getLimitString(String sql, boolean hasOffset)
Apply s limit clause to the query.
String getQuerySequencesString()
Get the select command used retrieve the names of all sequences.
String getSelectSequenceNextValString(String sequenceName)
Generate the select expression fragment that will retrieve the next value of a sequence as part of another (typically DML) statement.
String getSequenceNextValString(String sequenceName)
Generate the appropriate select statement to to retrieve the next value of a sequence.
ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter()
boolean isCurrentTimestampSelectStringCallable()
Should the value returned by getCurrentTimestampSelectString() be treated as callable.
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 supportsCurrentTimestampSelection()
Does this dialect support a way to retrieve the database's current timestamp value?
boolean supportsIdentityColumns()
Does this dialect support identity column key generation?
boolean supportsIfExistsAfterTableName()
boolean supportsLimit()
Does this dialect support some form of limiting query results via a SQL clause?
boolean supportsLobValueChangePropogation()
Does the dialect support propagating changes to LOB values back to the database? Talking about mutating the internal value of the locator as opposed to supplying a new locator instance...
boolean supportsPooledSequences()
Does this dialect support "pooled" sequences.
boolean supportsSequences()
Does this dialect support sequences?
boolean supportsTemporaryTables()
Does this dialect support temporary tables?
boolean supportsTupleDistinctCounts()
Does this dialect support `count(distinct a,b)`?
boolean supportsUnionAll()
Does this dialect support UNION ALL, which is generally a faster variant of UNION?
boolean supportsUnique()
Does this dialect support the UNIQUE column syntax?
[Expand]
Inherited Methods
From class org.hibernate.dialect.Dialect
From class java.lang.Object

Public Constructors

public H2Dialect ()

Public Methods

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

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

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.

public boolean dropTemporaryTableAfterUse ()

Do we need to drop the temporary table after use?

Returns
  • True if the table should be dropped.

public String getAddColumnString ()

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

Returns
  • The "add column" fragment.

public String getCreateSequenceString (String sequenceName)

Typically dialects which support sequences can create a sequence with a single command. This is convenience form of getCreateSequenceStrings(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(String).

Parameters
sequenceName The name of the sequence
Returns
  • The sequence creation command

public String getCreateTemporaryTableString ()

Command used to create a temporary table.

Returns
  • The command used to create a temporary table.

public String getCurrentTimestampSelectString ()

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

Returns
  • The command.

public String getDropSequenceString (String sequenceName)

Typically dialects which support sequences can drop a sequence with a single command. This is convenience form of getDropSequenceStrings(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(String).

Parameters
sequenceName The name of the sequence
Returns
  • The sequence drop commands

public String getForUpdateString ()

Get the string to append to SELECT statements to acquire locks for this dialect.

Returns
  • The appropriate FOR UPDATE clause string.

public String getIdentityColumnString ()

The syntax used during DDL to define a column as being an IDENTITY.

Returns
  • The appropriate DDL fragment.

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.

public String getIdentitySelectString ()

Get the select command to use to retrieve the last generated IDENTITY value.

Returns
  • The appropriate select command

public String getLimitString (String sql, boolean hasOffset)

Apply s limit clause to the query.

Typically dialects utilize variable limit clauses 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
sql The query to which to apply the limit.
hasOffset Is the query requesting an offset?
Returns
  • the modified SQL

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.

public String getSelectSequenceNextValString (String sequenceName)

Generate the select expression fragment that will retrieve 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.

public String getSequenceNextValString (String sequenceName)

Generate the appropriate select statement to to retrieve 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.

public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter ()

public boolean isCurrentTimestampSelectStringCallable ()

Should the value returned by getCurrentTimestampSelectString() be treated as callable. Typically this indicates that JDBC escape syntax is being used...

Returns

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

  • TRUE - Unequivocally, perform the temporary table DDL in isolation.
  • FALSE - Unequivocally, do not perform the temporary table DDL in isolation.
  • null - defer to the JDBC driver response in regards to dataDefinitionCausesTransactionCommit()

Returns
  • see the result matrix above.

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.

public boolean supportsIdentityColumns ()

Does this dialect support identity column key generation?

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

public boolean supportsIfExistsAfterTableName ()

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.

public boolean supportsLobValueChangePropogation ()

Does the dialect support propagating changes to LOB values back to the database? Talking about mutating the internal value of the locator as opposed to supplying a new locator instance...

For BLOBs, the internal value might be changed by: setBinaryStream(long), setBytes(long, byte[]), setBytes(long, byte[], int, int), or truncate(long).

For CLOBs, the internal value might be changed by: setAsciiStream(long), setCharacterStream(long), setString(long, String), setString(long, String, int, int), or 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 propagated back to the database; false otherwise.

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.

public boolean supportsSequences ()

Does this dialect support sequences?

Returns
  • True if sequences supported; false otherwise.

public boolean supportsTemporaryTables ()

Does this dialect support temporary tables?

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

public boolean supportsTupleDistinctCounts ()

Does this dialect support `count(distinct a,b)`?

Returns
  • True if the database supports counting disintct tuples; false otherwise.

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.

public boolean supportsUnique ()

Does this dialect support the UNIQUE column syntax?

Returns
  • boolean