[OPENJPA-2984] Record why an id class is no longer checked for Serializable - #176
Open
rzo1 wants to merge 1 commit into
Open
[OPENJPA-2984] Record why an id class is no longer checked for Serializable#176rzo1 wants to merge 1 commit into
rzo1 wants to merge 1 commit into
Conversation
…izable The check was not lost in the rewrite. Jakarta Persistence 3.2 section 2.4.1 dropped both the public and the Serializable requirement for a primary key class, and bf3d2b1 removed the warning deliberately: the same commit deleted the message key, relaxed the matching public-ness rules in the kernel and added a test with a package private, non-serializable id class. Restoring the warning would fire against metadata the specification allows, including that test's own entity. What was missing is the reason, so both parsers now carry it where the check used to be, along with the consequence that does survive: a non-serializable id class cannot be used where OpenJPA serializes the identity object it wraps, which detached entities, remote commit events and a distributed data cache do. The manual still listed the pre-3.2 rules; its identity class criteria are corrected. Note that the constructor requirement is only that one without arguments exists, of any visibility, since validateAppIdClassMethods uses getDeclaredConstructor().
solomax
approved these changes
Sep 3, 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.
To answer the review question: the check was not lost in the rewrite, and the warning should not come back.
Jakarta Persistence 3.2 section 2.4.1 dropped both the public and the
Serializablerequirement for a primary key class — the release notes say so verbatim — and bf3d2b1 removed the warning deliberately: the same commit deleted theid-class-not-serializablemessage key, relaxed the matching public-ness rules in the kernel (getConstructor→getDeclaredConstructor,setAccessible), and addedTestNonPublicIdClasswith a package-private, non-serializable id class. Restoring the warning would fire against metadata the specification allows, including that test's own entity, and against 29 of the 67@IdClasstargets in our test sources.What was missing is the reason, so both parsers now carry it where the check used to be, along with the consequence that does survive: a non-serializable id class cannot be used where OpenJPA serializes the identity object wrapping it — serializing a detached entity, remote commit events, a distributed data cache — which fails with a
NotSerializableExceptionnaming the class.The manual still listed the pre-3.2 rules, so the identity class criteria are corrected. Note the constructor requirement is only that a no-args one exists, of any visibility, since
validateAppIdClassMethodsusesgetDeclaredConstructor(); a record has none, so a record@IdClassis rejected.No behaviour change.
TestNonPublicIdClassalready pins the relaxation and would fail if anyone reinstated a hard check.