Note that there are some explanatory texts on larger screens.

plurals
  1. POCascade persisting issues with Doctrine2 and Symfony2
    text
    copied!<p>I am using Symfony2 for my application and i am using two Entity Managers like One is for read and other is for write.</p> <p>I am creating Entity manager object like that:</p> <pre class="lang-php prettyprint-override"><code>$em = $this-&gt;getDoctrine()-&gt;getEntityManager('write'); $em = $this-&gt;getDoctrine()-&gt;getEntityManager('read'); </code></pre> <p><strong>Initially it was working fine but now the following error is coming:</strong></p> <blockquote> <p>A new entity was found through the relationship '<code>AppBundle\Entity\ProfileViewer#viewer</code>' that was not configured to cascade persist operations for entity: <code>shamsi</code>. Explicitly persist the new entity or configure cascading persist operations on the relationship.</p> </blockquote> <p><strong>Here is my ProfileViewer Entity :</strong></p> <pre class="lang-php prettyprint-override"><code>/** * AppBundle\Entity\ProfileViewer * * @ORM\Table(name="profile_viewer") * @ORM\Entity */ class ProfileViewer { /** * @var bigint $id * * @ORM\Column(name="id", type="bigint", nullable=false) * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") */ private $id; /** * @var bigint $userId * * @ORM\Column(name="user_id", type="bigint", nullable=false) */ private $userId; /** * @var datetime $viewedAt * * @ORM\Column(name="viewed_at", type="datetime", nullable=true) */ private $viewedAt; /** * @ORM\ManyToOne(targetEntity="user", inversedBy="viewers") * @ORM\JoinColumn(name="viewer_id", referencedColumnName="id") */ private $viewer; public function __construct() { $this-&gt;viewedAt = new \DateTime(); } /** * Get id * * @return bigint */ public function getId() { return $this-&gt;id; } /** * Set userId * * @param bigint $userId */ public function setUserId($userId) { $this-&gt;userId = $userId; } /** * Get UserId * * @return bigint */ public function getUserId() { return $this-&gt;userId; } /** * Set viewedAt * * @param datetime $viewedAt */ public function setViewedAt($viewedAt) { $this-&gt;viewedAt = $viewedAt; } /** * Get viewedAt * * @return datetime */ public function getViewedAt() { return $this-&gt;viewedAt; } /** * Set viewer * * @param AppBundle\Entity\User $viewer */ public function setViewer(AppBundle\Entity\User $viewer) { $this-&gt;viewer = $viewer; } /** * Get viewer * * @return AppBundle\Entity\User */ public function getViewer() { return $this-&gt;viewer; } } </code></pre> <p>This error comes when I have created 2 Entity managers. I am stuck here please help me out...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload