Infinite Recursion with Jackson JSON and Hibernate JPA issue

前端 未结 25 3170
你的背包
你的背包 2020-11-21 07:31

When trying to convert a JPA object that has a bi-directional association into JSON, I keep getting

org.codehaus.jackson.map.JsonMappingException: Infinite          


        
25条回答
  •  情话喂你
    2020-11-21 07:56

    In my case it was enough to change relation from:

    @OneToMany(mappedBy = "county")
    private List towns;
    

    to:

    @OneToMany
    private List towns;
    

    another relation stayed as it was:

    @ManyToOne
    @JoinColumn(name = "county_id")
    private County county;
    

提交回复
热议问题