By Spring integration, I mean that I use spring-orm and spring-data-jpa in the app to create the EMFactory, handle declarative transactions, discover entities by classpath scanning, etc., and it worked fine. I wouldn't have been surprised, given the major version change, if Spring had a problem with the new version. It appeared that it didn't have any. That was not possible when switching from hibernate 3 to hibernate 4, and Spring had to rewrite many classes for hibernate 4 support.
I indeed let Hibernate set everything up. I just changed the hibernate version number in my gradle dependencies, added the hibernate-java8 dependency, removed the jadira dependency, and everything went fine. A typical mapped Instant field looks like this:
{{ /**
-
The registration date of the user
*/ private Instant registrationDate;}}
Regarding the last question, it's a tough one. I made that choice based on [this SO answer](http://stackoverflow.com/a/22925669/571407) and the [linked blog post|http://justatheory.com/computers/databases/postgresql/use-timestamptz.html). Given that JDBC uses the default timezone by default when setting a timestamp (unless you use the [method with an additional Calendar argument|https://docs.oracle.com/javase/8/docs/api/java/sql/PreparedStatement.html#setTimestamp-int-java.sql.Timestamp-java.util.Calendar-), using a timestamptz is much safer, because it pays attention to the timezone, meaning that no conversion needs to be done at all, and no Calendar needs to be passed to have the correct value stored in UTC.
|