Rui
Rui

Reputation: 3667

@Temporal(DATE) annotation does generate the data type with day accuracy in Spring Boot project using Hibernate

In a Spring Boot (2.7.11) project using MariaDB database, a new legacy date field is needed to be added to an existing JPA entity, assuming it to be Contact, and the accuracy should be day other than the default time of java.util.Date. So I added the following code to the Contact JPA entity on base of the Java EE 7 API doc of @Temporal annotation:

@Temporal(DATE)
private java.util.Date endDate;

Problem: the generated data type in the mapped table of Contact in the database is expected to be DATE, but the actual generated data type is DATETIME with time accuracy. How to resolve this?

Upvotes: 0

Views: 38

Answers (0)

Related Questions