When trying to convert a JPA object that has a bi-directional association into JSON, I keep getting
org.codehaus.jackson.map.JsonMappingException: Infinite
For some reason, in my case, it wasn't working with Set. I had to change it to List and use @JsonIgnore and @ToString.Exclude to get it working.
Replace Set with List:
//before
@OneToMany(mappedBy="client")
private Set addressess;
//after
@OneToMany(mappedBy="client")
private List addressess;
And add @JsonIgnore and @ToString.Exclude annotations:
@ManyToOne
@JoinColumn(name="client_id", nullable = false)
@JsonIgnore
@ToString.Exclude
private Client client;