title: Use existing database entry for foreign key in Doctrine
body: <p>Given already persisted objects for categories. How do one reuse the existing categories in a one-to-many relationship in new objects when only the id of the cateories is known</p>
  
  <pre><code>/** @Entity() */
  class Category {
      /**
       * @var string
       * @\Doctrine\ORM\Mapping\Column(type="string")
       */
      private $name;
      /** @var  string
       * @\Doctrine\ORM\Mapping\Id()
       * @\Doctrine\ORM\Mapping\Column(type="string")
       */
      private $id;
  
      /**
       * Category constructor.
       * @param string $name
       * @param string $id
       */
      public function __construct($name, $id)
      {
          $this-&gt;name = $name;
          $this-&gt;id   = $id;
      }
  
      /**
       * @return string
       */
      public function getName()
      {
          return $this-&gt;name;
      }
  
      /**
       * @return string
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  }
  </code></pre>
  
  <p>And now I have lets say two categories id=1 -> fiction and id=2 -> english book.
  Now I know the ids of the categories and want to save the one-to-many relations in my Book object.</p>
  
  <pre><code>/** @Entity() */
  class Book {
      /** @var  mixed
      * @\Doctrine\ORM\Mapping\OneToMany()
       */
      private $categories;
      /** @var  string */
      private $title;
  
      /**
       * Book constructor.
       * @param mixed $categories
       * @param string $title
       */
      public function __construct($categories, $title)
      {
          $this-&gt;categories = $categories;
          $this-&gt;title      = $title;
      }
  
      /**
       * @return mixed
       */
      public function getCategories()
      {
          return $this-&gt;categories;
      }
  
      /**
       * @return string
       */
      public function getTitle()
      {
          return $this-&gt;title;
      }
  }
  </code></pre>
  
  <p>Is it possible to create and persist a book object by hand with references an existing and already persisted object from which I do only know the id?</p>