Good time to all, tell me why there may be an error?

I use this code here:

$em = $this->getDoctrine()->getManager(); $do = $this->getDoctrine(); /** @var ContentBlock $ContentBlocks */ /** @var ContentBlockArchive $ContentBlocksArchive */ $ContentBlocksArchive = new ContentBlockArchive(); $ContentBlockContent = $do->getRepository(ContentBlockContent::class)->findOneBy(array('block_id'=>$ContentBlocks->getId())); $lang = $ContentBlockContent->getAliasId(); $type = $do->getRepository(ContentBlockType::class)->findOneBy(array('type'=>$ContentBlocks->getType())); $ContentBlocksArchive->setType($type); $ContentBlocksArchive->setValue($ContentBlockContent->getValue()); $ContentBlocksArchive->setLang($lang->getAlias()); $ContentBlocksArchive->setAlias($ContentBlocks->getAlias()); $ContentBlocksArchive->setName($ContentBlocks->getName()); $ContentBlocksArchive->setTimeAdd(); $em->persist($ContentBlocksArchive); $em->flush(); 

When it works, an error occurs:

 A new entity was found through the relationship 'App\Entity\ContentBlockContent#block_id' that was not configured to cascade persist operations for entity: App\Entity\ContentBlock@0000000052faa8f9000000000c55abc4. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). If you cannot find out which entity causes the problem implement 'App\Entity\ContentBlock#__toString()' to get a clue. 

Tell me why this error can occur I do not understand.

    1 answer 1

    In App \ Entity \ ContentBlockContent a new entry is created related to the 'block_id', but the persist is not executed for it and no cascading actions are configured. It is necessary to watch the connection.