title: JSON received different from JSON sent with Spring Rest and Hibernate
body: <p>I'm having difficulties with Spring Rest &amp; Hibernate. I'm doing API calls from my Android application and one of the POST Calls seems to have an issue. </p>
  
  <p>I have 2 classes : <code>Player</code> and <code>Game</code></p>
  
  <pre><code>@Entity
  @Table(name = "Game", schema = "statistics")
  public class GameEntity {
      private int matchId;
      private int firstPlayer;
      private int secondPlayer;
  
      @Column(name = "first_player")
      public int getFirstPlayer() {
          return firstPlayer;
      }
  
      public void setFirstPlayer(int firstPlayer) {
          this.firstPlayer = firstPlayer;
      }
  
      @Column(name = "second_player")
      public int getSecondPlayer() {
          return secondPlayer;
      }
  
      public void setSecondPlayer(int secondPlayer) {
          this.secondPlayer = secondPlayer;
      }
  }
  
  @Entity
  @Table(name = "Players", schema = "statistics")
  public class PlayersEntity {
      private int playerId;
      private String name;
  
      @Id
      @Column(name = "player_id")
      public int getPlayerId() {
          return playerId;
      }
  
      public void setPlayerId(int id) {
          this.playerId = id;
      }
  
      @Basic
      @Column(name = "name")
      public String getName() {
          return name;
      }Ga
  
      public void setName(String name) {
          this.name = name;
      }
  }
  </code></pre>
  
  <p>When I send a POST for <code>Player</code> : it works. 
  However when I do the same for <code>Game</code> it refuses it because it doesn't receive the values correctly - when I debugged the <code>@RequestBody</code> I found that the Entity received contained incorrect values (all were 0's since all the fields are Integers) : </p>
  
  <p><a href="https://i.stack.imgur.com/9edlf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9edlf.png" alt="incorrect json values"></a></p>
  
  <p>Even though, the JSON sent had the correct values :</p>
  
  <p><a href="https://i.stack.imgur.com/UEnAb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UEnAb.png" alt="correct JSON"></a></p>
  
  <p>And I end up with a SQL Error (because 2 of the 3 id's in <code>Game</code> are foreign keys referencing <code>Player</code>).</p>
  
  <p>I really don't see why and I don't know how to log HTTP Requests/Responses on Spring.</p>
  
  <p>Anyways, thanks in advance to anybody who would guide me to a right response &amp; stay safe.</p>