Struts2 网格 json
如何排除列为 FetchType.LAZY 的 Hibernate 对象?它会导致问题,因为我收到 org.hibernate.LazyInitializationException。我知道它正在尝试序列化对象,但由于会话已关闭而无法序列化。我怎样才能禁用它?我有很多对象可以执行此操作,但让它们渴望或删除它们是不可行的,因为它们太多了。请帮忙。
How can I exclude Hibernate objects that are listed as FetchType.LAZY? It causes problems because I get a org.hibernate.LazyInitializationException. I understand that it is trying to serialize the object and it can not because the session is closed. How can I disable it? I have many objects that do this and it would not be feasible to make them eager nor to remove them as there are too many of them. Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我能够按照 nmc 的建议使用 includeProperties,但是不必定义属性并查看 JSONUtil 是否可以忽略延迟加载的对象仍然很好。
I was able to use includeProperties as suggested by nmc, however it would still be nice to not have to define the properties and see if JSONUtil can just ignore lazy loaded objects.
在你的struts.xml中:
或者你也可以做一个
includeProperties
。请参阅 http://struts.apache.org/2.2.3/docs/ json-plugin.html 了解更多详细信息。In your struts.xml:
Or you can also do an
includeProperties
. See http://struts.apache.org/2.2.3/docs/json-plugin.html for more details.