Greetings!
I am currently developing an application and I am learning Hibernate ORM as I go along. I am using version 5.2.14 through Spring Boot. My database is MySQL 5.7.20.
I then used the hbm2ddl feature to create my database schema from my entity classes, however I was confused when Hibernate chose to generate a DATETIME
column for my java.time.Instant
property. I then experimented a bit (using java.util.Date
with TemporalType.TIMESTAMP
), but no matter what I tried, Hibernate insists on using DATETIME
. I asked this question on stackoverflow, which did not provide much value, so I went digging deeper. Now I have found that this seems to be intentional, since the MySQLDialect
class registers DATETIME
for use with the TIMESTAMP
type.
My question now is, why is this? I know I can make Hibernate “bend to my will”, by either not creating my Schema automatically or using the columnDefinition
property in my annotations, however I feel there is a reason for not using TIMESTAMP
in MySQL. Is there anyone who can enlighten me as to what it is?
Thanks!
Edit: I have found this old issue report, which was closed with a simple “DATETIME is correct”.