Jira issue originally created by user gedrox:
We are using several Doctrine managers in our project with the same entity classes and different database tables.
The problem appears when we are willing to merge entity with lazy associations from one manager to another. The second entity manager instance hasn't got the proxy object metadata defined yet so it fails with Doctrine\ORM\Mapping\MappingException exception "Class EntityProxy is not a valid entity or mapped super class.".
If both entity managers share the proxy objects the problem can be fixed by calling
which will register the entity metadata for the proxy classname as well.
Still if the proxy configuration differs, there is no fix found without changing the Doctrine ORM code.
The fix inside the Doctrine would be to detect Proxy classes before loading the metadata and load the metadata for it's parent class instead. Please see the diff attached with proposed solution.
Also I think this issue could arise when unserialized entity objects will be merged into the entity manager. I will try creating test case for this.
Comment created by gedrox:
Test case attached.
See my pull request in #332.
Imported 2 attachments from Jira into https://gist.github.com/caaa686d79a5945f5519