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
Java.lang.IllegalStateException: Cannot call sendError() after the response has been committed
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.
Here are my entities:
@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<Data> data1;
}
Repositories:
@Repository
@Transactional
public interface DataList extends JpaRepository<DataList,Long> {
}
@Repository
@Transactional
public interface Data extends JpaRepository<Data,Long> {
}
My error: Java.lang.IllegalStateException: Cannot call sendError() after the response has been committed
 
     
     
    