From 1a1604be2f0ad35d05d5ecac16aeaae8e4c9f4cd Mon Sep 17 00:00:00 2001 From: Jan Schatteman Date: Wed, 11 Oct 2023 22:39:09 +0200 Subject: [PATCH] HHH-17095 - Remove support for SQL Server versions older than 2012 Signed-off-by: Jan Schatteman --- .../dialect/CommunityDialectSelector.java | 2 + .../dialect/SQLServer2008Dialect.java | 5 +- .../dialect/CommunityDialectSelectorTest.java | 1 + .../dialect/SQLServer2008DialectTestCase.java | 92 ++++++++------- .../internal/DefaultDialectSelector.java | 4 +- .../hibernate/dialect/SQLServerDialect.java | 110 ++++++++---------- .../dialect/SQLServerSqlAstTranslator.java | 4 +- .../DefaultDialectSelectorTest.java | 1 + .../SqlServer2008SpatialDialect.java | 23 ---- 9 files changed, 104 insertions(+), 138 deletions(-) rename {hibernate-core/src/main/java/org/hibernate => hibernate-community-dialects/src/main/java/org/hibernate/community}/dialect/SQLServer2008Dialect.java (80%) rename {hibernate-core/src/test/java/org/hibernate/orm/test => hibernate-community-dialects/src/test/java/org/hibernate/community}/dialect/SQLServer2008DialectTestCase.java (94%) delete mode 100644 hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/sqlserver/SqlServer2008SpatialDialect.java diff --git a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/CommunityDialectSelector.java b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/CommunityDialectSelector.java index 1acf541a09..3810e5c9cd 100644 --- a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/CommunityDialectSelector.java +++ b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/CommunityDialectSelector.java @@ -94,6 +94,8 @@ public class CommunityDialectSelector implements DialectSelector { return SAPDBDialect.class; case "SQLServer2005": return SQLServer2005Dialect.class; + case "SQLServer2008": + return SQLServer2008Dialect.class; case "MaxDB": return MaxDBDialect.class; case "Sybase11": diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/SQLServer2008Dialect.java b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLServer2008Dialect.java similarity index 80% rename from hibernate-core/src/main/java/org/hibernate/dialect/SQLServer2008Dialect.java rename to hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLServer2008Dialect.java index d119d00400..51a1d43c26 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/SQLServer2008Dialect.java +++ b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLServer2008Dialect.java @@ -4,7 +4,10 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.dialect; +package org.hibernate.community.dialect; + +import org.hibernate.dialect.DatabaseVersion; +import org.hibernate.dialect.SQLServerDialect; /** * A dialect for Microsoft SQL Server 2008 with JDBC Driver 3.0 and above diff --git a/hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/CommunityDialectSelectorTest.java b/hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/CommunityDialectSelectorTest.java index 15b13b57dd..be9e6292c7 100644 --- a/hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/CommunityDialectSelectorTest.java +++ b/hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/CommunityDialectSelectorTest.java @@ -60,6 +60,7 @@ public class CommunityDialectSelectorTest { testDialectNamingResolution( SAPDBDialect.class ); testDialectNamingResolution( SQLServer2005Dialect.class ); + testDialectNamingResolution( SQLServer2008Dialect.class ); testDialectNamingResolution( SybaseAnywhereDialect.class ); testDialectNamingResolution( Sybase11Dialect.class ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/dialect/SQLServer2008DialectTestCase.java b/hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/SQLServer2008DialectTestCase.java similarity index 94% rename from hibernate-core/src/test/java/org/hibernate/orm/test/dialect/SQLServer2008DialectTestCase.java rename to hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/SQLServer2008DialectTestCase.java index 2dbea7f908..df19e5926c 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/dialect/SQLServer2008DialectTestCase.java +++ b/hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/SQLServer2008DialectTestCase.java @@ -4,17 +4,19 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.orm.test.dialect; +package org.hibernate.community.dialect; import java.util.Locale; import org.hibernate.LockMode; import org.hibernate.LockOptions; -import org.hibernate.dialect.SQLServerDialect; +import org.hibernate.community.dialect.SQLServerLegacyDialect; +import org.hibernate.dialect.DatabaseVersion; +import org.hibernate.dialect.Dialect; import org.hibernate.query.spi.Limit; -import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseUnitTestCase; +import org.hibernate.testing.orm.junit.JiraKey; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -29,11 +31,11 @@ import static org.junit.Assert.assertEquals; * @author Chris Cranford */ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { - private SQLServerDialect dialect; + private Dialect dialect; @Before public void setup() { - dialect = new SQLServerDialect(); + dialect = new SQLServerLegacyDialect( DatabaseVersion.make( 10 ) ); } @After @@ -53,7 +55,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-10736") + @JiraKey("HHH-10736") public void testGetLimitStringWithNewlineAfterSelect() { final String query = "select" + System.lineSeparator() + "* FROM Employee E WHERE E.firstName = :firstName"; assertEquals( @@ -64,7 +66,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-10736") + @JiraKey("HHH-10736") public void testGetLimitStringWithNewlineAfterSelectWithMultipleSpaces() { final String query = "select " + System.lineSeparator() + "* FROM Employee E WHERE E.firstName = :firstName"; assertEquals( @@ -75,7 +77,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-8507") + @JiraKey("HHH-8507") public void testGetLimitStringWithNewlineAfterColumnList() { final String query = "select E.fieldA,E.fieldB\r\nFROM Employee E WHERE E.firstName = :firstName"; assertEquals( @@ -88,7 +90,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-6950") + @JiraKey("HHH-6950") public void testGetLimitStringWithFromColumnName() { final String fromColumnNameSQL = "select persistent0_.rid as rid1688_, " + "persistent0_.deviationfromtarget as deviati16_1688_, " + // "from" character sequence as a part of the column name @@ -105,7 +107,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-8301") + @JiraKey("HHH-8301") public void testGetLimitStringAliasGeneration() { final String notAliasedSQL = "select column1, column2, column3, column4 from table1"; @@ -118,7 +120,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-10994") + @JiraKey("HHH-10994") public void testGetLimitStringAliasGenerationWithAliasesNoAs() { final String aliasedSQLNoAs = "select column1 c1, column c2, column c3, column c4 from table1"; assertEquals( @@ -130,7 +132,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-11352") + @JiraKey("HHH-11352") public void testPagingWithColumnNameStartingWithFrom() { final String sql = "select column1 c1, from_column c2 from table1"; assertEquals( "with query_ as (select row_.*,row_number() over (order by current_timestamp) as rownumber_ from (" + @@ -140,7 +142,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-7019") + @JiraKey("HHH-7019") public void testGetLimitStringWithSubselect() { final String subselectInSelectClauseSQL = "select persistent0_.id as col_0_0_, " + "(select max(persistent1_.acceptancedate) " + @@ -158,7 +160,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-11084") + @JiraKey("HHH-11084") public void testGetLimitStringWithSelectDistinctSubselect() { final String selectDistinctSubselectSQL = "select col0_.CONTENTID as CONTENT1_12_ " + "where col0_.CONTENTTYPE='PAGE' and (col0_.CONTENTID in " + @@ -173,7 +175,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-11084") + @JiraKey("HHH-11084") public void testGetLimitStringWithSelectDistinctSubselectNotFirst() { final String selectDistinctSubselectSQL = "select col0_.CONTENTID as CONTENT1_12_ FROM CONTEXT col0_ " + "where col0_.CONTENTTYPE='PAGE' and (col0_.CONTENTID in " + @@ -188,7 +190,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-6728") + @JiraKey("HHH-6728") public void testGetLimitStringCaseSensitive() { final String caseSensitiveSQL = "select persistent0_.id, persistent0_.uid AS tmp1, " + "(select case when persistent0_.name = 'Smith' then 'Neo' else persistent0_.id end) " + @@ -207,7 +209,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-6310") + @JiraKey("HHH-6310") public void testGetLimitStringDistinctWithinAggregation() { final String distinctInAggregateSQL = "select aggregate_function(distinct p.n) as f1 from table849752 p order by f1"; @@ -220,7 +222,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-10994") + @JiraKey("HHH-10994") public void testGetLimitStringDistinctWithinAggregationWithoutAlias() { final String distinctInAggregateSQL = "select aggregate_function(distinct p.n) from table849752 p order by f1"; @@ -233,7 +235,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-10994") + @JiraKey("HHH-10994") public void testGetLimitStringDistinctWithinAggregationWithAliasNoAs() { final String distinctInAggregateSQL = "select aggregate_function(distinct p.n) f1 from table849752 p order by f1"; @@ -246,7 +248,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-7370") + @JiraKey("HHH-7370") public void testGetLimitStringWithMaxOnly() { final String query = "select product2x0_.id as id0_, product2x0_.description as descript2_0_ " + "from Product2 product2x0_ order by product2x0_.id"; @@ -268,7 +270,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-7781") + @JiraKey("HHH-7781") public void testGetLimitStringWithCastOperator() { final String query = "select cast(lc302_doku6_.redniBrojStavke as varchar(255)) as col_0_0_, lc302_doku6_.dokumentiID as col_1_0_ " + "from LC302_Dokumenti lc302_doku6_ order by lc302_doku6_.dokumentiID DESC"; @@ -283,7 +285,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-10994") + @JiraKey("HHH-10994") public void testGetLimitStringWithCastOperatorWithAliasNoAs() { final String query = "select cast(lc302_doku6_.redniBrojStavke as varchar(255)) f1, lc302_doku6_.dokumentiID f2 " + "from LC302_Dokumenti lc302_doku6_ order by lc302_doku6_.dokumentiID DESC"; @@ -298,7 +300,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-10994") + @JiraKey("HHH-10994") public void testGetLimitStringWithCastOperatorWithoutAliases() { final String query = "select cast(lc302_doku6_.redniBrojStavke as varchar(255)), lc302_doku6_.dokumentiID " + "from LC302_Dokumenti lc302_doku6_ order by lc302_doku6_.dokumentiID DESC"; @@ -313,7 +315,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-8007") + @JiraKey("HHH-8007") public void testGetLimitStringSelectingMultipleColumnsFromSeveralTables() { final String query = "select t1.*, t2.* from tab1 t1, tab2 t2 where t1.ref = t2.ref order by t1.id desc"; @@ -326,7 +328,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-8007") + @JiraKey("HHH-8007") public void testGetLimitStringSelectingAllColumns() { final String query = "select * from tab1 t1, tab2 t2 where t1.ref = t2.ref order by t1.id desc"; @@ -339,7 +341,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-11145") + @JiraKey("HHH-11145") public void testGetLimitStringWithFromInColumnName() { final String query = "select [Created From Nonstock Item], field2 from table1"; @@ -351,7 +353,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-11145") + @JiraKey("HHH-11145") public void testGetLimitStringWithQuotedColumnNamesAndAlias() { final String query = "select [Created From Item] c1, field2 from table1"; @@ -363,7 +365,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-11145") + @JiraKey("HHH-11145") public void testGetLimitStringWithQuotedColumnNamesAndAliasWithAs() { final String query = "select [Created From Item] as c1, field2 from table1"; @@ -375,7 +377,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-11324") + @JiraKey("HHH-11324") public void testGetLimitStringWithSelectClauseNestedQueryUsingParenthesis() { final String query = "select t1.c1 as col_0_0, (select case when count(t2.c1)>0 then 'ADDED' else 'UNMODIFIED' end from table2 t2 WHERE (t2.c1 in (?))) as col_1_0 from table1 t1 WHERE 1=1 ORDER BY t1.c1 ASC"; @@ -388,7 +390,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-11650") + @JiraKey("HHH-11650") public void testGetLimitWithStringValueContainingParenthesis() { final String query = "select t1.c1 as col_0_0 FROM table1 t1 where t1.c1 = '(123' ORDER BY t1.c1 ASC"; @@ -400,7 +402,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-11324") + @JiraKey("HHH-11324") public void testGetLimitStringWithSelectClauseNestedQueryUsingParenthesisOnlyTop() { final String query = "select t1.c1 as col_0_0, (select case when count(t2.c1)>0 then 'ADDED' else 'UNMODIFIED' end from table2 t2 WHERE (t2.c1 in (?))) as col_1_0 from table1 t1 WHERE 1=1 ORDER BY t1.c1 ASC"; @@ -411,7 +413,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-8916") + @JiraKey("HHH-8916") public void testGetLimitStringUsingCTEQueryNoOffset() { Limit selection = toRowSelection( 0, 5 ); @@ -449,7 +451,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-8916") + @JiraKey("HHH-8916") public void testGetLimitStringUsingCTEQueryWithOffset() { Limit selection = toRowSelection( 1, 5 ); @@ -497,7 +499,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-9635") + @JiraKey("HHH-9635") public void testAppendLockHintReadPastLocking() { final String expectedLockHint = "tab1 with (updlock,rowlock,readpast)"; @@ -508,7 +510,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-9635") + @JiraKey("HHH-9635") public void testAppendLockHintReadPastLockingNoTimeOut() { final String expectedLockHint = "tab1 with (updlock,rowlock,readpast,nowait)"; @@ -520,7 +522,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-9635") + @JiraKey("HHH-9635") public void testAppendLockHintPessimisticRead() { final String expectedLockHint = "tab1 with (holdlock,rowlock)"; @@ -531,7 +533,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-9635") + @JiraKey("HHH-9635") public void testAppendLockHintPessimisticReadNoTimeOut() { final String expectedLockHint = "tab1 with (holdlock,rowlock,nowait)"; @@ -543,7 +545,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-9635") + @JiraKey("HHH-9635") public void testAppendLockHintWrite() { final String expectedLockHint = "tab1 with (updlock,holdlock,rowlock)"; @@ -554,7 +556,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-9635") + @JiraKey("HHH-9635") public void testAppendLockHintWriteWithNoTimeOut() { final String expectedLockHint = "tab1 with (updlock,holdlock,rowlock,nowait)"; @@ -567,7 +569,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-9635") + @JiraKey("HHH-9635") public void testAppendLockHintUpgradeNoWait() { final String expectedLockHint = "tab1 with (updlock,holdlock,rowlock,nowait)"; @@ -578,7 +580,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-9635") + @JiraKey("HHH-9635") public void testAppendLockHintUpgradeNoWaitNoTimeout() { final String expectedLockHint = "tab1 with (updlock,holdlock,rowlock,nowait)"; @@ -590,7 +592,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-9635") + @JiraKey("HHH-9635") public void testAppendLockHintUpgrade() { final String expectedLockHint = "tab1 with (updlock,holdlock,rowlock)"; @@ -601,7 +603,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-9635") + @JiraKey("HHH-9635") public void testAppendLockHintUpgradeNoTimeout() { final String expectedLockHint = "tab1 with (updlock,holdlock,rowlock,nowait)"; @@ -613,7 +615,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-9635") + @JiraKey("HHH-9635") public void testAppendLockHintPessimisticWrite() { final String expectedLockHint = "tab1 with (updlock,holdlock,rowlock)"; @@ -624,7 +626,7 @@ public class SQLServer2008DialectTestCase extends BaseUnitTestCase { } @Test - @TestForIssue(jiraKey = "HHH-9635") + @JiraKey("HHH-9635") public void testAppendLockHintPessimisticWriteNoTimeOut() { final String expectedLockHint = "tab1 with (updlock,holdlock,rowlock,nowait)"; diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/DefaultDialectSelector.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/DefaultDialectSelector.java index 722540379f..e04df7c728 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/DefaultDialectSelector.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/DefaultDialectSelector.java @@ -31,7 +31,6 @@ import org.hibernate.dialect.Oracle12cDialect; import org.hibernate.dialect.OracleDialect; import org.hibernate.dialect.PostgreSQLDialect; import org.hibernate.dialect.PostgresPlusDialect; -import org.hibernate.dialect.SQLServer2008Dialect; import org.hibernate.dialect.SQLServer2012Dialect; import org.hibernate.dialect.SQLServer2016Dialect; import org.hibernate.dialect.SQLServerDialect; @@ -124,9 +123,8 @@ public class DefaultDialectSelector implements DialectSelector { case "SQLServer": return SQLServerDialect.class; case "SQLServer2005": - return findCommunityDialect( name ); case "SQLServer2008": - return SQLServer2008Dialect.class; + return findCommunityDialect( name ); case "SQLServer2012": return SQLServer2012Dialect.class; case "SQLServer2016": diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java index e3fbd6284a..36f2aac602 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java @@ -117,7 +117,7 @@ import static org.hibernate.type.descriptor.DateTimeUtils.appendAsTimestampWithM * @author Gavin King */ public class SQLServerDialect extends AbstractTransactSQLDialect { - private final static DatabaseVersion MINIMUM_VERSION = DatabaseVersion.make( 10, 0 ); + private final static DatabaseVersion MINIMUM_VERSION = DatabaseVersion.make( 11, 0 ); /** * NOTE : 2100 is the documented limit supposedly - but in my testing, sending @@ -148,7 +148,7 @@ public class SQLServerDialect extends AbstractTransactSQLDialect { } private StandardSequenceExporter createSequenceExporter(DatabaseVersion version) { - return version.isSameOrAfter(11) ? new SqlServerSequenceExporter(this) : null; + return new SqlServerSequenceExporter(this); } @Override @@ -333,49 +333,48 @@ public class SQLServerDialect extends AbstractTransactSQLDialect { functionFactory.stddevPopSamp_stdevp(); functionFactory.varPopSamp_varp(); - if ( getVersion().isSameOrAfter( 11 ) ) { - functionContributions.getFunctionRegistry().register( - "format", - new SQLServerFormatEmulation( functionContributions.getTypeConfiguration() ) - ); + functionContributions.getFunctionRegistry().register( + "format", + new SQLServerFormatEmulation( functionContributions.getTypeConfiguration() ) + ); - //actually translate() was added in 2017 but - //it's not worth adding a new dialect for that! - functionFactory.translate(); + //actually translate() was added in 2017 but + //it's not worth adding a new dialect for that! + functionFactory.translate(); - functionFactory.median_percentileCont( true ); + functionFactory.median_percentileCont( true ); + + functionContributions.getFunctionRegistry().namedDescriptorBuilder( "datefromparts" ) + .setInvariantType( dateType ) + .setExactArgumentCount( 3 ) + .setParameterTypes(INTEGER) + .register(); + functionContributions.getFunctionRegistry().namedDescriptorBuilder( "timefromparts" ) + .setInvariantType( timeType ) + .setExactArgumentCount( 5 ) + .setParameterTypes(INTEGER) + .register(); + functionContributions.getFunctionRegistry().namedDescriptorBuilder( "smalldatetimefromparts" ) + .setInvariantType( timestampType ) + .setExactArgumentCount( 5 ) + .setParameterTypes(INTEGER) + .register(); + functionContributions.getFunctionRegistry().namedDescriptorBuilder( "datetimefromparts" ) + .setInvariantType( timestampType ) + .setExactArgumentCount( 7 ) + .setParameterTypes(INTEGER) + .register(); + functionContributions.getFunctionRegistry().namedDescriptorBuilder( "datetime2fromparts" ) + .setInvariantType( timestampType ) + .setExactArgumentCount( 8 ) + .setParameterTypes(INTEGER) + .register(); + functionContributions.getFunctionRegistry().namedDescriptorBuilder( "datetimeoffsetfromparts" ) + .setInvariantType( timestampType ) + .setExactArgumentCount( 10 ) + .setParameterTypes(INTEGER) + .register(); - functionContributions.getFunctionRegistry().namedDescriptorBuilder( "datefromparts" ) - .setInvariantType( dateType ) - .setExactArgumentCount( 3 ) - .setParameterTypes(INTEGER) - .register(); - functionContributions.getFunctionRegistry().namedDescriptorBuilder( "timefromparts" ) - .setInvariantType( timeType ) - .setExactArgumentCount( 5 ) - .setParameterTypes(INTEGER) - .register(); - functionContributions.getFunctionRegistry().namedDescriptorBuilder( "smalldatetimefromparts" ) - .setInvariantType( timestampType ) - .setExactArgumentCount( 5 ) - .setParameterTypes(INTEGER) - .register(); - functionContributions.getFunctionRegistry().namedDescriptorBuilder( "datetimefromparts" ) - .setInvariantType( timestampType ) - .setExactArgumentCount( 7 ) - .setParameterTypes(INTEGER) - .register(); - functionContributions.getFunctionRegistry().namedDescriptorBuilder( "datetime2fromparts" ) - .setInvariantType( timestampType ) - .setExactArgumentCount( 8 ) - .setParameterTypes(INTEGER) - .register(); - functionContributions.getFunctionRegistry().namedDescriptorBuilder( "datetimeoffsetfromparts" ) - .setInvariantType( timestampType ) - .setExactArgumentCount( 10 ) - .setParameterTypes(INTEGER) - .register(); - } functionFactory.windowFunctions(); functionFactory.inverseDistributionOrderedSetAggregates_windowEmulation(); functionFactory.hypotheticalOrderedSetAggregates_windowEmulation(); @@ -486,14 +485,7 @@ public class SQLServerDialect extends AbstractTransactSQLDialect { @Override public LimitHandler getLimitHandler() { - if ( getVersion().isSameOrAfter( 11 ) ) { - return SQLServer2012LimitHandler.INSTANCE; - } - else { - //this is a stateful class, don't cache - //it in the Dialect! - return new SQLServer2005LimitHandler(); - } + return SQLServer2012LimitHandler.INSTANCE; } @Override @@ -642,10 +634,7 @@ public class SQLServerDialect extends AbstractTransactSQLDialect { @Override public SequenceSupport getSequenceSupport() { - if ( getVersion().isBefore( 11 ) ) { - return NoSequenceSupport.INSTANCE; - } - else if ( getVersion().isSameOrAfter( 16 ) ) { + if ( getVersion().isSameOrAfter( 16 ) ) { return SQLServer16SequenceSupport.INSTANCE; } else { @@ -655,19 +644,12 @@ public class SQLServerDialect extends AbstractTransactSQLDialect { @Override public String getQuerySequencesString() { - return getVersion().isBefore( 11 ) - ? super.getQuerySequencesString() //null - // The upper-case name should work on both case-sensitive - // and case-insensitive collations. - : "select * from INFORMATION_SCHEMA.SEQUENCES"; + // The upper-case name should work on both case-sensitive and case-insensitive collations. + return "select * from INFORMATION_SCHEMA.SEQUENCES"; } @Override public String getQueryHintString(String sql, String hints) { - if ( getVersion().isBefore( 11 ) ) { - return super.getQueryHintString( sql, hints ); - } - final StringBuilder buffer = new StringBuilder( sql.length() + hints.length() + 12 ); @@ -714,7 +696,7 @@ public class SQLServerDialect extends AbstractTransactSQLDialect { @Override public boolean supportsFetchClause(FetchClauseType type) { - return getVersion().isSameOrAfter( 11 ); + return true; } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerSqlAstTranslator.java b/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerSqlAstTranslator.java index 893fa1ccc2..9fae16a627 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerSqlAstTranslator.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerSqlAstTranslator.java @@ -213,7 +213,7 @@ public class SQLServerSqlAstTranslator extends SqlAstTr if ( queryPart instanceof QueryGroup ) { // We can't use TOP for set operations if ( hasOffset || hasLimit ) { - if ( version.isBefore( 11 ) || !isRowsOnlyFetchClauseType( queryPart ) ) { + if ( !isRowsOnlyFetchClauseType( queryPart ) ) { return OffsetFetchClauseMode.EMULATED; } else { @@ -227,7 +227,7 @@ public class SQLServerSqlAstTranslator extends SqlAstTr if ( !hasOffset ) { return hasLimit ? OffsetFetchClauseMode.TOP_ONLY : null; } - else if ( version.isBefore( 11 ) || !isRowsOnlyFetchClauseType( queryPart ) ) { + else if ( !isRowsOnlyFetchClauseType( queryPart ) ) { return OffsetFetchClauseMode.EMULATED; } else if ( !queryPart.hasSortSpecifications() && ((QuerySpec) queryPart).getSelectClause().isDistinct() ) { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/strategyselectors/DefaultDialectSelectorTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/strategyselectors/DefaultDialectSelectorTest.java index c8309f5a56..b5341a81d8 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/strategyselectors/DefaultDialectSelectorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/strategyselectors/DefaultDialectSelectorTest.java @@ -12,6 +12,7 @@ import org.hibernate.community.dialect.DerbyTenSevenDialect; import org.hibernate.community.dialect.DerbyTenSixDialect; import org.hibernate.community.dialect.MySQL57Dialect; import org.hibernate.community.dialect.MySQL5Dialect; +import org.hibernate.community.dialect.SQLServer2008Dialect; import org.hibernate.dialect.*; import org.junit.jupiter.api.Test; diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/sqlserver/SqlServer2008SpatialDialect.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/sqlserver/SqlServer2008SpatialDialect.java deleted file mode 100644 index ef4046b73a..0000000000 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/sqlserver/SqlServer2008SpatialDialect.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ - -package org.hibernate.spatial.dialect.sqlserver; - - -import org.hibernate.dialect.SQLServer2008Dialect; -import org.hibernate.spatial.SpatialDialect; - -/** - * The SpatialDialect for Microsoft SQL Server (2008). - * - * @author Karel Maesen, Martin Steinwender. - * @deprecated A SpatialDialect is no longer required. Use the standard Dialect for this database. - */ -@Deprecated -public class SqlServer2008SpatialDialect extends SQLServer2008Dialect implements SpatialDialect { - -}