The fix for "HHH-12074 - order_inserts: flush during transaction causes incorrect insert ordering and subsequent constraint violation" added a "parent" field to BatchIdentifier, to sort entries.
However, the current code does not account for scenarios with cross-linked entities.
I've attached a ORMUnitTestCase sample.
It works with 5.2.12.Final.
It fails with 5.2.13.Final and later versions.