Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.

@Retention(CLASS) @Target({FIELD})

public @interface Temporal

Stores a java.util.Date field in a native date or timestamp column instead of the portable default, epoch milliseconds in an integer column.

Opt-in, because the two are different columns: an existing integer column keeps its milliseconds and an existing native one needs this annotation. Neither is converted into the other. A mapping that disagrees with the column it finds is reported by Session.schemaReport() as unsupported, and a backend refuses to start on it.

@Temporal(TemporalType.TIMESTAMP)
private Date createdAt;

Semantics, the same on every engine:

  • Values are written and read in UTC. The backend pins its own connections to UTC, so the server’s or the column’s time zone setting does not change what is stored. A TIMESTAMP WITH TIME ZONE column is read with the offset the server sends.
  • Precision is the millisecond, which is all a Date holds. A column with finer precision has the extra digits dropped on read; one with coarser precision rounds or truncates on write, as that engine does.
  • On SQLite, which has no native date type, the value is text in the form 2026-10-16 09:30:00.000, which sorts in time order. Rows written in a different textual form are read when they are ISO 8601, but compare as text in queries.

Applies to entity fields only; identifier, version and element collection values keep the portable storage, and the annotation cannot be combined with Convert.

Methods

public abstract TemporalType value() default TemporalType.TIMESTAMPThe native column type.

Method details

value

public abstract TemporalType value() default TemporalType.TIMESTAMP
The native column type.

Returns

TIMESTAMP or DATE