开发者社区 问答 正文

jackson延迟加载的对象如何处理??报错

搜索了没有想要的答案,报错如下

com.fasterxml.jackson.databind.JsonMappingException: failed to lazily initialize a collection of role: com.sun.pojo.Trade.sellers, no session or session was closed (through reference chain: java.util.ArrayList[0]->com.sun.pojo.ProdParas["prodClassify"]->com.sun.pojo.ProdClassify["products"]->org.hibernate.collection.PersistentSet[0]->com.sun.pojo.Product["seller"]->com.sun.pojo.Seller["trade"]->com.sun.pojo.Trade["sellers"])
	



如果要过滤这些属性该怎么做?大家都用的什么json jar包?

展开
收起
爱吃鱼的程序员 2020-06-14 18:59:00 817 分享 版权
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    在实体上加上@JsonIgnoreProperties(value={"hibernateLazyInitializer"})注解即可回复<aclass='referer'target='_blank'>@dcx013:你这个是超级多层的关系,懒加载吧回复<aclass='referer'target='_blank'>@清风流水:failedtolazilyinitializeacollectionofrolefailedtolazilyinitializeacollectionofrole报什么错没效果,还是一样报错,怎么过滤pojo中的set?

    2020-06-14 18:59:17
    赞同 展开评论
问答分类:
问答地址: