From 25207092c2b6b0d18c8e5a77de72f545947ee349 Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Tue, 17 Dec 2024 17:53:02 +0100 Subject: [PATCH] HHH-18892 Respect DB2 hash functions only available since version 11+ --- .../src/main/java/org/hibernate/dialect/DB2Dialect.java | 6 ++++-- .../org/hibernate/orm/test/query/hql/FunctionTests.java | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) 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 694fa05dae..02b4255d56 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/DB2Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/DB2Dialect.java @@ -457,8 +457,10 @@ public class DB2Dialect extends Dialect { functionFactory.generateSeries_recursive( getMaximumSeriesSize(), false, true ); functionFactory.hex( "hex(?1)" ); - functionFactory.sha( "hash(?1, 2)" ); - functionFactory.md5( "hash(?1, 0)" ); + if ( getDB2Version().isSameOrAfter( 11 ) ) { + functionFactory.sha( "hash(?1, 2)" ); + functionFactory.md5( "hash(?1, 0)" ); + } } /** diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/FunctionTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/FunctionTests.java index 38bbebe181..e48d9e120d 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/FunctionTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/FunctionTests.java @@ -2612,7 +2612,7 @@ public class FunctionTests { @RequiresDialect(PostgreSQLDialect.class) @RequiresDialect(MySQLDialect.class) @RequiresDialect(OracleDialect.class) - @RequiresDialect(DB2Dialect.class) + @RequiresDialect(value = DB2Dialect.class, majorVersion = 11) @RequiresDialect(SQLServerDialect.class) @RequiresDialect(H2Dialect.class) @RequiresDialect(HANADialect.class)