title: Google DataStore not storing child objects
body: <p>I have an entity Course that has a key to another entity (Document) inside.  </p>
  
  <pre><code>@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true")
  public class Course{
  
   @PrimaryKey
      @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
      private Key key;
  
   @Persistent private Key document;
  
  public Document getDocument() {
    if (document != null)
    return new DocumentServiceImpl().getDocumentById(document.getId());
    return null;
   }
  public void setDocument(Document document) {
    if (document != null)
     this.document = new DocumentServiceImpl().saveAndGetKey(document);
   }
  </code></pre>
  
  <p>In some test code I make a new Course entity, and assign a new Document entity, and the document entity is persisted when I set the document property on course.  When I persist course, it will persist without error, however once it is persisted the document property will be null. </p>
  
  <p>Any ideas? Here is my save function for course:</p>
  
  <pre><code>public Boolean save(Course c){
    Boolean isSaved = false;
    PersistenceManager pm = PMF.get().getPersistenceManager();
  
    try{   
     pm.makePersistent(c);
     isSaved = true;
    }
    catch(Exception e){
     e.printStackTrace();
     isSaved = false;
    }
    finally{
     pm.close();
    }
  
    return isSaved;
  
   }
  </code></pre>
  
  <p>Edit to add:</p>
  
  <pre><code>@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true")
  public class Document{
   @PrimaryKey
      @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
      private Key key;
  
   @Persistent private String   data;
   @Persistent private Set&lt;Key&gt;  dTags;
   @Persistent private Date   dateCreated;
   @Persistent private Date   dateEdited;
  
   public Document(){
    this.dateCreated = new Date();
   }
  
   public Long getId() {
    if (key == null){
     return null;
    } else {
     return key.getId();
    }
   }
   public void setId(Long id) {
    if (id != null)
    key = KeyFactory.createKey(this.getClass().getSimpleName(), id);
   }
  </code></pre>
  
  <p>from DocumentServicesImpl:</p>
  
  <pre><code>public Key saveAndGetKey(Document d) {
    try{
     if (d.getKey() == null){
      save(d);
     }
  
     return d.getKey();
    } catch (Exception e){
     return null;
    }  
   }
  
  public Boolean save(Document d) {
    Boolean isSaved = false;
    PersistenceManager pm = PMF.get().getPersistenceManager();
  
    try {
     pm.makePersistent(d);
     isSaved = true;
    } catch (Exception e) {
     e.printStackTrace();
     isSaved = false;
    }finally{pm.close();}
  
    return isSaved;
  
   }
  </code></pre>
  
  <p>public Document getDocumentById(Long id) {</p>
  
  <p>PersistenceManager pm = PMF.get().getPersistenceManager();
    Document d = new Document();</p>
  
  <p>try {
     d = pm.getObjectById(Document.class, id);
    } finally {
     pm.close();
    }</p>
  
  <p>return d;
   }</p>