I have examples of creating parent/child relationships using GAE/JPA in my jappstart project. Take a look at how the authentication related entities are related to each other here.
One-to-One (see UserAccount.java and PersistentUser.java):
// parent
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private PersistentUser persistentUser;
// child
@OneToOne(mappedBy = "persistentUser", fetch = FetchType.LAZY)
private UserAccount userAccount;
One-to-Many (see PersistentUser.java) :
@OneToMany(mappedBy = "persistentUser", cascade = CascadeType.ALL)
private Collection<PersistentLogin> persistentLogins;
Many-to-One (see PersistentLogin.java):
@ManyToOne(fetch = FetchType.LAZY)
private PersistentUser persistentUser;
Also, note in the constructors how KeyFactory is used for entities with a parent versus without a parent.
@Id
private Key key;
// this entity has a parent
public PersistentUser(final Key key, final String username) {
this.key = KeyFactory.createKey(key, getClass().getSimpleName(), username);
...
}
// this entity does not have a parent
public UserAccount(final String username) {
this.key = KeyFactory.createKey(getClass().getSimpleName(), username);
....
}
Hopefully, this is helpful for you. I couldn't tell from the question whether you were using JPA or JDO.