Infinite Recursion with Jackson JSON and Hibernate JPA issue

前端 未结 25 3136
你的背包
你的背包 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:35

    You Should use @JsonBackReference with @ManyToOne entity and @JsonManagedReference with @onetomany containing entity classes.

    @OneToMany(
                mappedBy = "queue_group",fetch = FetchType.LAZY,
                cascade = CascadeType.ALL
            )
        @JsonManagedReference
        private Set queues;
    
    
    
    @ManyToOne(cascade=CascadeType.ALL)
            @JoinColumn(name = "qid")
           // @JsonIgnore
            @JsonBackReference
            private Queue_group queue_group;
    

提交回复
热议问题