From a9fd8efe3363ddd141b8add965a5f725ab9ff05c Mon Sep 17 00:00:00 2001 From: Yanming Zhou Date: Fri, 14 Sep 2018 16:52:18 +0800 Subject: [PATCH] HHH-12977 - Update latest dialect for MySQL --- .../internal/StrategySelectorBuilder.java | 2 ++ .../main/java/org/hibernate/dialect/Database.java | 2 +- .../dialect/resolver/DialectFactoryTest.java | 2 +- .../internal/StandardDialectResolverTest.java | 15 +++++++++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java index 7d10f55545..e882125688 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java @@ -49,6 +49,7 @@ import org.hibernate.dialect.MckoiDialect; import org.hibernate.dialect.MimerSQLDialect; import org.hibernate.dialect.MySQL57Dialect; import org.hibernate.dialect.MySQL57InnoDBDialect; +import org.hibernate.dialect.MySQL8Dialect; import org.hibernate.dialect.MySQL5Dialect; import org.hibernate.dialect.MySQL5InnoDBDialect; import org.hibernate.dialect.Oracle10gDialect; @@ -223,6 +224,7 @@ public class StrategySelectorBuilder { addDialect( strategySelector, MySQL5InnoDBDialect.class ); addDialect( strategySelector, MySQL57InnoDBDialect.class ); addDialect( strategySelector, MySQL57Dialect.class ); + addDialect( strategySelector, MySQL8Dialect.class ); addDialect( strategySelector, Oracle8iDialect.class ); addDialect( strategySelector, Oracle9iDialect.class ); addDialect( strategySelector, Oracle10gDialect.class ); 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 f9db3a2d90..385662db9d 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Database.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Database.java @@ -324,7 +324,7 @@ public enum Database { MYSQL { @Override public Class latestDialect() { - return MySQL57Dialect.class; + return MySQL8Dialect.class; } @Override 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 be9fd60814..4d6714a968 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 @@ -113,7 +113,7 @@ public class DialectFactoryTest extends BaseUnitTestCase { testDetermination( "MySQL", 5, 5, MySQL55Dialect.class, resolver ); testDetermination( "MySQL", 5, 6, MySQL55Dialect.class, resolver ); testDetermination( "MySQL", 5, 7, MySQL57Dialect.class, resolver ); - testDetermination( "MySQL", 8, 0, MySQL57Dialect.class, resolver ); + testDetermination( "MySQL", 8, 0, MySQL8Dialect.class, resolver ); testDetermination( "MariaDB", "MariaDB connector/J", 10, 3, MariaDB103Dialect.class, resolver ); testDetermination( "MariaDB", "MariaDB connector/J", 10, 2, MariaDB102Dialect.class, resolver ); testDetermination( "MariaDB", "MariaDB connector/J", 10, 1, MariaDB10Dialect.class, resolver ); diff --git a/hibernate-core/src/test/java/org/hibernate/engine/jdbc/dialect/internal/StandardDialectResolverTest.java b/hibernate-core/src/test/java/org/hibernate/engine/jdbc/dialect/internal/StandardDialectResolverTest.java index b47971449d..61e59895dd 100644 --- a/hibernate-core/src/test/java/org/hibernate/engine/jdbc/dialect/internal/StandardDialectResolverTest.java +++ b/hibernate-core/src/test/java/org/hibernate/engine/jdbc/dialect/internal/StandardDialectResolverTest.java @@ -126,12 +126,27 @@ public class StandardDialectResolverTest extends BaseUnitTestCase { runMariaDBDialectTest( 5, 2, MariaDBDialect.class ); } + @Test + public void testResolveDialectInternalForMySQL57() throws SQLException { + runMySQLDialectTest( 5, 7, MySQL57Dialect.class ); + } + + @Test + public void testResolveDialectInternalForMySQL8() throws SQLException { + runMySQLDialectTest( 8, 0, MySQL8Dialect.class ); + } + private static void runMariaDBDialectTest( int majorVersion, int minorVersion, Class expectedDialect) throws SQLException { runDialectTest( "MariaDB", "MariaDB connector/J", majorVersion, minorVersion, expectedDialect ); } + private static void runMySQLDialectTest( + int majorVersion, int minorVersion, Class expectedDialect) + throws SQLException { + runDialectTest( "MySQL", "MySQL connector/J", majorVersion, minorVersion, expectedDialect ); + } private static void runSQLServerDialectTest( int version, Class expectedDialect)