title: Cascade persisting issues with Doctrine2 and Symfony2
body: <p>I am using Symfony2 for my application and I am using two Entity Managers; 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>Initially it was working fine but now the following error is coming:</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>Here is my ProfileViewer Entity:</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 two entity managers.</p>