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

Unexpected (changed) behavior of @Temporal(TemporalType.DATE) columns

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.2.6
    • Fix Version/s: 4.2.7.SP1, 4.3.0.CR1
    • Component/s: hibernate-core
    • Labels:
      None
    • Environment:
      Java 7, user.timeZone "Europe/Berlin", MySQL with UTC timezone
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Requires Release Note:
      Affirmative
    • Last commented by a user?:
      true

      Description

      Hi there,

      first of all, thanks for your continuing work for hibernate.

      Hibernate 4.2.6 shows a new behavior regarding the handling of

      @Temporal(TemporalType.DATE)
      private Calendar refDate;

      columns.

      Prior to 4.2.6 the seems to be handled like:

      • Take the date from the database and treat it like midnight
      • Then convert it to the userTimezone

      Now it seems to bee

      • Take the date from the database and treat it like midnight
      • Then convert it to the userTimezone
      • Strip the time

      This results in a calendar with a very different value than before. Technically it's probably more correct, but apart from breaking stuff, it's quite a different and unexpected behavior than @Temporal(TemporalType.TIMESTAMP) columns.

      A result from 4.2.5 and prior for a date column with the value '2013-10-15' was
      // Hibernate 4.2.5
      // Tue Oct 15 02:00:00 CEST 2013
      that can be correctly converted to a Joda Local Date with forced UTC timezone using
      new LocalDate(foobar.getRefDate(), ISOChronology.getInstanceUTC())
      resulting in exactly 2013-10-15

      Now hibernate 4.2.6 returns:
      // Hibernate 4.2.6
      // Tue Oct 15 00:00:00 CEST 2013

      This is quite different date.

      I'd vote to restore the old way as it is consistent with the conversion in TIMESTAMP columns.

      At least the changed should have been in the release notes as it is very likely to break stuff.

      I've created a little test case. You'll need a mysql datebase hibernate_tests for it.

      https://github.com/michael-simons/possible_hibernate_426_bug_with_date

      Thanks in advance.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: