There is a possible flow that cause issue, if a message is dispatch and not async, in the handler it's flushing that will cause a double flush.
I had an entity that was refering another entity, the double flush cause a "A new entity was found through the relationship...".
Work around is to put a cascade "remove" but the entity was suppose to be one sided.
Solution would be to decorate the unit of work to dispatch an specific event at the end (after the postCommitCleanup) so it will not be a "double flush" since nothing will be done after it.
There is a possible flow that cause issue, if a message is dispatch and not async, in the handler it's flushing that will cause a double flush.
I had an entity that was refering another entity, the double flush cause a "A new entity was found through the relationship...".
Work around is to put a cascade "remove" but the entity was suppose to be one sided.
Solution would be to decorate the unit of work to dispatch an specific event at the end (after the postCommitCleanup) so it will not be a "double flush" since nothing will be done after it.