Issue
I use Hibernate and try to do the following:
@Temporal(TemporalType.DATE)
@Column(name = "BIRTHDAY")
private Instant birthday;
but have this exception:
Caused by: org.hibernate.AnnotationException: @Temporal should only be set on a java.util.Date or java.util.Calendar property:
As was suggested I tried to use
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-java8</artifactId>
<version>${hibernate.ver}</version>
</dependency>
but have the same exception. Should I do some additional steps or how to resolve such a case?
Solution
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/
Answered By - HAYMbl4
Answer Checked By - Senaida (JavaFixing Volunteer)