We're updating the issue view to help you get more done. 

Add support for Java 8 date and time types (JSR-310)

Description

Implement support for the new Java 8 temporal Java types (JSR 310).

The initial implementation defines the following Types:

  • org.hibernate.type.DurationType - Maps a java.time.Duration to a SQL BIGINT (Long) representing the duration-in-nanoseconds.

  • org.hibernate.type.InstantType - Maps a java.time.Instant to a SQL TIMESTAMP

  • org.hibernate.type.LocalDateTimeType - Maps a java.time.LocalDateTime to a SQL TIMESTAMP

  • org.hibernate.type.LocalDateType - Maps a java.time.LocalDate to a SQL DATE

  • org.hibernate.type.LocalTimeType - Maps a java.time.LocalTime to a SQL TIME

  • org.hibernate.type.OffsetDateTimeType - Maps a java.time.OffsetDateTime to a SQL TIMESTAMP

  • org.hibernate.type.OffsetTimeType - Maps a java.time.OffsetTime to a SQL TIME

  • org.hibernate.type.ZonedDateTimeType - Maps a java.time.ZonedDateTime to a SQL TIMESTAMP

As this relies on Java 8 and Hibernate still maintains compatibility back to Java 6, a new module hibernate-java8 was added to isolate the Java 8 compatibility to just these classes. We will fold the classes from this module into hibernate-core once we baseline one Java 8.


Original request

It would be cool to be able to persist the date time types newly introduced in Java 8 in a reasonable way. Currently the values are persisted as blobs effectively.

There are already a user type implementations for the backport project of JSR-310 but they unfortunately don't work with the types from the java.time package. The support has also been requested in the user forums.

Environment

None

Status

Assignee

Steve Ebersole

Reporter

Oliver Gierke

Fix versions

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Priority

Major