title: Deleting child collection from parent
body: <p>I'm going crazy.</p>
  
  <p>This is the parent:</p>
  
  <pre><code>class Parent {
      /**
       * @Id
       * @GeneratedValue
       * @Column(type="integer")
       */
      protected $id;
  
      /**
       * @OneToMany(targetEntity="Core\Parent\Child", mappedBy="parent", cascade={"persist", "remove"})
       */
      protected $children;
  
  
      public function __construct() {
          $this-&gt;children = new \Doctrine\Common\Collections\ArrayCollection();
      }
  
  
      public function getChildren() {
          return $this-&gt;children-&gt;toArray();
      }
  
      public function removeAllChildren() {
          $this-&gt;children-&gt;clear();
      }
  
      public function addChild($child) {
          $this-&gt;children-&gt;add($child);
      }
  }
  </code></pre>
  
  <p>This is the child:</p>
  
  <pre><code>class Child {
      /**
       * @Id
       * @GeneratedValue
       * @Column(type="integer")
       */
      protected $id;
  
      /**
       * @ManyToOne(targetEntity="Core\Parent", inversedBy="children")
       * @JoinColumn(name="parent_id", referencedColumnName="id")
       */
      protected $parent;
  }
  </code></pre>
  
  <p>What is not working for me is deleting all EXISTING children for this parent. From my controller, I do:</p>
  
  <pre><code>$parent = $em-&gt;getRepository('Core\Parent')-&gt;find(1);
  $parent-&gt;removeAllChildren();
  </code></pre>
  
  <p>At this point, I can call <code>getChildren()</code> and it is empty. Before my script quits, I also do an: <code>$em-&gt;flush();</code></p>
  
  <p>However, I check the database tables and the data is still there! I don't get it, and it's driving me insane. How do I delete all the existing children for this parent?</p>