如何在Grails Web流中丢弃嵌套对象

时间:2012-04-12 05:29:49

标签: hibernate grails spring-webflow

我正在使用Grails网络流程。我有两个域类ProducutItem和Product。 Product Item有一个名为Product的产品的字段。

我使用productItem.product来引用该产品。由于我使用的是Web Flow,我不想让这些类可序列化,因此我必须在使用后丢弃它们。但我无法弄清楚如何丢弃嵌套产品Object。我尝试了 productItem.disacrd() productItem.product.discard(),但他们没有用

1 个答案:

答案 0 :(得分:0)

丢弃对象只会将它们与休眠会话断开连接。这不会使他们成为Serializable。

如果您希望避免序列化产品对象,可以尝试:

productItem.discard()
productItem.product=null