Top Description Fields Constructors Methods
org.hibernate.dialect

public Class DerbyDialect

extends DB2Dialect
Class Inheritance
Imports
java.lang.reflect.Method, java.sql.Types, org.slf4j.Logger, .LoggerFactory, org.hibernate.MappingException, org.hibernate.dialect.function.AnsiTrimFunction, .DerbyConcatFunction, org.hibernate.sql.CaseFragment, .DerbyCaseFragment, org.hibernate.util.ReflectHelper

Hibernate Dialect for Cloudscape 10 - aka Derby. This implements both an override for the identity column generator as well as for the case statement issue documented at: http://www.jroller.com/comments/kenlars99/Weblog/cloudscape_soon_to_be_derby
Author
Simon Johnston

Field Summary

Modifier and TypeField and Description
private int
private int
private static final Logger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public CaseFragment
createCaseFragment()

Overrides org.hibernate.dialect.Dialect.createCaseFragment.

Return the case statement modified for Cloudscape.
private void
public boolean
dropConstraints()

Overrides org.hibernate.dialect.DB2Dialect.dropConstraints.

Do we need to drop constraints before dropping tables in this dialect?
public String
getCrossJoinSeparator()

Overrides org.hibernate.dialect.DB2Dialect.getCrossJoinSeparator.

Get the separator to use for defining cross joins when translating HQL queries.
public String
getForUpdateString()

Overrides org.hibernate.dialect.DB2Dialect.getForUpdateString.

Get the string to append to SELECT statements to acquire locks for this dialect.
public String
getLimitString(String
The query to which to apply the limit.
query
,
final int
The offset of the limit
offset
,
final int
The limit of the limit ;)
limit
)

Overrides org.hibernate.dialect.Dialect.getLimitString.

Given a limit and an offset, apply the limit clause to the query.
public String
getQuerySequencesString()

Overrides org.hibernate.dialect.DB2Dialect.getQuerySequencesString.

Get the select command used retrieve the names of all sequences.
public String
getReadLockString(int
in milliseconds, -1 for indefinite wait and 0 for no wait.
timeout
)

Overrides org.hibernate.dialect.Dialect.getReadLockString.

Get the string to append to SELECT statements to acquire WRITE locks for this dialect.
public String
getSequenceNextValString(String
the name of the sequence
sequenceName
)

Overrides org.hibernate.dialect.DB2Dialect.getSequenceNextValString.

Generate the appropriate select statement to to retrieve the next value of a sequence.
private int
getWithIndex(String querySelect)

public String
getWriteLockString(int
in milliseconds, -1 for indefinite wait and 0 for no wait.
timeout
)

Overrides org.hibernate.dialect.Dialect.getWriteLockString.

Get the string to append to SELECT statements to acquire WRITE locks for this dialect.
private boolean
hasForUpdateClause(int forUpdateIndex)

private boolean
hasWithClause(String normalizedSelect)

private boolean
public boolean
public boolean
supportsLimit()

Overrides org.hibernate.dialect.DB2Dialect.supportsLimit.

Does this dialect support some form of limiting query results via a SQL clause?
public boolean
supportsLimitOffset()

Overrides org.hibernate.dialect.Dialect.supportsLimitOffset.

Does this dialect's LIMIT support (if any) additionally support specifying an offset?
public boolean
supportsLobValueChangePropogation()

Overrides org.hibernate.dialect.DB2Dialect.supportsLobValueChangePropogation.

Does the dialect support propagating changes to LOB values back to the database?
public boolean
supportsSequences()

Overrides org.hibernate.dialect.DB2Dialect.supportsSequences.

Does this dialect support sequences?
public boolean
supportsUnboundedLobLocatorMaterialization()

Overrides org.hibernate.dialect.Dialect.supportsUnboundedLobLocatorMaterialization.

Is it supported to materialize a LOB locator outside the transaction in which it was created?
public boolean
supportsVariableLimit()

Overrides org.hibernate.dialect.Dialect.supportsVariableLimit.

Does this dialect support bind variables (i.e., prepared statement parameters) for its limit/offset?
Inherited from org.hibernate.dialect.DB2Dialect:
convertToFirstRowValuedoesReadCommittedCauseWritersToBlockReadersgenerateTemporaryTableNamegetAddColumnStringgetCreateSequenceStringgetCreateTemporaryTablePostfixgetCreateTemporaryTableStringgetCurrentTimestampSelectStringgetDropSequenceStringgetIdentityColumnStringgetIdentityInsertStringgetIdentitySelectStringgetLimitStringgetLowercaseFunctiongetResultSetgetSelectClauseNullStringisCurrentTimestampSelectStringCallablemainregisterResultSetOutParameterrequiresCastingOfParametersInSelectClausesupportsCurrentTimestampSelectionsupportsEmptyInListsupportsIdentityColumnssupportsNotNullUniquesupportsOuterJoinForUpdatesupportsParametersInInsertSelectsupportsPooledSequencessupportsResultSetPositionQueryMethodsOnForwardOnlyCursorsupportsTemporaryTablessupportsTupleDistinctCountssupportsUnionAlluseMaxForLimit

Field Detail

driverVersionMajorback to summary
private int driverVersionMajor
driverVersionMinorback to summary
private int driverVersionMinor
logback to summary
private static final Logger log

Hides org.hibernate.dialect.Dialect.log.

Constructor Detail

DerbyDialectback to summary
public DerbyDialect()

Method Detail

createCaseFragmentback to summary
public CaseFragment createCaseFragment()

Overrides org.hibernate.dialect.Dialect.createCaseFragment.

Return the case statement modified for Cloudscape.

Returns:CaseFragment

Doc from org.hibernate.dialect.Dialect.createCaseFragment.

This dialect's org.hibernate.sql.CaseFragment strategy.

determineDriverVersionback to summary
private void determineDriverVersion()
Annotations
@SuppressWarnings:UnnecessaryUnboxing
dropConstraintsback to summary
public boolean dropConstraints()

Overrides org.hibernate.dialect.DB2Dialect.dropConstraints.

Doc from org.hibernate.dialect.Dialect.dropConstraints.

Do we need to drop constraints before dropping tables in this dialect?

Returns:boolean

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

getCrossJoinSeparatorback to summary
public String getCrossJoinSeparator()

Overrides org.hibernate.dialect.DB2Dialect.getCrossJoinSeparator.

Doc from org.hibernate.dialect.Dialect.getCrossJoinSeparator.

Get the separator to use for defining cross joins when translating HQL queries.

Typically this will be either [ cross join ] or [, ]

Note that the spaces are important!

getForUpdateStringback to summary
public String getForUpdateString()

Overrides org.hibernate.dialect.DB2Dialect.getForUpdateString.

Doc from org.hibernate.dialect.Dialect.getForUpdateString.

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

Returns:String

The appropriate FOR UPDATE clause string.

getLimitStringback to summary
public String getLimitString(String query, final int offset, final int limit)

Overrides org.hibernate.dialect.Dialect.getLimitString.

Doc from org.hibernate.dialect.Dialect.getLimitString.

Given a limit and an offset, apply the limit clause to the query.

From Derby 10.5 Docs:

Query
[ORDER BY clause]
[result offset clause]
[fetch first clause]
[FOR UPDATE clause]
[WITH {RR|RS|CS|UR}]
Parameters
query:String

The query to which to apply the limit.

offset:int

The offset of the limit

limit:int

The limit of the limit ;)

Returns:String

The modified query statement with the limit applied.

getQuerySequencesStringback to summary
public String getQuerySequencesString()

Overrides org.hibernate.dialect.DB2Dialect.getQuerySequencesString.

Doc from org.hibernate.dialect.Dialect.getQuerySequencesString.

Get the select command used retrieve the names of all sequences.

Returns:String

The select command; or null if sequences are not supported.

getReadLockStringback to summary
public String getReadLockString(int timeout)

Overrides org.hibernate.dialect.Dialect.getReadLockString.

Doc from org.hibernate.dialect.Dialect.getReadLockString.

Get the string to append to SELECT statements to acquire WRITE locks for this dialect. Location of the of the returned string is treated the same as getForUpdateString.

Parameters
timeout:int

in milliseconds, -1 for indefinite wait and 0 for no wait.

Returns:String

The appropriate LOCK clause string.

getSequenceNextValStringback to summary
public String getSequenceNextValString(String sequenceName)

Overrides org.hibernate.dialect.DB2Dialect.getSequenceNextValString.

Doc from org.hibernate.dialect.Dialect.getSequenceNextValString.

Generate the appropriate select statement to to retrieve the next value of a sequence.

This should be a "stand alone" select statement.

Parameters
sequenceName:String

the name of the sequence

Returns:String

String The "nextval" select string.

Annotations
@Override
getWithIndexback to summary
private int getWithIndex(String querySelect)
getWriteLockStringback to summary
public String getWriteLockString(int timeout)

Overrides org.hibernate.dialect.Dialect.getWriteLockString.

Doc from org.hibernate.dialect.Dialect.getWriteLockString.

Get the string to append to SELECT statements to acquire WRITE locks for this dialect. Location of the of the returned string is treated the same as getForUpdateString.

Parameters
timeout:int

in milliseconds, -1 for indefinite wait and 0 for no wait.

Returns:String

The appropriate LOCK clause string.

hasForUpdateClauseback to summary
private boolean hasForUpdateClause(int forUpdateIndex)
hasWithClauseback to summary
private boolean hasWithClause(String normalizedSelect)
isTenPointFiveReleaseOrNewerback to summary
private boolean isTenPointFiveReleaseOrNewer()
supportsCommentOnback to summary
public boolean supportsCommentOn()

Overrides org.hibernate.dialect.DB2Dialect.supportsCommentOn.

supportsLimitback to summary
public boolean supportsLimit()

Overrides org.hibernate.dialect.DB2Dialect.supportsLimit.

Doc from org.hibernate.dialect.Dialect.supportsLimit.

Does this dialect support some form of limiting query results via a SQL clause?

Returns:boolean

True if this dialect supports some form of LIMIT.

supportsLimitOffsetback to summary
public boolean supportsLimitOffset()

Overrides org.hibernate.dialect.Dialect.supportsLimitOffset.

Doc from org.hibernate.dialect.Dialect.supportsLimitOffset.

Does this dialect's LIMIT support (if any) additionally support specifying an offset?

Returns:boolean

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

supportsLobValueChangePropogationback to summary
public boolean supportsLobValueChangePropogation()

Overrides org.hibernate.dialect.DB2Dialect.supportsLobValueChangePropogation.

Doc from org.hibernate.dialect.Dialect.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: java.sql.Blob#setBinaryStream, java.sql.Blob#setBytes(long, byte[]), java.sql.Blob#setBytes(long, byte[], int, int), or java.sql.Blob#truncate(long).

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

Returns:boolean

True if the changes are propagated back to the database; false otherwise.

supportsSequencesback to summary
public boolean supportsSequences()

Overrides org.hibernate.dialect.DB2Dialect.supportsSequences.

Doc from org.hibernate.dialect.Dialect.supportsSequences.

Does this dialect support sequences?

Returns:boolean

True if sequences supported; false otherwise.

supportsUnboundedLobLocatorMaterializationback to summary
public boolean supportsUnboundedLobLocatorMaterialization()

Overrides org.hibernate.dialect.Dialect.supportsUnboundedLobLocatorMaterialization.

Doc from org.hibernate.dialect.Dialect.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:boolean

True if unbounded materialization is supported; false otherwise.

supportsVariableLimitback to summary
public boolean supportsVariableLimit()

Overrides org.hibernate.dialect.Dialect.supportsVariableLimit.

Doc from org.hibernate.dialect.Dialect.supportsVariableLimit.

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

Returns:boolean

True if bind variables can be used; false otherwise.