You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "rzo1 (via GitHub)" <gi...@apache.org> on 2026/10/23 13:20:51 UTC
[PR] [OPENJPA-3019] Write an in-place change to an element of a collection converted as a whole [openjpa]
rzo1 opened a new pull request, #223:
URL: https://github.com/apache/openjpa/pull/223
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).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@openjpa.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [OPENJPA-3019] Write an in-place change to an element of a collection converted as a whole [openjpa]
Posted by "rzo1 (via GitHub)" <gi...@apache.org>.
rzo1 commented on code in PR #223:
URL: https://github.com/apache/openjpa/pull/223#discussion_r4367956850
##########
openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java:
##########
@@ -4318,12 +4325,50 @@ private boolean hasTransactionalObjects() {
* Return a copy of all dirty state managers.
*/
protected Collection getDirtyStates() {
+ dirtyCheckWholeConverted();
if (!hasTransactionalObjects())
return Collections.EMPTY_SET;
return _transCache.copyDirty();
}
+ /**
+ * Notify the broker that the given instance has a collection or map
+ * field that is converted as a whole, so that an element changed in
+ * place is found at flush.
+ */
+ void addWholeConverted(StateManagerImpl sm) {
+ lock();
+ try {
+ if (_wholeConverted == null)
Review Comment:
Added braces to all the new blocks in the PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@openjpa.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [OPENJPA-3019] Write an in-place change to an element of a collection converted as a whole [openjpa]
Posted by "rzo1 (via GitHub)" <gi...@apache.org>.
rzo1 commented on PR #223:
URL: https://github.com/apache/openjpa/pull/223#issuecomment-6402182219
The `testOrthanRemoval` failure is not caused by this change. It fails on master too: it is a regression from OPENJPA-2940, where the annotation parser applies `cascade=ALL` after `orphanRemoval`, so the element is never deleted. The fix is in #224 (OPENJPA-3024), which also includes your two test commits. Once that is merged, I will rebase this PR onto master, the test commits drop out, and CI should go green.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@openjpa.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [OPENJPA-3019] Write an in-place change to an element of a collection converted as a whole [openjpa]
Posted by "solomax (via GitHub)" <gi...@apache.org>.
solomax merged PR #223:
URL: https://github.com/apache/openjpa/pull/223
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@openjpa.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [OPENJPA-3019] Write an in-place change to an element of a collection converted as a whole [openjpa]
Posted by "solomax (via GitHub)" <gi...@apache.org>.
solomax commented on code in PR #223:
URL: https://github.com/apache/openjpa/pull/223#discussion_r4365701565
##########
openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java:
##########
@@ -4318,12 +4325,50 @@ private boolean hasTransactionalObjects() {
* Return a copy of all dirty state managers.
*/
protected Collection getDirtyStates() {
+ dirtyCheckWholeConverted();
if (!hasTransactionalObjects())
return Collections.EMPTY_SET;
return _transCache.copyDirty();
}
+ /**
+ * Notify the broker that the given instance has a collection or map
+ * field that is converted as a whole, so that an element changed in
+ * place is found at flush.
+ */
+ void addWholeConverted(StateManagerImpl sm) {
+ lock();
+ try {
+ if (_wholeConverted == null)
Review Comment:
As usual I would add `{}` :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@openjpa.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org