From 7b1d1a1f3a2ff775c1ed846d3046d366bfa58d16 Mon Sep 17 00:00:00 2001 From: Pierrick Rouxel Date: Wed, 2 Jan 2019 23:34:14 +0100 Subject: [PATCH] HHH-12856 Add AS400V7R3Dialect as default for V7R3 of IBM i --- .../main/java/org/hibernate/dialect/Database.java | 13 +++++++++++-- .../dialect/resolver/DialectFactoryTest.java | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Database.java b/hibernate-core/src/main/java/org/hibernate/dialect/Database.java index 4cca9edc35..ca4bfef6e4 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Database.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Database.java @@ -47,7 +47,7 @@ public enum Database { DB2 { @Override public Class latestDialect() { - return DB2400Dialect.class; + return DB2400V7R3Dialect.class; } @Override @@ -55,9 +55,18 @@ public enum Database { final String databaseName = info.getDatabaseName(); if ( "DB2 UDB for AS/400".equals( databaseName ) ) { - return new DB2400Dialect(); + final int majorVersion = info.getDatabaseMajorVersion(); + final int minorVersion = info.getDatabaseMinorVersion(); + + if ( majorVersion > 7 || ( majorVersion == 7 && minorVersion >= 3 ) ) { + return latestDialectInstance( this ); + } + else { + return new DB2400Dialect(); + } } + if ( databaseName.startsWith( "DB2/" ) ) { return new DB2Dialect(); } diff --git a/hibernate-core/src/test/java/org/hibernate/dialect/resolver/DialectFactoryTest.java b/hibernate-core/src/test/java/org/hibernate/dialect/resolver/DialectFactoryTest.java index 8c75ba5ee2..7eaf8d8406 100644 --- a/hibernate-core/src/test/java/org/hibernate/dialect/resolver/DialectFactoryTest.java +++ b/hibernate-core/src/test/java/org/hibernate/dialect/resolver/DialectFactoryTest.java @@ -153,6 +153,7 @@ public class DialectFactoryTest extends BaseUnitTestCase { testDetermination( "DB2/LINUX390", DB2Dialect.class, resolver ); testDetermination( "DB2/AIX64", DB2Dialect.class, resolver ); testDetermination( "DB2 UDB for AS/400", DB2400Dialect.class, resolver ); + testDetermination( "DB2 UDB for AS/400", 7, 3, DB2400V7R3Dialect.class, resolver ); testDetermination( "Oracle", 8, Oracle8iDialect.class, resolver ); testDetermination( "Oracle", 9, Oracle9iDialect.class, resolver ); testDetermination( "Oracle", 10, Oracle10gDialect.class, resolver );