Lets say, I have entity Forum with ManyToMany relations with User.
I need to validate user changes and I use code like
$uow = $this->getDoctrine()
$changeSet = $uow->getEntityChangeSet($forum);
if (.... bla-bla-bla....)
$em = $this->getDoctrine()->getEntityManager();
Unfortunately, whenever I try to change manyToMany relations - I got error
SQLSTATE: Integrity constraint violation: 1062 Duplicate entry '4-4' for key 'PRIMARY'
If I comment uow code - everything works just great.
It looks like bug in UnitOfWork implementation.
Let me know if you need more details from me.