title: symfony2 JMSSerializerBundle deserialize entity with OneToMany association
body: <p>I have <code>Category</code> <code>OneToMany</code> <code>Post</code> association in doctrine2 setup like this:</p>
  
  <p>Category:</p>
  
  <pre><code>...
  /**
   * @ORM\OneToMany(targetEntity="Post", mappedBy="category")
   * @Type("ArrayCollection&lt;Platform\BlogBundle\Entity\Post&gt;")
   */
  protected $posts;
  ...
  </code></pre>
  
  <p>Post:</p>
  
  <pre><code>...
  /**
   * @ORM\ManyToOne(targetEntity="Category", inversedBy="posts")
   * @ORM\JoinColumn(name="category_id", referencedColumnName="id")
   * @Type("Platform\BlogBundle\Entity\Category")
   */
  protected $category;
  ...
  </code></pre>
  
  <p>I am trying to deserialize following json object (both entities with id of 1 already exist in database)</p>
  
  <pre><code>{
      "id":1,
      "title":"Category 1",
      "posts":[
          {
              "id":1
          }
      ]
  }
  </code></pre>
  
  <p>using JMSSerializerBundle serializer's deserialize method configured with doctrine object constructor</p>
  
  <pre><code>jms_serializer.object_constructor:
      alias: jms_serializer.doctrine_object_constructor
      public: false
  </code></pre>
  
  <p>with following result:</p>
  
  <pre><code>Platform\BlogBundle\Entity\Category {#2309
    #id: 1
    #title: "Category 1"
    #posts: Doctrine\Common\Collections\ArrayCollection {#2314
      -elements: array:1 [
        0 =&gt; Platform\BlogBundle\Entity\Post {#2524
          #id: 1
          #title: "Post 1"
          #content: "post 1 content"
          #category: null
        }
      ]
    }
  }
  </code></pre>
  
  <p>Which is fine at first sight. The problem is, that associated <code>Post</code> has <code>category</code> field set to <code>null</code>, resulting in no association on <code>persist()</code>. If I try to deserialize this:</p>
  
  <pre><code>{
      "id":1,
      "title":"Category 1",
      "posts":[
          {
              "id":1
              "category": {
                  "id":1
              }
          }
      ]
  }
  </code></pre>
  
  <p>it works fine but that is not what I want to do :( I suspect that solution could be to somehow reverse the order in which entities are saved. If the post was saved first and category second, this should work.</p>
  
  <p>How to save this association properly?</p>