[OPENJPA-2974] Convert String cache mode properties to their enum again - #174
Open
rzo1 wants to merge 1 commit into
Open
[OPENJPA-2974] Convert String cache mode properties to their enum again#174rzo1 wants to merge 1 commit into
rzo1 wants to merge 1 commit into
Conversation
convertToKernelValue() returned a String value for cache.retrieveMode and cache.storeMode untouched. Since PR #144 the bean property for those keys resolves to the new JPA 3.2 setters on EntityManagerImpl, which take the jakarta enums, so em.setProperty("jakarta.persistence.cache.retrieveMode", "USE") reached Method.invoke with a String and died with an argument type mismatch. The same applies to the map passed to createEntityManager(). The conversion is now driven by the target type rather than by the key: a value already of the target type passes through, a String is parsed into the target enum, and an enum of a different type is mapped by constant name, which is what lets a jakarta CacheStoreMode reach a kernel DataCacheStoreMode. An unusable String now fails with a message naming the property and its legal values instead of an argument type mismatch. The early return this replaces cannot simply be dropped: it was added with those setters and is what keeps the enum-valued form working. Being type-driven, it also fixes jakarta.persistence.lock.scope="EXTENDED", which failed in StringUtil.parse with "Unsupported type". A null mode now resets the fetch plan to its default rather than meaning BYPASS, so clearing one of these properties does not leave the plan bypassing the cache; both setters document that.
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.
convertToKernelValue()returned a String value forcache.retrieveModeandcache.storeModeuntouched. Since this PR the bean property for those keys resolves to the new JPA 3.2 setters onEntityManagerImpl, which take the jakarta enums, soem.setProperty("jakarta.persistence.cache.retrieveMode", "USE")reachedMethod.invokewith a String and died with an argument type mismatch. The same applies to the map passed tocreateEntityManager(), so this affects ordinary configuration, not only the new API.The conversion is now driven by the target type rather than by the key: a value already of the target type passes through, a String is parsed into the target enum, and an enum of a different type is mapped by constant name — which is what lets a jakarta
CacheStoreModereach a kernelDataCacheStoreMode. An unusable String now fails with a message naming the property and its legal values. The early return this replaces cannot simply be dropped: it was added together with those setters and is what keeps the enum-valued form working.Being type-driven, it also fixes
jakarta.persistence.lock.scope="EXTENDED", which failed inStringUtil.parsewith "Unsupported type".A null mode now resets the fetch plan to its default rather than meaning BYPASS, so clearing one of these properties does not leave the plan bypassing the cache; both setters document that.