Alexander Schwartz (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=6267ec4...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNmRmZjkxMDkz...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16081?atlOrigin=eyJpIjoiNmRmZj...
) HHH-16081 (
https://hibernate.atlassian.net/browse/HHH-16081?atlOrigin=eyJpIjoiNmRmZj...
) Hibernate 6 attribute converter assumes values are immutable (
https://hibernate.atlassian.net/browse/HHH-16081?atlOrigin=eyJpIjoiNmRmZj...
)
Issue Type: Bug Affects Versions: 6.1.6 Assignee: Unassigned Components: hibernate-core
Created: 23/Jan/2023 08:05 AM Environment: Keycloak test case in a Hibernate 6 evaluation
branch -
https://github.com/keycloak/keycloak/issues/16551 (
https://github.com/keycloak/keycloak/issues/16551 )
Also breaks in the test case template repo:
https://github.com/ahus1/hibernate-test-case-templates/tree/is-HHH-xxxx-a...
(
https://github.com/ahus1/hibernate-test-case-templates/tree/is-HHH-xxxx-a...
) Priority: Major Reporter: Alexander Schwartz (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=6267ec4...
)
During a migration from H5 to H6 with the Keycloak project, I found a change in the
behavior how attribute converters are handled. It seems that a property which results from
an attribute converter must not be changed / are assumed to be immutable, as they are not
be found by H6 dirty checking.
Our example:
* Read an entity from the DB where property is converted from JSON to a HashMap
* Modify the contents of the HashMap
* While H5 marks the entity as dirty and writes it to the DB, H6 doesn't recognize it
as dirty, and doesn't write it to the database.
The workaround is to first clone the map for the attribute before modifying it. Then dirty
tracking works as before. Another possible workaround is to add a @Mutability(...) to the
field.
Here's a reproducer example:
https://github.com/hibernate/hibernate-test-case-templates/compare/main.....
(
https://github.com/hibernate/hibernate-test-case-templates/compare/main.....
)
In the Zulip Chat Gavin King suggested that Hibernate might default to non-mutable
properties for converted attributes by default:
https://hibernate.zulipchat.com/#narrow/stream/132096-hibernate-user/topi...
(
https://hibernate.zulipchat.com/#narrow/stream/132096-hibernate-user/topi...
)
(
https://hibernate.atlassian.net/browse/HHH-16081#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16081#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100214- sha1:02c55de )