HHH-11634 - ActionQueue#InsertActionSorter fails to generate right order

Use the same object for both the remove and the add operations
This commit is contained in:
Vlad Mihalcea 2017-04-19 21:02:02 +03:00
parent 84d61690c5
commit 020414e1aa
2 changed files with 5 additions and 4 deletions

View File

@ -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 );
}
}

View File

@ -71,12 +71,13 @@ public class InsertOrderingDuplicateTest
public void testBatching() throws SQLException {
doInHibernate( this::sessionFactory, session -> {
SaleDocumentItem saleDocumentItem = new SaleDocumentItem();
session.persist( saleDocumentItem );
SaleDocumentSummary saleDocumentsummary = new SaleDocumentSummary();
session.persist(saleDocumentsummary);
SaleDocumentItem saleDocumentItem = new SaleDocumentItem();
saleDocumentsummary.addItem( saleDocumentItem );
session.persist( saleDocumentItem );
Product product = new Product();
session.persist(product);