Hibernate 7 Date and Time Mapping: Instant vs LocalDateTime vs OffsetDateTime (What Round-Trips)
One moment written into every java.time column on Hibernate 7.4.14, read back across two JVM time zones on H2 and PostgreSQL 17: Instant always round-trips, LocalDateTime keeps the wall clock (but a DST-gap time moves an hour), OffsetDateTime loses its offset on PostgreSQL, ZonedDateTime never gets its region back, and @TimeZoneStorage NORMALIZE silently shifts the instant. Plus a decision table and what the Hibernate 8.0.0.Beta4 default flip of java_time_use_direct_jdbc changes (beta, labelled as such).
Which Java type should hold a timestamp in Hibernate 7 — Instant, LocalDateTime or OffsetDateTime — and what do you actually get back after you save it and read it in another process? Most answers describe the mapping tables. This one ran the round trips: one moment written into every column, read back in a new session, then read again by a JVM with a different default time zone, on H2 and on a real PostgreSQL 17 in Docker. Short version: Instant always returns the same moment, LocalDateTime returns the same wall clock but is not a moment, OffsetDateTime returns the same moment but PostgreSQL forgets its offset, and ZonedDateTime never gets its region back.
Verified against. Hibernate ORM 7.4.14.Final (latest 7.x GA on Maven Central on 2026-10-28), Jakarta Persistence 3.2.0, Java 25 (Temurin 25.0.5), H2 2.5.252, PostgreSQL 17.11 (postgres:17-alpine) with pgjdbc 42.7.14, HSQLDB 2.7.4 for one comparison. The Hibernate 8 note uses 8.0.0.Beta4, published 2026-10-28, which is a beta: its behaviour can change before 8.0 final. Every console block below is copied verbatim from a file in the date-time module of the companion repository, regenerated by one script.
The decision table: what round-trips
Everything below is read off the transcripts in the sections that follow. “Same moment” means the value read back is the same point on the time line; “offset” and “region” mean the +05:30 and the Europe/Paris parts. Results are identical in JVM zones Asia/Kolkata and America/New_York unless a cell says otherwise.
Java type
Column Hibernate creates (H2 / PostgreSQL)
Same moment back?
Offset back?
Region back?
Use it for
Instant
timestamp with time zone on both
Yes, in any JVM zone
n/a
n/a
“When did it happen”: audit, created-at, events
LocalDateTime
timestamp / timestamp without time zone
No such thing: it is not a moment. The wall clock comes back unchanged
n/a
n/a
A schedule in a known zone (“opens 09:00”). In a JVM whose zone has DST, a time inside the spring-forward gap is moved by an hour on Hibernate 7
OffsetDateTime (default)
timestamp with time zone on both
Yes
H2: yes. PostgreSQL: no, comes back as UTC
n/a
A moment you must show with the offset it was captured in, on H2-like storage only
OffsetDateTime + @TimeZoneStorage(COLUMN)
timestamptz plus an integer offset column
Yes
Yes, on both
n/a
A moment plus the offset it was captured in, on any database
OffsetDateTime + NORMALIZE_UTC
timestamptz
Yes
Always UTC
n/a
Same as the default, spelled out
OffsetDateTime + NORMALIZE
timestamp without time zone
Only if the reading JVM has the same default zone as the writing JVM
The reader’s
n/a
Avoid
ZonedDateTime (default or COLUMN)
timestamptz (+ offset column for COLUMN)
Yes
Default: H2 yes, PostgreSQL UTC. COLUMN: yes
Never: Europe/Paris comes back as +02:00 or Z
Only if you store the region name yourself in a second column
The rest of the page explains each row, starts from the smallest model that makes the table obvious, and ends with what changes in Hibernate 8. Go straight to the Hibernate 8 note if that is why you are here.
Start here: a moment, a wall clock, and the zone between them
Two different things hide behind the word “timestamp”. A moment is a point on the one global time line: “the order was placed at 08:30 UTC”. Everyone, everywhere, agrees on it. A wall clock is what a clock on a wall shows: “14:00”. It is only a moment once you say whose wall. Instant, OffsetDateTime and ZonedDateTime are moments; LocalDateTime is a wall clock.
The picture shows the same moment written three ways, plus the wall clock that is a moment only in Kolkata. That framing answers most questions in advance: if you need to compare, sort, or compute durations between two events, you need a moment, so not LocalDateTime. If you only need to show or schedule a wall clock in a place you already know, a moment type adds nothing.
The JVM gets a vote too. Every Java process has a default time zone (-Duser.timezone, or the machine’s). Several Hibernate paths consult it, which is why the tests here run in two JVM zones: Asia/Kolkata (+05:30, no daylight saving) and America/New_York (daylight saving). A container that starts with a different zone than your laptop is the usual way this goes wrong.
Going deeper: why the tests are built this way
One entity, Event.java, has a column for each mapping. The test RoundTripTest.java writes the same moment into all of them, then reads the row in a new session (so nothing comes from the first-level cache) and also runs a plain-JDBC select cast(col as varchar) to show what another tool would see. The cross-zone runs are two separate JVMs: -Ddt.phase=write in one zone, then -Ddt.phase=read in the other, against the same database. run-all.sh runs the whole matrix: two databases, two zones, same-JVM and cross-zone, then Hibernate 7 with the direct-JDBC flag on, then the Hibernate 8 beta. The tests assert the same facts that they print, so a result in this post that stops being true fails the build.
Module README with the version table and an index of every output file
Mapping needs no annotation for the common cases. Hibernate picks a column type from the Java type, so a java.time field is just a field:
/** A point on the UTC time line. */
@Column(name = "instant_col")
private Instant instant;
/** A calendar date and wall-clock time with no zone and no offset. */
@Column(name = "ldt_col")
private LocalDateTime localDateTime;
/** Hibernate's default storage for OffsetDateTime (dialect-derived, see 05-ddl). */
@Column(name = "odt_default_col")
private OffsetDateTime offsetDefault;
@TimeZoneStorage(TimeZoneStorageType.NATIVE)
@Column(name = "odt_native_col")
private OffsetDateTime offsetNative;
@TimeZoneStorage(TimeZoneStorageType.NORMALIZE)
@Column(name = "odt_normalize_col")
private OffsetDateTime offsetNormalize;
@TimeZoneStorage(TimeZoneStorageType.NORMALIZE_UTC)
@Column(name = "odt_normalize_utc_col")
private OffsetDateTime offsetNormalizeUtc;
@TimeZoneStorage(TimeZoneStorageType.COLUMN)
@TimeZoneColumn(name = "odt_column_col_offset")
@Column(name = "odt_column_col")
private OffsetDateTime offsetColumn;
That excerpt is from Event.java. The first three fields have no storage annotation at all. The four OffsetDateTime fields below them differ only in their @TimeZoneStorage, which is how the table above compares the modes against the same input. Written in a JVM whose zone is Asia/Kolkata and read back in a new session on H2 (from 01-roundtrip-h2-Asia_Kolkata-same-jvm-h7.txt):
# 01-roundtrip (same-jvm)
# Hibernate ORM 7.4.14.Final, JDK 25, database H2 2.5.252 (2026-09-23), JVM default zone Asia/Kolkata, java_time_use_direct_jdbc false (default)
# written: Instant 2026-06-15T08:30:00Z, LocalDateTime 2026-06-15T14:00, OffsetDateTime 2026-06-15T14:00+05:30 (all the same moment; the LocalDateTime is the Kolkata wall clock)
Instant out 2026-06-15T08:30:00Z | equals true | same instant true | raw 2026-06-15 08:30:00+00
LocalDateTime out 2026-06-15T14:00 | equals true | same instant n/a | raw 2026-06-15 14:00:00
OffsetDateTime default out 2026-06-15T14:00+05:30 | equals true | same instant true | raw 2026-06-15 14:00:00+05:30
OffsetDateTime NATIVE out 2026-06-15T14:00+05:30 | equals true | same instant true | raw 2026-06-15 14:00:00+05:30
OffsetDateTime NORMALIZE out 2026-06-15T14:00+05:30 | equals true | same instant true | raw 2026-06-15 14:00:00
OffsetDateTime NORMALIZE_UTC out 2026-06-15T08:30Z | equals false | same instant true | raw 2026-06-15 08:30:00+00
OffsetDateTime COLUMN out 2026-06-15T14:00+05:30 | equals true | same instant true | raw 2026-06-15 08:30:00+00
Read it column by column. equals true means you got back an object equal to the one you stored. OffsetDateTime NORMALIZE_UTC says equals false but same instant true: 08:30Z and 14:00+05:30 are the same moment but not equals, because OffsetDateTime.equals compares the offset too. Use isEqual or compare toInstant() when you mean “same moment”. The NORMALIZE row looks perfect here only because this JVM’s zone happens to be +05:30, the offset that was written; the cross-zone section below shows what that costs. The last column is what another tool sees: Instant is stored as 08:30:00+00, LocalDateTime as the bare 14:00:00.
On PostgreSQL the same code gives a different picture (01-roundtrip-postgres-Asia_Kolkata-same-jvm-h7.txt):
Instant out 2026-06-15T08:30:00Z | equals true | same instant true | raw 2026-06-15 14:00:00+05:30
LocalDateTime out 2026-06-15T14:00 | equals true | same instant n/a | raw 2026-06-15 14:00:00
OffsetDateTime default out 2026-06-15T08:30Z | equals false | same instant true | raw 2026-06-15 14:00:00+05:30
OffsetDateTime NATIVE out 2026-06-15T08:30Z | equals false | same instant true | raw 2026-06-15 14:00:00+05:30
OffsetDateTime NORMALIZE out 2026-06-15T14:00+05:30 | equals true | same instant true | raw 2026-06-15 14:00:00
OffsetDateTime NORMALIZE_UTC out 2026-06-15T08:30Z | equals false | same instant true | raw 2026-06-15 14:00:00+05:30
OffsetDateTime COLUMN out 2026-06-15T14:00+05:30 | equals true | same instant true | raw 2026-06-15 14:00:00+05:30
Look at the OffsetDateTime default and NATIVE rows. The moment is right (same instant true) but the offset is gone: 14:00+05:30 comes back as 08:30Z. PostgreSQL’s timestamptz stores only the moment and shows it in the session’s zone; it never stored +05:30. H2’s TIMESTAMP WITH TIME ZONE does keep the offset. Only COLUMN mode keeps it on both, because it writes the offset into a second column; that is the integer column in the DDL (05-ddl-postgres-Asia_Kolkata-h7.txt).
Same Java type, different answer per database. A test that passes on H2 proves nothing about whether an OffsetDateTime keeps its offset on PostgreSQL. If the offset matters to your business rule, test against the database you ship on, or use @TimeZoneStorage(TimeZoneStorageType.COLUMN).
Going deeper: the column types Hibernate generates
Read from information_schema after Hibernate created the tables (05-ddl-postgres-Asia_Kolkata-h7.txt):
event odt_column_col_offset integer precision null
event id bigint precision null
event instant_col timestamp with time zone precision 6
event ldt_col timestamp without time zone precision 6
event odt_column_col timestamp with time zone precision 6
event odt_default_col timestamp with time zone precision 6
event odt_native_col timestamp with time zone precision 6
event odt_normalize_col timestamp without time zone precision 6
event odt_normalize_utc_col timestamp with time zone precision 6
zoned_event zdt_column_col_offset integer precision null
zoned_event id bigint precision null
zoned_event zdt_column_col timestamp with time zone precision 6
zoned_event zdt_default_col timestamp with time zone precision 6
Instant maps to timestamp with time zone by default (measured: the default behaves like hibernate.type.preferred_instant_jdbc_type=TIMESTAMP_UTC; see the section on settings below). NORMALIZE is the one OffsetDateTime mode that creates a zone-less column. The default storage for OffsetDateTime and ZonedDateTime comes from the dialect, which is why H2 and PostgreSQL agree here but other databases may not (not run here).
Reading your own writes in one process proves little. Real systems write from one place and read from another: a batch job in UTC, a web node in Asia/Kolkata, a laptop in America/New_York. So the next test writes in a JVM with zone Asia/Kolkata, stops, and reads the same rows from a second JVM whose default zone is America/New_York.
The diagram follows one row through two JVMs. The NORMALIZE column keeps only the wall clock 14:00, in the writer’s zone, and the reader pins it to its zone, so 14:00 Kolkata becomes 14:00 New York, a different moment. The real output, PostgreSQL first (01-roundtrip-postgres-America_New_York-written-in-Asia_Kolkata-h7.txt):
# 01-roundtrip (written-in-Asia_Kolkata)
# Hibernate ORM 7.4.14.Final, JDK 25, database PostgreSQL 17.11, JVM default zone America/New_York, java_time_use_direct_jdbc false (default)
# written by another JVM whose default zone was Asia/Kolkata; this JVM only reads (see scripts/run-all.sh)
# written: Instant 2026-06-15T08:30:00Z, LocalDateTime 2026-06-15T14:00, OffsetDateTime 2026-06-15T14:00+05:30 (all the same moment; the LocalDateTime is the Kolkata wall clock)
Instant out 2026-06-15T08:30:00Z | equals true | same instant true | raw 2026-06-15 04:30:00-04
LocalDateTime out 2026-06-15T14:00 | equals true | same instant n/a | raw 2026-06-15 14:00:00
OffsetDateTime default out 2026-06-15T08:30Z | equals false | same instant true | raw 2026-06-15 04:30:00-04
OffsetDateTime NATIVE out 2026-06-15T08:30Z | equals false | same instant true | raw 2026-06-15 04:30:00-04
OffsetDateTime NORMALIZE out 2026-06-15T14:00-04:00 | equals false | same instant false | raw 2026-06-15 14:00:00
OffsetDateTime NORMALIZE_UTC out 2026-06-15T08:30Z | equals false | same instant true | raw 2026-06-15 04:30:00-04
OffsetDateTime COLUMN out 2026-06-15T14:00+05:30 | equals true | same instant true | raw 2026-06-15 04:30:00-04
This corrects an earlier version of this post. It said that with NORMALIZE “only the displayed offset changes” when the JVM zone changes, with the same instant either way. That was measured in a single process that both wrote and read under the new zone. Across two JVMs with different zones, the instant itself moves. NORMALIZE is not a display quirk; it silently shifts data. Keep fleets on one user.timezone, or do not use NORMALIZE.
Going deeper: what each @TimeZoneStorage mode doesTimeZoneStorageType has six constants in 7.4.14 (and in 8.0.0.Beta4), read from the jar with javap (10-javap-hibernate-settings.txt):
public static final org.hibernate.annotations.TimeZoneStorageType NATIVE;
public static final org.hibernate.annotations.TimeZoneStorageType NORMALIZE;
public static final org.hibernate.annotations.TimeZoneStorageType NORMALIZE_UTC;
public static final org.hibernate.annotations.TimeZoneStorageType COLUMN;
public static final org.hibernate.annotations.TimeZoneStorageType AUTO;
public static final org.hibernate.annotations.TimeZoneStorageType DEFAULT;
DEFAULT is a sentinel meaning “use hibernate.timezone.default_storage”, whose own default is derived from the dialect. Measured outcome: no annotation behaves like NATIVE on H2 and on PostgreSQL (the first rows of the transcripts above). NORMALIZE_UTC stores in UTC and always returns UTC. COLUMN keeps a second column with the offset. The earlier version of this post derived the dialect-based default by decompiling MetadataBuilderImpl; this version only claims what the runs show.
ZonedDateTime is the type people reach for to “keep the time zone”. Hibernate keeps the offset, never the region, and that is by design. A ZonedDateTime of 10:30 in Europe/Paris was written on both databases, in Kolkata, and read in New York (04-zoned-postgres-America_New_York-written-in-Asia_Kolkata-h7.txt):
ZonedDateTime default out 2026-06-15T08:30Z | equals false | same instant true | zone Z | raw 2026-06-15 04:30:00-04
ZonedDateTime COLUMN out 2026-06-15T10:30+02:00 | equals false | same instant true | zone +02:00 | raw 2026-06-15 04:30:00-04
The moment is right (same instant true). The region is gone: the default mode returns Z on PostgreSQL (and +02:00 on H2, 04-zoned-h2-America_New_York-written-in-Asia_Kolkata-h7.txt), and COLUMN returns the fixed offset +02:00. Neither is Europe/Paris, so a later “add one day” computation will not follow Paris’s daylight-saving change. The Hibernate team closed the issue that asked for this, HHH-16289, as Rejected (“describes expected behavior”). If your rule needs the region, store the zone id in your own column and combine them in code.
Going deeper: the setting where ZonedDateTime cannot be saved at all
With Hibernate 7.4.14, hibernate.type.java_time_use_direct_jdbc=true and the PostgreSQL driver 42.7.14, a ZonedDateTime cannot be bound, and an entity containing one cannot even be read, not even a row where it is null (04-zoned-failure-postgres-America_New_York-directtrue-h7.txt):
# 04-zoned-failure
# Hibernate ORM 7.4.14.Final, JDK 25, database PostgreSQL 17.11, JVM default zone America/New_York, java_time_use_direct_jdbc true (set)
# ZonedDateTime on PostgreSQL with java_time_use_direct_jdbc=true
## persist(new ZonedEvent(zonedDefault = 2026-06-15T10:30+02:00[Europe/Paris]))
org.hibernate.exception.SQLGrammarException: Unable to bind parameter #3 - 2026-06-15T10:30+02:00[Europe/Paris] [Cannot cast an instance of java.time.ZonedDateTime to type Types.TIMESTAMP_WITH_TIMEZONE] [n/a]
org.postgresql.util.PSQLException: Cannot cast an instance of java.time.ZonedDateTime to type Types.TIMESTAMP_WITH_TIMEZONE
## find(ZonedEvent.class, 2) -- a row whose ZonedDateTime columns are NULL
org.hibernate.exception.DataException: Could not extract column [4] from JDBC ResultSet [conversion to class java.time.ZonedDateTime from timestamptz not supported] [n/a]
org.postgresql.util.PSQLException: conversion to class java.time.ZonedDateTime from timestamptz not supported
This is the driver’s limitation (pgjdbc has no ZonedDateTime support in setObject/getObject), exposed because 7.4 hands it the value unconverted when you flip the flag. It matters in the Hibernate 8 section: the beta flips that flag by default, and on PostgreSQL the same ZonedDateTime mapping still works there (04-zoned-postgres-America_New_York-same-jvm-h8.txt), because Hibernate falls back for types the dialect says the driver does not support.
LocalDateTime comes back as written in every run above, in both databases, across JVM zones. Its risk is not storage, it is meaning: it has no zone, so it is ambiguous around daylight saving. New York clocks jump from 02:00 straight to 03:00 on 8 March 2026, so 02:30 that day never exists; and 01:30 on 1 November exists twice.
static final LocalDateTime GAP = LocalDateTime.of(2026, 3, 8, 2, 30);
static final LocalDateTime OVERLAP = LocalDateTime.of(2026, 11, 1, 1, 30);
static final LocalDateTime PLAIN = LocalDateTime.of(2026, 6, 15, 14, 0);
plain wall clock in 2026-06-15T14:00 | out 2026-06-15T14:00 | equals true | raw 2026-06-15 14:00:00
gap 02:30 on 2026-03-08 in 2026-03-08T02:30 | out 2026-03-08T03:30 | equals false | raw 2026-03-08 03:30:00
overlap 01:30 on 2026-11-01 in 2026-11-01T01:30 | out 2026-11-01T01:30 | equals true | raw 2026-11-01 01:30:00
The time in the gap, 02:30, came back as 03:30, and the raw column holds 03:30: the value was changed before it reached the database, with no exception. The overlap value (01:30 on 1 November, which exists twice) and the plain one survived in this run. The same run in a JVM in Asia/Kolkata, which has no daylight saving, loses nothing (02-dst-postgres-Asia_Kolkata-local-date-time-h7.txt). H2 behaves like PostgreSQL (02-dst-h2-America_New_York-local-date-time-h7.txt).
The diagram shows why. With the default setting Hibernate first converts the LocalDateTime to a legacy java.sql.Timestamp, which is defined in terms of the JVM’s zone, and a Timestamp for a non-existent local time is silently moved forward. When the flag is on, the java.time value goes to the driver as it is. The Hibernate issue describing this, HHH-16722, was closed as “Out of Date” on 2026-10-02. The practical rule is the old one: use LocalDateTime for wall clocks in a place you know (a shop’s opening time), not for events, and not for anything that must survive daylight-saving gaps on Hibernate 7.
HHH-16722: the report about LocalDateTime at daylight-saving boundaries
Precision: microseconds, and who rounds
LocalDateTime, Instant and OffsetDateTime have nanosecond precision in Java. The generated columns do not: on H2 and PostgreSQL the default column is timestamp(6), microseconds (05-ddl-postgres-Asia_Kolkata-h7.txt). What happens to the last three digits depends on the database. Four values were written with different nanosecond parts on each:
H2 and PostgreSQL round half up; HSQLDB truncates. The row that matters is .999999999: where the database rounds, 14:00:00.999999999 becomes 14:00:01, the next second, so rounding can change the seconds, minutes and even the day if the value is near midnight. Truncating engines never do that. If you compare a value you saved against the value you read back, normalise it on the Java side first to what your engine does: value.truncatedTo(ChronoUnit.MICROS) matches a truncating engine, but not a rounding one.
Correction to the common advice, and to the earlier version of this post.@Column(precision = 9) still does nothing for a temporal field: the column stays timestamp(6) on both databases. But the earlier post stopped there. Jakarta Persistence 3.2 added a separate attribute, @Column(secondPrecision = ...), and it does work: on H2 it creates timestamp(9) and keeps all nine digits, secondPrecision = 3 keeps milliseconds on both, and on PostgreSQL secondPrecision = 9 is capped to timestamp(6) because that database has no more.
That block (08-column-precision-h2-Asia_Kolkata-h7.txt) is H2; the PostgreSQL run is 08-column-precision-postgres-Asia_Kolkata-h7.txt. The attribute was added to the annotation in 3.2; the jar confirms secondPrecision() exists in both 3.2.0 and the 4.0.0-M7 milestone (10-javap-jakarta-persistence.txt).
Going deeper: what the earlier version of this post claimed about HSQLDB and H2
The earlier version reported that H2 rounds and HSQLDB truncates (measured on H2 2.4.240 and HSQLDB 2.7.3 inside the Spring Boot test suite, Hibernate 7.4.5). The same result holds on the newer drivers above (H2 2.5.252, HSQLDB 2.7.4) and PostgreSQL joins H2 on the rounding side. The experiment source is EdgeCasesTest.java; the entity is PrecisionEvent.java.
The two settings the usual advice reaches for
Two settings are repeated in almost every blog post on this topic. Both were tested.
hibernate.jdbc.time_zone tells Hibernate which zone to use when binding timestamps. Set to a zone that differs from the JVM’s (here Asia/Kolkata while the JVM was in New York), on PostgreSQL (06-jdbc-time-zone-postgres-America_New_York-h7.txt):
LocalDateTime in 2026-07-04T09:00 | out 2026-07-04T09:00 | raw 2026-07-04 18:30:00
Instant in 2026-07-04T03:30:00Z | out 2026-07-04T03:30:00Z | raw 2026-07-03 23:30:00-04
OffsetDateTime in 2026-07-04T09:00+05:30 | out 2026-07-04T03:30Z | raw 2026-07-03 23:30:00-04
Through Hibernate every row round-trips transparently (out equals in), so the app looks fine. But the raw column for the LocalDateTime holds 18:30, not the 09:00 the app saved: Hibernate treated the wall clock as New York time and wrote it in Kolkata time. Any other tool that reads the table, a report, a data export, a second service, sees the shifted value. Instant and OffsetDateTime are not affected, because they already name a moment. The shift comes from the gap between the two zones, so setting both the JVM zone and this property to the same zone (the usual choice is UTC) removes it; I did not run that exact combination separately.
The nasty one. Through Hibernate the round trip is transparent, so every test you write in the application passes. The shifted bytes only show up in a tool that reads the table without Hibernate, which is exactly the report or export that is wrong in production and right in your tests.
hibernate.type.preferred_instant_jdbc_type is often given as TIMESTAMP_UTC “to get modern JDBC binding”. That is already the default on both databases tested: the column is timestamp with time zone without setting anything. The setting only matters in the other direction. With TIMESTAMP the column becomes zone-less and the raw value follows the JVM zone (07-preferred-instant-jdbc-type-postgres-Asia_Kolkata-timestamp-h7.txt):
column type timestamp without time zone | Instant in 2026-07-04T03:30:00Z | out 2026-07-04T03:30:00Z | raw 2026-07-04 09:00:00
Going deeper: @Temporal and java.util.Date@Temporal is deprecated since Jakarta Persistence 3.2, which the class file says (10-javap-jakarta-persistence.txt):
It is still present, still deprecated, in the 4.0.0-M7 milestone used by the Hibernate 8 beta, so it is not removed there yet (same file). You do not need it: a java.util.Date with no annotation, as in Legacy.java:
/** No @Temporal annotation at all. */
@Column(name = "util_date_col")
private Date utilDate;
maps to timestamp and round-trips (09-legacy-types-postgres-Asia_Kolkata-h7.txt), though what you get back is a java.sql.Timestamp, and Timestamp.equals(Date) is false while Date.equals(Timestamp) is true:
java.util.Date in 2026-06-15T08:30:00Z | out 2026-06-15T08:30:00Z | class java.sql.Timestamp
java.util.Date in.equals(out) true | out.equals(in) false
Correction to an assumption. The old expectation was that a java.util.Date or Calendar field requires@Temporal to boot. It does not: on 7.4.14 the entity above boots and the value round-trips. If you are migrating away from @Temporal and cannot change the field type yet, removing the annotation is safe.
The earlier version of this post also showed that @Temporal on an Instant logs a warning (HHH90000033) but still boots. That was measured in the older Spring Boot chapter on 7.4.5 and not re-run here. Details of the warning on a LocalDate field are in JPA Persistence Annotations in Hibernate 7.
Hibernate 8: what changes for date and time (beta)
Status: pre-release. Everything in this section comes from Hibernate ORM 8.0.0.Beta4 (Maven Central, 2026-10-28) with Jakarta Persistence 4.0.0-M7. It is not a release, and the behaviour described can change before 8.0 final. Where something is from the documentation rather than from a run, it says so.
What the primary sources say. The official 8.0 migration guide (page header: version 8.0.0.Beta4) has one section on this, “Direct JDBC handling of java.time values”: the default of hibernate.type.java_time_use_direct_jdbc is now true; previously Hibernate converted java.time values to legacy java.sql types before passing them to JDBC; now it passes them directly “where the configured dialect reports support for the Java type”, falls back to the legacy representation for unsupported types and logs the limitation; and setting the property to false keeps the old behaviour. The tracking issue is HHH-20792 (“Flip the default for hibernate.type.java_time_use_direct_jdbc”, resolved Fixed, fix version 8.0.0.Beta2). It adds that the flip “cannot be a simple flip” because drivers support JDBC 4.2 unevenly, so the dialect now reports which java.time types the driver and database support. The jar agrees: JAVA_TIME_USE_DIRECT_JDBC_DEFAULT = true is a constant in Beta4’s MappingSettings and is not among the date/time settings of 7.4.14 (10-javap-hibernate-settings.txt). The setting itself is not new: it exists in 7.4.14 with default false.
What I did not find. The migration guide says nothing about @TimeZoneStorage, TimeZoneStorageType or the temporal column types, and TimeZoneStorageType still has the same six constants in Beta4 (same javap file). I found no other date/time mapping change in the guide apart from an unrelated MySQL @CurrentTimestamp note (now(6)), which I did not run because there is no MySQL here. If you know of a Hibernate 8 temporal change that is not in that guide, treat it as unverified.
What happens when you run it. The same module was run on Beta4 with its default (flag true) on H2 and PostgreSQL, and on Hibernate 7.4.14 with the flag set both ways, so every difference below is the flag, not the version. Hibernate 7.4.14 versus 8.0.0.Beta4, same tests:
What was run
Hibernate 7.4.14 (flag false)
Hibernate 8.0.0.Beta4 (flag true)
LocalDateTime 02:30 in New York’s spring-forward gap, H2 and PostgreSQL
comes back 03:30
comes back 02:30
hibernate.jdbc.time_zone different from the JVM zone: raw LocalDateTime column
shifted (18:30 for 09:00)
not shifted (09:00:00), on both databases
OffsetDateTime with NORMALIZE / NORMALIZE_UTC on H2
honoured: column is zone-less / returns UTC
ignored: column becomes timestamp with time zone, value returns as +05:30 like NATIVE
OffsetDateTime with NORMALIZE on PostgreSQL
honoured
honoured (unchanged)
ZonedDateTime on PostgreSQL
works with the default; fails to bind and to read if you set the flag to true yourself
works (the guide says unsupported types fall back to the legacy path)
plain wall clock in 2026-06-15T14:00 | out 2026-06-15T14:00 | equals true | raw 2026-06-15 14:00:00
gap 02:30 on 2026-03-08 in 2026-03-08T02:30 | out 2026-03-08T02:30 | equals true | raw 2026-03-08 02:30:00
overlap 01:30 on 2026-11-01 in 2026-11-01T01:30 | out 2026-11-01T01:30 | equals true | raw 2026-11-01 01:30:00
OffsetDateTime NORMALIZE out 2026-06-15T14:00+05:30 | equals true | same instant true | raw 2026-06-15 14:00:00+05:30
OffsetDateTime NORMALIZE_UTC out 2026-06-15T14:00+05:30 | equals true | same instant true | raw 2026-06-15 14:00:00+05:30
On H2 the generated column for the NORMALIZE field is timestamp with time zone under Beta4 (05-ddl-h2-America_New_York-h8.txt), while Hibernate 7 creates a zone-less one. The same difference appears on Hibernate 7.4.14 when the flag is set to true by hand (01-roundtrip-h2-America_New_York-same-jvm-directtrue-h7.txt), and the flag set back to false on Beta4 restores the Hibernate 7 results (01-roundtrip-h2-America_New_York-same-jvm-directfalse-h8.txt). So the flag is the cause, not any other change in the beta.
What that means for you. A LocalDateTime in a daylight-saving gap stops being silently moved, and hibernate.jdbc.time_zone stops shifting the raw column for zone-less types. Both are improvements, but they change stored values for anyone relying on the old behaviour, and the migration guide itself tells you to verify temporal handling with your driver. Whether the final 8.0 keeps this default, and how Oracle, SQL Server and MySQL drivers behave under it, I have not verified (only H2 and PostgreSQL were run). To keep the Hibernate 7 behaviour on 8, set hibernate.type.java_time_use_direct_jdbc=false, as the guide says. The wider list of Hibernate 8 changes is in Hibernate 8 and Jakarta Persistence 4.0 Preview: What Will Break.
Going deeper: how to reproduce the Hibernate 8 runsmvn test -Dhibernate.version=8.0.0.Beta4 -Dpersistence.version=4.0.0-M7 -Dh.label=h8 in the module runs the same tests; add -Ddt.directJdbc=false to set the flag back. run-all.sh does both for you and writes the -h8 files. The Hibernate 8 files carry the same header lines, including the effective value of the flag. Db.java is where the property is set:
String direct = System.getProperty("dt.directJdbc", "default");
if (!direct.equals("default")) {
cfg.setProperty("hibernate.type.java_time_use_direct_jdbc", direct);
}
extra.forEach(cfg::setProperty);
HHH-17559: the earlier “prefer java.time handling” work that introduced the setting (fix version 6.5.0.CR1)
Questions people ask
Does Hibernate 7 automatically handle daylight saving time? For Instant and OffsetDateTime yes, because they name a moment. For LocalDateTime, no: on Hibernate 7 a time inside a spring-forward gap is moved an hour (shown above), and the Hibernate 8 beta changes that default.
Why are my timestamps appearing as hex or binary? I could not reproduce the cause the earlier version of this post gave (an outdated driver or dialect), so I will not repeat it as fact. What I did reproduce: a java.time type with no SQL counterpart, YearMonth, is silently serialised into a bytea/binary column on both databases, while Year maps to an integer and Duration to a numeric (09-legacy-types-postgres-Asia_Kolkata-h7.txt). If the column you see is binary, check for such a type first.
How do I store only a year and month? The default is the serialised binary shown above, which you cannot query. Map it to a LocalDate (day 1) or use an AttributeConverter to a string or integer such as 202606.
Instant vs OffsetDateTime — which one?Instant for machine-generated moments (created-at, audit, events). OffsetDateTime only when the offset a user or device had must be kept, and then add @TimeZoneStorage(COLUMN) if you run on PostgreSQL, because otherwise the offset is not stored. Both produce a timezone-aware column.
What about MySQL and Oracle? Not run here. MySQL’s TIMESTAMP type is bounded in 2038 and is affected by the time_zone system variable, so DATETIME(6) is the usual choice; Oracle has TIMESTAMP WITH TIME ZONE and TIMESTAMP WITH LOCAL TIME ZONE. These are database documentation facts, not measured by this module, and the H2-versus-PostgreSQL difference above is a reason to test your own database.
Going deeper: migrating from java.util.Date to java.time
A low-risk sequence: change the entity field (Date to LocalDate, Instant or OffsetDateTime, as the meaning requires), update the column type to match, remove @Temporal as each field moves, align the JVM zone and hibernate.jdbc.time_zone (UTC is the common choice), and check existing data before assuming every stored value was UTC. Moving a Date column to Instant is only value-preserving if the old values were written as UTC moments; if they were wall clocks in a local zone, that zone has to be applied during the change. A field with no @Temporal at all already works on Hibernate 7.4.14, as shown above, so the annotation can go first.
Should you reach for anything fancy here? Probably not. Use Instant for moments, LocalDate/LocalTime for calendar facts, run every JVM in the same zone (UTC), and test on the database you ship. Reach for OffsetDateTime with COLUMN only when the offset is part of the data, and for ZonedDateTime only if you also store the region yourself. Avoid NORMALIZE. And if you plan to move to Hibernate 8, re-run your own date tests with the new flag default before anything else.
Further reading
hibernate-demo (companion repository), module date-time: every value above, regenerated by scripts/run-all.sh; output/ holds all the transcripts
Repository chapter 13: the original experiments this module supersedes (Hibernate 7.4.5, H2/HSQLDB only)
No Comments yet!