From 98a98eefe5f6dcfd6b4f43d2afa0e815c6cc55b4 Mon Sep 17 00:00:00 2001 From: Vlad Mihalcea Date: Wed, 19 Apr 2017 21:02:02 +0300 Subject: [PATCH] HHH-11634 - ActionQueue#InsertActionSorter fails to generate right order Use the same object for both the remove and the add operations (cherry picked from commit 020414e1aa79058c8a3196898a815079c38a8315) --- .../src/main/java/org/hibernate/engine/spi/ActionQueue.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/ActionQueue.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/ActionQueue.java index 4b98dfce48..45c97d3d65 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/ActionQueue.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/ActionQueue.java @@ -1105,7 +1105,7 @@ public class ActionQueue { for ( int j = i - 1; j >= 0; j-- ) { BatchIdentifier prevBatchIdentifier = latestBatches.get( j ); if(prevBatchIdentifier.getParentEntityNames().contains( entityName )) { - latestBatches.remove( i ); + latestBatches.remove( batchIdentifier ); latestBatches.add( j, batchIdentifier ); } } @@ -1116,7 +1116,7 @@ public class ActionQueue { //Take care of unidirectional @OneToOne associations but exclude bidirectional @ManyToMany if(nextBatchIdentifier.getChildEntityNames().contains( entityName ) && !batchIdentifier.getChildEntityNames().contains( nextBatchIdentifier.getEntityName() )) { - latestBatches.remove( i ); + latestBatches.remove( batchIdentifier ); latestBatches.add( j, batchIdentifier ); } }