diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java index 3e582f3a5d..ff5939a805 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java @@ -67,6 +67,7 @@ public class H2Dialect extends Dialect { private final LimitHandler limitHandler; private final boolean cascadeConstraints; + private final boolean useLocalTime; private final int version; @@ -101,6 +102,8 @@ public class H2Dialect extends Dialect { supportsTuplesInSubqueries = version >= 104198; // Prior to 1.4.200 the 'cascade' in 'drop table' was implicit cascadeConstraints = version >= 104200; + // 1.4.200 introduced changes in current_time and current_timestamp + useLocalTime = version >= 140199; getDefaultProperties().setProperty( AvailableSettings.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE ); // http://code.google.com/p/h2database/issues/detail?id=235 @@ -191,6 +194,21 @@ public class H2Dialect extends Dialect { CommonFunctionFactory.rownum( queryEngine ); } + @Override + public String currentTime() { + return useLocalTime ? "localtime" : super.currentTime(); + } + + @Override + public String currentTimestamp() { + return useLocalTime ? "localtimestamp" : super.currentTimestamp(); + } + + @Override + public String currentTimestampWithTimeZone() { + return "current_timestamp"; + } + @Override public SqlAstTranslatorFactory getSqlAstTranslatorFactory() { return new StandardSqlAstTranslatorFactory() {