FIX: Recursive batch flush can save dependant beans in wrong order

This commit is contained in:
Roland Praml
2023-08-08 16:59:46 +02:00
committed by Roland Praml
parent 83e87b0c67
commit d3427876b7
3 changed files with 66 additions and 16 deletions
@@ -224,14 +224,21 @@ public final class BatchControl {
* Execute all the requests contained in the list.
*/
void executeNow(ArrayList<PersistRequest> list) throws BatchedSqlException {
for (int i = 0; i < list.size(); i++) {
if (i % batchSize == 0) {
// hit the batch size so flush
flushPstmtHolder();
boolean old = transaction.isFlushOnQuery();
transaction.setFlushOnQuery(false);
// disable flush on query due transsaction callbacks
try {
for (int i = 0; i < list.size(); i++) {
if (i % batchSize == 0) {
// hit the batch size so flush
flushPstmtHolder();
}
list.get(i).executeNow();
}
list.get(i).executeNow();
flushPstmtHolder();
} finally {
transaction.setFlushOnQuery(old);
}
flushPstmtHolder();
}
public void flushOnCommit() throws BatchedSqlException {