HHH-9570: Auto-detect SQL Server 2014

Copying a previous workaround for the same issue: https://github.com/hibernate/hibernate-orm/pull/395

- Previously, SQL Server version 12 (SQL Server 2014) was an unknown version, resulting in the SQLServerDialect
- Add version 12 to the switch statement so that SQLServer2012Dialect  is now returned by default, as SQL Server 2014 is much more similar to SQL Server 2012 than SQL Server 2000
- Add test case
- Add Oracle and SQL Server environments for testing purpose
This commit is contained in:
Gustavo Adolfo Rodríguez Libreros 2016-04-24 22:44:04 -05:00 committed by Vlad Mihalcea
parent 7ad1c59876
commit 01430c5be1
5 changed files with 26 additions and 2 deletions

View File

@ -142,6 +142,8 @@ subprojects { subProject ->
testRuntime( libraries.hsqldb )
testRuntime( libraries.postgresql )
testRuntime( libraries.mysql )
testRuntime( libraries.oracle )
testRuntime( libraries.mssql )
testRuntime( libraries.mariadb )
testRuntime( libraries.woodstox )

View File

@ -51,5 +51,19 @@ ext {
'jdbc.pass' : 'hibernate_orm_test',
'jdbc.url' : 'jdbc:postgresql:hibernate_orm_test'
],
oracle : [
'db.dialect' : 'org.hibernate.dialect.Oracle10gDialect',
'jdbc.driver': 'oracle.jdbc.driver.OracleDriver',
'jdbc.user' : 'hibernate_orm_test',
'jdbc.pass' : 'hibernate_orm_test',
'jdbc.url' : 'jdbc:oracle:thin:@localhost:1521/xe'
],
mssql : [
'db.dialect' : 'org.hibernate.dialect.SQLServer2012Dialect',
'jdbc.driver': 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
'jdbc.user' : 'hibernate_orm_test',
'jdbc.pass' : 'hibernate_orm_test',
'jdbc.url' : 'jdbc:sqlserver://localhost;instance=SQLEXPRESS;databaseName=hibernate_orm_test;user=sa;password=adm1n'
]
]
}

View File

@ -156,6 +156,7 @@ public class StandardDialectResolver implements DialectResolver {
case 10:
return new SQLServer2008Dialect();
case 11:
case 12:
return new SQLServer2012Dialect();
default:
LOG.unknownSqlServerVersion( majorVersion );

View File

@ -9,7 +9,6 @@ package org.hibernate.engine.jdbc.dialect.internal;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import org.hibernate.dialect.Dialect;
@ -18,8 +17,8 @@ import org.hibernate.dialect.PostgreSQL82Dialect;
import org.hibernate.dialect.PostgreSQL9Dialect;
import org.hibernate.dialect.SQLServer2005Dialect;
import org.hibernate.dialect.SQLServer2008Dialect;
import org.hibernate.dialect.SQLServer2012Dialect;
import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.dialect.resolver.DialectResolverTest;
import org.hibernate.dialect.resolver.TestingDialectResolutionInfo;
import org.hibernate.testing.junit4.BaseUnitTestCase;
@ -56,6 +55,12 @@ public class StandardDialectResolverTest extends BaseUnitTestCase {
runSQLServerDialectTest( 11, SQLServer2008Dialect.class );
}
@Test
public void testResolveDialectInternalForSQLServer2014()
throws SQLException {
runSQLServerDialectTest( 12, SQLServer2012Dialect.class );
}
@Test
public void testResolveDialectInternalForUnknownSQLServerVersion()
throws SQLException {

View File

@ -88,6 +88,8 @@ ext {
postgresql: 'org.postgresql:postgresql:9.4-1202-jdbc41',
mysql: 'mysql:mysql-connector-java:5.1.38',
mariadb: 'org.mariadb.jdbc:mariadb-java-client:1.1.7',
oracle: 'com.oracle.ojdbc:ojdbc7:12.1.0.2.0',
mssql: 'com.microsoft.sqlserver:sqljdbc4:4.0',
jboss_jta: "org.jboss.jbossts:jbossjta:4.16.4.Final",
xapool: "com.experlog:xapool:1.5.0",
mockito: 'org.mockito:mockito-core:1.9.0',