title: Getting infinite Json response when using many to one mapping in spring
body: <p>I am trying to create Many to one mapping between two entities in spring. However when I try to fetch the values using a restController I get </p>
  
  <blockquote>
    <p>Java.lang.IllegalStateException: Cannot call sendError() after the
    response has been committed</p>
  </blockquote>
  
  <p>error and an infinite JSON response. Adding JSON ignore solves this issue but then I don't get that column in my response at all. I don't know how to fix this. Please help. Thanks in advance.</p>
  
  <p>Here are my entities:</p>
  
  <pre><code>@Entity
  @Table(name="tbl1")
  public class Data {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private long id;
  
      @Column(name = "customer")
      private String customer;
  
  
  
      @ManyToOne(fetch = FetchType.EAGER)
      @JoinColumn(name="data_id", insertable = true, nullable = false, updatable = false)
      private DataList dataList1;
  
  }
  
  @Entity
  @Table(name="tbl2")
  public class DataList {
  
      @Id
      @GeneratedValue(strategy=GenerationType.AUTO)
      @Column(name="data_id")
      private Long dataId;
  
  
  
      @Column(name="user_name")
      private String userName;
  
  
  
      @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER,mappedBy = "dataList1")
      private List&lt;Data&gt; data1;
  
  
  }
  </code></pre>
  
  <p>Repositories:</p>
  
  <pre><code>@Repository
  @Transactional
  public interface DataList extends JpaRepository&lt;DataList,Long&gt; {
  }
  @Repository
  @Transactional
  public interface Data extends JpaRepository&lt;Data,Long&gt; {
  }
  </code></pre>
  
  <p>My error: <code>Java.lang.IllegalStateException: Cannot call sendError() after the response has been committed</code></p>