Add Envers generic‑type handling for JSON collections #838#841
Open
gebhardt wants to merge 1 commit intovladmihalcea:masterfrom
Open
Add Envers generic‑type handling for JSON collections #838#841gebhardt wants to merge 1 commit intovladmihalcea:masterfrom
gebhardt wants to merge 1 commit intovladmihalcea:masterfrom
Conversation
(detailed message generated by Claude Opus 4.6) When Hibernate Envers builds audit entity mappings, JavaXMember.getJavaType() returns only the raw Class (e.g. List.class) instead of the full ParameterizedType (e.g. List<MyType>). This causes Jackson to deserialize JSON collections as LinkedHashMap objects instead of the expected POJO type. This commit applies three fixes to JsonJavaTypeDescriptor: 1. Constructor fix: The (ObjectMapperWrapper, Type) constructor now extracts the raw type from a ParameterizedType before passing it to the superclass, allowing subclasses to provide the full generic type via TypeReference. 2. setParameterValues guard: When propertyType is already a ParameterizedType (e.g. set by a constructor), it is no longer overwritten with a less specific raw Class from Envers. 3. Reflection fallback: When setParameterValues receives only a raw Collection or Map type, the full generic signature is recovered by reflecting on the entity field using DynamicParameterizedType.ENTITY and DynamicParameterizedType.PROPERTY. Root cause: Envers loses generic type information when constructing synthetic JavaXProperty instances for audit entities. This should additionally be reported as a bug against Hibernate ORM / Envers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(detailed message generated by Claude Opus 4.6)
When Hibernate Envers builds audit entity mappings, JavaXMember.getJavaType() returns only the raw Class (e.g. List.class) instead of the full ParameterizedType (e.g. List). This causes Jackson to deserialize JSON collections as LinkedHashMap objects instead of the expected POJO type.
This commit applies three fixes to JsonJavaTypeDescriptor:
Constructor fix: The (ObjectMapperWrapper, Type) constructor now extracts the raw type from a ParameterizedType before passing it to the superclass, allowing subclasses to provide the full generic type via TypeReference.
setParameterValues guard: When propertyType is already a ParameterizedType (e.g. set by a constructor), it is no longer overwritten with a less specific raw Class from Envers.
Reflection fallback: When setParameterValues receives only a raw Collection or Map type, the full generic signature is recovered by reflecting on the entity field using DynamicParameterizedType.ENTITY and DynamicParameterizedType.PROPERTY.
Root cause: Envers loses generic type information when constructing synthetic JavaXProperty instances for audit entities. This should additionally be reported as a bug against Hibernate ORM / Envers.