Infinite loop with spring-boot in a one to many relation

前端 未结 6 1852
梦谈多话
梦谈多话 2021-02-06 09:52

In a rest application, I use spring boot with jpa.

I have a class Lodger

who have

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, m         


        
6条回答
  •  说谎
    说谎 (楼主)
    2021-02-06 10:08

    It happens when you have a cycle in return object and spring tries to serialize it to other type.

    Try to create DTO or Value Object (simple POJO) without cycles from returned model and then return it.

提交回复
热议问题