From 36d656399810493052b778a1b4aec5a4ce3fcef9 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Tue, 8 Nov 2016 18:53:48 -0600 Subject: [PATCH] HHH-11220 - Auto-detect SQL Server 2016 when the major version is 13 --- .../internal/StandardDialectResolver.java | 25 ++++++++++++++----- .../hibernate/internal/CoreMessageLogger.java | 4 +-- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/StandardDialectResolver.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/StandardDialectResolver.java index ffb5dd889e..ae838142d2 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/StandardDialectResolver.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/StandardDialectResolver.java @@ -149,19 +149,32 @@ public class StandardDialectResolver implements DialectResolver { final int majorVersion = info.getDatabaseMajorVersion(); switch ( majorVersion ) { - case 8: + case 8: { return new SQLServerDialect(); - case 9: + } + case 9: { return new SQLServer2005Dialect(); - case 10: + } + case 10: { return new SQLServer2008Dialect(); + } case 11: case 12: + case 13: { return new SQLServer2012Dialect(); - default: - LOG.unknownSqlServerVersion( majorVersion ); + } + default: { + if ( majorVersion < 8 ) { + LOG.unknownSqlServerVersion( majorVersion, SQLServerDialect.class ); + return new SQLServerDialect(); + } + else { + // assume `majorVersion > 13` + LOG.unknownSqlServerVersion( majorVersion, SQLServer2012Dialect.class ); + return new SQLServer2012Dialect(); + } + } } - return new SQLServerDialect(); } if ( "Sybase SQL Server".equals( databaseName ) || "Adaptive Server Enterprise".equals( databaseName ) ) { diff --git a/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java b/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java index 17cd1933d6..dd43bc2999 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java @@ -1339,8 +1339,8 @@ public interface CoreMessageLogger extends BasicLogger { void unknownOracleVersion(int databaseMajorVersion); @LogMessage(level = WARN) - @Message(value = "Unknown Microsoft SQL Server major version [%s] using SQL Server 2000 dialect", id = 385) - void unknownSqlServerVersion(int databaseMajorVersion); + @Message(value = "Unknown Microsoft SQL Server major version [%s] using [%s] dialect", id = 385) + void unknownSqlServerVersion(int databaseMajorVersion, Class dialectClass); @LogMessage(level = WARN) @Message(value = "ResultSet had no statement associated with it, but was not yet registered", id = 386)