public class Cache71Dialect extends Dialect
Caché 2007.1 dialect.
This class is required in order to use Hibernate with Intersystems Caché SQL. Compatible with Caché 2007.1.
<h2>PREREQUISITES</h2> These setup instructions assume that both Caché and Hibernate are installed and operational. <br> <h2>HIBERNATE DIRECTORIES AND FILES</h2> JBoss distributes the InterSystems Cache' dialect for Hibernate 3.2.1 For earlier versions of Hibernate please contact <a href="http://www.intersystems.com/support/cache-support.html">InterSystems Worldwide Response Center</A> (WRC) for the appropriate source files. <br> <h2>CACHÉ DOCUMENTATION</h2> Documentation for Caché is available online when Caché is running. It can also be obtained from the <a href="http://www.intersystems.com/cache/downloads/documentation.html">InterSystems</A> website. The book, "Object-oriented Application Development Using the Caché Post-relational Database: is also available from Springer-Verlag. <br> <h2>HIBERNATE DOCUMENTATION</h2> Hibernate comes with extensive electronic documentation. In addition, several books on Hibernate are available from <a href="http://www.manning.com">Manning Publications Co</a>. Three available titles are "Hibernate Quickly", "Hibernate in Action", and "Java Persistence with Hibernate". <br> <h2>TO SET UP HIBERNATE FOR USE WITH CACHÉ</h2> The following steps assume that the directory where Caché was installed is C:\CacheSys. This is the default installation directory for Caché. The default installation directory for Hibernate is assumed to be C:\Hibernate. <p/> If either product is installed in a different location, the pathnames that follow should be modified appropriately. <p/> Caché version 2007.1 and above is recommended for use with Hibernate. The next step depends on the location of your CacheDB.jar depending on your version of Caché. <ol> <li>Copy C:\CacheSys\dev\java\lib\JDK15\CacheDB.jar to C:\Hibernate\lib\CacheDB.jar.</li> <p/> <li>Insert the following files into your Java classpath: <p/> <ul> <li>All jar files in the directory C:\Hibernate\lib</li> <li>The directory (or directories) where hibernate.properties and/or hibernate.cfg.xml are kept.</li> </ul> </li> <p/> <li>In the file, hibernate.properties (or hibernate.cfg.xml), specify the Caché dialect and the Caché version URL settings.</li> </ol> <p/> For example, in Hibernate 3.2, typical entries in hibernate.properties would have the following "name=value" pairs: <p/> <table cols=3 border cellpadding=5 cellspacing=0> <tr> <th>Property Name</th> <th>Property Value</th> </tr> <tr> <td>hibernate.dialect</td> <td>org.hibernate.dialect.Cache71Dialect</td> </tr> <tr> <td>hibernate.connection.driver_class</td> <td>com.intersys.jdbc.CacheDriver</td> </tr> <tr> <td>hibernate.connection.username</td> <td>(see note 1)</td> </tr> <tr> <td>hibernate.connection.password</td> <td>(see note 1)</td> </tr> <tr> <td>hibernate.connection.url</td> <td>jdbc:Cache://127.0.0.1:1972/USER</td> </tr> </table> <p/> <b>NOTE:</b> Please contact your administrator for the userid and password you should use when attempting access via JDBC. By default, these are chosen to be "_SYSTEM" and "SYS" respectively as noted in the SQL standard. <br> <h2>CACHÉ VERSION URL</h2> This is the standard URL for the JDBC driver. For a JDBC driver on the machine hosting Caché, use the IP "loopback" address, 127.0.0.1. For 1972, the default port, specify the super server port of your Caché instance. For USER, substitute the NAMESPACE which contains your Caché database data. <br> <h2>CACHÉ DIALECTS</h2> Choices for Dialect are: <br> <p/> <ol> <li>org.hibernate.dialect.Cache71Dialect (requires Caché 2007.1 or above)</li> <p/> </ol> <br> <h2>SUPPORT FOR IDENTITY COLUMNS</h2> Caché 2007.1 or later supports identity columns. For Hibernate to use identity columns, specify "native" as the generator. <br> <h2>SEQUENCE DIALECTS SUPPORT SEQUENCES</h2> <p/> To use Hibernate sequence support with Caché in a namespace, you must FIRST load the following file into that namespace: <pre> etc\CacheSequences.xml </pre> For example, at the COS terminal prompt in the namespace, run the following command: <p> d LoadFile^%apiOBJ("c:\hibernate\etc\CacheSequences.xml","ck") <p> In your Hibernate mapping you can specify sequence use. <p> For example, the following shows the use of a sequence generator in a Hibernate mapping: <pre> <id name="id" column="uid" type="long" unsaved-value="null"> <generator class="sequence"/> </id> </pre> <br> <p/> Some versions of Hibernate under some circumstances call getSelectSequenceNextValString() in the dialect. If this happens you will receive the error message: new MappingException( "Dialect does not support sequences" ). <br> <h2>HIBERNATE FILES ASSOCIATED WITH CACHÉ DIALECT</h2> The following files are associated with Caché dialect: <p/> <ol> <li>src\org\hibernate\dialect\Cache71Dialect.java</li> <li>src\org\hibernate\dialect\function\ConditionalParenthesisFunction.java</li> <li>src\org\hibernate\dialect\function\ConvertFunction.java</li> <li>src\org\hibernate\exception\CacheSQLStateConverter.java</li> <li>src\org\hibernate\sql\CacheJoinFragment.java</li> </ol> Cache71Dialect ships with Hibernate 3.2. All other dialects are distributed by InterSystems and subclass Cache71Dialect.
Modifier and Type | Field and Description |
---|---|
static ViolatedConstraintNameExtracter |
EXTRACTER
The Cache ViolatedConstraintNameExtracter.
|
CLOSED_QUOTE, DEFAULT_BATCH_SIZE, LEGACY_LOB_MERGE_STRATEGY, NEW_LOCATOR_LOB_MERGE_STRATEGY, NO_BATCH, QUOTE, STANDARD_DEFAULT_BATCH_LOAD_SIZING_STRATEGY, STREAM_XFER_LOB_MERGE_STRATEGY
Constructor and Description |
---|
Cache71Dialect()
Creates new <code>Cache71Dialect</code> instance.
|
Modifier and Type | Method and Description |
---|---|
boolean |
areStringComparisonsCaseInsensitive()
Are string comparisons implicitly case insensitive.
|
boolean |
bindLimitParametersFirst()
Does the <tt>LIMIT</tt> clause come at the start of the
<tt>SELECT</tt> statement, rather than at the end?
|
SQLExceptionConversionDelegate |
buildSQLExceptionConversionDelegate()
Build an instance of a
SQLExceptionConversionDelegate for
interpreting dialect-specific error or SQLState codes. |
protected void |
commonRegistration() |
JoinFragment |
createOuterJoinFragment()
Create a
JoinFragment strategy responsible
for handling this dialect’s variations in how joins are handled. |
boolean |
dropConstraints()
Do we need to drop constraints before dropping tables in this dialect?
|
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 |
getCascadeConstraintsString()
Completely optional cascading drop clause
|
MultiTableBulkIdStrategy |
getDefaultMultiTableBulkIdStrategy() |
IdentityColumnSupport |
getIdentityColumnSupport()
Get the appropriate
IdentityColumnSupport |
LimitHandler |
getLimitHandler()
Returns the delegate managing LIMIT clause.
|
String |
getLimitString(String sql,
boolean hasOffset)
Apply s 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
|
String |
getNativeIdentifierGeneratorStrategy()
Resolves the native generation strategy associated to this dialect.
|
String |
getNoColumnsInsertString()
The fragment used to insert a row without specifying any column values.
|
String |
getNullColumnString()
The keyword used to specify a nullable column.
|
ResultSet |
getResultSet(CallableStatement ps)
Given a callable statement previously processed by
Dialect.registerResultSetOutParameter(java.sql.CallableStatement, int) ,
extract the ResultSet from the OUT parameter. |
ViolatedConstraintNameExtracter |
getViolatedConstraintNameExtracter() |
boolean |
hasAlterTable()
Does this dialect support the <tt>ALTER TABLE</tt> syntax?
|
boolean |
hasSelfReferentialForeignKeyBug()
Does the database/driver have bug in deleting rows that refer to other rows being deleted in the same query?
|
boolean |
qualifyIndexName()
Do we need to qualify index names with the schema name?
|
protected void |
register71Functions() |
int |
registerResultSetOutParameter(CallableStatement statement,
int col)
Registers a parameter (either OUT, or the new REF_CURSOR param type available in Java 8) capable of
returning
ResultSet by position. |
boolean |
supportsCascadeDelete()
Does this dialect support cascaded delete on foreign key definitions?
|
boolean |
supportsCheck()
Does this dialect support check constraints?
|
boolean |
supportsEmptyInList()
Does this dialect support empty IN lists?
<p/>
For example, is [where XYZ in ()] a supported construct?
|
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 |
supportsOuterJoinForUpdate()
Does this dialect support <tt>FOR UPDATE</tt> in conjunction with
outer joined rows?
|
boolean |
supportsResultSetPositionQueryMethodsOnForwardOnlyCursor()
Does this dialect support asking the result set its positioning
information on forward only cursors.
|
boolean |
supportsSequences()
Does this dialect support sequences?
|
boolean |
supportsVariableLimit()
Does this dialect support bind variables (i.e., prepared statement
parameters) for its limit/offset?
|
boolean |
useMaxForLimit()
Does the <tt>LIMIT</tt> clause take a "maximum" row number instead
of a total number of returned rows?
<p/>
This is easiest understood via an example.
|
addSqlHintOrComment, appendLockHint, appendLockHint, applyLocksToSql, augmentRecognizedTableTypes, bindLimitParametersInReverseOrder, buildIdentifierHelper, buildSQLExceptionConverter, canCreateCatalog, canCreateSchema, cast, cast, cast, closeQuote, contributeTypes, convertToFirstRowValue, createCaseFragment, defaultScrollMode, doesReadCommittedCauseWritersToBlockReaders, doesRepeatableReadCauseReadersToBlockWriters, escapeLiteral, forceLimitUsage, forceLobAsLastValue, forUpdateOfColumns, getAddColumnSuffixString, getAddForeignKeyConstraintString, getAddPrimaryKeyConstraintString, getAddUniqueConstraintString, getAlterTableString, getAuxiliaryDatabaseObjectExporter, getCallableStatementSupport, getCaseInsensitiveLike, getCastTypeName, getColumnAliasExtractor, getColumnComment, getCreateCatalogCommand, getCreateMultisetTableString, getCreateSchemaCommand, getCreateSequenceString, getCreateSequenceString, getCreateSequenceStrings, getCreateSequenceStrings, getCreateTableString, getCrossJoinSeparator, getCurrentSchemaCommand, getCurrentTimestampSelectString, getCurrentTimestampSQLFunctionName, getDefaultBatchLoadSizingStrategy, getDefaultProperties, getDialect, getDialect, getDropCatalogCommand, getDropForeignKeyString, getDropSchemaCommand, getDropSequenceString, getDropSequenceStrings, getDropTableString, getForeignKeyExporter, getForUpdateNowaitString, getForUpdateNowaitString, getForUpdateSkipLockedString, getForUpdateSkipLockedString, getForUpdateString, getForUpdateString, getForUpdateString, getForUpdateString, getForUpdateString, getFunctions, getHibernateTypeName, getHibernateTypeName, getIndexExporter, getInExpressionCountLimit, getKeywords, getLimitString, getLobMergeStrategy, getMaxAliasLength, getNameQualifierSupport, getNativeIdentifierGeneratorClass, getNotExpression, getQueryHintString, getQueryHintString, getQuerySequencesString, getReadLockString, getReadLockString, getResultSet, getResultSet, getSchemaNameResolver, getSelectClauseNullString, getSelectGUIDString, getSelectSequenceNextValString, getSequenceExporter, getSequenceInformationExtractor, getSequenceNextValString, getSqlTypeDescriptorOverride, getTableComment, getTableExporter, getTableTypeString, getTypeName, getTypeName, getUniqueDelegate, getUniqueKeyExporter, getWriteLockString, getWriteLockString, inlineLiteral, isCurrentTimestampSelectStringCallable, isJdbcLogWarningsEnabledByDefault, isLegacyLimitHandlerBehaviorEnabled, isLockTimeoutParameterized, isTypeNameRegistered, openQuote, prependComment, quote, registerColumnType, registerColumnType, registerFunction, registerHibernateType, registerHibernateType, registerKeyword, registerResultSetOutParameter, remapSqlTypeDescriptor, renderOrderByElement, replaceResultVariableInOrderByClauseWithPosition, requiresCastingOfParametersInSelectClause, requiresParensForTupleDistinctCounts, supportsBindAsCallableArgument, supportsCaseInsensitiveLike, supportsCircularCascadeDeleteConstraints, supportsColumnCheck, supportsCommentOn, supportsCurrentTimestampSelection, supportsExistsInSelect, supportsExpectedLobUsagePattern, supportsIfExistsAfterAlterTable, supportsIfExistsAfterConstraintName, supportsIfExistsAfterTableName, supportsIfExistsBeforeConstraintName, supportsIfExistsBeforeTableName, supportsLobValueChangePropogation, supportsLockTimeouts, supportsNamedParameters, supportsNationalizedTypes, supportsNonQueryWithCTE, supportsNotNullUnique, supportsParametersInInsertSelect, supportsPartitionBy, supportsPooledSequences, supportsRowValueConstructorSyntax, supportsRowValueConstructorSyntaxInInList, supportsSkipLocked, supportsSubqueryOnMutatingTable, supportsSubselectAsInPredicateLHS, supportsTableCheck, supportsTupleCounts, supportsTupleDistinctCounts, supportsTuplesInSubqueries, supportsUnboundedLobLocatorMaterialization, supportsUnionAll, supportsUnique, supportsUniqueConstraintInCreateAlterTable, supportsValuesList, toBooleanValueString, toString, transformSelectString, useFollowOnLocking, useFollowOnLocking, useInputStreamToInsertBlob
public static final ViolatedConstraintNameExtracter EXTRACTER
The Cache ViolatedConstraintNameExtracter.
public Cache71Dialect()
Creates new <code>Cache71Dialect</code> instance. Sets up the JDBC / Caché type mappings.
protected final void commonRegistration()
protected final void register71Functions()
public boolean hasAlterTable()
Dialect
Does this dialect support the <tt>ALTER TABLE</tt> syntax?
hasAlterTable
in class Dialect
public boolean qualifyIndexName()
Dialect
Do we need to qualify index names with the schema name?
qualifyIndexName
in class Dialect
public String getAddForeignKeyConstraintString(String constraintName, String[] foreignKey, String referencedTable, String[] primaryKey, boolean referencesPrimaryKey)
Dialect
The syntax used to add a foreign key constraint to a table.
getAddForeignKeyConstraintString
in class Dialect
constraintName
- The FK constraint name.foreignKey
- The names of the columns comprising the FKreferencedTable
- The table referenced by the FKprimaryKey
- The explicit columns in the referencedTable referenced
by this FK.referencesPrimaryKey
- if false, constraint should be
explicit about which column names the constraint refers topublic boolean supportsCheck()
Does this dialect support check constraints?
false
(Cache does not support check constraints)public String getAddColumnString()
Dialect
The syntax used to add a column to a table (optional).
getAddColumnString
in class Dialect
public String getCascadeConstraintsString()
Dialect
Completely optional cascading drop clause
getCascadeConstraintsString
in class Dialect
public boolean dropConstraints()
Dialect
Do we need to drop constraints before dropping tables in this dialect?
dropConstraints
in class Dialect
public boolean supportsCascadeDelete()
Dialect
Does this dialect support cascaded delete on foreign key definitions?
supportsCascadeDelete
in class Dialect
true
indicates that the dialect does support cascaded delete on foreign keys.public boolean hasSelfReferentialForeignKeyBug()
Dialect
Does the database/driver have bug in deleting rows that refer to other rows being deleted in the same query?
hasSelfReferentialForeignKeyBug
in class Dialect
true
if the database/driver has this bugpublic MultiTableBulkIdStrategy getDefaultMultiTableBulkIdStrategy()
getDefaultMultiTableBulkIdStrategy
in class Dialect
public String getNativeIdentifierGeneratorStrategy()
Dialect
Resolves the native generation strategy associated to this dialect. <p/> Comes into play whenever the user specifies the native generator.
getNativeIdentifierGeneratorStrategy
in class Dialect
public IdentityColumnSupport getIdentityColumnSupport()
Dialect
Get the appropriate IdentityColumnSupport
getIdentityColumnSupport
in class Dialect
public boolean supportsSequences()
Dialect
Does this dialect support sequences?
supportsSequences
in class Dialect
public boolean supportsOuterJoinForUpdate()
Dialect
Does this dialect support <tt>FOR UPDATE</tt> in conjunction with outer joined rows?
supportsOuterJoinForUpdate
in class Dialect
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode)
Dialect
Get a strategy instance which knows how to acquire a database-level lock of the specified mode for this dialect.
getLockingStrategy
in class Dialect
lockable
- The persister for the entity to be locked.lockMode
- The type of lock to be acquired.public LimitHandler getLimitHandler()
Dialect
Returns the delegate managing LIMIT clause.
getLimitHandler
in class Dialect
public boolean supportsLimit()
Dialect
Does this dialect support some form of limiting query results via a SQL clause?
supportsLimit
in class Dialect
public boolean supportsLimitOffset()
Dialect
Does this dialect’s LIMIT support (if any) additionally support specifying an offset?
supportsLimitOffset
in class Dialect
public boolean supportsVariableLimit()
Dialect
Does this dialect support bind variables (i.e., prepared statement parameters) for its limit/offset?
supportsVariableLimit
in class Dialect
public boolean bindLimitParametersFirst()
Dialect
Does the <tt>LIMIT</tt> clause come at the start of the <tt>SELECT</tt> statement, rather than at the end?
bindLimitParametersFirst
in class Dialect
public boolean useMaxForLimit()
Dialect
Does the <tt>LIMIT</tt> clause take a "maximum" row number instead of a total number of returned rows? <p/> 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) <p/> So essentially, is limit relative from offset? Or is limit absolute?
useMaxForLimit
in class Dialect
public String getLimitString(String sql, boolean hasOffset)
Dialect
Apply s limit clause to the query.
<p/>
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.
<p/>
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
Dialect.getLimitString(String, int, int)
.
getLimitString
in class Dialect
sql
- The query to which to apply the limit.hasOffset
- Is the query requesting an offset?public int registerResultSetOutParameter(CallableStatement statement, int col) throws SQLException
Dialect
Registers a parameter (either OUT, or the new REF_CURSOR param type available in Java 8) capable of
returning ResultSet
by position. Pre-Java 8, registering such ResultSet-returning
parameters varied greatly across database and drivers; hence its inclusion as part of the Dialect contract.
registerResultSetOutParameter
in class Dialect
statement
- The callable statement.col
- The bind position at which to register the output param.SQLException
- Indicates problems registering the param.public ResultSet getResultSet(CallableStatement ps) throws SQLException
Dialect
Given a callable statement previously processed by Dialect.registerResultSetOutParameter(java.sql.CallableStatement, int)
,
extract the ResultSet
from the OUT parameter.
getResultSet
in class Dialect
ps
- The callable statement.SQLException
- Indicates problems extracting the result set.public String getLowercaseFunction()
Dialect
The name of the SQL function that transforms a string to lowercase
getLowercaseFunction
in class Dialect
public String getNullColumnString()
Dialect
The keyword used to specify a nullable column.
getNullColumnString
in class Dialect
public JoinFragment createOuterJoinFragment()
Dialect
Create a JoinFragment
strategy responsible
for handling this dialect’s variations in how joins are handled.
createOuterJoinFragment
in class Dialect
JoinFragment
strategy.public String getNoColumnsInsertString()
Dialect
The fragment used to insert a row without specifying any column values. This is not possible on some databases.
getNoColumnsInsertString
in class Dialect
public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate()
Dialect
Build an instance of a SQLExceptionConversionDelegate
for
interpreting dialect-specific error or SQLState codes.
<p/>
When Dialect.buildSQLExceptionConverter()
returns null, the default
SQLExceptionConverter
is used to interpret SQLState and
error codes. If this method is overridden to return a non-null value,
the default SQLExceptionConverter
will use the returned
SQLExceptionConversionDelegate
in addition to the following
standard delegates:
<ol>
<li>a "static" delegate based on the JDBC 4 defined SQLException hierarchy;</li>
<li>a delegate that interprets SQLState codes for either X/Open or SQL-2003 codes,
depending on java.sql.DatabaseMetaData#getSQLStateType</li>
</ol>
<p/>
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 a vendor-specific ErrorCode rather than the SQLState.
<p/>
Specific Dialects may override to return whatever is most appropriate for that vendor.
buildSQLExceptionConversionDelegate
in class Dialect
public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter()
getViolatedConstraintNameExtracter
in interface ConversionContext
getViolatedConstraintNameExtracter
in class Dialect
public boolean supportsEmptyInList()
Dialect
Does this dialect support empty IN lists? <p/> For example, is [where XYZ in ()] a supported construct?
supportsEmptyInList
in class Dialect
public boolean areStringComparisonsCaseInsensitive()
Dialect
Are string comparisons implicitly case insensitive. <p/> In other words, does [where 'XYZ' = 'xyz'] resolve to true?
areStringComparisonsCaseInsensitive
in class Dialect
public boolean supportsResultSetPositionQueryMethodsOnForwardOnlyCursor()
Dialect
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.
<p/>
NOTE : this is highly driver dependent!
supportsResultSetPositionQueryMethodsOnForwardOnlyCursor
in class Dialect
ResultSet.isAfterLast()
and
ResultSet.isBeforeFirst()
are supported for forward
only cursors; false otherwise.Copyright © 2001-2018 Red Hat, Inc. All Rights Reserved.