Jira issue originally created by user mnapoli:
I have met a bug with cascade remove that I managed to reproduce with this use case (see also the diagram in the attachments):
All these associations are bidirectional, and with "cascade remove".
When I remove User:
If collections are lazy-loaded, then step 1. will clear the roles from the identityMap, but step 3. will reload the roles (because the authorizations will be lazy-loaded) and re-insert them in the identityMap.
As a consequence, the first flush() succeeds, but any further flush() yields:
[Doctrine\ORM\ORMInvalidArgumentException] A new entity was found through the relationship 'Role#user' that was not configured to cascade persist operations for entity...
I am creating a PR with a testcase, and probably a fix.
Comment created by mnapoli:
PR : #837
Comment created by @doctrinebot:
A related Github Pull-Request [GH-837] was closed:
Issue was closed with resolution "Fixed"