1) I faced the same issue on Spring Boot 2.1.2 which uses Hibernate 5.3.7.
I read here that java.util.LocalDateTime
handling was introduced in Hibernate 5.2.3, before that version you had to use one of the following date types:
- java.util.Date
- java.util.Calendar
- java.sql.Date
- java.sql.Time
- java.sql.Timestamp
But it still did not work for me...
So I came up with javax.persistence.PrePersist
annotation:
...
@Column(name = "created_at", updatable = false)
@Temporal(TemporalType.TIMESTAMP)
private Date createdAt;
...
@PrePersist
public void prePersistCreatedAt() {
this.createdAt = new java.util.Date();
}
2)
This post discusses that topic and gives decent explanation: Please explain about insertable=false and updatable=false in reference to the JPA @Column annotation.
Also pay attention to the not accepted posts, especially:
Defining insertable=false, updatable=false is useful when you need to map a field more than once in an entity...