[hibernate-commits] Hibernate SVN: r10785 - in trunk/Hibernate3: etc src/org/hibernate/dialect

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Mon Nov 13 07:53:19 EST 2006


Author: steve.ebersole at jboss.com
Date: 2006-11-13 07:53:18 -0500 (Mon, 13 Nov 2006)
New Revision: 10785

Added:
   trunk/Hibernate3/etc/CacheSequences.xml
Modified:
   trunk/Hibernate3/src/org/hibernate/dialect/Cache71Dialect.java
Log:
minor changes to dialect for intersystems CacheSQL

Added: trunk/Hibernate3/etc/CacheSequences.xml
===================================================================
--- trunk/Hibernate3/etc/CacheSequences.xml	2006-11-11 05:13:01 UTC (rev 10784)
+++ trunk/Hibernate3/etc/CacheSequences.xml	2006-11-13 12:53:18 UTC (rev 10785)
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+An example of enabling support for sequences in Intersystems' Cache SQL 2007.1 database.
+-->
+
+<Export generator="Cache" version="9" zv="Cache for Windows NT (Intel) 5.0.17 (Build 6006U)" ts="2005-09-29 14:10:54">
+<Project name="Hibernate_Sequences" LastModified="2005-09-29 14:10:54">
+  <Items>
+    <ProjectItem name="InterSystems.Sequences" type="CLS"/>
+  </Items>
+</Project>
+<Class name="InterSystems.Sequences">
+<Description><![CDATA[
+Class to maintain a table of counters for Oracle sequence or MSSql identity columns
+<br><br>Counters can be incremented by calling the stored procedure BEFORE the insert
+using syntax like:  call InterSystems.Sequences_GetNext("Name"), or using standard SQL,
+or part of an SQL select like:
+<br><br>select InterSystems.Sequences_GetNext(sequencename) from InterSystems.Sequences where Name='sequencename'
+<br>
+<br>Can also be queried as table InterSystems.Sequences, but that data is actually stored
+in ^InterSystems.Sequences. Note use of %CacheSqlStorage to speed incrementing.
+<br>
+<br> Note: to make the Sequences system-wide, simply map ^InterSystems.Sequences* to a
+common location
+ <br>
+	<br> Note: counter names are case-insensitive and force to uppercase on disk.
+<br><br> Merge of ideas by JSL and APC 09/2005
+]]></Description>
+<ClassType>persistent</ClassType>
+<SqlRowIdPrivate>1</SqlRowIdPrivate>
+<StorageStrategy>custom</StorageStrategy>
+<Super>%Persistent</Super>
+<TimeChanged>60172,44404.735854</TimeChanged>
+<TimeCreated>60137,56752.747989</TimeCreated>
+<ClassDefinitionError>0</ClassDefinitionError>
+
+<Index name="UniqueIndex1">
+<IdKey>1</IdKey>
+<PrimaryKey>1</PrimaryKey>
+<Properties>Name</Properties>
+<Unique>1</Unique>
+</Index>
+
+<Property name="Name">
+<Description>
+The name of the sequence or identity, forced to uppercase. Typically a tablename
+(MSSQL identities) or an Oracle-like Sequence name</Description>
+<Type>%String</Type>
+<Parameter name="MAXLEN" value="64"/>
+</Property>
+
+<Property name="Counter">
+<Description>
+Last assigned value for this Name. Initial </Description>
+<Type>%Integer</Type>
+<InitialExpression>0</InitialExpression>
+</Property>
+
+<Method name="GetNext">
+<Description>
+Returns an integer value with next assigned counter.</Description>
+<ClassMethod>1</ClassMethod>
+<FormalSpec>name:%String</FormalSpec>
+<ReturnType>%Integer</ReturnType>
+<SqlProc>1</SqlProc>
+<Implementation><![CDATA[ quit $increment(^InterSystems.Sequences($zcvt(name,"U")))  //force name to uppercase to be safe
+]]></Implementation>
+</Method>
+
+<Method name="Init">
+<Description>
+Hibernate procedure to intialise a sequence, but can be used at any time</Description>
+<ClassMethod>1</ClassMethod>
+<FormalSpec>SequenceName:%String</FormalSpec>
+<ReturnType>%Integer</ReturnType>
+<SqlProc>1</SqlProc>
+<Implementation><![CDATA[
+	set ^InterSystems.Sequences($zcvt(SequenceName,"U"))=0
+	quit 0
+]]></Implementation>
+</Method>
+
+<Method name="Drop">
+<Description>
+Hibernate procedure to kill a sequence, but can be used at any time</Description>
+<ClassMethod>1</ClassMethod>
+<FormalSpec>SequenceName:%String</FormalSpec>
+<ReturnType>%Integer</ReturnType>
+<SqlProc>1</SqlProc>
+<Implementation><![CDATA[
+	kill ^InterSystems.Sequences($zcvt(SequenceName,"U"))
+	quit 0
+]]></Implementation>
+</Method>
+
+<Storage name="custom">
+<Type>%CacheSQLStorage</Type>
+<StreamLocation>^InterSystems.SequencesS</StreamLocation>
+<Property name="Counter"/>
+<Property name="Name">
+<Selectivity>1</Selectivity>
+</Property>
+<SQLMap name="datamap">
+<Type>data</Type>
+<Global>^InterSystems.Sequences</Global>
+<Structure>delimited</Structure>
+<Subscript name="1">
+<Expression>{Name}</Expression>
+</Subscript>
+<Data name="Counter"/>
+</SQLMap>
+</Storage>
+</Class>
+<Checksum value="3603995477"/>
+</Export>

Modified: trunk/Hibernate3/src/org/hibernate/dialect/Cache71Dialect.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/dialect/Cache71Dialect.java	2006-11-11 05:13:01 UTC (rev 10784)
+++ trunk/Hibernate3/src/org/hibernate/dialect/Cache71Dialect.java	2006-11-13 12:53:18 UTC (rev 10785)
@@ -1,4 +1,4 @@
-//$Id:  $
+//$Id: $
 package org.hibernate.dialect;
 
 import java.sql.CallableStatement;
@@ -35,7 +35,6 @@
  * Cach&eacute; 2007.1 dialect. This class is required in order to use Hibernate with Intersystems Caché SQL.<br>
  * <br>
  * Compatible with Caché 2007.1.
- * Cache JDBC driver version ?.?.
  * <br>
  * <head>
  * <title>Cach&eacute; and Hibernate</title>
@@ -46,10 +45,7 @@
  * These setup instructions assume that both Cach&eacute; and Hibernate are installed and operational.
  * <br>
  * <h2>HIBERNATE DIRECTORIES AND FILES</h2>
- * InterSystems support for Hibernate 2.1.8 and Hibernate 3.0.5
- * requires different dialect files from those distributed with Hibernate 3.2.
- * Also Hibernate 2.1.8 has a different directory and Java package structure which is reflected in the InterSystems sources.
- * JBoss distributes the InterSystems Cache' dialect for Hibernate 3.2.
+ * 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.
@@ -78,7 +74,6 @@
  * Hibernate.  The next step depends on the location of your
  * CacheDB.jar depending on your version of Cach&eacute;.
  * <ol>
- * <li>Copy C:\CacheSys\dev\java\lib\CacheDB.jar to C:\Hibernate\lib\CacheDB.jar.</li>
  * <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:
@@ -99,18 +94,15 @@
  * <table cols=3 border cellpadding=5 cellspacing=0>
  * <tr>
  * <th>Property Name</th>
- * <th>Property Value 3.2</th>
- * <th>Property Value 2.1.8</th>
+ * <th>Property Value</th>
  * </tr>
  * <tr>
  * <td>hibernate.dialect</td>
  * <td>org.hibernate.dialect.Cache71Dialect</td>
- * <td>net.sf.hibernate.dialect.Cache50Dialect</td>
  * </tr>
  * <tr>
  * <td>hibernate.connection.driver_class</td>
  * <td>com.intersys.jdbc.CacheDriver</td>
- * <td>com.intersys.jdbc.CacheDriver</td>
  * </tr>
  * <tr>
  * <td>hibernate.connection.username</td>
@@ -125,7 +117,6 @@
  * <tr>
  * <td>hibernate.connection.url</td>
  * <td>jdbc:Cache://127.0.0.1:1972/USER</td>
- * <td>jdbc:Cache://127.0.0.1:1972/USER</td>
  * </tr>
  * </table>
  * <p/>
@@ -146,100 +137,24 @@
  * <br>
  * <p/>
  * <ol>
- * <li>
- * org.hibernate.dialect.Cache50Dialect (requires Cach&eacute;
- * 5.0 or above)
- * </li>
- * <p/>
- * <li>org.hibernate.dialect.Cache51Dialect (requires Cach&eacute; 5.1 or
- * above)</li>
- * <p/>
- * <li>org.hibernate.dialect.Cache51SequenceDialect (requires Cach&eacute; 5.1 or
- * above)</li>
- * <p/>
  * <li>org.hibernate.dialect.Cache71Dialect (requires Cach&eacute;
  * 2007.1 or above)</li>
  * <p/>
- * <li>org.hibernate.dialect.Cache71SequenceDialect (requires Cach&eacute;
- * 2007.1 or above)</li>
  * </ol>
- * <p/>
- * Setting up for Cach&eacute; 5.0 is similar except that the hibernate
- * dialect package is "org.hibernate.dialect.Cache50Dialect"
  * <br>
- * <h2>SETTING UP CACH&Eacute; DIALECT FROM INTERSYSTEMS SOURCES</h2>
- * <p/>
- * InterSystems provides source code for the Hibernate Dialect classes.
- * Therefore, you must first place the source code in the proper locations
- * and compile it into Java class files.
- * Doing this will eliminate possible version mismatches in the compiled Java code.
- * <p/>
- * To begin, unzip the InterSystems source into the PARENT directory of the location where you installed Hibernate.
- * The InterSystems zip file that contains InterSystems Hibernate support for
- * Hibernate 2.1.8 and Hibernate 3.0.5 already contains hibernate-2.1
- * and hibernate-3.0 in its directory structure.  This is why you must
- * unzip to the directory CONTAINING your Hibernate install directory.
- * <p/>
- * If you are using Hibernate 3.2, JBoss has already built the right JAR file for you.
- * If you are NOT using Hibernate 3.2, then you must do the following:
- * <p/>
- * <ol>
- * <li>In your Hibernate install directory, after the unzip we described above,
- * type the following:
- * <br>
- * <pre>
- *     build
- * </pre></li>
- * <li>Copy the JAR file to the proper place.
- * <p/>
- * For Hibernate 3.0.5, copy
- * <pre>
- * ..\hibernate\hibernate3.jar
- * </pre>
- * to the Hibernate install directory.
- * <p/>
- * For Hibernate 2.1.8, copy
- * <pre>
- *     ..\hibernate\hibernate.2jar
- * </pre>
- * to the Hibernate install directory.</li>
- * <p/>
- * <li>Test your installation by configuring etc\hibernate.properties for your Cach&eacute; database,
- * and then running the following:
- * <pre>
- *     build eg
- * </pre>
- * The build process reports its success or failure.  If you see,
- * <pre>
- *     BUILD FAILED
- * </pre>
- * please contact the
- * <a href="http://www.intersystems.com/support/cache-support.html">InterSystems Worldwide Response Center</A>
- * for assistance.
- * </li>
- * </ol>
- * <br>
  * <h2>SUPPORT FOR IDENTITY COLUMNS</h2>
- * Cach&eacute; 5.1 or later supports identity columns.  This includes Cache' 2007.1.  To cause
+ * Cach&eacute; 2007.1 or later supports identity columns.  For
  * Hibernate to use identity columns, specify "native" as the
- * generator.  Also make sure that
- * hibernate.jdbc.use_get_generated_keys is set to true, which is the
- * default.  In the Cache' 2007.1 release, with the
- * Cache71Dialect, you can set hibernate.jdbc.use_get_generated_keys to
- * false, and still use identity columns.
+ * generator.
  * <br>
  * <h2>SEQUENCE DIALECTS SUPPORT SEQUENCES</h2>
- * You do not have to use the sequence dialects with Cach&eacute;.
- * These are Cache50SequenceDialect, Cache51SequenceDialect and Cache71SequenceDialect.
- * But if you choose to use them, set them up as follows:
  * <p/>
  * To use Hibernate sequence support with Cach&eacute; in a namespace, you must FIRST load the following file into that namespace:
  * <pre>
  *     src\org\hibernate\dialect\CacheSequences.xml
  * </pre>
  * In your Hibernate mapping you can specify sequence use.
- * When you are using a Cache' sequence dialect, the type "native" maps to sequence.
- * <p/>
+ * <p>
  * For example, the following shows the use of a sequence generator in a Hibernate mapping:
  * <pre>
  *     &lt;id name="id" column="uid" type="long" unsaved-value="null"&gt;
@@ -255,47 +170,6 @@
  * getSelectSequenceNextValString() in the dialect.  If this happens
  * you will receive the error message: new MappingException( "Dialect
  * does not support sequences" ).
- * <h2>BIGINT SUPPORT</h2>
- * Cach&eacute; 5.1 and above supports BIGINT. 2007.1 supports BIGINT.
- * <p/>
- * Cach&eacute; 5.0.x does not have direct BIGINT support.
- * To imitate BIGINT support in Cache 5.0.x, in the SQL configuration,
- * remap %INTEGER as follows, to be used by Cach&eacute; 5.0.x  dialects:
- * <p/>
- * <pre>
- *     %Library.Integer(MAXVAL=99999999999999999999,MINVAL=-999999999999999999)
- * </pre>
- * <p/>
- * To change SQL settings:
- * <p/>
- * <ol>
- * <li>In Cach&eacute; 2007.1, use the System Management Portal.</li>
- * <p/>
- * <li>In Cach&eacute; 5.0, use the Configuration Manager.</li>
- * </ol>
- * <p/>
- * Set Cach&eacute; SQL to allow:
- * <p/>
- * <ol>
- * <li>delimited identifiers</li>
- * <li>drop of non-existent tables</li>
- * <li>drop of non-existent constraints</li>
- * </ol>
- * <p/>
- * <h2>HIBERNATE 2.1.8</h2>
- * Hibernate 2.1.8 requires different source files from InterSystems reflecting
- * the different directory and Java package structure of Hibernate 2.1.8.
- * Please contact
- * <a href="http://www.intersystems.com/support/cache-support.html">InterSystems Worldwide Response Center</A> (WRC)
- * for these source files if you need to use Hibernate 2.1.8.
- * <p/>
- * To run a Caché application with Hibernate 2.1.8, set the following flag when starting your JVM:
- * <pre>
- *      -Dhibernate.jdbc.use_streams_for_binary=false
- * </pre>
- * <p/>
- * In Hibernate 3.0.5, this flag is not necessary;
- * it is taken care of by the Cach&eacute; dialect itself.
  * <br>
  * <h2>HIBERNATE FILES ASSOCIATED WITH CACH&Eacute; DIALECT</h2>
  * The following files are associated with Cach&eacute; dialect:
@@ -308,87 +182,6 @@
  * <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.
- * <h2>Limitations</h2>
- * The following is a list of the currently known limitations of using Cache' with Hibernate. Please check with InterSystems on the latest status as these are server side issues.
- * <p/>
- * The following also lists known issues with running the full Hibernate regression tests against InterSystems Cache'.
- * <p/>
- * - Delete of self-referential foreign keys.
- * <p/>
- * We do not current support deletion of a table row when the table has a foreign key that references itself and the foreign key in the table row references that table row. (self-referential foreign keys)
- * <p/>
- * - Support for "SELECT FOR UPDATE."
- * <p/>
- * The default locking mode strategy for Cache' is Hibernate's UpdateLockingStrategy, which you use with Hibernate's versioning capability.
- * <p/>
- * To use Concurrency modes that requires other locking strategies you can subclass your Cache' dialect and define a locking strategy.
- * <p/>
- * Cache' does not currently support "SELECT FOR UPDATE."  While grammatically correct, it does no locking.
- * <p/>
- * In versions prior to 2007.1, there are limitations in support for outer joins (see Cache' documentation).
- * <p/>
- * For example, Cache' prior to 2007.1 does support "NOT NULL" clauses in the ON conditions.
- * <p/>
- * Cache' does not support using longvarbinary or longvarchar in a where clause.
- * <p/>
- * In Hibernate regression tests, Baz.hbm.xml, FooBar.hbm.xml, Glarch.hbm.xml and XY.hbm.xml have to be edited to replace "!" by BANG and "^" by CARET.  Our own identifier translation is not enough since Hibernate uses names containing these in its own mapping files and Hibernate (on the client-side) does not know about our server-side mapping.
- * <p/>
- * There are some tests that involve batch operations where the test
- * will succeed if you increase the size of the lock table from
- * 786432 (the default) to 1786432.  You can use the System Management
- * Portal in 2007.1 or the configuration manager in 5.0.X to increase the
- * size of the lock table.  This requirement of increasing the lock
- * table size is specific to running the Hibernate regression tests.
- * <p/>
- * Cache' fails tests that attempt to COUNT stream fields
- * <p/>
- * Here is an example of such an error message, SQL ERROR -37: Aggregate function COUNT not supported for Stream fields
- * <p/>
- * We fail on tests that use mappings like the following
- * <p/>
- * <pre>
- * 			&lt;property name="yob" formula="year(dob)"/&gt;
- * </pre>
- * and the error is:
- * <p/>
- * ERROR #359: User defined SQL Function 'SQLUSER.YEAR' does not exist
- * <p/>
- * If the mapping is changed to
- * <p/>
- * <pre>
- * 			&lt;property name="yob" formula="{fn year(dob)}"/&gt;
- * </pre>
- * then such tests succeed.
- * <p/>
- * Cache' 2007.1 supports temp tables.  Prior versions do not.
- * <p/>
- * We do not support row valued expression.  So WHERE clauses like "WHERE (a,b,c) = (d,e,f)" give syntax errors.  The Hibernate regression tests use row valued expressions and we fail on these.
- * <p/>
- * For example:
- * <p/>
- * <pre>
- * result = s.createQuery("from Transaction txn where txn.value = (1.5, 'AUD')").list();
- * </pre>
- * will not generate valid Cache' SQL because of the parenthesis around (1.5, 'AUD')
- * <p/>
- * Queries like the following:
- * <p/>
- * <pre>
- * session.createQuery("select extract(second from current_timestamp()), extract(minute from current_timestamp()), extract(hour from current_timestamp()) from Mammal m").list();
- * </pre>
- * <p/>
- * will not work, because we do support "extract" function.
- * <p/>
- * We do not support in () (empty parenthesis)
- * <p/>
- * We do not guarantee the case of a column returned using a group by clause.
- * <p/>
- * For instance in the regression test,
- * <p/>
- * <pre>
- * list = s.find("select new Result( baz.name, max(foo.long), count(foo) ) from Baz baz join baz.fooArray foo group by baz.name");
- * </pre>
- * we return baz.name in lower case, and the test that generates this SQL fails.
  *
  * @author Jonathan Levinson
  */
@@ -702,11 +495,11 @@
 	}
 
 	public String getSequenceNextValString(String sequenceName) {
-		return "select InterSystems.Sequences_GetNext('" + sequenceName + "') from InterSystems.Sequences where ucase(name)=ucase('" + sequenceName + "'))";
+		return "select InterSystems.Sequences_GetNext('" + sequenceName + "') from InterSystems.Sequences where ucase(name)=ucase('" + sequenceName + "')";
 	}
 
 	public String getSelectSequenceNextValString(String sequenceName) {
-		return "(select InterSystems.Sequences_GetNext('" + sequenceName + "') from InterSystems.Sequences where ucase(name)=ucase('" + sequenceName + "')))";
+		return "(select InterSystems.Sequences_GetNext('" + sequenceName + "') from InterSystems.Sequences where ucase(name)=ucase('" + sequenceName + "'))";
 	}
 
 	public String getCreateSequenceString(String sequenceName) {




More information about the hibernate-commits mailing list