`hibernate.type.preferred_instant_jdbc_type` is not taken into account by Hibernate Envers

Description

Problem description:

In Hibernate 5 → 6 migration guide (https://github.com/hibernate/hibernate-orm/blob/6.0/migration-guide.adoc#instant-mapping-changes) hibernate.type.preferred_instant_jdbc_type property is described. For backward compatibility it is recommended to set it to TIMESTAMPT. In that case the property forces Hibernate 6 to use specified TIMESTAMP to represent java.time.Instant type. Everything works fine for hibernate entities, but it does not work for Envers.

Envers forces fields of java.time.Instant type to be mapped on TIMESTAMPT_UTC, no matter if you have set the property as described.

How to reproduce:

To reproduce the issue, it is enough to add following-like field to test entity:

set property described above:

and configure logging of SQL queries with parameters bound:

In that case, after new entity is created following like information can be see in logs for entity’s table:

and following like information cab be seen for audit table:

Workaround:

It is possible to workaround the issue by implementing own org.hibernate.usertype.UserType for java.time.Instant type with mapping it to TIMESTAMPT.

Activity

Show:

Details

Assignee

Reporter

Labels

Components

Affects versions

Priority

Created September 27, 2023 at 9:22 AM
Updated September 27, 2023 at 9:22 AM