在我的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"是空的。
在我的情况下,我做错了什么?
答案 0 :(得分:0)
PersistenceManager有一个FetchPlan。 FetchPlan具有最大“获取深度”,您可以在此链接http://www.datanucleus.org/products/accessplatform_4_0/jdo/fetchgroup.html
之后设置