Replies: 3 comments
-
|
Do you want to say that our logic in the loop: comes with some flaws that we are missing to flush and clear for the last batch of that iteration? Thanks |
Beta Was this translation helpful? Give feedback.
-
|
You're absolutely right, and thank you for pointing that out! I just ran a test and you were correct - the final I missed that private Object persistOrMerge(...) {
result = persistOrMergeIterable(...);
if (flushSize > 0) {
entityManager.flush();
if (clearOnFlush) {
entityManager.clear(); // ← Already here!
}
}
return result; // All entities are detached at this point
}So there's no "mixed state" bug - all returned entities are consistently detached. I apologize for the confusion. I should have traced through the complete call stack before reporting. Thanks for your patience! 🙏 |
Beta Was this translation helpful? Give feedback.
-
|
Closed as |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi
While reviewing the JPA module code, I noticed something that might be problematic. I wanted to get your thoughts.
What I found:
In
DefaultJpaOperations.persistOrMergeIterable(), when usingclearOnFlush=true:Potential Issue:
The returned list contains entities in different states:
This could cause problems in downstream handlers:
Expectation: Returned entities should be in a consistent state (all managed or all detached), not mixed.
Is this mixed-state behavior intentional, or should the method guarantee consistent entity states in the returned list?
Thanks for your time!
Beta Was this translation helpful? Give feedback.
All reactions