From 60a8857e5895cd1258a4888061ff11734b3e5906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Thu, 14 Mar 2019 10:41:36 +0100 Subject: [PATCH 1/3] HHH-13266 Mark most databases as not supporting nanosecond-precision storage for timestamps At least PostgreSQL, Oracle, MySQL and HANA don't support it. --- .../org/hibernate/test/type/AbstractJavaTimeTypeTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/test/type/AbstractJavaTimeTypeTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/AbstractJavaTimeTypeTest.java index a2968470718f..0e9d38cefbda 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/type/AbstractJavaTimeTypeTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/AbstractJavaTimeTypeTest.java @@ -26,6 +26,7 @@ import org.hibernate.cfg.Configuration; import org.hibernate.dialect.Dialect; import org.hibernate.dialect.H2Dialect; +import org.hibernate.dialect.Oracle8iDialect; import org.hibernate.dialect.PostgreSQL81Dialect; import org.hibernate.type.descriptor.sql.SqlTypeDescriptor; @@ -255,8 +256,8 @@ public final S alsoTestRemappingsWithH2(Class Date: Thu, 14 Mar 2019 15:24:32 +0100 Subject: [PATCH 2/3] HHH-13266 Skip tests that involve timestamps before epoch with MySQL/Mariadb --- .../test/type/AbstractJavaTimeTypeTest.java | 15 +++++ .../org/hibernate/test/type/InstantTest.java | 33 +++++++---- .../hibernate/test/type/LocalDateTest.java | 28 ++++++---- .../test/type/LocalDateTimeTest.java | 29 ++++++---- .../hibernate/test/type/LocalTimeTest.java | 28 ++++++---- .../test/type/OffsetDateTimeTest.java | 40 +++++++------ .../hibernate/test/type/OffsetTimeTest.java | 28 ++++++---- .../test/type/ZonedDateTimeTest.java | 56 +++++++++++-------- 8 files changed, 165 insertions(+), 92 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/test/type/AbstractJavaTimeTypeTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/AbstractJavaTimeTypeTest.java index 0e9d38cefbda..1c83b62cc4e6 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/type/AbstractJavaTimeTypeTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/AbstractJavaTimeTypeTest.java @@ -19,6 +19,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; +import java.util.function.Consumer; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -26,6 +27,7 @@ import org.hibernate.cfg.Configuration; import org.hibernate.dialect.Dialect; import org.hibernate.dialect.H2Dialect; +import org.hibernate.dialect.MariaDB10Dialect; import org.hibernate.dialect.Oracle8iDialect; import org.hibernate.dialect.PostgreSQL81Dialect; import org.hibernate.type.descriptor.sql.SqlTypeDescriptor; @@ -246,6 +248,19 @@ protected AbstractParametersBuilder() { remappingDialectClasses.add( null ); // Always test without remapping } + public S skippedForDialects(List> dialectClasses, Consumer skippedIfDialectMatchesClasses) { + boolean skip = false; + for ( Class dialectClass : dialectClasses ) { + if ( dialectClass.isInstance( dialect ) ) { + skip = true; + } + } + if ( !skip ) { + skippedIfDialectMatchesClasses.accept( thisAsS() ); + } + return thisAsS(); + } + @SafeVarargs public final S alsoTestRemappingsWithH2(Class ... dialectClasses) { if ( dialect instanceof H2Dialect ) { diff --git a/hibernate-core/src/test/java/org/hibernate/test/type/InstantTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/InstantTest.java index 1bb7bb5f2dad..b88e8782b916 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/type/InstantTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/InstantTest.java @@ -15,12 +15,16 @@ import java.time.OffsetDateTime; import java.time.ZoneId; import java.time.ZoneOffset; +import java.util.Arrays; import java.util.List; import javax.persistence.Basic; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; +import org.hibernate.dialect.MariaDBDialect; +import org.hibernate.dialect.MySQLDialect; + import org.junit.runners.Parameterized; /** @@ -45,18 +49,23 @@ public static List data() { .add( 2017, 11, 6, 19, 19, 1, 0, ZONE_UTC_MINUS_8 ) .add( 2017, 11, 6, 19, 19, 1, 0, ZONE_PARIS ) .add( 2017, 11, 6, 19, 19, 1, 500, ZONE_PARIS ) - .add( 1970, 1, 1, 0, 0, 0, 0, ZONE_GMT ) - .add( 1900, 1, 1, 0, 0, 0, 0, ZONE_GMT ) - .add( 1900, 1, 1, 0, 0, 0, 0, ZONE_OSLO ) - .add( 1900, 1, 1, 0, 0, 0, 0, ZONE_PARIS ) - .add( 1900, 1, 2, 0, 9, 21, 0, ZONE_PARIS ) - .add( 1900, 1, 1, 0, 0, 0, 0, ZONE_AMSTERDAM ) - .add( 1900, 1, 2, 0, 19, 32, 0, ZONE_AMSTERDAM ) - // Affected by HHH-13266 (JDK-8061577) - .add( 1892, 1, 1, 0, 0, 0, 0, ZONE_OSLO ) - .add( 1899, 12, 31, 23, 59, 59, 999_999_999, ZONE_PARIS ) - .add( 1899, 12, 31, 23, 59, 59, 999_999_999, ZONE_AMSTERDAM ) - .add( 1600, 1, 1, 0, 0, 0, 0, ZONE_AMSTERDAM ) + .skippedForDialects( + // MySQL/Mariadb cannot store values equal to epoch exactly, or less, in a timestamp. + Arrays.asList( MySQLDialect.class, MariaDBDialect.class ), + b -> b + .add( 1970, 1, 1, 0, 0, 0, 0, ZONE_GMT ) + .add( 1900, 1, 1, 0, 0, 0, 0, ZONE_GMT ) + .add( 1900, 1, 1, 0, 0, 0, 0, ZONE_OSLO ) + .add( 1900, 1, 1, 0, 0, 0, 0, ZONE_PARIS ) + .add( 1900, 1, 2, 0, 9, 21, 0, ZONE_PARIS ) + .add( 1900, 1, 1, 0, 0, 0, 0, ZONE_AMSTERDAM ) + .add( 1900, 1, 2, 0, 19, 32, 0, ZONE_AMSTERDAM ) + // Affected by HHH-13266 (JDK-8061577) + .add( 1892, 1, 1, 0, 0, 0, 0, ZONE_OSLO ) + .add( 1899, 12, 31, 23, 59, 59, 999_999_999, ZONE_PARIS ) + .add( 1899, 12, 31, 23, 59, 59, 999_999_999, ZONE_AMSTERDAM ) + .add( 1600, 1, 1, 0, 0, 0, 0, ZONE_AMSTERDAM ) + ) .build(); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/type/LocalDateTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/LocalDateTest.java index e2176c2d8fb9..417636b875d4 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/type/LocalDateTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/LocalDateTest.java @@ -14,12 +14,15 @@ import java.sql.Types; import java.time.LocalDate; import java.time.ZoneId; +import java.util.Arrays; import java.util.List; import javax.persistence.Basic; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; +import org.hibernate.dialect.MariaDBDialect; +import org.hibernate.dialect.MySQLDialect; import org.hibernate.type.descriptor.sql.TimestampTypeDescriptor; import org.hibernate.testing.TestForIssue; @@ -44,16 +47,21 @@ public static List data() { // Not affected by HHH-13266 (JDK-8061577) .add( 2017, 11, 6, ZONE_UTC_MINUS_8 ) .add( 2017, 11, 6, ZONE_PARIS ) - .add( 1970, 1, 1, ZONE_GMT ) - .add( 1900, 1, 1, ZONE_GMT ) - .add( 1900, 1, 1, ZONE_OSLO ) - .add( 1900, 1, 2, ZONE_PARIS ) - .add( 1900, 1, 2, ZONE_AMSTERDAM ) - // Affected by HHH-13266 (JDK-8061577), but only when remapping dates as timestamps - .add( 1892, 1, 1, ZONE_OSLO ) - .add( 1900, 1, 1, ZONE_PARIS ) - .add( 1900, 1, 1, ZONE_AMSTERDAM ) - .add( 1600, 1, 1, ZONE_AMSTERDAM ) + .skippedForDialects( + // MySQL/Mariadb cannot store values equal to epoch exactly, or less, in a timestamp. + Arrays.asList( MySQLDialect.class, MariaDBDialect.class ), + b -> b + .add( 1970, 1, 1, ZONE_GMT ) + .add( 1900, 1, 1, ZONE_GMT ) + .add( 1900, 1, 1, ZONE_OSLO ) + .add( 1900, 1, 2, ZONE_PARIS ) + .add( 1900, 1, 2, ZONE_AMSTERDAM ) + // Affected by HHH-13266 (JDK-8061577), but only when remapping dates as timestamps + .add( 1892, 1, 1, ZONE_OSLO ) + .add( 1900, 1, 1, ZONE_PARIS ) + .add( 1900, 1, 1, ZONE_AMSTERDAM ) + .add( 1600, 1, 1, ZONE_AMSTERDAM ) + ) .build(); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/type/LocalDateTimeTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/LocalDateTimeTest.java index 877ab318c978..7224460f4b82 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/type/LocalDateTimeTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/LocalDateTimeTest.java @@ -12,12 +12,16 @@ import java.sql.Timestamp; import java.time.LocalDateTime; import java.time.ZoneId; +import java.util.Arrays; import java.util.List; import javax.persistence.Basic; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; +import org.hibernate.dialect.MariaDBDialect; +import org.hibernate.dialect.MySQLDialect; + import org.junit.runners.Parameterized; /** @@ -42,16 +46,21 @@ public static List data() { .add( 2017, 11, 6, 19, 19, 1, 0, ZONE_UTC_MINUS_8 ) .add( 2017, 11, 6, 19, 19, 1, 0, ZONE_PARIS ) .add( 2017, 11, 6, 19, 19, 1, 500, ZONE_PARIS ) - .add( 1970, 1, 1, 0, 0, 0, 0, ZONE_GMT ) - .add( 1900, 1, 1, 0, 0, 0, 0, ZONE_GMT ) - .add( 1900, 1, 1, 0, 0, 0, 0, ZONE_OSLO ) - .add( 1900, 1, 2, 0, 9, 21, 0, ZONE_PARIS ) - .add( 1900, 1, 2, 0, 19, 32, 0, ZONE_AMSTERDAM ) - // Affected by HHH-13266 (JDK-8061577) - .add( 1892, 1, 1, 0, 0, 0, 0, ZONE_OSLO ) - .add( 1900, 1, 1, 0, 9, 20, 0, ZONE_PARIS ) - .add( 1900, 1, 1, 0, 19, 31, 0, ZONE_AMSTERDAM ) - .add( 1600, 1, 1, 0, 0, 0, 0, ZONE_AMSTERDAM ) + .skippedForDialects( + // MySQL/Mariadb cannot store values equal to epoch exactly, or less, in a timestamp. + Arrays.asList( MySQLDialect.class, MariaDBDialect.class ), + b -> b + .add( 1970, 1, 1, 0, 0, 0, 0, ZONE_GMT ) + .add( 1900, 1, 1, 0, 0, 0, 0, ZONE_GMT ) + .add( 1900, 1, 1, 0, 0, 0, 0, ZONE_OSLO ) + .add( 1900, 1, 2, 0, 9, 21, 0, ZONE_PARIS ) + .add( 1900, 1, 2, 0, 19, 32, 0, ZONE_AMSTERDAM ) + // Affected by HHH-13266 (JDK-8061577) + .add( 1892, 1, 1, 0, 0, 0, 0, ZONE_OSLO ) + .add( 1900, 1, 1, 0, 9, 20, 0, ZONE_PARIS ) + .add( 1900, 1, 1, 0, 19, 31, 0, ZONE_AMSTERDAM ) + .add( 1600, 1, 1, 0, 0, 0, 0, ZONE_AMSTERDAM ) + ) .build(); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/type/LocalTimeTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/LocalTimeTest.java index 567865842741..64c3baa580c4 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/type/LocalTimeTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/LocalTimeTest.java @@ -14,12 +14,15 @@ import java.sql.Types; import java.time.LocalTime; import java.time.ZoneId; +import java.util.Arrays; import java.util.List; import javax.persistence.Basic; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; +import org.hibernate.dialect.MariaDBDialect; +import org.hibernate.dialect.MySQLDialect; import org.hibernate.type.descriptor.sql.TimestampTypeDescriptor; import org.junit.runners.Parameterized; @@ -59,18 +62,23 @@ public static List data() { .add( 19, 19, 1, 0, ZONE_UTC_MINUS_8 ) .add( 19, 19, 1, 0, ZONE_PARIS ) .add( 19, 19, 1, 500, ZONE_PARIS ) - .add( 0, 0, 0, 0, ZONE_GMT ) - .add( 0, 0, 0, 0, ZONE_OSLO ) .add( 0, 9, 20, 0, ZONE_PARIS ) .add( 0, 19, 31, 0, ZONE_AMSTERDAM ) - .add( 0, 0, 0, 0, ZONE_AMSTERDAM ) - .addPersistedWithoutHibernate( 1900, 1, 1, 0, 0, 0, 0, ZONE_OSLO ) - .addPersistedWithoutHibernate( 1900, 1, 2, 0, 9, 21, 0, ZONE_PARIS ) - .addPersistedWithoutHibernate( 1900, 1, 2, 0, 19, 32, 0, ZONE_AMSTERDAM ) - .addPersistedWithoutHibernate( 1892, 1, 1, 0, 0, 0, 0, ZONE_OSLO ) - .addPersistedWithoutHibernate( 1900, 1, 1, 0, 9, 20, 0, ZONE_PARIS ) - .addPersistedWithoutHibernate( 1900, 1, 1, 0, 19, 31, 0, ZONE_AMSTERDAM ) - .addPersistedWithoutHibernate( 1600, 1, 1, 0, 0, 0, 0, ZONE_AMSTERDAM ) + .skippedForDialects( + // MySQL/Mariadb cannot store values equal to epoch exactly, or less, in a timestamp. + Arrays.asList( MySQLDialect.class, MariaDBDialect.class ), + b -> b + .add( 0, 0, 0, 0, ZONE_GMT ) + .add( 0, 0, 0, 0, ZONE_OSLO ) + .add( 0, 0, 0, 0, ZONE_AMSTERDAM ) + .addPersistedWithoutHibernate( 1900, 1, 1, 0, 0, 0, 0, ZONE_OSLO ) + .addPersistedWithoutHibernate( 1900, 1, 2, 0, 9, 21, 0, ZONE_PARIS ) + .addPersistedWithoutHibernate( 1900, 1, 2, 0, 19, 32, 0, ZONE_AMSTERDAM ) + .addPersistedWithoutHibernate( 1892, 1, 1, 0, 0, 0, 0, ZONE_OSLO ) + .addPersistedWithoutHibernate( 1900, 1, 1, 0, 9, 20, 0, ZONE_PARIS ) + .addPersistedWithoutHibernate( 1900, 1, 1, 0, 19, 31, 0, ZONE_AMSTERDAM ) + .addPersistedWithoutHibernate( 1600, 1, 1, 0, 0, 0, 0, ZONE_AMSTERDAM ) + ) .build(); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/type/OffsetDateTimeTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/OffsetDateTimeTest.java index c61fe1d9b5a1..9926fea2f515 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/type/OffsetDateTimeTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/OffsetDateTimeTest.java @@ -14,6 +14,7 @@ import java.time.OffsetDateTime; import java.time.ZoneId; import java.time.ZoneOffset; +import java.util.Arrays; import java.util.List; import java.util.function.Consumer; import javax.persistence.Basic; @@ -22,6 +23,8 @@ import javax.persistence.Id; import org.hibernate.Query; +import org.hibernate.dialect.MariaDBDialect; +import org.hibernate.dialect.MySQLDialect; import org.hibernate.type.OffsetDateTimeType; import org.hibernate.testing.TestForIssue; @@ -68,22 +71,27 @@ public static List data() { .add( 2017, 11, 6, 19, 19, 1, 0, "-02:00", ZONE_PARIS ) .add( 2017, 11, 6, 19, 19, 1, 0, "-06:00", ZONE_PARIS ) .add( 2017, 11, 6, 19, 19, 1, 0, "-08:00", ZONE_PARIS ) - .add( 1970, 1, 1, 0, 0, 0, 0, "+01:00", ZONE_GMT ) - .add( 1970, 1, 1, 0, 0, 0, 0, "+00:00", ZONE_GMT ) - .add( 1970, 1, 1, 0, 0, 0, 0, "-01:00", ZONE_GMT ) - .add( 1900, 1, 1, 0, 0, 0, 0, "+01:00", ZONE_GMT ) - .add( 1900, 1, 1, 0, 0, 0, 0, "+00:00", ZONE_GMT ) - .add( 1900, 1, 1, 0, 0, 0, 0, "-01:00", ZONE_GMT ) - .add( 1900, 1, 1, 0, 0, 0, 0, "+00:00", ZONE_OSLO ) - .add( 1900, 1, 1, 0, 9, 21, 0, "+00:09:21", ZONE_PARIS ) - .add( 1900, 1, 1, 0, 19, 32, 0, "+00:19:32", ZONE_PARIS ) - .add( 1900, 1, 1, 0, 19, 32, 0, "+00:19:32", ZONE_AMSTERDAM ) - // Affected by HHH-13266 - .add( 1892, 1, 1, 0, 0, 0, 0, "+00:00", ZONE_OSLO ) - .add( 1900, 1, 1, 0, 9, 20, 0, "+00:09:21", ZONE_PARIS ) - .add( 1900, 1, 1, 0, 19, 31, 0, "+00:19:32", ZONE_PARIS ) - .add( 1900, 1, 1, 0, 19, 31, 0, "+00:19:32", ZONE_AMSTERDAM ) - .add( 1600, 1, 1, 0, 0, 0, 0, "+00:19:32", ZONE_AMSTERDAM ) + .skippedForDialects( + // MySQL/Mariadb cannot store values equal to epoch exactly, or less, in a timestamp. + Arrays.asList( MySQLDialect.class, MariaDBDialect.class ), + b -> b + .add( 1970, 1, 1, 0, 0, 0, 0, "+01:00", ZONE_GMT ) + .add( 1970, 1, 1, 0, 0, 0, 0, "+00:00", ZONE_GMT ) + .add( 1970, 1, 1, 0, 0, 0, 0, "-01:00", ZONE_GMT ) + .add( 1900, 1, 1, 0, 0, 0, 0, "+01:00", ZONE_GMT ) + .add( 1900, 1, 1, 0, 0, 0, 0, "+00:00", ZONE_GMT ) + .add( 1900, 1, 1, 0, 0, 0, 0, "-01:00", ZONE_GMT ) + .add( 1900, 1, 1, 0, 0, 0, 0, "+00:00", ZONE_OSLO ) + .add( 1900, 1, 1, 0, 9, 21, 0, "+00:09:21", ZONE_PARIS ) + .add( 1900, 1, 1, 0, 19, 32, 0, "+00:19:32", ZONE_PARIS ) + .add( 1900, 1, 1, 0, 19, 32, 0, "+00:19:32", ZONE_AMSTERDAM ) + // Affected by HHH-13266 + .add( 1892, 1, 1, 0, 0, 0, 0, "+00:00", ZONE_OSLO ) + .add( 1900, 1, 1, 0, 9, 20, 0, "+00:09:21", ZONE_PARIS ) + .add( 1900, 1, 1, 0, 19, 31, 0, "+00:19:32", ZONE_PARIS ) + .add( 1900, 1, 1, 0, 19, 31, 0, "+00:19:32", ZONE_AMSTERDAM ) + .add( 1600, 1, 1, 0, 0, 0, 0, "+00:19:32", ZONE_AMSTERDAM ) + ) .build(); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/type/OffsetTimeTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/OffsetTimeTest.java index 6f14192208da..448a74ea2921 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/type/OffsetTimeTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/OffsetTimeTest.java @@ -16,12 +16,15 @@ import java.time.OffsetTime; import java.time.ZoneId; import java.time.ZoneOffset; +import java.util.Arrays; import java.util.List; import javax.persistence.Basic; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; +import org.hibernate.dialect.MariaDBDialect; +import org.hibernate.dialect.MySQLDialect; import org.hibernate.type.descriptor.sql.BigIntTypeDescriptor; import org.hibernate.type.descriptor.sql.TimestampTypeDescriptor; @@ -66,19 +69,24 @@ public static List data() { .add( 19, 19, 1, 0, "+01:30", ZONE_PARIS ) .add( 19, 19, 1, 500, "+01:00", ZONE_PARIS ) .add( 19, 19, 1, 0, "-08:00", ZONE_PARIS ) - .add( 0, 0, 0, 0, "+01:00", ZONE_GMT ) - .add( 0, 0, 0, 0, "+00:00", ZONE_GMT ) - .add( 0, 0, 0, 0, "-01:00", ZONE_GMT ) - .add( 0, 0, 0, 0, "+00:00", ZONE_OSLO ) .add( 0, 9, 20, 0, "+00:09:21", ZONE_PARIS ) .add( 0, 19, 31, 0, "+00:19:32", ZONE_PARIS ) .add( 0, 19, 31, 0, "+00:19:32", ZONE_AMSTERDAM ) - .add( 0, 0, 0, 0, "+00:19:32", ZONE_AMSTERDAM ) - .addPersistedWithoutHibernate( 1892, 1, 1, 0, 0, 0, 0, "+00:00", ZONE_OSLO ) - .addPersistedWithoutHibernate( 1900, 1, 1, 0, 9, 20, 0, "+00:09:21", ZONE_PARIS ) - .addPersistedWithoutHibernate( 1900, 1, 1, 0, 19, 31, 0, "+00:19:32", ZONE_PARIS ) - .addPersistedWithoutHibernate( 1900, 1, 1, 0, 19, 31, 0, "+00:19:32", ZONE_AMSTERDAM ) - .addPersistedWithoutHibernate( 1600, 1, 1, 0, 0, 0, 0, "+00:19:32", ZONE_AMSTERDAM ) + .skippedForDialects( + // MySQL/Mariadb cannot store values equal to epoch exactly, or less, in a timestamp. + Arrays.asList( MySQLDialect.class, MariaDBDialect.class ), + b -> b + .add( 0, 0, 0, 0, "+01:00", ZONE_GMT ) + .add( 0, 0, 0, 0, "+00:00", ZONE_GMT ) + .add( 0, 0, 0, 0, "-01:00", ZONE_GMT ) + .add( 0, 0, 0, 0, "+00:00", ZONE_OSLO ) + .add( 0, 0, 0, 0, "+00:19:32", ZONE_AMSTERDAM ) + .addPersistedWithoutHibernate( 1892, 1, 1, 0, 0, 0, 0, "+00:00", ZONE_OSLO ) + .addPersistedWithoutHibernate( 1900, 1, 1, 0, 9, 20, 0, "+00:09:21", ZONE_PARIS ) + .addPersistedWithoutHibernate( 1900, 1, 1, 0, 19, 31, 0, "+00:19:32", ZONE_PARIS ) + .addPersistedWithoutHibernate( 1900, 1, 1, 0, 19, 31, 0, "+00:19:32", ZONE_AMSTERDAM ) + .addPersistedWithoutHibernate( 1600, 1, 1, 0, 0, 0, 0, "+00:19:32", ZONE_AMSTERDAM ) + ) .build(); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/type/ZonedDateTimeTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/ZonedDateTimeTest.java index 6621b9a85402..de7fe39ae080 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/type/ZonedDateTimeTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/ZonedDateTimeTest.java @@ -14,6 +14,7 @@ import java.time.ZoneId; import java.time.ZoneOffset; import java.time.ZonedDateTime; +import java.util.Arrays; import java.util.List; import java.util.function.Consumer; import javax.persistence.Basic; @@ -22,6 +23,8 @@ import javax.persistence.Id; import org.hibernate.Query; +import org.hibernate.dialect.MariaDBDialect; +import org.hibernate.dialect.MySQLDialect; import org.hibernate.type.ZonedDateTimeType; import org.hibernate.testing.TestForIssue; @@ -72,30 +75,35 @@ public static List data() { .add( 2017, 11, 6, 19, 19, 1, 0, "GMT-02:00", ZONE_PARIS ) .add( 2017, 11, 6, 19, 19, 1, 0, "GMT-06:00", ZONE_PARIS ) .add( 2017, 11, 6, 19, 19, 1, 0, "GMT-08:00", ZONE_PARIS ) - .add( 1970, 1, 1, 0, 0, 0, 0, "GMT+01:00", ZONE_GMT ) - .add( 1970, 1, 1, 0, 0, 0, 0, "GMT+00:00", ZONE_GMT ) - .add( 1970, 1, 1, 0, 0, 0, 0, "GMT-01:00", ZONE_GMT ) - .add( 1900, 1, 1, 0, 0, 0, 0, "GMT+01:00", ZONE_GMT ) - .add( 1900, 1, 1, 0, 0, 0, 0, "GMT+00:00", ZONE_GMT ) - .add( 1900, 1, 1, 0, 0, 0, 0, "GMT-01:00", ZONE_GMT ) - .add( 1900, 1, 1, 0, 0, 0, 0, "GMT+00:00", ZONE_OSLO ) - .add( 1900, 1, 1, 0, 9, 21, 0, "GMT+00:09:21", ZONE_PARIS ) - .add( 1900, 1, 1, 0, 9, 21, 0, "Europe/Paris", ZONE_PARIS ) - .add( 1900, 1, 1, 0, 19, 31, 0, "Europe/Paris", ZONE_PARIS ) - .add( 1900, 1, 1, 0, 19, 32, 0, "GMT+00:19:32", ZONE_PARIS ) - .add( 1900, 1, 1, 0, 19, 32, 0, "Europe/Amsterdam", ZONE_PARIS ) - .add( 1900, 1, 1, 0, 19, 32, 0, "GMT+00:19:32", ZONE_AMSTERDAM ) - .add( 1900, 1, 1, 0, 19, 32, 0, "Europe/Amsterdam", ZONE_AMSTERDAM ) - // Affected by HHH-13266 - .add( 1892, 1, 1, 0, 0, 0, 0, "GMT+00:00", ZONE_OSLO ) - .add( 1892, 1, 1, 0, 0, 0, 0, "Europe/Oslo", ZONE_OSLO ) - .add( 1900, 1, 1, 0, 9, 20, 0, "GMT+00:09:21", ZONE_PARIS ) - .add( 1900, 1, 1, 0, 9, 20, 0, "Europe/Paris", ZONE_PARIS ) - .add( 1900, 1, 1, 0, 19, 31, 0, "GMT+00:19:32", ZONE_PARIS ) - .add( 1900, 1, 1, 0, 19, 31, 0, "GMT+00:19:32", ZONE_AMSTERDAM ) - .add( 1900, 1, 1, 0, 19, 31, 0, "Europe/Amsterdam", ZONE_AMSTERDAM ) - .add( 1600, 1, 1, 0, 0, 0, 0, "GMT+00:19:32", ZONE_AMSTERDAM ) - .add( 1600, 1, 1, 0, 0, 0, 0, "Europe/Amsterdam", ZONE_AMSTERDAM ) + .skippedForDialects( + // MySQL/Mariadb cannot store values equal to epoch exactly, or less, in a timestamp. + Arrays.asList( MySQLDialect.class, MariaDBDialect.class ), + b -> b + .add( 1970, 1, 1, 0, 0, 0, 0, "GMT+01:00", ZONE_GMT ) + .add( 1970, 1, 1, 0, 0, 0, 0, "GMT+00:00", ZONE_GMT ) + .add( 1970, 1, 1, 0, 0, 0, 0, "GMT-01:00", ZONE_GMT ) + .add( 1900, 1, 1, 0, 0, 0, 0, "GMT+01:00", ZONE_GMT ) + .add( 1900, 1, 1, 0, 0, 0, 0, "GMT+00:00", ZONE_GMT ) + .add( 1900, 1, 1, 0, 0, 0, 0, "GMT-01:00", ZONE_GMT ) + .add( 1900, 1, 1, 0, 0, 0, 0, "GMT+00:00", ZONE_OSLO ) + .add( 1900, 1, 1, 0, 9, 21, 0, "GMT+00:09:21", ZONE_PARIS ) + .add( 1900, 1, 1, 0, 9, 21, 0, "Europe/Paris", ZONE_PARIS ) + .add( 1900, 1, 1, 0, 19, 31, 0, "Europe/Paris", ZONE_PARIS ) + .add( 1900, 1, 1, 0, 19, 32, 0, "GMT+00:19:32", ZONE_PARIS ) + .add( 1900, 1, 1, 0, 19, 32, 0, "Europe/Amsterdam", ZONE_PARIS ) + .add( 1900, 1, 1, 0, 19, 32, 0, "GMT+00:19:32", ZONE_AMSTERDAM ) + .add( 1900, 1, 1, 0, 19, 32, 0, "Europe/Amsterdam", ZONE_AMSTERDAM ) + // Affected by HHH-13266 + .add( 1892, 1, 1, 0, 0, 0, 0, "GMT+00:00", ZONE_OSLO ) + .add( 1892, 1, 1, 0, 0, 0, 0, "Europe/Oslo", ZONE_OSLO ) + .add( 1900, 1, 1, 0, 9, 20, 0, "GMT+00:09:21", ZONE_PARIS ) + .add( 1900, 1, 1, 0, 9, 20, 0, "Europe/Paris", ZONE_PARIS ) + .add( 1900, 1, 1, 0, 19, 31, 0, "GMT+00:19:32", ZONE_PARIS ) + .add( 1900, 1, 1, 0, 19, 31, 0, "GMT+00:19:32", ZONE_AMSTERDAM ) + .add( 1900, 1, 1, 0, 19, 31, 0, "Europe/Amsterdam", ZONE_AMSTERDAM ) + .add( 1600, 1, 1, 0, 0, 0, 0, "GMT+00:19:32", ZONE_AMSTERDAM ) + .add( 1600, 1, 1, 0, 0, 0, 0, "Europe/Amsterdam", ZONE_AMSTERDAM ) + ) .build(); } From bc832559e966b808cbf771e18a89c60f98fed2e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Thu, 14 Mar 2019 16:03:42 +0100 Subject: [PATCH 3/3] HHH-13266 Skip some tests that apparently trigger bugs in HANA --- .../java/org/hibernate/test/type/LocalDateTest.java | 3 +++ .../java/org/hibernate/test/type/LocalTimeTest.java | 10 ++++++++++ .../java/org/hibernate/test/type/OffsetTimeTest.java | 10 ++++++++++ 3 files changed, 23 insertions(+) diff --git a/hibernate-core/src/test/java/org/hibernate/test/type/LocalDateTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/LocalDateTest.java index 417636b875d4..8cf5dabc4ca2 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/type/LocalDateTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/LocalDateTest.java @@ -21,10 +21,12 @@ import javax.persistence.Entity; import javax.persistence.Id; +import org.hibernate.dialect.AbstractHANADialect; import org.hibernate.dialect.MariaDBDialect; import org.hibernate.dialect.MySQLDialect; import org.hibernate.type.descriptor.sql.TimestampTypeDescriptor; +import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.TestForIssue; import org.junit.runners.Parameterized; @@ -32,6 +34,7 @@ * Tests for storage of LocalDate properties. */ @TestForIssue(jiraKey = "HHH-10371") +@SkipForDialect(value = AbstractHANADialect.class, comment = "HANA systematically returns the wrong date when the JVM default timezone is not UTC") public class LocalDateTest extends AbstractJavaTimeTypeTest { private static class ParametersBuilder extends AbstractParametersBuilder { diff --git a/hibernate-core/src/test/java/org/hibernate/test/type/LocalTimeTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/LocalTimeTest.java index 64c3baa580c4..a7aa5628be8f 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/type/LocalTimeTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/LocalTimeTest.java @@ -21,10 +21,13 @@ import javax.persistence.Entity; import javax.persistence.Id; +import org.hibernate.dialect.AbstractHANADialect; import org.hibernate.dialect.MariaDBDialect; import org.hibernate.dialect.MySQLDialect; import org.hibernate.type.descriptor.sql.TimestampTypeDescriptor; +import org.hibernate.testing.SkipForDialect; +import org.junit.Test; import org.junit.runners.Parameterized; /** @@ -167,6 +170,13 @@ protected Object getActualJdbcValue(ResultSet resultSet, int columnIndex) throws return resultSet.getTimestamp( columnIndex ); } + @Override + @Test + @SkipForDialect(value = AbstractHANADialect.class, comment = "HANA seems to return a java.sql.Timestamp instead of a java.sql.Time") + public void writeThenNativeRead() { + super.writeThenNativeRead(); + } + @Entity(name = ENTITY_NAME) static final class EntityWithLocalTime { @Id diff --git a/hibernate-core/src/test/java/org/hibernate/test/type/OffsetTimeTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/OffsetTimeTest.java index 448a74ea2921..8a4203cbfc16 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/type/OffsetTimeTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/OffsetTimeTest.java @@ -23,11 +23,14 @@ import javax.persistence.Entity; import javax.persistence.Id; +import org.hibernate.dialect.AbstractHANADialect; import org.hibernate.dialect.MariaDBDialect; import org.hibernate.dialect.MySQLDialect; import org.hibernate.type.descriptor.sql.BigIntTypeDescriptor; import org.hibernate.type.descriptor.sql.TimestampTypeDescriptor; +import org.hibernate.testing.SkipForDialect; +import org.junit.Test; import org.junit.runners.Parameterized; /** @@ -178,6 +181,13 @@ protected Object getActualJdbcValue(ResultSet resultSet, int columnIndex) throws return resultSet.getTimestamp( columnIndex ); } + @Override + @Test + @SkipForDialect(value = AbstractHANADialect.class, comment = "HANA seems to return a java.sql.Timestamp instead of a java.sql.Time") + public void writeThenNativeRead() { + super.writeThenNativeRead(); + } + @Entity(name = ENTITY_NAME) static final class EntityWithOffsetTime { @Id