title: How to post ManyToOne and OneToOne entity using JSON format?
body: <p>I have <code>comment</code> entity which has <code>user_id</code> and <code>project_id</code> as foreign keys. And comments can have parent-child relation in the same table which is mentioned by <code>parent_commnent_id</code>. </p>
  
  <pre><code>import com.fasterxml.jackson.annotation.JsonIgnore;
  import org.hibernate.annotations.Fetch;
  import org.hibernate.annotations.FetchMode;
  
  import javax.persistence.*;
  import java.util.ArrayList;
  import java.util.List;
  
  @Entity
  @Table
  public class Comment {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name = "comment_id")
      private int commentId;
  
      @ManyToOne
      @JsonIgnore
      @JoinColumn(name = "project_id")
      private Project projectId;
  
      @Column(name = "comment")
      private String comment;
  
      @OneToOne(cascade = CascadeType.ALL)
      @JoinColumn(name = "user_id", referencedColumnName = "user_id")
  
      private RegisteredUser user;
  
      @ManyToOne
      @JsonIgnore
      @JoinColumn(name = "Parent_comment_id")
      public Comment ParentCommentId;
  
      @OneToMany(mappedBy = "ParentCommentId")
      public List&lt;Comment&gt; childComments = new ArrayList&lt;Comment&gt;();
  
      public int getCommentId() {
          return commentId;
      }
  
      public void setComment(String comment) {
          this.comment = comment;
      }
  
      public Project getProjectId() {
          return projectId;
      }
  
      public void setProjectId(Project projectId) {
          this.projectId = projectId;
      }
  
      public RegisteredUser getUser() {
          return user;
      }
  
      public void setUser(RegisteredUser user) {
          this.user = user;
      }
  
      public String getComment() {
          return comment;
      }
  
      public void setCommentId(int commentId) {
          this.commentId = commentId;
      }
  }
  
  </code></pre>
  
  <p>I have inserted some data manually </p>
  
  <pre><code>INSERT INTO comment (comment, Parent_comment_id, project_id, user_id) VALUES ( 'first comment', null, 1, 1);
  INSERT INTO comment (comment, Parent_comment_id, project_id, user_id) VALUES ( 'first child comment', 1, 1, 2);
  </code></pre>
  
  <p>Which returns me this </p>
  
  <p><a href="https://i.stack.imgur.com/X34n8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/X34n8.png" alt="enter image description here"></a></p>
  
  <p>But i am unable to post data by postman. I have tried this</p>
  
  <pre><code>{
      "comment": "third comment",
      "userId": 2, 
      "projectId" : 3,
      "parentCommentId" : 2
  }
  </code></pre>
  
  <p>Which inserts the data but returns <code>userId</code>, <code>projectId</code>, and <code>parentCommentId</code> as null.</p>
  
  <p>and I also tried this.</p>
  
  <pre><code>{    
       "comment": "third comment",
       "user": {
              "userId" : 2
          }
  }
  </code></pre>
  
  <p>which gives me 500 error.</p>