I have a problem that I can't solve, I tried it with JsonIgnore too, but it didn't work either. I have a ToDo list, and I want my tasks to output the UserID I gave to them. The problem is because every user has a Task array, the tasks are giving me an infinite loop of tasks and users.
that's my Code:
User:
@Entity
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private String name;
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL)
private Set<Task> tasks;
Task:
@Entity
public class Task {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private String name;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "user_id", nullable = false)
private User user;
then I have normal getter and setter and a toString method.

