I have an entity Course that has a key to another entity (Document)
inside.
==================== START ======================
@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);
}
==================== END ====================
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.
Any ideas? Here is my save function for course:
========= START ===========
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;
}
========= END ==============
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google App Engine" 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?hl=en
-~----------~----~----~----~------~----~------~--~---