When mapping an {{OffsetDateTime}} field to an SQL Server {{DATETIMEOFFSET}} column, the value is saved incorrectly: The offset gets replaced by the JVM's default system time zone, resulting in a different point in time being persisted. The only instance when the persisted date is correct is when the original offset of the {{OffsetDateTime}} value is happens to be the same as the system time zone offset (i.e. {{OffsetDateTime}} vales with zero offset are saved correctly if and only if the system time zone is set to UTC).
I have created a test project to demonstrate using Testcontainers for the SQL Server dependency, so it should require zero setup provided that you already have a docker daemon running. Running {{mvn test}} should be all you have to do (takes a few minutes on first try for Docker magic to happen).
Find the test case here: https://github.com/ bender6 cwatzl /hibernate-sqlserver-testcase-HHH-13369-test-case-template-based
(UPDATE: rewrote the test case to be based on official unit test template without Spring dependencies) |
|