// sort entities for insertion
List sorted = new ArrayList(entities);
EntitySorter sorter = new AshwoodEntitySorter();
sorter.setEntityResolver(new EntityResolver(destinationNode.getDataMaps()));
sorter.sortDbEntities(sorted, false);
if (cleaningDestination) {
// reverse insertion order for deletion
List entitiesInDeleteOrder = new ArrayList(sorted.size());
entitiesInDeleteOrder.addAll(sorted);