Strange Jackson exception being thrown when serializing Hibernate object

前端 未结 15 2707
离开以前
离开以前 2020-11-29 18:12

Jackson is throwing a weird exception that I don\'t know how to fix. I\'m using Spring, Hibernate and Jackson.

I have already considered that lazy-loading is causing

15条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-29 18:53

    I had a similar problem with lazy loading via the hibernate proxy object. Got around it by annotating the class having lazyloaded private properties with:

    @JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
    

    I assume you can add the properties on your proxy object that breaks the JSON serialization to that annotation.

    Avoid Jackson serialization on non fetched lazy objects

提交回复
热议问题