This is my District Controller, when I try to fetch data after saving I get the error, even when I try get object form getDistrict(Long id)
the same strikes ple
That's because for Statemaster
in json the set of Districtmaster
's is put.
And each Districtmaster
has the Statemaster
in itself, so it's also put into the json. So that you get the infinite recursion
@JsonIgnore
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY,
mappedBy="statemaster")
public Set getDistrictmasters() {
return this.districtmasters;
}
Adding @JsonIgnore
annotation on Set
will prevent that recursion.
You can put the @JsonIgnore
at public Statemaster getStatemaster()
either.