1

如何排除列为 FetchType.LAZY 的 Hibernate 对象?它会导致问题,因为我得到一个 org.hibernate.LazyInitializationException。我知道它正在尝试序列化对象并且它不能因为会话已关闭。我怎样才能禁用它?我有很多对象可以做到这一点,因为它们太多了,所以让它们渴望或删除它们是不可行的。请帮忙。

4

2 回答 2

1

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

<result name="success" type="json">
    <param name="includeProperties"> ^gridModel\[\d+\]\.first, ^gridModel\[\d+\]\.last, rows, page, total, record</param>               
</result>    
于 2011-07-22T16:55:57.990 回答
0

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.

于 2011-07-21T21:35:59.660 回答