protected void addSortedModifications ( List < DbOperation > flush ) { // calculate sorted set of all modified entity types SortedSet < Class < ? > > modifiedEntityTypes = new TreeSet < Class < ? > > ( MODIFICATION_TYPE_COMPARATOR ) ; modifiedEntityTypes . addAll ( updates . keySet ( ) ) ; modifiedEntityTypes . addAll ( deletes . keySet ( ) ) ; modifiedEntityTypes . addAll ( bulkOperations . keySet ( ) ) ; for ( Class < ? > type : modifiedEntityTypes ) { // first perform entity UPDATES addSortedModificationsForType ( type , updates . get ( type ) , flush ) ; // next perform entity DELETES addSortedModificationsForType ( type , deletes . get ( type ) , flush ) ; // last perform bulk operations SortedSet < DbBulkOperation > bulkOperationsForType = bulkOperations . get ( type ) ; if ( bulkOperationsForType != null ) { flush . addAll ( bulkOperationsForType ) ; } } //the very last perform bulk operations for which the order is important if ( bulkOperationsInsertionOrder != null ) { flush . addAll ( bulkOperationsInsertionOrder ) ; } }
Adds a correctly ordered list of UPDATE and DELETE operations to the flush .