From 405d80bd294b996972077d27ed178c05d9b4233e Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Tue, 30 Apr 2024 23:06:56 +0200 Subject: [PATCH] HHH-18043 Change SQL Server default timestamp precision to 7 --- .../community/dialect/SQLServerLegacyDialect.java | 11 +---------- .../java/org/hibernate/dialect/SQLServerDialect.java | 11 +---------- migration-guide.adoc | 3 ++- 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLServerLegacyDialect.java b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLServerLegacyDialect.java index f43a35a040..5e441106f4 100644 --- a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLServerLegacyDialect.java +++ b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLServerLegacyDialect.java @@ -812,18 +812,9 @@ public class SQLServerLegacyDialect extends AbstractTransactSQLDialect { }; } - /** - * SQL server supports up to 7 decimal digits of - * fractional second precision in a datetime2, - * but since its duration arithmetic functions - * try to fit durations into an int, - * which is impossible with such high precision, - * so default to generating {@code datetime2(3)} - * columns. - */ @Override public int getDefaultTimestampPrecision() { - return 6; //microseconds! + return 7; } @Override 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 1ecf96529d..feb6c45c0f 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java @@ -815,18 +815,9 @@ public class SQLServerDialect extends AbstractTransactSQLDialect { }; } - /** - * SQL server supports up to 7 decimal digits of - * fractional second precision in a datetime2, - * but since its duration arithmetic functions - * try to fit durations into an int, - * which is impossible with such high precision, - * so default to generating {@code datetime2(3)} - * columns. - */ @Override public int getDefaultTimestampPrecision() { - return 6; //microseconds! + return 7; } /** diff --git a/migration-guide.adoc b/migration-guide.adoc index ca0c08ee20..a9acaff418 100644 --- a/migration-guide.adoc +++ b/migration-guide.adoc @@ -132,9 +132,10 @@ String isDefault(); [[ddl-implicit-datatype-timestamp]] -== Default precision for Oracle timestamp +== Default precision for timestamp on some databases The default precision for Oracle timestamps was changed to 9 i.e. nanosecond precision. +The default precision for SQL Server timestamps was changed to 7 i.e. 100 nanosecond precision. [[todo]] == Todos (dev)