Closed
Description
Hi,
I found that when I was clearing the EntityManager for a specific entity class, only detach is executed for entities within the identityMap.
Clearing the scheduled insertions for that class isn't done.
Did anyone else experience this?
What I found is that newly persisted entities are not added to the identityMap and therefor are not removed.
My solution to this issue would be the following:
// Class UnitOfWork
// Method clear
if ($entityName === null) {
...
} else {
foreach ($this->identityMap as $className => $entities) {
...
}
foreach ($this->entityInsertions as $hash => $entity) {
if (get_class($entity) != $entityName) {
continue;
}
unset($this->entityInsertions[$hash]);
}
}
This has been proven to work in my case.
Let me know what you think
For this I created a pull request