I am using Spring boot 1.4.2, which brings hibernate 5.0.11 (JPA 2.1). I want to use Java 8 temporary classes in my entities, and therefore included hibernate-java8.
My entity defines the LocalDate field.
@Entity
@Table(name = "my_alarms_timeline", indexes = {...})
public class MyAlarm {
...
@Column(name = "validity_date")
@NotNull
private LocalDate validityDate;
}
I expect this to be matched with a date in my H2 database.
In my DB I declare this as validity_date DATE NOT NULL,
When I try to run the tests, I get the following error:
[INFO] Caused by: org.hibernate.tool.schema.spi.SchemaManagementException:
Schema-validation: wrong column type encountered in column [validity_date] in table [my_alarms_timeline];
found [date (Types#DATE)], but expecting [timestamp (Types#TIMESTAMP)]
To my surprise, if I change the definition of the database to validity_date TIMESTAMP NOT NULL,I get an error
Caused by: org.hibernate.tool.schema.spi.SchemaManagementException:
Schema-validation: wrong column type encountered in column [validity_date] in table [my_alarms_timeline];
found [timestamp (Types#TIMESTAMP)], but expecting [date (Types#DATE)]
This is just the return message from the previous one.
I also tried using instead of turning it on hibernate-java8, AttributeConverter<LocalDate, java.sql.Date>but it gives the same error result.
What should I do so that my local date is correctly matched to a date in the database?
LocalDateTime TIMESTAMP, ...