I'm working with an entity Called "Session" kept in an HTTP Session. This session is related to an Article, which is related to an Image. The problem is when i want to update this session by changing a simple datetime row. I Want to update it everytime i call an AJaX Request. When the article's image is not null, i got an error when flushing, somehow my image has become null. I have no idea how to handle this. When there's no image inside the Article, everything works. And, somehow, when i call a "flush" in a totally random function, i got the error that my entity is invalid (" An exception occurred while executing 'INSERT INTO photo..").
Here is the code i'm using to read and update my session.
$em = $this->getDoctrine()->getManager();
$currentSession = $symfonySession->get('currentSession');
if($currentSession == null)
return new Response(404);
$currentSession = $em->merge($currentSession);
$currentSession->setUpdated(new \Datetime());
$em->flush();
$em->detach($currentSession);
$symfonySession->set('currentSession', $currentSession);
Well, i still have no idea how exactly it worked, but i only removed cascade={"all"}
.