I am in the process of updating an application that deals with the delivery of packages. Technology used: java 8 and hibernate 5.1 (with the possibility to upgrade to newest version) SQL Server.
So far the application was used only in a single country and all the events in the system (package registered, package delivered etc.) are managed in the code and stored in the database using old java Date. Entities, calculations, everything uses java.util.Date
.
I want to write new module using java 8 time classes.
The events will be using the new java.time.Instant
class as it is a specific and time-zone independent moment in time.
The question: is there a possibility to define entities with java.time.Instant
and database schema with definitions that are human readable?
By default, when declaring entities with Instant:
@Column(name = "Event")
protected Instant event;
Database schema is created as Event varbinary(255)
, which is impossible to read.
I could define it in the database as Event datetime
, but then I would have to make a define it as java.sql.Timestamp
and make a conversion to java.time.Instant
every time.
Is there some SQL Server definition I'm missing? Maybe some entity annotation to make conversion easy? Possibly some different class to use as an entity field to make conversion trivial? Should I use different class from java.time
package?