In my RemoteServiceImpl (gwt) i would return an ArrayList. The model has a few members referencing to other objects which are also persistable. The whole object tree comes from gae datastore. I have to detach the objects before returning them in RemoteServiceImpl. Unfortunately after invoking pm.detachCopy() the nested information is lost which was previously present.
@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 and Setter present just omitted for brevity. After detaching the field waterConditions is not null but it contains nothing all members for example "ph" are null.
What i am do wrong in my case?
The PersistenceManager has a FetchPlan. A FetchPlan has a maximum "fetch depth" which you can set following this link http://www.datanucleus.org/products/accessplatform_4_0/jdo/fetchgroup.html