Skip to content

[OPENJPA-3019] Write an in-place change to an element of a collection converted as a whole - #223

Open
rzo1 wants to merge 6 commits into
masterfrom
OPENJPA-3019
Open

rzo1 wants to merge 6 commits into
masterfrom
OPENJPA-3019

Conversation

@rzo1

@rzo1 rzo1 commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Reported on #220 by @ilgrosso: changing an element of a converted List<PlainAttr> in place produced no UPDATE. The spec requires it ("Synchronization to the Database": a modification includes "modification of a mutable value of a persistent property or field").

The collection proxy only tracks adds and removes. For collection and map fields converted as a whole, the converted value is now saved on load and compared before each flush, before an AUTO flush for a query, and on merge; a field whose value differs is marked dirty. The broker holds these instances weakly. Other fields are not affected.

Cost: one convertToDatabaseColumn call per load of such a field, and one per flush for each such instance still in the persistence context.

Based on #220 (OPENJPA-3017).

Base automatically changed from OPENJPA-3017 to master October 24, 2026 02:00
Comment thread openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java Outdated
rzo1 and others added 6 commits October 25, 2026 10:27
… converted as a whole

The proxy of such a collection only sees adds and removes, so a change made
inside an element was never written. The converted value of these fields is
now saved when they are loaded, and compared once before each flush; a field
whose converted value differs is marked dirty.
…onverted value check

- merge() of a detached instance whose element was changed in place now
  marks the field dirty when its converted value differs.
- An AUTO flush before a query checks these fields first.
- A converter that cannot convert to the database no longer breaks loading.
- A dirty field is not converted again by the check, and the value written
  at flush becomes the new saved value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants