[
https://issues.apache.org/jira/browse/OPENJPA-3023?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18132359#comment-18132359
]
ASF subversion and git services commented on OPENJPA-3023:
----------------------------------------------------------
Commit e9be53d9f05cbf5279ca29ac23ef158da509b523 in openjpa's branch
refs/heads/OPENJPA-3023 from Richard Zowalla
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=e9be53d9f ]
[OPENJPA-3023] Use pattern matching for the Date copy
> The data cache shares the value of a converted attribute between persistence
> contexts
> -------------------------------------------------------------------------------------
>
> Key: OPENJPA-3023
> URL: https://issues.apache.org/jira/browse/OPENJPA-3023
> Project: OpenJPA
> Issue Type: Bug
> Reporter: Richard Zowalla
> Assignee: Richard Zowalla
> Priority: Major
>
> With the data cache enabled, the value of an attribute with an
> {{AttributeConverter}} is stored in the cache as the Java object, and the
> same object is given to every persistence context that loads the instance
> from the cache. A change made in place to such a value in one persistence
> context is seen by the others, also when the transaction is rolled back.
> {code:java}
> @Convert(converter = ItemListConverter.class)
> private List<Item> items;
> {code}
> {code:java}
> em.getTransaction().begin();
> em.find(Entity.class, id).getItems().get(0).setName("changed");
> em.getTransaction().rollback();
> // new EntityManager
> em2.find(Entity.class, id).getItems().get(0).getName(); // "changed"
> {code}
> Cause: {{AbstractPCData.toData()}} copies a collection but keeps its
> elements, and {{toNestedData()}} keeps a value that is not a proxy. On the
> way back {{toNestedFields()}} returns the cached collection itself for
> elements that are not entities, embeddables, dates or locales. The cache and
> all persistence contexts share the element objects.
> For a converted attribute the cache can hold the converted database value and
> run the converter when the instance is loaded from the cache, so every
> persistence context gets its own copy.
> Related to the Apache Syncope report in the linked issue, where the elements
> of a converted {{List<PlainAttr>}} are changed in place.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)