title: How to add values to many side in one to many relationship spring boot
body: <p>I have merchant and address tables. one merchant can have multiple address and one address has one merchant(one to many relationship).When add merchant value with address I'm getting this error. How to solve this error?
  This is the error.</p>
  
  <pre><code>{
      "timestamp": 1554878673504,
      "status": 500,
      "error": "Internal Server Error",
      "message": "could not execute statement; SQL [n/a]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement",
      "path": "/merchant-service/save-merchant"
  }
  </code></pre>
  
  <p>This is my input values:</p>
  
  <pre><code> {
          "idNo": null,
          "idType": null,
          "emailId": "email@gmail.com",
          "name": null,
          "status": true,
          "createdBy": null,
          "modifiedBy": null,
          "createdDate": null,
          "modifiedDate": null,
          "contacts": [
              {"contactNo": "0766601122"}],
          "addresses": [
              {"line1": "manipay"},
              {"line1": "suthumalai"}
              ]
      }
  </code></pre>
  
  <p>this is my code in merchant model:</p>
  
  <pre><code> @OneToMany(fetch = FetchType.LAZY,cascade = {CascadeType.ALL}, mappedBy = "merchant")
      private Set&lt;Address&gt; addresses = new HashSet&lt;Address&gt;(
              0);
  </code></pre>
  
  <p>this is my code in Address model:</p>
  
  <pre><code> @ManyToOne(fetch = FetchType.LAZY)
      @JoinColumn(name = "merchant_id", nullable = false)
  //    @JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
  //    @Getter(onMethod = @__( @JsonIgnore))
  //    @Setter
      private Merchant merchant;
  </code></pre>
  
  <p>this is my service:</p>
  
  <pre><code>public Merchant saveMerchant(Merchant merchant) {
         merchant = merchantRepository.save(merchant);
         return merchant;
      }
  </code></pre>