Skip to content

Commit

Permalink
Fix assertions in Hibernate ORM 5.6 compatibility tests
Browse files Browse the repository at this point in the history
Hibernate ORM 5.6 does not, in fact, preserve information for OffsetTime
columns. It just slaps the current JVM timezone on a stored LocalTime.

(cherry picked from commit bedb7b1)
  • Loading branch information
yrodiere authored and aloubyansky committed Oct 31, 2023
1 parent f5f88a8 commit e28b706
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public int run(String... args) {
checkEqual(createdEntity.duration, loadedEntity.duration);
checkEqual(createdEntity.uuid, loadedEntity.uuid);
checkEqual(createdEntity.instant, loadedEntity.instant);
checkEqual(createdEntity.offsetTime.withOffsetSameInstant(ZoneId.systemDefault().getRules().getOffset(Instant.now())),
checkEqual(createdEntity.offsetTime.toLocalTime().atOffset(ZoneId.systemDefault().getRules().getOffset(Instant.now())),
loadedEntity.offsetTime);
checkEqual(createdEntity.offsetDateTime.atZoneSameInstant(ZoneId.systemDefault()).toOffsetDateTime(),
loadedEntity.offsetDateTime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,8 @@ public void instant() {
public void offsetTime() {
assertThat(findOld().offsetTime)
.isEqualTo(LocalTime.of(12, 58, 30, 0)
.atOffset(ZoneOffset.ofHours(2))
// Hibernate ORM 5 used to normalize these values to the JVM TZ
.withOffsetSameInstant(ZoneId.systemDefault().getRules().getOffset(Instant.now())));
.atOffset(ZoneId.systemDefault().getRules().getOffset(Instant.now())));
}

// https://github.com/hibernate/hibernate-orm/blob/6.2/migration-guide.adoc#timezone-and-offset-storage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,8 @@ public void instant() {
public void offsetTime() {
assertThat(findOld().offsetTime)
.isEqualTo(LocalTime.of(12, 58, 30, 0)
.atOffset(ZoneOffset.ofHours(2))
// Hibernate ORM 5 used to normalize these values to the JVM TZ
.withOffsetSameInstant(ZoneId.systemDefault().getRules().getOffset(Instant.now())));
.atOffset(ZoneId.systemDefault().getRules().getOffset(Instant.now())));
}

// https://github.com/hibernate/hibernate-orm/blob/6.2/migration-guide.adoc#timezone-and-offset-storage
Expand Down

0 comments on commit e28b706

Please sign in to comment.