title: Undefined index "order", mapping error?
body: <p>I have a <code>ManyToMany</code> relationship defined as follow:</p>
  
  <p><code>OrderHasMedia.php</code> </p>
  
  <pre><code>/**
   * @ORM\Entity
   * @ORM\Table(name="order_has_media__media")
   */
  class OrderHasMedia {
  
      /**
       * @ORM\Id
       * @ORM\ManyToOne(targetEntity="PL\OrderBundle\Entity\Order", inversedBy="order_document", cascade={"all"})
       */
      protected $order;
  
      /**
       * @ORM\Id
       * @ORM\ManyToOne(targetEntity="Application\Sonata\MediaBundle\Entity\Media", inversedBy="order_document", cascade={"all"})
       */
      protected $media;
  
  }
  </code></pre>
  
  <p><code>Order.php</code></p>
  
  <pre><code>/**
   * @ORM\Entity
   * @ORM\Table(name="tb_order")
   * @Gedmo\Loggable
   */
  class Order {
  
      /**
       * @ORM\OneToMany(targetEntity="PL\OrderBundle\Entity\OrderHasMedia", mappedBy="order" , cascade={"all"})
       */
      protected $order_document;
  
  }
  </code></pre>
  
  <p><code>Media.php</code></p>
  
  <pre><code>class Media extends BaseMedia {
  
      /**
       * @var Collection
       * @ORM\OneToMany(targetEntity="PL\OrderBundle\Entity\OrderHasMedia", mappedBy="media", cascade={"all"})
       *
       */
      protected $order_document;
  
  }
  </code></pre>
  
  <p>If I try to add a new order I get this error:</p>
  
  <blockquote>
    <p>ContextErrorException: Notice: Undefined index: id in
    /var/www/html/apps/portal_de_logistica/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php
    line 685</p>
  </blockquote>
  
  <pre><code>in /var/www/html/apps/portal_de_logistica/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php line 685
  at ErrorHandler-&gt;handle('8', 'Undefined index: id', '/var/www/html/apps/portal_de_logistica/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php', '685', array('entity' =&gt; object(OrderHasMedia), 'result' =&gt; array(), 'uow' =&gt; object(UnitOfWork), 'versioned' =&gt; null, 'field' =&gt; 'order', 'change' =&gt; array(null, object(Order)), 'newVal' =&gt; object(Order), 'assoc' =&gt; array('fieldName' =&gt; 'order', 'id' =&gt; true, 'joinColumns' =&gt; array(array('name' =&gt; 'order_id', 'referencedColumnName' =&gt; 'id')), 'cascade' =&gt; array('remove', 'persist', 'refresh', 'merge', 'detach'), 'inversedBy' =&gt; 'order_document', 'targetEntity' =&gt; 'PL\OrderBundle\Entity\Order', 'fetch' =&gt; '2', 'type' =&gt; '2', 'mappedBy' =&gt; null, 'isOwningSide' =&gt; true, 'sourceEntity' =&gt; 'PL\OrderBundle\Entity\OrderHasMedia', 'isCascadeRemove' =&gt; true, 'isCascadePersist' =&gt; true, 'isCascadeRefresh' =&gt; true, 'isCascadeMerge' =&gt; true, 'isCascadeDetach' =&gt; true, 'sourceToTargetKeyColumns' =&gt; array('order_id' =&gt; 'id'), 'joinColumnFieldNames' =&gt; array('order_id' =&gt; 'order_id'), 'targetToSourceKeyColumns' =&gt; array('id' =&gt; 'order_id'), 'orphanRemoval' =&gt; false), 'oid' =&gt; '000000005c17f96200007f239e737d4c', 'newValId' =&gt; array('no_order' =&gt; '3424'), 'targetClass' =&gt; object(ClassMetadata), 'owningTable' =&gt; 'order_has_media__media', 'joinColumn' =&gt; array('name' =&gt; 'order_id', 'referencedColumnName' =&gt; 'id'), 'sourceColumn' =&gt; 'order_id', 'targetColumn' =&gt; 'id', 'quotedColumn' =&gt; 'order_id')) in /var/www/html/apps/portal_de_logistica/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php line 685
  </code></pre>
  
  <p>Where is the error? What's wrong in my mapping?</p>