Before I used only one entity manager to interact with my database.
Everything worked well till I add 2 new entity manager (one entity manager to insert data and one entity manager to select data)
-> I want to make a replication of my database later.
I think, I can solve the problem alone, but I just want to understand why this error appears :
A new entity was found through the relationship 'AppBundle\Entity\Userinterest#user'
that was not configured to cascade persist operations for entity: my_username.
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"})
I think, I understand the problem :) :
My User from FOSUserBundle is authenticate with the default entity manager.
$userinteret->setUser($this->getUser());
$em = $this->getDoctrine()->getManager();
$em->persist($userinteret);
$em->flush();
Then, I don't know how is stored the token_storage. But because I use the user from the token_storage, I think the probem come from there.