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

OffsetDateTime value changes after fetching the row from the database

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.0.5
    • Fix Version/s: 5.1.0, 5.0.8
    • Component/s: None
    • Labels:
      None
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

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

      Description

      I found this issue while investigating a reported bug for LocalDate on StackOverflow.

      Starting from this entity:

      @Entity(name = "OffsetDateTimeEvent")
      public static class OffsetDateTimeEvent {
      
          @Id
          private Long id;
      
          @NotNull
          @Column(name = "START_DATE", nullable = false)
          private OffsetDateTime startDate;
      }
      

      when running this logic:

      doInJPA(entityManager -> {
          OffsetDateTimeEvent event = new OffsetDateTimeEvent();
          event.id = 1L;
          event.startDate = OffsetDateTime.of(1, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC);
          entityManager.persist(event);
      });
      
      doInJPA(entityManager -> {
          OffsetDateTimeEvent event = entityManager.find(OffsetDateTimeEvent.class, 1L);
          assertEquals(OffsetDateTime.of(1, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC), event.startDate);
      });
      

      we get this assertion failure:

      java.lang.AssertionError: expected:<0001-01-01T00:00Z> but was:<0001-01-01T01:34:52+01:34:52>

      Test case will be added after I know the issue number.

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: