Struts2 网格 json

发布于 2024-11-25 16:09:28 字数 180 浏览 3 评论 0原文

如何排除列为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

开始看清了 2024-12-02 16:09:28

我能够按照 nmc 的建议使用 includeProperties,但是不必定义属性并查看 JSONUtil 是否可以忽略延迟加载的对象仍然很好。

<result name="success" type="json">
    <param name="includeProperties"> ^gridModel\[\d+\]\.first, ^gridModel\[\d+\]\.last, rows, page, total, record</param>               
</result>    

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.

<result name="success" type="json">
    <param name="includeProperties"> ^gridModel\[\d+\]\.first, ^gridModel\[\d+\]\.last, rows, page, total, record</param>               
</result>    
北城挽邺 2024-12-02 16:09:28

在你的struts.xml中:

<result name="success" type="json">
    <param name="excludeProperties">
        <!-- insert comma separated parameters to be excluded here -->
    </param>
</result>

或者你也可以做一个includeProperties。请参阅 http://struts.apache.org/2.2.3/docs/ json-plugin.html 了解更多详细信息。

In your struts.xml:

<result name="success" type="json">
    <param name="excludeProperties">
        <!-- insert comma separated parameters to be excluded here -->
    </param>
</result>

Or you can also do an includeProperties. See http://struts.apache.org/2.2.3/docs/json-plugin.html for more details.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文