title: JPA and JSON serialization problems
body: <p>Help solve the problem.
  I have 2 entity classes:</p>
  
  <p>1.</p>
  
  <pre><code>@Entity
  @Table(name = "topic")
  public class Topic {
  @Id
  @Column(name = "topic_id")
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private int id;
  @Column(name = "system_id")
  private int systemId;
  @Column(name = "topic_name")
  private String name;
  @OneToMany(mappedBy = "topic", fetch = FetchType.EAGER, orphanRemoval = true)
  private List&lt;Faq&gt; faqList;
  // getters and setters
  @Override
  public String toString() {
      return "Topic{" +
              "id=" + id +
              ", systemId=" + systemId +
              ", name='" + name + '\'' +
              ", faqList=" + faqList +
              '}';
  }
  }
  </code></pre>
  
  <p>2.</p>
  
  <pre><code>@Entity
  @Table(name = "faq")
  public class Faq {
  @Id
  @Column(name = "faq_id")
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private int id;
  @Column(name = "question")
  private String question;
  @Column(name = "answer")
  private String answer;
  @ManyToOne
  @JoinColumn(name = "topic_id")
  @JsonIgnore
  private Topic topic;
  //getters and setters     
  @Override
  public String toString() {
      return "Faq{" +
              "id=" + id +
              ", question='" + question + '\'' +
              ", answer='" + answer + '\'' +
              ", topicId=" + topic.getId() +
              '}';
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I was forced to in toString method write to console only topic.id, because getting an error "StackOverflow". A similar situation with serialisation to JSON (jackson converter), therefore I used @JsonIgnore annotation. And all was okay. But there is a problem: when i send JSON object from controller.js <code>{topic: {id: "1"}, question: "test", answer: "test"}</code> to the server</p>
  
  <pre><code>@RequestMapping(method = RequestMethod.POST, value = "/faqs")
  @ResponseBody
  public Message editFaq(@RequestBody Faq faq) {
      System.out.println(faq);
  
      Message message = new Message("ok");
      return message;
  }
  </code></pre>
  
  <p>in System.out I got NullPointerException. I think that is because @JsonIgnore, when i try get faq.toString (topic.getId()) I got exception. How can I solve this problem? </p>
  
  <p>I solved this, adding path variable to the post:</p>
  
  <pre><code>@RequestMapping(method = RequestMethod.POST, value = "/faqs/{topicId}")
  ...
  Topic topic = new Topic();
  topic.setId(topicId);
  faq.setTopic(topic);
  </code></pre>
  
  <p>But this is spike.</p>