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 0e9d38cefb..1c83b62cc4 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.ExecutionException; 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.AvailableSettings; 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 @@ abstract class AbstractJavaTimeTypeTest extends BaseCoreFunctionalTestCase 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 1bb7bb5f2d..b88e8782b9 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.LocalDateTime; 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 class InstantTest extends AbstractJavaTimeTypeTest 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 e2176c2d8f..417636b875 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.Timestamp; 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 class LocalDateTest extends AbstractJavaTimeTypeTest 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 877ab318c9..7224460f4b 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.SQLException; 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 class LocalDateTimeTest extends AbstractJavaTimeTypeTest 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 5678658427..64c3baa580 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.Timestamp; 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 class LocalTimeTest extends AbstractJavaTimeTypeTest 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 c61fe1d9b5..9926fea2f5 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.LocalDateTime; 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.Entity; 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 class OffsetDateTimeTest extends AbstractJavaTimeTypeTest 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 6f14192208..448a74ea29 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.OffsetDateTime; 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 class OffsetTimeTest extends AbstractJavaTimeTypeTest 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 6621b9a854..de7fe39ae0 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.LocalDateTime; 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.Entity; 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 class ZonedDateTimeTest extends AbstractJavaTimeTypeTest 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(); }