Package org.hibernate.dialect
Class Cache71Dialect
java.lang.Object
org.hibernate.dialect.Dialect
org.hibernate.dialect.Cache71Dialect
Caché 2007.1 dialect. This class is required in order to use Hibernate with Intersystems Cach� SQL.
Compatible with Cach� 2007.1.
Caché and Hibernate
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" ).
Compatible with Cach� 2007.1.
Caché and Hibernate
PREREQUISITES
These setup instructions assume that both Caché and Hibernate are installed and operational.HIBERNATE DIRECTORIES AND FILES
JBoss distributes the InterSystems Cache' dialect for Hibernate 3.2.1 For earlier versions of Hibernate please contact InterSystems Worldwide Response Center (WRC) for the appropriate source files.CACHÉ DOCUMENTATION
Documentation for Caché is available online when Caché is running. It can also be obtained from the InterSystems website. The book, "Object-oriented Application Development Using the Caché Post-relational Database: is also available from Springer-Verlag.HIBERNATE DOCUMENTATION
Hibernate comes with extensive electronic documentation. In addition, several books on Hibernate are available from Manning Publications Co. Three available titles are "Hibernate Quickly", "Hibernate in Action", and "Java Persistence with Hibernate".TO SET UP HIBERNATE FOR USE WITH CACHÉ
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. If either product is installed in a different location, the pathnames that follow should be modified appropriately. 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é.- Copy C:\CacheSys\dev\java\lib\JDK15\CacheDB.jar to C:\Hibernate\lib\CacheDB.jar.
- Insert the following files into your Java classpath:
- All jar files in the directory C:\Hibernate\lib
- The directory (or directories) where hibernate.properties and/or hibernate.cfg.xml are kept.
- In the file, hibernate.properties (or hibernate.cfg.xml), specify the Caché dialect and the Caché version URL settings.
| Property Name | Property Value |
|---|---|
| hibernate.dialect | org.hibernate.dialect.Cache71Dialect |
| hibernate.connection.driver_class | com.intersys.jdbc.CacheDriver |
| hibernate.connection.username | (see note 1) |
| hibernate.connection.password | (see note 1) |
| hibernate.connection.url | jdbc:Cache://127.0.0.1:1972/USER |
- Note 1
- 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.
CACHÉ VERSION URL
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.CACHÉ DIALECTS
Choices for Dialect are:- org.hibernate.dialect.Cache71Dialect (requires Caché 2007.1 or above)
SUPPORT FOR IDENTITY COLUMNS
Caché 2007.1 or later supports identity columns. For Hibernate to use identity columns, specify "native" as the generator.SEQUENCE DIALECTS SUPPORT SEQUENCES
To use Hibernate sequence support with Caché in a namespace, you must FIRST load the following file into that namespace:
etc\CacheSequences.xml
For example, at the COS terminal prompt in the namespace, run the
following command:
d LoadFile^%apiOBJ("c:\hibernate\etc\CacheSequences.xml","ck")
In your Hibernate mapping you can specify sequence use.
For example, the following shows the use of a sequence generator in a Hibernate mapping:
<id name="id" column="uid" type="long" unsaved-value="null">
<generator class="sequence"/>
</id>
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" ).
HIBERNATE FILES ASSOCIATED WITH CACHÉ DIALECT
The following files are associated with Caché dialect:- src\org\hibernate\dialect\Cache71Dialect.java
- src\org\hibernate\dialect\function\ConditionalParenthesisFunction.java
- src\org\hibernate\dialect\function\ConvertFunction.java
- src\org\hibernate\exception\CacheSQLStateConverter.java
- src\org\hibernate\sql\CacheJoinFragment.java
-
Field Summary
FieldsFields inherited from class org.hibernate.dialect.Dialect
CLOSED_QUOTE, DEFAULT_BATCH_SIZE, NO_BATCH, QUOTE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAre string comparisons implicitly case insensitive.booleanDoes the LIMIT clause come at the start of the SELECT statement, rather than at the end?Build an instance of the SQLExceptionConverter preferred by this dialect for converting SQLExceptions into Hibernate's JDBCException hierarchy.protected final voidCreate aJoinFragmentstrategy responsible for handling this dialect's variations in how joins are handled.booleanDo we need to drop constraints before dropping tables in this dialect?booleanDo we need to drop the temporary table after use?generateTemporaryTableName(String baseTableName) Generate a temporary table name given the base table.The syntax used to add a column to a table (optional).getAddForeignKeyConstraintString(String constraintName, String[] foreignKey, String referencedTable, String[] primaryKey, boolean referencesPrimaryKey) The syntax used to add a foreign key constraint to a table.Completely optional cascading drop clauseGet any fragments needing to be postfixed to the command for temporary table creation.Command used to create a temporary table.The syntax used during DDL to define a column as being an IDENTITY.Get the select command to use to retrieve the last generated IDENTITY value.getLimitString(String sql, boolean hasOffset) Apply s limit clause to the query.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.The name of the SQL function that transforms a string to lowercaseThe class (which implementsIdentifierGenerator) which acts as this dialects native generation strategy.The fragment used to insert a row without specifying any column values.The keyword used to specify a nullable column.Given a callable statement previously processed byDialect.registerResultSetOutParameter(java.sql.CallableStatement, int), extract theResultSetfrom the OUT parameter.booleanDoes this dialect support the ALTER TABLE syntax?booleanWhether this dialect have an Identity clause added to the data type or a completely separate identity data typebooleanDoes 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.booleanDo we need to qualify index names with the schema name?protected final voidintregisterResultSetOutParameter(CallableStatement statement, int col) Registers an OUT parameter which will be returning aResultSet.booleanbooleanbooleanDoes this dialect support empty IN lists?booleanbooleanbooleanbooleanDoes this dialect support identity column key generation?booleanDoes this dialect support some form of limiting query results via a SQL clause?booleanDoes this dialect's LIMIT support (if any) additionally support specifying an offset?booleanDoes this dialect support FOR UPDATE in conjunction with outer joined rows?booleanDoes this dialect support asking the result set its positioning information on forward only cursors.booleanDoes this dialect support sequences?booleanDoes this dialect support temporary tables?booleanDoes this dialect support the UNIQUE column syntax?booleanDoes this dialect support bind variables (i.e., prepared statement parameters) for its limit/offset?booleanDoes the LIMIT clause take a "maximum" row number instead of a total number of returned rows?Methods inherited from class org.hibernate.dialect.Dialect
addTypeOverride, appendIdentitySelectToInsert, appendLockHint, applyLocksToSql, bindLimitParametersInReverseOrder, closeQuote, convertToFirstRowValue, createCaseFragment, doesReadCommittedCauseWritersToBlockReaders, doesRepeatableReadCauseReadersToBlockWriters, forceLimitUsage, forUpdateOfColumns, getAddPrimaryKeyConstraintString, getCastTypeName, getColumnAliasExtractor, getColumnComment, getCreateMultisetTableString, getCreateSequenceString, getCreateSequenceString, getCreateSequenceStrings, getCreateSequenceStrings, getCreateTableString, getCrossJoinSeparator, getCurrentTimestampSelectString, getCurrentTimestampSQLFunctionName, getDefaultProperties, getDialect, getDialect, getDropForeignKeyString, getDropSequenceString, getDropSequenceStrings, getDropTemporaryTableString, getForUpdateNowaitString, getForUpdateNowaitString, getForUpdateString, getForUpdateString, getForUpdateString, getForUpdateString, getForUpdateString, getFunctions, getHibernateTypeName, getHibernateTypeName, getIdentityColumnString, getIdentityInsertString, getIdentitySelectString, getKeywords, getLimitString, getMaxAliasLength, getQuerySequencesString, getReadLockString, getSelectClauseNullString, getSelectGUIDString, getSelectSequenceNextValString, getSequenceNextValString, getTableComment, getTableTypeString, getTypeName, getTypeName, getTypeOverrides, getViolatedConstraintNameExtracter, getWriteLockString, isCurrentTimestampSelectStringCallable, isLockTimeoutParameterized, openQuote, quote, registerColumnType, registerColumnType, registerFunction, registerHibernateType, registerHibernateType, registerKeyword, replaceResultVariableInOrderByClauseWithPosition, requiresCastingOfParametersInSelectClause, supportsBindAsCallableArgument, supportsCircularCascadeDeleteConstraints, supportsColumnCheck, supportsCommentOn, supportsCurrentTimestampSelection, supportsExistsInSelect, supportsExpectedLobUsagePattern, supportsIfExistsAfterTableName, supportsIfExistsBeforeTableName, supportsInsertSelectIdentity, supportsLobValueChangePropogation, supportsLockTimeouts, supportsNotNullUnique, supportsParametersInInsertSelect, supportsPooledSequences, supportsRowValueConstructorSyntax, supportsRowValueConstructorSyntaxInInList, supportsSubqueryOnMutatingTable, supportsSubselectAsInPredicateLHS, supportsTableCheck, supportsTupleCounts, supportsTupleDistinctCounts, supportsUnboundedLobLocatorMaterialization, supportsUnionAll, supportsUniqueConstraintInCreateAlterTable, toBooleanValueString, toString, transformSelectString, useInputStreamToInsertBlob
-
Field Details
-
EXTRACTER
-
-
Constructor Details
-
Cache71Dialect
public Cache71Dialect()Creates newCach�71Dialectinstance. Sets up the JDBC / Cach� type mappings.
-
-
Method Details
-
commonRegistration
protected final void commonRegistration() -
register71Functions
protected final void register71Functions() -
hasAlterTable
public boolean hasAlterTable()Description copied from class:DialectDoes this dialect support the ALTER TABLE syntax?- Overrides:
hasAlterTablein classDialect- Returns:
- True if we support altering of tables; false otherwise.
-
qualifyIndexName
public boolean qualifyIndexName()Description copied from class:DialectDo we need to qualify index names with the schema name?- Overrides:
qualifyIndexNamein classDialect- Returns:
- boolean
-
supportsUnique
public boolean supportsUnique()Description copied from class:DialectDoes this dialect support the UNIQUE column syntax?- Overrides:
supportsUniquein classDialect- Returns:
- boolean
-
getAddForeignKeyConstraintString
public String getAddForeignKeyConstraintString(String constraintName, String[] foreignKey, String referencedTable, String[] primaryKey, boolean referencesPrimaryKey) The syntax used to add a foreign key constraint to a table.- Overrides:
getAddForeignKeyConstraintStringin classDialect- Parameters:
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 to- Returns:
- String
-
supportsCheck
public boolean supportsCheck() -
getAddColumnString
Description copied from class:DialectThe syntax used to add a column to a table (optional).- Overrides:
getAddColumnStringin classDialect- Returns:
- The "add column" fragment.
-
getCascadeConstraintsString
Description copied from class:DialectCompletely optional cascading drop clause- Overrides:
getCascadeConstraintsStringin classDialect- Returns:
- String
-
dropConstraints
public boolean dropConstraints()Description copied from class:DialectDo we need to drop constraints before dropping tables in this dialect?- Overrides:
dropConstraintsin classDialect- Returns:
- True if constraints must be dropped prior to dropping the table; false otherwise.
-
supportsCascadeDelete
public boolean supportsCascadeDelete()- Overrides:
supportsCascadeDeletein classDialect
-
hasSelfReferentialForeignKeyBug
public boolean hasSelfReferentialForeignKeyBug()- Overrides:
hasSelfReferentialForeignKeyBugin classDialect
-
supportsTemporaryTables
public boolean supportsTemporaryTables()Description copied from class:DialectDoes this dialect support temporary tables?- Overrides:
supportsTemporaryTablesin classDialect- Returns:
- True if temp tables are supported; false otherwise.
-
generateTemporaryTableName
Description copied from class:DialectGenerate a temporary table name given the base table.- Overrides:
generateTemporaryTableNamein classDialect- Parameters:
baseTableName- The table name from which to base the temp table name.- Returns:
- The generated temp table name.
-
getCreateTemporaryTableString
Description copied from class:DialectCommand used to create a temporary table.- Overrides:
getCreateTemporaryTableStringin classDialect- Returns:
- The command used to create a temporary table.
-
performTemporaryTableDDLInIsolation
Description copied from class:DialectDoes 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 theDatabaseMetaData.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:Boolean.TRUE- Unequivocally, perform the temporary table DDL in isolation.Boolean.FALSE- Unequivocally, do not perform the temporary table DDL in isolation.- null - defer to the JDBC driver response in regards to
DatabaseMetaData.dataDefinitionCausesTransactionCommit()
- Overrides:
performTemporaryTableDDLInIsolationin classDialect- Returns:
- see the result matrix above.
-
getCreateTemporaryTablePostfix
Description copied from class:DialectGet any fragments needing to be postfixed to the command for temporary table creation.- Overrides:
getCreateTemporaryTablePostfixin classDialect- Returns:
- Any required postfix.
-
dropTemporaryTableAfterUse
public boolean dropTemporaryTableAfterUse()Description copied from class:DialectDo we need to drop the temporary table after use?- Overrides:
dropTemporaryTableAfterUsein classDialect- Returns:
- True if the table should be dropped.
-
supportsIdentityColumns
public boolean supportsIdentityColumns()Description copied from class:DialectDoes this dialect support identity column key generation?- Overrides:
supportsIdentityColumnsin classDialect- Returns:
- True if IDENTITY columns are supported; false otherwise.
-
getNativeIdentifierGeneratorClass
Description copied from class:DialectThe class (which implementsIdentifierGenerator) which acts as this dialects native generation strategy. Comes into play whenever the user specifies the native generator.- Overrides:
getNativeIdentifierGeneratorClassin classDialect- Returns:
- The native generator class.
-
hasDataTypeInIdentityColumn
public boolean hasDataTypeInIdentityColumn()Description copied from class:DialectWhether this dialect have an Identity clause added to the data type or a completely separate identity data type- Overrides:
hasDataTypeInIdentityColumnin classDialect- Returns:
- boolean
-
getIdentityColumnString
Description copied from class:DialectThe syntax used during DDL to define a column as being an IDENTITY.- Overrides:
getIdentityColumnStringin classDialect- Returns:
- The appropriate DDL fragment.
- Throws:
MappingException- If IDENTITY generation is not supported.
-
getIdentitySelectString
Description copied from class:DialectGet the select command to use to retrieve the last generated IDENTITY value.- Overrides:
getIdentitySelectStringin classDialect- Returns:
- The appropriate select command
-
supportsSequences
public boolean supportsSequences()Description copied from class:DialectDoes this dialect support sequences?- Overrides:
supportsSequencesin classDialect- Returns:
- True if sequences supported; false otherwise.
-
supportsForUpdate
public boolean supportsForUpdate() -
supportsForUpdateOf
public boolean supportsForUpdateOf() -
supportsForUpdateNowait
public boolean supportsForUpdateNowait() -
supportsOuterJoinForUpdate
public boolean supportsOuterJoinForUpdate()Description copied from class:DialectDoes this dialect support FOR UPDATE in conjunction with outer joined rows?- Overrides:
supportsOuterJoinForUpdatein classDialect- Returns:
- True if outer joined rows can be locked via FOR UPDATE.
-
getLockingStrategy
Description copied from class:DialectGet a strategy instance which knows how to acquire a database-level lock of the specified mode for this dialect.- Overrides:
getLockingStrategyin classDialect- Parameters:
lockable- The persister for the entity to be locked.lockMode- The type of lock to be acquired.- Returns:
- The appropriate locking strategy.
-
supportsLimit
public boolean supportsLimit()Description copied from class:DialectDoes this dialect support some form of limiting query results via a SQL clause?- Overrides:
supportsLimitin classDialect- Returns:
- True if this dialect supports some form of LIMIT.
-
supportsLimitOffset
public boolean supportsLimitOffset()Description copied from class:DialectDoes this dialect's LIMIT support (if any) additionally support specifying an offset?- Overrides:
supportsLimitOffsetin classDialect- Returns:
- True if the dialect supports an offset within the limit support.
-
supportsVariableLimit
public boolean supportsVariableLimit()Description copied from class:DialectDoes this dialect support bind variables (i.e., prepared statement parameters) for its limit/offset?- Overrides:
supportsVariableLimitin classDialect- Returns:
- True if bind variables can be used; false otherwise.
-
bindLimitParametersFirst
public boolean bindLimitParametersFirst()Description copied from class:DialectDoes the LIMIT clause come at the start of the SELECT statement, rather than at the end?- Overrides:
bindLimitParametersFirstin classDialect- Returns:
- true if limit parameters should come before other parameters
-
useMaxForLimit
public boolean useMaxForLimit()Description copied from class:DialectDoes 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?- Overrides:
useMaxForLimitin classDialect- Returns:
- True if limit is relative from offset; false otherwise.
-
getLimitString
Description copied from class:DialectApply s limit clause to the query. Typically dialects utilizevariablelimit 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 andDialect.getLimitString(String, int, int).- Overrides:
getLimitStringin classDialect- Parameters:
sql- The query to which to apply the limit.hasOffset- Is the query requesting an offset?- Returns:
- the modified SQL
-
registerResultSetOutParameter
Description copied from class:DialectRegisters an OUT parameter which will be returning aResultSet. How this is accomplished varies greatly from DB to DB, hence its inclusion (along withDialect.getResultSet(java.sql.CallableStatement)) here.- Overrides:
registerResultSetOutParameterin classDialect- Parameters:
statement- The callable statement.col- The bind position at which to register the OUT param.- Returns:
- The number of (contiguous) bind positions used.
- Throws:
SQLException- Indicates problems registering the OUT param.
-
getResultSet
Description copied from class:DialectGiven a callable statement previously processed byDialect.registerResultSetOutParameter(java.sql.CallableStatement, int), extract theResultSetfrom the OUT parameter.- Overrides:
getResultSetin classDialect- Parameters:
ps- The callable statement.- Returns:
- The extracted result set.
- Throws:
SQLException- Indicates problems extracting the result set.
-
getLowercaseFunction
Description copied from class:DialectThe name of the SQL function that transforms a string to lowercase- Overrides:
getLowercaseFunctionin classDialect- Returns:
- The dialect-specific lowercase function.
-
getNullColumnString
Description copied from class:DialectThe keyword used to specify a nullable column.- Overrides:
getNullColumnStringin classDialect- Returns:
- String
-
createOuterJoinFragment
Description copied from class:DialectCreate aJoinFragmentstrategy responsible for handling this dialect's variations in how joins are handled.- Overrides:
createOuterJoinFragmentin classDialect- Returns:
- This dialect's
JoinFragmentstrategy.
-
getNoColumnsInsertString
Description copied from class:DialectThe fragment used to insert a row without specifying any column values. This is not possible on some databases.- Overrides:
getNoColumnsInsertStringin classDialect- Returns:
- The appropriate empty values clause.
-
buildSQLExceptionConverter
Description copied from class:DialectBuild 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.- Overrides:
buildSQLExceptionConverterin classDialect- Returns:
- The Dialect's preferred SQLExceptionConverter.
-
supportsEmptyInList
public boolean supportsEmptyInList()Description copied from class:DialectDoes this dialect support empty IN lists? For example, is [where XYZ in ()] a supported construct?- Overrides:
supportsEmptyInListin classDialect- Returns:
- True if empty in lists are supported; false otherwise.
-
areStringComparisonsCaseInsensitive
public boolean areStringComparisonsCaseInsensitive()Description copied from class:DialectAre string comparisons implicitly case insensitive. In other words, does [where 'XYZ' = 'xyz'] resolve to true?- Overrides:
areStringComparisonsCaseInsensitivein classDialect- Returns:
- True if comparisons are case insensitive.
-
supportsResultSetPositionQueryMethodsOnForwardOnlyCursor
public boolean supportsResultSetPositionQueryMethodsOnForwardOnlyCursor()Description copied from class:DialectDoes this dialect support asking the result set its positioning information on forward only cursors. Specifically, in the case of scrolling fetches, Hibernate needs to useResultSet.isAfterLast()andResultSet.isBeforeFirst(). Certain drivers do not allow access to these methods for forward only cursors. NOTE : this is highly driver dependent!- Overrides:
supportsResultSetPositionQueryMethodsOnForwardOnlyCursorin classDialect- Returns:
- True if methods like
ResultSet.isAfterLast()andResultSet.isBeforeFirst()are supported for forward only cursors; false otherwise.
-