While doing a sync of a hierarchy of DataCollections, the order by which collections (root collection and child collections of modified objects) are synced is random by default. The problem is with the way the rankings, set in the FXOneToMany annotations, are taken into account. By default, all the rankings are 0, so the process goes like this:
1. The root collection creates a BatchService and registeres itself with priority 0.
2. In a recursive function registerWithChildren, child collections get added with priority: parentPriority * 100 + childRanking. So if both parentPriority and childRanking are 0 (the default), all collections get registered with priority 0.
Probably the easiest fix would be to change the root collection's priority to 1.
Also, why doesn't the delete order also take rankings into account? The formula for the priority of deleted objects' child collections is parentPriority + 1.
Also, note that there's a bug in the documentation of FXOneToMany: it says that the formula for the priority of child collections is parentPriority + 100 + childRanking.