I have an entity with a field defined following way:
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "some_datetime")
private java.util.Date someDateTime;
I would assume that Hibernate would create a table with corresponding column of type DATETIME(3) (for MySQL), however the table's column is just a DATETIME, so when I store a Date with milliseconds they are lost:
describe some_table;
+---------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+-------+
| ... | ... | NO | PRI | NULL | |
| some_datetime | datetime | YES | | NULL | |
| ... | ... | NO | | NULL | |
+---------------+--------------+------+-----+---------+-------+
I guess I need to add a columnDefinition parameter to the @Column annotation, but why it's not done automatically by Hibernate, as I explicitly told that I want to have a TIMESTAMP supported by the table.
I tried the above with:
- 10.1.14 - MariaDB
- 5.7.29 - MySQL
Hibernate version is 5.2.18.Final with MySQL5InnoDBDialect