title: how to save parent object containing child object using spring boot in @ManyToOne unidirectional mapping?
body: <p>I am new in spring boot. I've two model classes Party(parent) and PartyCategory(child). PartyCategory stores data id, labelAr and labelEn successfully.</p>
  
  <p>Now I am passing child id in json request and getting null values for labelAr and labelEn in json response as pasted below. Can someone please help what and doing wrong here. </p>
  
  <p>I've pasted my code as well.</p>
  
  <p>Json Request:</p>
  
  <pre><code>{
  
      "name": "Party A",
      "description": "Description of Party A",
      "category": {
          "id": 1
      }
  }
  </code></pre>
  
  <p>Json response;</p>
  
  <pre><code>{
      "id": 6,
      "name": "Party A",
      "description": "Description of Party A",
      "category": {
          "id": 1,
          "labelAr": null,
          "labelEn": null
      }
  }
  </code></pre>
  
  <p>Party.java:</p>
  
  <pre><code>   public class Party {
  
          @Id
          @GeneratedValue(strategy = GenerationType.AUTO)
          private Integer id;
          private String name;
          private String description;
          @ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.EAGER)
          @JoinColumn(name = "category_id")
          private PartyCategory category;
  
          ....setters and getters
     }
  </code></pre>
  
  <p>PartyCategory.java:-</p>
  
  <pre><code>public class PartyCategory {
  
      @Id
      @GeneratedValue
      private Integer id;
      private String labelAr;
      private String labelEn;
  
      ...setters and getters..
  </code></pre>
  
  <p>Repositories:</p>
  
  <pre><code>public interface PartyCategoryRepository extends JpaRepository&lt;PartyCategory, Integer&gt; {
  
  }
  
  public interface PartyRepository extends JpaRepository&lt;Party, Integer&gt; {
  
  }
  </code></pre>
  
  <p>Services:</p>
  
  <pre><code>public class PartyServiceImpl {
      @Autowired
      PartyRepository partyRepository;
  
  public Party saveParty(Party party) {
  
          return partyRepository.save(party);
      }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>@RestController
  public class PartyController {
  
      @Autowired
      PartyServiceImpl partyServiceIml;
  
  
      @PostMapping(value = "/party/save")
      public Party saveParty(@RequestBody Party party ) {
          Party returnedParty = partyServiceIml.saveParty(party);
          return returnedParty;
      }
  }
  </code></pre>