I switched to Java 8 and Hibernate 5 to solve the problem of the inability to store milliseconds in Hibernate.
private LocalDateTime date = LocalDateTime.now();
public LocalDateTime getDate() {
return date;
}
Maven Dependencies
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-java8</artifactId>
<version>5.0.1.Final</version>
</dependency>
Although this Hibernate still saves the LocalDateTime object as tinyblob. What am I missing? I am using MySQL 5.6.19
According to this
Hibernate Issue , the hibernate-java8 module should map this to TIMESTAMP. I tried to place @Column(columnDefinition="TIMESTAMP)on the receiver, but this led to a DataIntegrityViolationException.
Placed @Type(type="org.hibernate.type.LocalDateTimeType")on a getter. The database table is still saved as tinyblob.
source
share