From 2c55a1feb10ef57b370648ce1ba9f3b4edf0ab87 Mon Sep 17 00:00:00 2001 From: Jan Schatteman Date: Wed, 15 Feb 2023 21:19:37 +0100 Subject: [PATCH] HHH-16082 - Correction to the epoch extraction for DB2 Signed-off-by: Jan Schatteman --- .../src/main/java/org/hibernate/dialect/DB2Dialect.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/DB2Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/DB2Dialect.java index 9306dbfe16..e1b5a2b4ea 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/DB2Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/DB2Dialect.java @@ -1012,6 +1012,12 @@ public class DB2Dialect extends Dialect { return "dayofweek(?2)"; case QUARTER: return "quarter(?2)"; + case EPOCH: + if ( getDB2Version().isBefore( 11 ) ) { + return timestampdiffPattern( TemporalUnit.SECOND, TemporalType.TIMESTAMP, TemporalType.TIMESTAMP ) + .replace( "?2", "'1970-01-01 00:00:00'" ) + .replace( "?3", "?2" ); + } } return super.extractPattern( unit ); }