0

Why does postman return the same object to me in my get request multiple times? In my OneToMany relation I have Fetch.Lazy, however when I make the request it returns the same object multiple times. Attached screenshot of the output.

enter image description here

Documento.java

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "pais_id", nullable = false)
    private Pais pais;

Pais.java

    @OneToMany(mappedBy = "pais",fetch = FetchType.LAZY)
    private Set<Documento> documento;

I'm just returning a country(PAIS)

melolo
  • 115
  • 6
  • Which has a document, the document has pais, which has a document, which has a pais, which has a document, which has a pais, which.... Well you probably get the drift. You have a bi-directional relationship the whole `Pais` will be serialized so including the set of `Documento` which each have a `Pais` again. I'm a bit surprised you don't actually get a stack overflow error instead. – M. Deinum Apr 22 '21 at 09:09
  • Yeah i saw the error , and i got stackoverflow error. How could i fix it? – melolo Apr 22 '21 at 09:10

0 Answers0