From 9369fbd59781bc40e82c687deb571f33f37627bf Mon Sep 17 00:00:00 2001 From: Marco Belladelli Date: Wed, 4 Jan 2023 15:12:42 +0100 Subject: [PATCH] Fix date_trunc function for DB2 10 --- .../java/org/hibernate/community/dialect/DB2LegacyDialect.java | 3 ++- .../src/main/java/org/hibernate/dialect/DB2Dialect.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/DB2LegacyDialect.java b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/DB2LegacyDialect.java index 6df0c59ee6..da6d4a78e5 100644 --- a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/DB2LegacyDialect.java +++ b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/DB2LegacyDialect.java @@ -312,6 +312,7 @@ public class DB2LegacyDialect extends Dialect { functionFactory.stddevPopSamp(); functionFactory.varPopSamp(); functionFactory.varianceSamp(); + functionFactory.dateTrunc(); } else { // Before version 11, the position function required the use of the code units @@ -327,11 +328,11 @@ public class DB2LegacyDialect extends Dialect { functionFactory.stddevSamp_sumCount(); queryEngine.getSqmFunctionRegistry().registerAlternateKey( "var_pop", "variance" ); functionFactory.varSamp_sumCount(); + functionFactory.dateTrunc_trunc(); } functionFactory.addYearsMonthsDaysHoursMinutesSeconds(); functionFactory.yearsMonthsDaysHoursMinutesSecondsBetween(); - functionFactory.dateTrunc(); functionFactory.bitLength_pattern( "length(?1)*8" ); // DB2 wants parameter operands to be casted to allow lengths bigger than 255 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 292f972241..6782af42ad 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/DB2Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/DB2Dialect.java @@ -297,6 +297,7 @@ public class DB2Dialect extends Dialect { functionFactory.stddevPopSamp(); functionFactory.varPopSamp(); functionFactory.varianceSamp(); + functionFactory.dateTrunc(); } else { // Before version 11, the position function required the use of the code units @@ -312,11 +313,11 @@ public class DB2Dialect extends Dialect { functionFactory.stddevSamp_sumCount(); queryEngine.getSqmFunctionRegistry().registerAlternateKey( "var_pop", "variance" ); functionFactory.varSamp_sumCount(); + functionFactory.dateTrunc_trunc(); } functionFactory.addYearsMonthsDaysHoursMinutesSeconds(); functionFactory.yearsMonthsDaysHoursMinutesSecondsBetween(); - functionFactory.dateTrunc(); functionFactory.bitLength_pattern( "length(?1)*8" ); // DB2 wants parameter operands to be casted to allow lengths bigger than 255