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
This commit is contained in:
Gavin King 2020-08-24 23:53:03 +02:00 committed by Andrea Boriero
parent ab5d350805
commit 9d33bc39fb
1 changed files with 18 additions and 0 deletions

View File

@ -67,6 +67,7 @@ public class H2Dialect extends Dialect {
private final LimitHandler limitHandler; private final LimitHandler limitHandler;
private final boolean cascadeConstraints; private final boolean cascadeConstraints;
private final boolean useLocalTime;
private final int version; private final int version;
@ -101,6 +102,8 @@ public class H2Dialect extends Dialect {
supportsTuplesInSubqueries = version >= 104198; supportsTuplesInSubqueries = version >= 104198;
// Prior to 1.4.200 the 'cascade' in 'drop table' was implicit // Prior to 1.4.200 the 'cascade' in 'drop table' was implicit
cascadeConstraints = version >= 104200; 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 ); getDefaultProperties().setProperty( AvailableSettings.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
// http://code.google.com/p/h2database/issues/detail?id=235 // http://code.google.com/p/h2database/issues/detail?id=235
@ -191,6 +194,21 @@ public class H2Dialect extends Dialect {
CommonFunctionFactory.rownum( queryEngine ); 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 @Override
public SqlAstTranslatorFactory getSqlAstTranslatorFactory() { public SqlAstTranslatorFactory getSqlAstTranslatorFactory() {
return new StandardSqlAstTranslatorFactory() { return new StandardSqlAstTranslatorFactory() {