title: add item to the collection with foreign key via REST call
body: <p>I have 2 jpa entities with bidirectional associasion.</p>
  
  <p>Entity <code>Container</code> that holds collection of items (oneToMany)
  Ommiting getter/setters</p>
  
  <pre><code>@javax.persistence.Entity
  @Table(name = "CONTAINER")
  public class Container implements Serializable {
      private static final long serialVersionUID = -3288335692695653843L;
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name = "ID")
      private Long id;
  
      @OneToMany(fetch = FetchType.LAZY, mappedBy = "container", cascade = CascadeType.ALL)
      private List&lt;Item&gt; items;
  
  }
  </code></pre>
  
  <p>Entity <code>Item</code> contains reference back to the container (ManyToOne), with attributes value and date.
  Ommiting setter/getters</p>
  
  <pre><code>@javax.persistence.Entity
  @Table(name = "ITEM")
  public class Item implements Serializable {
  
      private static final long serialVersionUID = -758343957629274274L;
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name = "ID")
      private Long id;
  
      @Basic
      private Long value;
      @Basic
      private Date date;
  
      @ManyToOne(fetch = FetchType.EAGER)
      @JoinColumn(name = "CONTAINER_ID")
      private Container container;
  }
  </code></pre>
  
  <p>Also i am using spring-data repositories to expose data.</p>
  
  <p>My Interface repositories just extends <code>CrudRepository&lt;Container, Long&gt;</code> and <code>CrudRepository&lt;Item, Long&gt;</code></p>
  
  <pre><code>@RepositoryRestResource
  public interface ItemRepository extends CrudRepository&lt;Item, Long&gt; {
  }
  
  @RepositoryRestResource
  public interface ContainerRepository extends CrudRepository&lt;Container, Long&gt; {
  }
  </code></pre>
  
  <p>I am trying to create items via REST calls.</p>
  
  <p>First i tried this on items repository <code>rest/items</code></p>
  
  <pre><code>POST { "value" : 666, "date" : "2016-01-31T23:00:00.000+0000", "container": {"id":"1"}}
  </code></pre>
  
  <p>But it just creates item with null reference on container.</p>
  
  <p>When i try to add via container repository <code>rest/containers/1/items</code></p>
  
  <pre><code>POST { "value" : 666, "date" : "2016-01-31T23:00:00.000+0000", "container": {"id":"1"}}
  </code></pre>
  
  <p>I get <code>HTTP/1.1 204 No Content</code> and <code>&lt;Response body is empty&gt;</code>. No instance is created.</p>
  
  <p>My question is how i can add item via REST call that has reference to the container.</p>
  
  <p>EDIT: To specify my question, i want to add new item for the existing container. I am not sure how to deal with with foreign ID key when creating instance of Item via rest(json)</p>