title: Symfony2: class 'Doctrine\Common\Collections\ArrayCollection' was not found in the chain configured namespaces
body: <p>Error occurs when attempting to persist a one-to-many relationship.  In particular, a client may have multiple household members; a given household member is associated with one and only one client.  [I am new to Symfony so errors are expected!]  Your guidance gratefully accepted.</p>
  
  <p>N.B. Alternate controller snippet below yields integrity constraint error by trying to set the client's id in the household table to null.</p>
  
  <h3>Clients Entity snippet</h3>
  
  <pre class="lang-php prettyprint-override"><code>namespace Mana\AdminBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  use Doctrine\Common\Collections\ArrayCollection;
  
  /**
   * Mana\AdminBundle\Entity\Clients
   *
   * @ORM\Table(name="clients")
   * @ORM\Entity
   */
  class Clients
  {
      protected $members;
  
      public function __construct()
      {
          $this-&gt;members = new ArrayCollection();
      }
  
      public function getMembers()
      {
          return $this-&gt;members;
      }
  
      public function setMembers(ArrayCollection $members)
      {
          $this-&gt;members = $members;
      }
  
      /**
       * @var integer $id
       *
       * @ORM\Column(name="id", type="integer", nullable=false)
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="IDENTITY")
       * @ORM\OneToMany(targetEntity="Household", mappedBy="clients")
       * @ORM\ManyToOne(targetEntity="EthDesc", inversedBy="clients")
       * @ORM\JoinColumn(name="eid", referencedColumnName="id")
       */
  </code></pre>
  
  <h3>Household Entity snippet</h3>
  
  <pre class="lang-php prettyprint-override"><code>namespace Mana\AdminBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  
  /**
   * Mana\AdminBundle\Entity\Household
   *
   * @ORM\Table(name="household")
   * @ORM\Entity(repositoryClass="Mana\AdminBundle\Entity\HouseholdRepository")
   */
  class Household {
  
      /**
       * @var integer $hid
       *
       * @ORM\Column(name="hid", type="integer", nullable=false)
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="IDENTITY")
       * @ORM\ManyToOne(targetEntity="Clients", inversedBy="members")
       * @ORM\JoinColumn(name="cid", referencedColumnName="id")
       * @ORM\ManyToOne(targetEntity="EthDesc", inversedBy="members")
       * @ORM\JoinColumn(name="eid", referencedColumnName="id")
       */
  </code></pre>
  
  <h3>ClientsType snippet</h3>
  
  <pre class="lang-php prettyprint-override"><code>    -&gt;add('members', 'collection', array(
          'type' =&gt; new HouseholdType(),
          'allow_add' =&gt; true, 
          'by_reference' =&gt; false,
          'cascade_validation'  =&gt; true,
          ));
  </code></pre>
  
  <h3>Controller snippet</h3>
  
  <pre class="lang-php prettyprint-override"><code>public function createAction(Request $request) {
      $entity = new Clients();
      $form = $this-&gt;createForm(new ClientsType(), $entity);
      $form-&gt;bind($request);
  
      if ($form-&gt;isValid()) {
          $em = $this-&gt;getDoctrine()-&gt;getManager();
          $em-&gt;persist($entity);
          $em-&gt;persist($entity-&gt;getMembers());
          $em-&gt;flush();
          return $this-&gt;redirect($this-&gt;generateUrl('clients_show', array('id' =&gt; $entity-&gt;getId())));
      }
  }
  </code></pre>
  
  <h3>Alternate controller snippet</h3>
  
  <pre class="lang-php prettyprint-override"><code>public function createAction(Request $request) {
      $entity = new Clients();
      $form = $this-&gt;createForm(new ClientsType(), $entity);
      $form-&gt;bind($request);
  
      if ($form-&gt;isValid()) {
          $em = $this-&gt;getDoctrine()-&gt;getManager();
          $em-&gt;persist($entity);
          foreach ($entity-&gt;getMembers() as $member)
          {
              $em-&gt;persist($member);
          }
          $em-&gt;flush();
          return $this-&gt;redirect($this-&gt;generateUrl('clients_show', array('id' =&gt; $entity-&gt;getId())));
      }
  </code></pre>