Details
Description
My problem : i have a class table inheritance, with only 3 class, one abstract and two concrete.
says AbstractClass, ConcretClassA and ConcreteClassB
All three are declared with @entity
if i already have in my identity map the ConcretClassA with id = 1
when i do an entityManager->find('ConcreteClassB', 1) the identityMap returns me the ConcretClassA with id = 1
that's not correct !
it should return a null value instead
That's because the entityRepository (and all the other doctrine class) call the UnitOfWork tryGetById with the rootEntityName, which in my case is AbstractClass.
See the first line of the entityRepository's find method :
$this->_em->getUnitOfWork()->tryGetById($id, $this->_class->rootEntityName)
if i change this line to :
$this->_em->getUnitOfWork()->tryGetById($id, $this->_class->name)
the find method return the expected null value.
So, why the UnitOfWork tryGetById method is always called with the rootEntityName ?
The identity map HAS to work by root entity name.
Otherwise think of an inheritance hierachy A
> B. Then both $em>find('A', 1); and $em->find('B', 1); should return the same instance.If this does not hold you are screwed.
Your problem is more subtle, i am not sure what the expected behavior should be here.