Hibernate @Temporal for Java 8 java.time.Instant
Java 8 Date and time API is supported by JPA 2.2 using the columnDefinition:
@Column(name = "local_time", columnDefinition = "TIME")
private LocalTime localTime;
@Column(name = "local_date", columnDefinition = "DATE")
private LocalDate localDate;
@Column(name = "local_date_time", columnDefinition = "TIMESTAMP")
private LocalDateTime localDateTime;
You can not use @Temporal
with java 8 time, if you want date with time use LocalDateTime
, if you want only date use LocalDate
without @Temporal
anotation.
look also http://www.thoughts-on-java.org/persist-localdate-localdatetime-jpa/