In Symfony2, is it possible to check if particular entity was already persisted and is present in the EntityManager?
I'm working with some data import and some of the records might be exact duplicates. I'm doing bulk inserts, i.e., calling flush() only after certain amount of entities were persisted. So, I need to check if the entity I am trying to persist is not in the EntityManager already.
yes you shoud use the unitOfWork http://phpdox.de/demo/Symfony2/classes/Doctrine_ORM_UnitOfWork.xhtml#isEntityScheduled
$uow = $this->getDoctrine()->getManager()->getUnitOfWork()
$exist = $uow->isEntityScheduled( $entity );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With