#1644 - ENH: Improve batch flush when multiple "top level" (unrelated) types are persisted

This commit is contained in:
rob bygrave
2019-03-04 12:42:08 +13:00
parent a4698ea1b6
commit 86d0216159
2 changed files with 68 additions and 4 deletions
@@ -69,6 +69,7 @@ public final class BatchControl {
* Size of the largest buffer.
*/
private int bufferMax;
private int topCounter;
private Queue earlyQueue;
private Queue lateQueue;
@@ -246,6 +247,7 @@ public final class BatchControl {
pstmtHolder.clear();
beanHoldMap.clear();
maxDepth = 0;
topCounter = 0;
}
private void flushBuffer(boolean resetTop) throws BatchedSqlException {
@@ -319,10 +321,8 @@ public final class BatchControl {
if (maybe != -1) {
beanDepth = maybe;
} else {
// we can't be certain of the relative ordering for this type so
// flush and reset the batch as we are changing the type of our top level
// bean so just keep it simple and flush and reset the top
flushReset();
// additional "top level" bean type ordered by save() order
beanDepth += ++topCounter;
}
}