Hibernate SVN: r16644 - core/branches/Branch_3_3/core/src/main/java/org/hibernate/dialect.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-06-01 11:17:56 -0400 (Mon, 01 Jun 2009)
New Revision: 16644
Modified:
core/branches/Branch_3_3/core/src/main/java/org/hibernate/dialect/H2Dialect.java
Log:
HHH-3401 - H2 Database Dialect Fixes
Modified: core/branches/Branch_3_3/core/src/main/java/org/hibernate/dialect/H2Dialect.java
===================================================================
--- core/branches/Branch_3_3/core/src/main/java/org/hibernate/dialect/H2Dialect.java 2009-06-01 15:14:58 UTC (rev 16643)
+++ core/branches/Branch_3_3/core/src/main/java/org/hibernate/dialect/H2Dialect.java 2009-06-01 15:17:56 UTC (rev 16644)
@@ -20,7 +20,6 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.dialect;
@@ -40,30 +39,32 @@
* A dialect compatible with the H2 database.
*
* @author Thomas Mueller
- *
*/
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)
- }
+ 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");
- registerColumnType(Types.BIT, "bit");
+ registerColumnType(Types.BIT, "boolean");
registerColumnType(Types.CHAR, "char($l)");
registerColumnType(Types.DATE, "date");
registerColumnType(Types.DECIMAL, "decimal($p,$s)");
@@ -165,7 +166,7 @@
// registerFunction("minute", new StandardSQLFunction("minute", Hibernate.INTEGER));
// registerFunction("month", new StandardSQLFunction("month", Hibernate.INTEGER));
registerFunction("monthname", new StandardSQLFunction("monthname", Hibernate.STRING));
- registerFunction("quater", new StandardSQLFunction("quater", Hibernate.INTEGER));
+ registerFunction("quarter", new StandardSQLFunction("quarter", Hibernate.INTEGER));
// registerFunction("second", new StandardSQLFunction("second", Hibernate.INTEGER));
registerFunction("week", new StandardSQLFunction("week", Hibernate.INTEGER));
// registerFunction("year", new StandardSQLFunction("year", Hibernate.INTEGER));
@@ -215,10 +216,10 @@
}
public String getLimitString(String sql, boolean hasOffset) {
- return new StringBuffer(sql.length() + 20).
- append(sql).
- append(hasOffset ? " limit ? offset ?" : " limit ?").
- toString();
+ return new StringBuffer(sql.length() + 20)
+ .append(sql)
+ .append(hasOffset ? " limit ? offset ?" : " limit ?")
+ .toString();
}
public boolean bindLimitParametersInReverseOrder() {
@@ -266,29 +267,27 @@
}
private static ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
+ /**
+ * Extract the name of the violated constraint from the given SQLException.
+ *
+ * @param sqle The exception that was the result of the constraint violation.
+ * @return The extracted constraint name.
+ */
+ public String extractConstraintName(SQLException sqle) {
+ String constraintName = null;
+ // 23000: Check constraint violation: {0}
+ // 23001: Unique index or primary key violation: {0}
+ if ( sqle.getSQLState().startsWith( "23" ) ) {
+ final String message = sqle.getMessage();
+ final int idx = message.indexOf( "violation: " );
+ if ( idx > 0 ) {
+ constraintName = message.substring( idx + "violation: ".length() );
+ }
+ }
+ return constraintName;
+ }
+ };
- /**
- * Extract the name of the violated constraint from the given SQLException.
- *
- * @param sqle The exception that was the result of the constraint violation.
- * @return The extracted constraint name.
- */
- public String extractConstraintName(SQLException sqle) {
- String constraintName = null;
- // 23000: Check constraint violation: {0}
- // 23001: Unique index or primary key violation: {0}
- if(sqle.getSQLState().startsWith("23")) {
- String message = sqle.getMessage();
- int idx = message.indexOf("violation: ");
- if(idx > 0) {
- constraintName = message.substring(idx + "violation: ".length());
- }
- }
- return constraintName;
- }
-
- };
-
public boolean supportsTemporaryTables() {
return true;
}
@@ -319,4 +318,4 @@
public boolean supportsLobValueChangePropogation() {
return false;
}
-}
\ No newline at end of file
+}
15 years, 5 months
Hibernate SVN: r16643 - core/trunk/core/src/main/java/org/hibernate/dialect.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-06-01 11:14:58 -0400 (Mon, 01 Jun 2009)
New Revision: 16643
Modified:
core/trunk/core/src/main/java/org/hibernate/dialect/H2Dialect.java
Log:
HHH-3401 - H2 Database Dialect Fixes
Modified: core/trunk/core/src/main/java/org/hibernate/dialect/H2Dialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/H2Dialect.java 2009-05-31 23:41:31 UTC (rev 16642)
+++ core/trunk/core/src/main/java/org/hibernate/dialect/H2Dialect.java 2009-06-01 15:14:58 UTC (rev 16643)
@@ -20,7 +20,6 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.dialect;
@@ -40,30 +39,32 @@
* A dialect compatible with the H2 database.
*
* @author Thomas Mueller
- *
*/
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");
+
+ 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");
- registerColumnType(Types.BIT, "bit");
+ registerColumnType(Types.BIT, "boolean");
registerColumnType(Types.CHAR, "char($l)");
registerColumnType(Types.DATE, "date");
registerColumnType(Types.DECIMAL, "decimal($p,$s)");
@@ -165,7 +166,7 @@
// registerFunction("minute", new StandardSQLFunction("minute", Hibernate.INTEGER));
// registerFunction("month", new StandardSQLFunction("month", Hibernate.INTEGER));
registerFunction("monthname", new StandardSQLFunction("monthname", Hibernate.STRING));
- registerFunction("quater", new StandardSQLFunction("quater", Hibernate.INTEGER));
+ registerFunction("quarter", new StandardSQLFunction("quarter", Hibernate.INTEGER));
// registerFunction("second", new StandardSQLFunction("second", Hibernate.INTEGER));
registerFunction("week", new StandardSQLFunction("week", Hibernate.INTEGER));
// registerFunction("year", new StandardSQLFunction("year", Hibernate.INTEGER));
@@ -179,7 +180,6 @@
registerFunction("user", new NoArgSQLFunction("user", Hibernate.STRING));
getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
-
}
public String getAddColumnString() {
@@ -215,11 +215,11 @@
}
public String getLimitString(String sql, boolean hasOffset) {
- return new StringBuffer(sql.length() + 20).
- append(sql).
- append(hasOffset ? " limit ? offset ?" : " limit ?").
- toString();
- }
+ return new StringBuffer( sql.length() + 20 )
+ .append( sql )
+ .append( hasOffset ? " limit ? offset ?" : " limit ?" )
+ .toString();
+ }
public boolean bindLimitParametersInReverseOrder() {
return true;
@@ -266,7 +266,6 @@
}
private static ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
-
/**
* Extract the name of the violated constraint from the given SQLException.
*
@@ -274,19 +273,18 @@
* @return The extracted constraint name.
*/
public String extractConstraintName(SQLException sqle) {
- String constraintName = null;
- // 23000: Check constraint violation: {0}
- // 23001: Unique index or primary key violation: {0}
- if(sqle.getSQLState().startsWith("23")) {
- String message = sqle.getMessage();
- int idx = message.indexOf("violation: ");
- if(idx > 0) {
- constraintName = message.substring(idx + "violation: ".length());
- }
- }
- return constraintName;
+ String constraintName = null;
+ // 23000: Check constraint violation: {0}
+ // 23001: Unique index or primary key violation: {0}
+ if ( sqle.getSQLState().startsWith( "23" ) ) {
+ final String message = sqle.getMessage();
+ int idx = message.indexOf( "violation: " );
+ if ( idx > 0 ) {
+ constraintName = message.substring( idx + "violation: ".length() );
+ }
+ }
+ return constraintName;
}
-
};
public boolean supportsTemporaryTables() {
@@ -319,4 +317,4 @@
public boolean supportsLobValueChangePropogation() {
return false;
}
-}
\ No newline at end of file
+}
15 years, 5 months