title: one to many relationship how to save data in spring boot
body: <p>below is my stores enitity</p>
  
  <pre><code>@Entity
  @Table(name="stores")
  public class Stores {
      @Id
      @GeneratedValue
      private Long id;
  
      @Column(name ="incharge_id")
      private Integer inchargeId;
  
      @Column(name = "store_name")
      private String storeName;
  
      @OneToMany(mappedBy = "stores",
              fetch = FetchType.LAZY,
              cascade = CascadeType.ALL)
      private Set&lt;Items&gt; items;
  
      public Set&lt;Items&gt; getItems() {
          return items;
      }
  
      public void setItems(Set&lt;Items&gt; items) {
          this.items = items;
          for (Items item : items) {
              item.setStores(this);
          }
      }
  
      public Long getId() {
          return id;
      }
  
      public void setId(Long id) {
          this.id = id;
      }
  
      public Integer getInchargeId() {
          return inchargeId;
      }
  
      public void setInchargeId(Integer inchargeId) {
          this.inchargeId = inchargeId;
      }
  
      public String getStoreName() {
          return storeName;
      }
  
      public void setStoreName(String storeName) {
          this.storeName = storeName;
      }
  }
  </code></pre>
  
  <p>Below is my item entity</p>
  
  <pre><code>package bt.gov.dit.inventoryservice.model;
  
  import javax.persistence.*;
  import java.util.Date;
  
  @Entity
  @Table(name = "items")
  public class Items {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long Id;
  
      @Column(name="item_name")
      private String itemName;
  
      @ManyToOne
      private Categories categories;
  
      @ManyToOne(fetch = FetchType.LAZY)
      //@JoinColumn(name = "book_category_id", referencedColumnName = "id")
      @JoinColumn(name = "stores_id", nullable = false,referencedColumnName = "id")
      private Stores stores;
  
      @Column(name="insert_date")
      private Date insertDate;
  
      @Column(name="update_date")
      private Date updateDate;
  
      public Long getId() {
          return Id;
      }
  
      public void setId(Long id) {
          Id = id;
      }
  
      public String getItemName() {
          return itemName;
      }
  
      public void setItemName(String itemName) {
          this.itemName = itemName;
      }
  
      public Categories getCategories() {
          return categories;
      }
  
      public void setCategories(Categories categories) {
          this.categories = categories;
      }
  
      public Stores getStores() {
          return stores;
      }
  
      public void setStores(Stores stores) {
          this.stores = stores;
          stores.getItems().add(this);
      }
  
      public Date getInsertDate() {
          return insertDate;
      }
  
      public void setInsertDate(Date insertDate) {
          this.insertDate = insertDate;
      }
  
      public Date getUpdateDate() {
          return updateDate;
      }
  
      public void setUpdateDate(Date updateDate) {
          this.updateDate = updateDate;
      }
  }
  
  </code></pre>
  
  <p>I have one-to-many relationship between them. One store can have many items. But I don't know how to insert items with stores . I have tried the default save of Jpa respoistory but in place of stores_id (which is the foreign key) it saves null. Can anyone tell me how to implement the service?</p>