[
https://issues.apache.org/jira/browse/OPENJPA-2974?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18111062#comment-18111062
]
ASF subversion and git services commented on OPENJPA-2974:
----------------------------------------------------------
Commit 872abe814124315e5dff20477ea3c2638a8b8eaf in openjpa's branch
refs/heads/master from Richard Zowalla
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=872abe814 ]
[OPENJPA-2974] Convert String cache mode properties to their enum again
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.
> String cache mode properties no longer converted to enum
> --------------------------------------------------------
>
> Key: OPENJPA-2974
> URL: https://issues.apache.org/jira/browse/OPENJPA-2974
> Project: OpenJPA
> Issue Type: Sub-task
> Components: jpa
> Affects Versions: 4.2.0
> Reporter: Maxim Solodovnik
> Priority: Major
> Fix For: 4.2.0
>
>
> Discussion thread:
> https://github.com/apache/openjpa/pull/144#discussion_r3683004301
> **(medium)** The early `return (T) value;` now also fires for String values
> of `cache.retrieveMode`/`cache.storeMode`, skipping the enum conversion
> below. Since EntityManagerImpl now exposes
> `setCacheRetrieveMode(CacheRetrieveMode)`,
> `em.setProperty("jakarta.persistence.cache.retrieveMode", "USE")` will try to
> inject a raw String into the enum setter and fail, whereas the old code
> converted it. Should Strings still be converted to the target enum here?
--
This message was sent by Atlassian Jira
(v8.20.10#820010)