When committing transaction with batch insertions using {{SessionFactory}} there is an error in {{ActionQueue.InsertActionSorter.sort(insertions)}}, where could be some entities from batches removed. Lines 759 - 815 in Hibernate 5.2.10.Final. When in inner loop is called {{this.latestBatches.remove(i)}} more than once, then some entity could have multiple occurence in {{this.latestBatches}}, other one could disappear.
{noformat} for(int i = 0; i < this.latestBatches.size(); ++i) { batchIdentifier = (ActionQueue.InsertActionSorter.BatchIdentifier)this.latestBatches.get(i); String entityName = batchIdentifier.getEntityName();
int j; ActionQueue.InsertActionSorter.BatchIdentifier nextBatchIdentifier; for(j = i - 1; j >= 0; --j) { nextBatchIdentifier = (ActionQueue.InsertActionSorter.BatchIdentifier)this.latestBatches.get(j); if (nextBatchIdentifier.getParentEntityNames().contains(entityName)) { this.latestBatches.remove(i); this.latestBatches.add(j, batchIdentifier); } }
for(j = i + 1; j < this.latestBatches.size(); ++j) { nextBatchIdentifier = (ActionQueue.InsertActionSorter.BatchIdentifier)this.latestBatches.get(j); if (nextBatchIdentifier.getChildEntityNames().contains(entityName) && !batchIdentifier.getChildEntityNames().contains(nextBatchIdentifier.getEntityName())) { this.latestBatches.remove(i); this.latestBatches.add(j, batchIdentifier); } } } {noformat} |
|