From 9d33bc39fb187bbfa666b6224b53007b425629cf Mon Sep 17 00:00:00 2001 From: Gavin King Date: Mon, 24 Aug 2020 23:53:03 +0200 Subject: [PATCH] prefer localtime, localtimestamp on H2 1.4.200 As suggested by @famod we need to use localtime instead or current_time because of changes in H2. See https://github.com/hibernate/hibernate-orm/pull/3412 --- .../java/org/hibernate/dialect/H2Dialect.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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() {