I have some probles with JPA @Temporal(TemporalType.DATE) annotation, during application demployment. So I created spring data + postgres 9.5 + hibernate 4.3.10 app and setted hbm2ddl.auto to 'validate'.
hibernate.hbm2ddl.auto = validate
Here is Entity:
@Entity
@Table(name = "locomotive")
public class LocomotiveEntity {
private Long locomotiveId;
@Column(name = "status")
private int status;
@Temporal(TemporalType.DATE)
private java.util.Date constructionYear;
...
Also I created locomotive table using this script:
CREATE TABLE "locomotive"
(
"locomotiveId" bigserial PRIMARY KEY,
"status" integer NOT NULL,
"constructionYear" DATE NOT NULL
);
But I see exception during demployment:
Caused by: org.hibernate.HibernateException: Wrong
column type in public.constructionYear for column constructionYear.
Found: date, expected: timestamp
So I have 'DATE' type column in my db, and 'DATE' java type. What I did wrong?
datetype does not include the time of day. You have to use at leasttimestamp.