A: 

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.

Taylor Leese
I am actually using JDO, and I'ld rather stick to it. My learning-curve is steep as it is :)
David
A: 

If you have a reference to a Father in the Child and to the Children in the Father than you have the potential for inconsistency assuming that the relationship between Father and Child is two-way (ie. every Child's father should be in the list of Children for that Father). Only one of the two references is necessary.

Both solutions will work, but keeping the list of children in the father has two disadvantages:

  1. Every access to the Father object will download the list keys to the child object. If there are many keys, this could cause unnecessary overhead.
  2. I believe that GAE limits the size of a list to 5,000 items.
Do you have a source for #1? It seems to me there shouldn't be much overhead with lazy loading. Also, the entities Key will already contain the necessary information to obtain it's parent regardless if there is an actual relationship defined via @ManyToOne, etc.
Taylor Leese
Look at page 20 of this Google I/O presentation from 2009http://dl.google.com/io/2009/pres/W_0415_Building_Scalable_Complex_App_Engines.pdf
Ahhmm... I didn't know about the inconsistency part.However, in my scenario fetching the a Father object, does normally mean fetching its Child objects.How would I fetch the offsprings of a certain Father, without having a Collection of references to them?
David
A: 
naikus
Thanks, btw a typo in my second example the children list should have been :@Persistentprivate List<Key> childern;
naikus
A: 
David