Infinite Recursion with Jackson JSON and Hibernate JPA issue

前端 未结 25 3213
你的背包
你的背包 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条回答
  •  闹比i
    闹比i (楼主)
    2020-11-21 07:50

    I also met the same problem. I used @JsonIdentityInfo's ObjectIdGenerators.PropertyGenerator.class generator type.

    That's my solution:

    @Entity
    @Table(name = "ta_trainee", uniqueConstraints = {@UniqueConstraint(columnNames = {"id"})})
    @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
    public class Trainee extends BusinessObject {
    ...
    

提交回复
热议问题