To override the default commit order for collections because of a unique constraint (delete before insert instead of insert before delete), I manually add removed collection items to a separate array inside the entity instead of using orphanRemoval. In a preFlush event listener I call entityManager#remove on each removed collection item followed by entityManager#flush.
However, this seems to cause the preFlush event to be caught in an infinite recursive loop. Although this seems somewhat expected, the documentation says it is safe to call entityManager#flush inside the preFlush event: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html#preflush, which is why I implemented it anyway.
Is this a mistake in the documentation or could this be a bug?