Hibernate basic value type mapping in Date type support Date,time,timestamp These three options, where
Date: The date type in the corresponding database, indicating that only dates are displayed
Time: The date type in the corresponding database, indicating that only times are displayed
Timestamp: The timestamp type in the corresponding database, which corresponds to a datetime type if the database supports a DateTime type, indicating that the DateTime is displayed (this is a guess after I have tested it).
Following excerpt from: Open source China
The fields used to store the full time in MySQL include TIMESTAMP and DATETIME two. A lot of people in the choice of Time field is a bit dizzy, in the end I choose which one, they two what is the difference?
Date Range
TIMESTAMP support from ' 1970-01-01 00:00:01′ to ' 2038-01-19 03:14:07′ UTC. This time may not be a problem for the people who are currently working, and we can persist until we retire, but for some young readers, there will be bug2k+38 problems.
DATETIME from ' 1000-01-01 00:00:00′ until ' 9999-12-31 23:59:59′.
Given the difference in scope between the two, your current event log uses TIMESTAMP without any problems, but if it is to record your grandfather and grandson's birthday, it will be DATETIME.
In addition, I suggest that if it is related to the current time, you can choose TIMESTAMP. For example, the time to add a record, or to select DATETIME.
Storage-related comparisons
TIMESTAMP requires 4 bytes of storage space, while DATETIME requires 8 bytes
[Hibernate] The date type of the base value type mapping