【发布时间】:2015-02-19 07:13:37
【问题描述】:
在我的 RemoteServiceImpl (gwt) 中,我将返回一个 ArrayList。该模型有一些成员引用其他也可以持久化的对象。整个对象树来自 gae 数据存储。在 RemoteServiceImpl 中返回对象之前,我必须分离它们。不幸的是,在调用 pm.detachCopy() 之后,之前存在的嵌套信息丢失了。
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
@FetchGroup(name = "wc", members = {@Persistent(name = "waterConditions",
recursionDepth = -1)})
@JsonSerialize(include = JsonSerialize.Inclusion.NON_EMPTY)
public class InventoryInhabitant implements Serializable {
...
@Persistent(defaultFetchGroup = "true")
@Element(dependent = "true")
private InventoryWaterConditions waterConditions;
....
}
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
@JsonSerialize(include = JsonSerialize.Inclusion.NON_EMPTY)
public class InventoryWaterConditions implements Serializable {
...
@Persistent(defaultFetchGroup = "true")
@Element(dependent = "true")
private InventoryPh ph;
...
}
为简洁起见,Getter 和 Setter 被省略。分离字段 waterConditions 后不为空,但它不包含任何成员,例如“ph”为空。
在我的情况下我做错了什么?
【问题讨论】:
-
您是否在 FetchPlan 上设置了最大提取深度?
-
我试过 @Persistent(defaultFetchGroup = "true", recursionDepth = -1) 但没用。但是请提示我, detachCopy 受 FetchPlan 配置影响?
-
PM有一个FetchPlan,可以按照datanucleus.org/products/accessplatform_4_0/jdo/fetchgroup.html设置最大FetchDepth
-
Neil,非常感谢,它通过设置 pm.setMaxFetchDepth(-1) 起作用。
-
太棒了,添加为答案,以便您接受
标签: java google-app-engine gwt jdo datanucleus