HHH-3401 - H2 Database Dialect Fixes

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@16643 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Steve Ebersole 2009-06-01 15:14:58 +00:00
parent f0eb349e87
commit 409f2e8569
1 changed files with 36 additions and 38 deletions

View File

@ -20,7 +20,6 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*
*/
package org.hibernate.dialect;
@ -40,11 +39,11 @@ import org.hibernate.util.ReflectHelper;
* A dialect compatible with the H2 database.
*
* @author Thomas Mueller
*
*/
public class H2Dialect extends Dialect {
private String querySequenceString;
public H2Dialect() {
super();
@ -57,13 +56,15 @@ public class H2Dialect extends Dialect {
if ( buildid < 32 ) {
querySequenceString = "select name from information_schema.sequences";
}
} catch(Throwable e) {
}
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 @@ public class H2Dialect extends Dialect {
// 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 @@ public class H2Dialect extends Dialect {
registerFunction("user", new NoArgSQLFunction("user", Hibernate.STRING));
getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
}
public String getAddColumnString() {
@ -215,10 +215,10 @@ public class H2Dialect extends Dialect {
}
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,7 +266,6 @@ public class H2Dialect extends Dialect {
}
private static ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
/**
* Extract the name of the violated constraint from the given SQLException.
*
@ -278,7 +277,7 @@ public class H2Dialect extends Dialect {
// 23000: Check constraint violation: {0}
// 23001: Unique index or primary key violation: {0}
if ( sqle.getSQLState().startsWith( "23" ) ) {
String message = sqle.getMessage();
final String message = sqle.getMessage();
int idx = message.indexOf( "violation: " );
if ( idx > 0 ) {
constraintName = message.substring( idx + "violation: ".length() );
@ -286,7 +285,6 @@ public class H2Dialect extends Dialect {
}
return constraintName;
}
};
public boolean supportsTemporaryTables() {