Doctrine error: New Entity was found through relationship
This is typical problem of doctrine with joined relations.
And, to be specific, this would happen when trying to save an entity with relationship and the one being joined is fetched from memcached/redis or from other entity manager or you just populated it and not getting through Entity Manager
Solution to the doctrine error
Use the merge on EntityManager before you persist the object
Say you have an entity for pen and entity for color as well.. You want to save a new pen but you assigned a color from memcached object
$color = $this->memcacheGiveMeColor('blue'); $color = $em->merge($color) $pen->setColor($color); $em->persist($pen); $em->flush();
Make sure you are using the object that is returned from merge!
If you are not reading from the memcached or other factory, and you are reading directly from Entity Manager then you wont have this error.