Configure timestamp precision

134 views
Skip to first unread message

Michael Brizic

unread,
Aug 2, 2022, 5:26:58 AM8/2/22
to H2 Database
We have a Java object annotated with @Column (columnDefinition = "DATETIME(6)") and this has usually worked fine with our production app using MySQL.

However, we are upgrading to Java 17, and now notice that on Linux-based OS that nanoseconds precision is default. In addition to this, we are using Hibernate ORM and the infamous Optimistic Lock by annotating the column with @Version.

Our integration tests fail with H2 because there is a mismatch in precision between storing DATETIME(6) but the system/JVM using nanoseconds precision.

My question is whether there is any way to override the columnDefinition to update the precision to 9 when running our integration tests with the H2 database, but keeping the precision of 6 for when we run our app in production with MySQL?
Reply all
Reply to author
Forward
0 new messages