Author: max.andersen(a)jboss.com
Date: 2007-01-19 10:42:10 -0500 (Fri, 19 Jan 2007)
New Revision: 11068
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/H2Dialect.java
Log:
HHH-2300 Updated dialect for H2 database engine
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/H2Dialect.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/H2Dialect.java 2007-01-19
15:14:43 UTC (rev 11067)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/H2Dialect.java 2007-01-19
15:42:10 UTC (rev 11068)
@@ -10,6 +10,7 @@
import org.hibernate.dialect.function.VarArgsSQLFunction;
import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
import org.hibernate.exception.ViolatedConstraintNameExtracter;
+import org.hibernate.util.ReflectHelper;
/**
* A dialect compatible with the H2 database.
@@ -19,9 +20,22 @@
*/
public class H2Dialect extends Dialect {
+ private String querySequenceString;
public H2Dialect() {
super();
-
+
+ querySequenceString = "select sequence_name from
information_schema.sequences";
+ try {
+ // HHH-2300
+ Class constants = ReflectHelper.classForName(
"org.h2.engine.Constants" );
+ Integer build = (Integer)constants.getDeclaredField("BUILD_ID"
).get(null);
+ int buildid = build.intValue();
+ if(buildid < 32) {
+ querySequenceString = "select name from
information_schema.sequences";
+ }
+ } catch(Throwable e) {
+ // ignore (probably H2 not in the classpath)
+ }
registerColumnType(Types.BOOLEAN, "boolean");
registerColumnType(Types.BIGINT, "bigint");
registerColumnType(Types.BINARY, "binary");
@@ -216,7 +230,7 @@
}
public String getQuerySequencesString() {
- return "select name from information_schema.sequences";
+ return querySequenceString;
}
public boolean supportsSequences() {