title: Spring Boot foreign key entity null
body: <p><code>Spring Boot</code> version <code>2.1.6</code>.</p>
  
  <p>I have <code>User</code> class :</p>
  
  <pre><code>@Data
  @Entity
  public class User {
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      @Column(name = "id")
      Long userID;
      String eMail;
      public User()
      {
  
      }
  }
  </code></pre>
  
  <p>And a <code>LoginCredential</code> class :</p>
  
  <pre><code>@Data
  @Entity
  public class LoginCredential {
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      @Column(name = "id")
      Long userID;
      String eMail;
      String passwordHash;
      @OneToOne(cascade = CascadeType.ALL)
      @JoinColumn(name = "id", referencedColumnName = "id")
      User user;
      public LoginCredential()
      {
  
      }
  }
  </code></pre>
  
  <p>Shouldn't it create an instance of <code>User</code> when I create an instance of <code>LoginCredential</code>.</p>
  
  <p>Cause I run this command : <code>curl -X POST -H "Content-Type: application/json" -d "{ \"email\": \"a\", \"passwordHash\": \"b\" }" http://localhost:8080/login</code></p>
  
  <p>And I got an instance of <code>LoginCredential</code> <strong>but not</strong> of an <code>User</code>.</p>
  
  <p>Response :</p>
  
  <p><code>{"userID":1,"passwordHash":"b","user":null,"email":"a"}</code></p>
  
  <p>And then I run this command : <code>curl -X POST -H "Content-Type: application/json" -d "{ \"email\": \"c\", \"passwordHash\": \"d\" ,\"user\":{}}" http://localhost:8080/login</code></p>
  
  <p>And what I got is <strong>nothing</strong>, not of same ID.</p>
  
  <p>Response :</p>
  
  <p><code>{"userID":2,"passwordHash":"d","user":{"userID":3,"email":null},"email":"c"}</code></p>
  
  <p><strong>Am I missing something ? How this can be resolved ?</strong></p>
  
  <p><code>LoginCredentialController</code> partially :</p>
  
  <pre><code>@PostMapping("/login")
  LoginCredential newLoginCredential(@RequestBody LoginCredential newLoginCredential)
  {   
      return repository.save(newLoginCredential);
  }
  </code></pre>
  
  <p>My <a href="https://pastebin.com/V0R40E5j" rel="nofollow noreferrer">pom.xml</a></p>
  
  <p>My <a href="https://pastebin.com/kmqGxsC1" rel="nofollow noreferrer">application.properties</a></p>