You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JPA Map storage doesn't downgrade entityVersion when modifying a row written with a future entityVersion #9716
When the Map JPA store reads data from a row, it accepts data that is written by another Keycloak version with entityVersion N+1. Thereby it ignores new fields written by a later version during JSON de-serialization.
When it then writes the data back to the database, it uses its JSON serializer and writes the data in the format of its own JSON schema to the row. Therefore, it should downgrade the entityVersion to N as well, so that is future version of Keycloak can again migrate the data to a later entity version.
Version
17.0.0-SNAPSHOT
Expected behavior
when data is written to the row, the entity version is always the SUPPORTED_VERSION_* of the implementation
Actual behavior
when data is written to the row, the entity version is kept "as is", thereby leaving the N+1 version in the row. This prevents a future migration of the JSON and is inconsistent with the data in the JSON column.
Possible refactoring: Rework repetitive calls to checkEntityVersionForUpdate() in JpaClientEntity to a method annotated with @PreUpdate and @PrePersist, so that is called whenever a SQL insert or update is triggered.
This would prevent missing an update to the entity version in cases where Hibernate triggers an update to the database.
Activity
Update the entityVersion also for downgrades, as it needs to match th…