title: Spring JPA + Hibernate : OneToMany bidirectional persisting
body: <p>How to persist child entity in oneToMany relationship ?</p>
  
  <pre><code>@Entity
  public class Payment implements Serializable {
  
    @ManyToOne(cascade = {CascadeType.ALL}, fetch = FetchType.LAZY)
    @JoinColumn(name = "registration", nullable = false)
    private Registration registration;
  }
  
  @Entity 
  public class Registration implements Serializable {
  
   @OneToMany(mappedBy="registration", cascade = {CascadeType.ALL}, fetch = FetchType.LAZY)
   private List&lt;Payment&gt; payment;
  }
  </code></pre>
  
  <p>On registration creation, if registration column is not nullable in Payment table :</p>
  
  <blockquote>
    <p>com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException:
    Column 'registration' cannot be null</p>
  </blockquote>
  
  <p>But if registration is nullable then a payment is created but registration column is null :</p>
  
  <p><a href="https://i.stack.imgur.com/nJ0ug.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nJ0ug.png" alt="enter image description here"></a></p>
  
  <p>Until an exception occurs and "HH000010: On release of batch it still contained JDBC statements" be executed.</p>
  
  <p>Please can you help me, to disabled Hibernate batch or understand what is wrong ?</p>