I am not able to get child entities to load once they are persisted. I
am certain that they are saving because I can see them in the
datastore if I deploy an application and try it. For example if I have
the following two entities...
public class Parent implements Serializable{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Extension(vendorName="datanucleus", key="gae.encoded-pk",
value="true")
private String key;
@OneToMany(cascade=CascadeType.ALL)
private List<Child> children = new ArrayList<Child>();
//getters and setters
}
public class Child implements Serializable{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Extension(vendorName="datanucleus", key="gae.encoded-pk",
value="true")
private String key;
private String name;
@ManyToOne
private Parent parent;
//getters and setters
}
I can save the parent and a child just fine using the following:
Parent parent = new Parent();
Child child = new Child();
child.setName("Child Object");
parent.getChildren().add(child);
em.persist(parent);
However when I try to load the parent and then try to access the
children (I know GAE lazy loads) I do not get the child records.
//parent already successfully loaded
parent.getChildren.size(); // this returns 0
I've looked at tutorial after tutorial and nothing has worked so far.
I'm using version 1.3.3.1 of the SDK. I've seen the problem mentioned
on various blogs and even the App Engine group I believe but the
answer is always JDO related (dealing with fetch groups). Am I doing
something wrong or has anyone else had this problem and solved it for
JPA?
--
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.