Hi, when it comes to define relationships in the datastore, I have problems to define a mapping between GAE python and GAE Java objects . It is especially relevant as at the moment it is only possible to upload data for a GAE Java application using GAE python script 'appcfg.py upload_data ...' ( http://code.google.com/appengine/docs/python/tools/uploadingdata.html ).
I'll take the example of an unowned one-to-many relationship between an 'Ontology' object and 'Term' objects. To upload the data, I define this GAE python classes (following tutorial: http://code.google.com/appengine/articles/modeling.html) class Ontology(db.Model): name = db.StringProperty() class Term(db.Model): name = db.StringProperty() ontology = db.ReferenceProperty(Ontology, collection_name='terms') Once the upload is done, I want to access the data in a GAE Java application. According to the datastore viewer, it looks like the corresponding GAE Java classes should be: @PersistenceCapable(identityType = IdentityType.APPLICATION) public class Ontology { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key key; @Persistent private String name; } @PersistenceCapable(identityType = IdentityType.APPLICATION) public class Term { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key key; @Persistent private String name; @Persistent private Key ontology; } But according to the GAE Java relationship tutorial ( http://code.google.com/appengine/docs/java/datastore/relationships.html#Unowned_Relationships ), a one-to-many relationship should be modeled as: @PersistenceCapable(identityType = IdentityType.APPLICATION) public class Ontology { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key key; @Persistent private String name; @Persistent private Set<Key> terms; } @PersistenceCapable(identityType = IdentityType.APPLICATION) public class Term { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key key; @Persistent private String name; } Are there any rules to insure consistency between a GAE Python and GAE Java relationship models when using the datastore? many thanks, Vincent. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
