Uploaded image for project: 'Hibernate ORM'
  1. HHH-11621

Wrong ZonedDateTime value read near daylight savings time change

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Rejected
    • Affects Version/s: 5.0.12
    • Fix Version/s: None
    • Component/s: hibernate-core
    • Labels:
    • Environment:
      Hibernate 5.0.12
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true
    • Sprint:

      Description

      A ZonedDateTime entity attribute returns the wrong value when read from the database. This happens when the value is just before the changeover to daylight savings time in the Fall.

      The special timestamp of Germanys daylight saving in October 2017 "2017-10-29T02:00:00+02:00" is returned after read as follows:

      2017-10-29T02:00+01:00[Europe/Berlin] <- WRONG

      Attached is a simple maven project that can be used to reproduce this issue (a pre-build artifact is already contained in the archive).

      A README.md is included guiding through the steps needed...

      Note: the original description indicated that the bug only affected an attribute annotated with @Id. The attached test case (playground-prj.tar.gz) that executes a query that ends up loading entities with a ZonedDateTime attribute from the Session cache, so the ZonedDateTime values are not actually read from the database. If the cache is cleared before executing the query, then the incorrect value will be read.

      The output will be:

      10:31:35,094 INFO [org.jboss.jbaesner.playground.jpa.TimeTestStartupBean] (ServerService Thread Pool – 65) epoch[0]: 1509231600, instant: 2017-10-28T23:00:00Z, toString: 2017-10-29T01:00+02:00[Europe/Berlin], withZoneSameInstant: 2017-10-29T01:00+02:00[Europe/Berlin], offset: +02:00
      10:31:35,941 INFO [org.jboss.jbaesner.playground.jpa.TimeTestStartupBean] (ServerService Thread Pool – 65) epoch[1]: 1509235200, instant: 2017-10-29T00:00:00Z, toString: 2017-10-29T02:00+02:00[Europe/Berlin], withZoneSameInstant: 2017-10-29T02:00+02:00[Europe/Berlin], offset: +02:00
      10:31:35,944 INFO [org.jboss.jbaesner.playground.jpa.TimeTestStartupBean] (ServerService Thread Pool – 65) epoch[2]: 1509238800, instant: 2017-10-29T01:00:00Z, toString: 2017-10-29T02:00+01:00[Europe/Berlin], withZoneSameInstant: 2017-10-29T02:00+01:00[Europe/Berlin], offset: +01:00
      10:31:35,949 INFO [org.jboss.jbaesner.playground.jpa.TimeTestStartupBean] (ServerService Thread Pool – 65) ------------------------------------------------------------------------------------------------
      10:31:35,949 INFO [org.jboss.jbaesner.playground.jpa.TimeTestStartupBean] (ServerService Thread Pool – 65) – Now read with Id on Value –
      10:31:35,950 INFO [org.jboss.jbaesner.playground.jpa.TimeTestStartupBean] (ServerService Thread Pool – 65) – here all ZonedDateTimes are correct...
      10:31:35,950 INFO [org.jboss.jbaesner.playground.jpa.TimeTestStartupBean] (ServerService Thread Pool – 65) ------------------------------------------------------------------------------------------------
      10:31:36,050 INFO [org.hibernate.hql.internal.QueryTranslatorFactoryInitiator] (ServerService Thread Pool – 65) HHH000397: Using ASTQueryTranslatorFactory
      10:31:36,719 INFO [org.jboss.jbaesner.playground.jpa.TimeTestStartupBean] (ServerService Thread Pool – 65) epoch[0]: 1509231600, instant: 2017-10-28T23:00:00Z, toString: 2017-10-29T01:00+02:00[Europe/Berlin], withZoneSameInstant: 2017-10-29T01:00+02:00[Europe/Berlin], offset: +02:00
      10:31:36,720 INFO [org.jboss.jbaesner.playground.jpa.TimeTestStartupBean] (ServerService Thread Pool – 65) epoch[1]: 1509235200, instant: 2017-10-29T00:00:00Z, toString: 2017-10-29T02:00+02:00[Europe/Berlin], withZoneSameInstant: 2017-10-29T02:00+02:00[Europe/Berlin], offset: +02:00
      10:31:36,720 INFO [org.jboss.jbaesner.playground.jpa.TimeTestStartupBean] (ServerService Thread Pool – 65) epoch[2]: 1509238800, instant: 2017-10-29T01:00:00Z, toString: 2017-10-29T02:00+01:00[Europe/Berlin], withZoneSameInstant: 2017-10-29T02:00+01:00[Europe/Berlin], offset: +01:00
      10:31:36,720 INFO [org.jboss.jbaesner.playground.jpa.TimeTestStartupBean] (ServerService Thread Pool – 65) ------------------------------------------------------------------------------------------------
      10:31:36,720 INFO [org.jboss.jbaesner.playground.jpa.TimeTestStartupBean] (ServerService Thread Pool – 65) – Now read with Id on Timestamp –
      10:31:36,721 INFO [org.jboss.jbaesner.playground.jpa.TimeTestStartupBean] (ServerService Thread Pool – 65) – here the epoch[1] is wrong...
      10:31:36,721 INFO [org.jboss.jbaesner.playground.jpa.TimeTestStartupBean] (ServerService Thread Pool – 65) ------------------------------------------------------------------------------------------------
      10:31:36,736 INFO [org.jboss.jbaesner.playground.jpa.TimeTestStartupBean] (ServerService Thread Pool – 65) epoch[0]: 1509231600, instant: 2017-10-28T23:00:00Z, toString: 2017-10-29T01:00+02:00[Europe/Berlin], withZoneSameInstant: 2017-10-29T01:00+02:00[Europe/Berlin], offset: +02:00
      10:31:36,737 INFO [org.jboss.jbaesner.playground.jpa.TimeTestStartupBean] (ServerService Thread Pool – 65) epoch[1]: 1509238800, instant: 2017-10-29T01:00:00Z, toString: 2017-10-29T02:00+01:00[Europe/Berlin], withZoneSameInstant: 2017-10-29T02:00+01:00[Europe/Berlin], offset: +01:00
      10:31:36,738 INFO [org.jboss.jbaesner.playground.jpa.TimeTestStartupBean] (ServerService Thread Pool – 65) epoch[2]: 1509238800, instant: 2017-10-29T01:00:00Z, toString: 2017-10-29T02:00+01:00[Europe/Berlin], withZoneSameInstant: 2017-10-29T02:00+01:00[Europe/Berlin], offset: +01:00
      10:31:36,738 INFO [org.jboss.jbaesner.playground.jpa.TimeTestStartupBean] (ServerService Thread Pool – 65) ------------------------------------------------------------------------------------------------

        Attachments

          Issue links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: