title: Hibernate binding returns null on insert
body: <p>I'm here to get help because I've been searching the internet for a few hours without finding my answers. Maybe someone here will have a solution to my problem.</p>
  <p>I'm new with spring boot, so don't be too mean to me, I probably missed some information in the documentation.
  I'm trying to add data to my database with a json file that looks like this one.
  Everything works correctly up to the OneToMany relationship and vice versa ManyToOne (I followed the doc <a href="https://en.wikibooks.org/wiki/Java_Persistence/OneToMany" rel="nofollow noreferrer">here</a>).
  I put <em>Cascade.ALL</em> to propagate to entities.
  As you can see, Hibernate makes a binding with a null value, as if it had never been inserted whereas it seems to be at the previous step.
  A lot of topics deal with this problem, and for many of them they have been solved with the null = false option, but it doesn't work for me.</p>
  <p>Information:
  A contact can have multiple email addresses, and an email address belongs to only one contact.</p>
  <p>My code :</p>
  <p><strong>Emails</strong></p>
  <pre class="lang-java prettyprint-override"><code>@NoArgsConstructor
  @AllArgsConstructor
  @Getter
  @Setter
  @Entity
  @Table(name = &quot;Email&quot;)
  public class Email implements Serializable {
  
      @Id
      @GeneratedValue
      @Column(name = &quot;idEmail&quot;)
      private int id;
  
      @Column(name = &quot;Email&quot;)
      @JsonProperty(&quot;mail&quot;)
      private String email;
  
      @ManyToOne(fetch = FetchType.LAZY)
      @JoinColumn(name = &quot;Contact_idContact&quot;)
      private Contact contact;
  }
  </code></pre>
  <p><strong>Contact</strong></p>
  <pre class="lang-java prettyprint-override"><code>@Entity
  @Table(name = &quot;Contact&quot;)
  @NoArgsConstructor
  @AllArgsConstructor
  @Getter
  @Setter
  public class Contact implements Serializable {
  
      @GeneratedValue
      @Id
      @Column(name = &quot;idContact&quot;, nullable = false, unique = true)
      private int id;
  
      @Column(name = &quot;Nom&quot;)
      private String nom;
  
      @Column(name = &quot;Prenom&quot;)
      private String prenom;
  
      @Column(name = &quot;Mobile&quot;)
      private String mobile;
  
      @OneToMany(cascade = CascadeType.ALL, mappedBy = &quot;contact&quot;)
      private Set&lt;Email&gt; emails = new HashSet&lt;&gt;();
  }
  </code></pre>
  <p>My json post :</p>
  <pre class="lang-json prettyprint-override"><code>{
  &quot;contacts&quot;: [
      {
        &quot;nom&quot;: &quot;myName&quot;,
        &quot;prenom&quot;: &quot;MyFirstName&quot;,
        &quot;mobile&quot;: &quot;06666666666&quot;,
        &quot;emails&quot;: [
          {
            &quot;mail&quot;: &quot;mail1@test.com&quot;
          },
            {
            &quot;mail&quot;: &quot;mail2@test.com&quot;
          }
        ],
      }
    ]
  }
  </code></pre>
  <p><strong>POST Method</strong></p>
  <pre class="lang-java prettyprint-override"><code> @PostMapping(&quot;/add&quot;)
      public ResponseEntity&lt;Void&gt; addContact(@RequestBody Contact contact) {
  
          Contact contact1 = contactService.save(contact);
          URI location = ServletUriComponentsBuilder
                  .fromCurrentRequest()
                  .path(&quot;/{id}&quot;)
                  .buildAndExpand(contact1.getId())
                  .toUri();
          return ResponseEntity.created(location).build();
      }
  </code></pre>
  <p>Error:</p>
  <pre><code>2020-10-15 16:40:16.501 DEBUG 13608 --- [nio-9000-exec-2] org.hibernate.SQL                        : insert into Contact (Mobile, Nom, Prenom, idContact) values (?, ?, ?, ?)
  2020-10-15 16:40:16.502 TRACE 13608 --- [nio-9000-exec-2] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [VARCHAR] - [06666666666]
  2020-10-15 16:40:16.503 TRACE 13608 --- [nio-9000-exec-2] o.h.type.descriptor.sql.BasicBinder      : binding parameter [2] as [VARCHAR] - [MyName]
  2020-10-15 16:40:16.504 TRACE 13608 --- [nio-9000-exec-2] o.h.type.descriptor.sql.BasicBinder      : binding parameter [3] as [VARCHAR] - [MyFirstName]
  2020-10-15 16:40:16.505 TRACE 13608 --- [nio-9000-exec-2] o.h.type.descriptor.sql.BasicBinder      : binding parameter [4] as [INTEGER] - [46]
  2020-10-15 16:40:16.510 DEBUG 13608 --- [nio-9000-exec-2] org.hibernate.SQL                        : insert into Email (Contact_idContact, Email, idEmail) values (?, ?, ?)
  2020-10-15 16:40:16.511 TRACE 13608 --- [nio-9000-exec-2] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [INTEGER] - [null]
  2020-10-15 16:40:16.512 TRACE 13608 --- [nio-9000-exec-2] o.h.type.descriptor.sql.BasicBinder      : binding parameter [2] as [VARCHAR] - [mail1@test.com]
  2020-10-15 16:40:16.512 TRACE 13608 --- [nio-9000-exec-2] o.h.type.descriptor.sql.BasicBinder      : binding parameter [3] as [INTEGER] - [47]
  2020-10-15 16:40:16.542  WARN 13608 --- [nio-9000-exec-2] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 1048, SQLState: 23000
  2020-10-15 16:40:16.542 ERROR 13608 --- [nio-9000-exec-2] o.h.engine.jdbc.spi.SqlExceptionHelper   : Column 'Contact_idContact' cannot be null
  2020-10-15 16:40:16.636 ERROR 13608 --- [nio-9000-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement] with root cause
  </code></pre>
  <p>In this case, <code>Contact_idContact</code> should be 46 as inserted.</p>
  <p>What's wrong with it?</p>