-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JPA AttributeConverter does not persist entity in some cases #13234
Comments
hi @mposolda , I suspect this triggers some unexpected interaction with the entity enhancement, which we use in Quarkus (and didn't use in WildFly). The problem would be that technically you're not writing onto the property. Would you be able to verify this theory, by using a workaround which makes the property write explicit?
I'm not entirely sure of this, as I don't know why it would seem to work when you change keys. |
@Sanne Thanks, I've tried this but there was not any change in the behaviour. Explicitly calling "setter" does not help... |
Interesting, thanks for trying @mposolda . I'll see if someone on the team can prioritize this, but TBH it won't be looked at before next week. |
I created https://hibernate.atlassian.net/browse/HHH-14329 to track this, as this is indeed an enhancement issue. |
Describe the bug
In Keycloak, we use the AttributeConverter implementation. The use-case is to save the JSON String into one column in the database table. Hence we use the converter, which converts the Map object into JSON String and this JSON String is then supposed to be saved in the DB in the column of type CLOB.
The code of the converter is here: https://github.com/mposolda/keycloak/blob/KEYCLOAK-16244-quarkus-reproduce/model/jpa/src/main/java/org/keycloak/models/jpa/converter/MapStringConverter.java
It is used in the entity as shown here: https://github.com/mposolda/keycloak/blob/KEYCLOAK-16244-quarkus-reproduce/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RealmLocalizationTextsEntity.java#L79 (The TEXTS column is supposed to be just String (CLOB) in the database.)
The issue is when we update the map and update the value for some key in the map as shown here:
https://github.com/mposolda/keycloak/blob/KEYCLOAK-16244-quarkus-reproduce/model/jpa/src/main/java/org/keycloak/models/jpa/JpaRealmProvider.java#L894
then the entity is not updated in the DB. When adding completely new "key" or removing the key from the map, the object is correctly updated in the DB. The issue is just updating the value of existing key in the map. Which means that "map" has exactly same keys as before, however it just has different values. In case that keys in the map were changed (adding or removing key to the map), things work as expected.
I am not 100% sure if this is bug in the quarkus hibernate subsystem, but the behaviour on "standalone" hibernate or when using on Wildfly is working fine. So I assume it is Quarkus bug, but not 100%...
Let me know if this is enough description, or if you want me to provide some more proper reproducer.
Quarkus version: 1.9.1.Final
java -version:
openjdk version "11.0.9" 2020-10-20
OpenJDK Runtime Environment (build 11.0.9+11-Ubuntu-0ubuntu1.18.04.1)
OpenJDK 64-Bit Server VM (build 11.0.9+11-Ubuntu-0ubuntu1.18.04.1, mixed mode, sharing)
The text was updated successfully, but these errors were encountered: