1
votes

I am getting following exception while saving the entity.(Database names configured in config.yml file.)

[{"message":"A new entity was found through the relationship 'Seal\MdBundle\Entity\MdJournal#user' that was not configured to cascade persist operations for entity: test. Explicitly persist the new entity or configure cascading persist operations on the relationship. If you cannot find out which entity causes the problem implement 'Seal\OAuthServerBundle\Entity\User#__toString()' to get a clue.","class":"InvalidArgumentException" ,"exceptionClassName":"InvalidArgumentException"}]

1
Either persist & flush the user oder cascade them. I don't see a problem with multiple object managers.Aitch

1 Answers

0
votes

Persist your entity user before MdJournal.

$user = new User();
$mdJournal = new MdJournal();
$mdJournal->setUser($user);
$em1 = $this->getDoctrine()->getEntityManager("db1")
$em2 = $this->getDoctrine()->getEntityManager("db2")
$em1->persist($user);
$em2->persist($mdJournal);
$em1->flush();
$em2->flush();

OR Add into OneToMany relation

* @ORM\OneToMany(targetEntity="MdJournal", mappedBy="user", cascade={"all"})