title: Spring Rest - Field with @ManyToOne mapping is null
body: <p>I have the below scenario:</p>
  
  <ol>
  <li>2 entities, User and Company;</li>
  <li>I'm using H2database;</li>
  <li>I persist a Company and everything is OK and id 1 is returned;</li>
  <li><p>When I try to save a User to Company, my field <strong>company_id</strong> in database, is empty. I don't know what is happening! See my json to persist a user:</p>
  
  <p>{
      "id": null,
      "name": "My Name",
      "login": "My Login",
      "mail":"my@mail.com",
      "password":"secret",
      "federalID":"0000000",
      "company":{"id": 1}
  }</p></li>
  </ol>
  
  <p><em>I'll no post Controllers and other class, just will show de important to solve this. Below the classes used with your maps</em>.</p>
  
  <p><strong>The User class:</strong></p>
  
  <pre><code>@Entity(name = "users")
  @Table(name = "users")
  @EqualsAndHashCode
  @Data
  public class User {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long id;
      private String name;
      private String login;
      private String mail;
      private String password;
      private String federalID;
      @ManyToOne(optional = false, cascade = CascadeType.ALL)
      @JoinColumn(name = "company_id", referencedColumnName="company_id")
      private Company company;
  }
  </code></pre>
  
  <p><strong>The Company class:</strong></p>
  
  <pre><code>@Entity(name="companies")
  @Table(name="companies")
  @EqualsAndHashCode
  @Data
  public class Company {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long id;
      private String name;
      private String federalID;
      @OneToMany(mappedBy="company", targetEntity=User.class, fetch=FetchType.EAGER) 
      private List&lt;User&gt; users;
  }
  </code></pre>
  
  <p><strong>Rest of User Entity (<em>Company Controller follow the same pattern</em>):</strong></p>
  
  <pre><code>@RestController
  public class UsersController {
  
      @Autowired 
      UserRepository userRepository;
  
      @RequestMapping(value = "/user", method = RequestMethod.GET)
      public List&lt;User&gt; getUsers(){
          return userRepository.findAll();
      }
  
      @RequestMapping(value = "/user/{id}", method = RequestMethod.GET)
      public User getUser(@PathVariable("id") Long id){
          return userRepository.findById(id);
      }
  
      @RequestMapping(value = "/user", method = RequestMethod.POST)
      public ResponseEntity&lt;User&gt; createUser(@RequestBody User company){
          return new ResponseEntity&lt;&gt;(userRepository.save(company), HttpStatus.CREATED);
      }
  
      @RequestMapping(value = "/user/{id}", method = RequestMethod.DELETE)
      public ResponseEntity&lt;Void&gt; deleteUser(@PathVariable("id") Long id){
          userRepository.delete(id);
  
          return new ResponseEntity&lt;Void&gt;(HttpStatus.OK);
      }
  
  }
  </code></pre>