Repository navigation
[OPENJPA-2973] Consult the AttributeConverter for null values - #201
Merged
Merged
Conversation
A converter may legitimately map null to a column or attribute default, so drop the val == null short-circuits in the externalization path. A null returned by the converter still stores/reads a null column value. Collection and map fields keep converting their elements through ConverterElementHandler, so the new guard mirrors isExternalized(). Arrays stay on the whole-value path, matching the same collection/map test that MappingRepository applies before its array handling. Queries are left alone: a null in a query means SQL NULL and is not passed through the converter, so "x IS NULL", "x = :nullParam", "SET x = NULL" and "SET x = :nullParam" keep one meaning between them. A RuntimeException from a converter is still wrapped in a StoreException, but with the localized converter-err message, so the failure names the field and the offending value instead of only the converter's own text. Document why the converter is invoked reflectively (openjpa-kernel does not depend on jakarta.persistence-api) and that there is no container hook for CDI-managed converters, and note the incompatibility in the 4.2.0 migration considerations. The test converters are made null-safe, as the specification requires of a converter, and the null shapes they cover - an array attribute with an auto-applied converter, a converted attribute of an embeddable and an absent embeddable - are pinned by tests.
solomax
approved these changes
Oct 6, 2026
cristof
approved these changes
Oct 6, 2026
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.
As required by Jakarta Persistence 3.2 an
AttributeConverteris now consulted fornullin both directions; previously a null attribute or a null column value bypassed it, so a converter mappingnullto a column default was never applied. Queries are deliberately unaffected: anullin a query still means SQLNULLand is never passed through the converter, soIS NULLand null parameters keep their previous meaning. Converter implementations must therefore be null-safe — the bundled test converters were not and are fixed — and the migration guide documents both the requirement and the change in stored data; the CDI and direct-cast questions from the review are answered in comments, since the kernel has neither a container hook nor thejakarta.persistencedependency.