I stumbled on this feature of App Engine's Datastore that you don't actually have to have a persisted root entity to have strongly consistent behavior work with GAE. You can use a computed key to store and load child entities. My question is: Is this a good practice or does this rely too much on an implementation quirk of the Datastore?
Here's an example using Python. This idiom will work with Java, too, I'm sure.
Let's say you have a child entity:
CustomerReport(ndb.Model):
foo=ndb.StringProperty
bar=ndb.FloatProperty
#...
CustomerReports are generated based on a real entity type, Customer. But you can save with strong consistency this report entity by computing an ancestor key for a non-existent parent entity like this:
ReportRoot(ndb.Model):
pass
Like so:
CustomerReport(parent=ndb.Key(ReportRoot, customer.key.id()), ... ).put()
Which can be retrieved again by simply computing the key:
CustomerReport.query(ancestor=ndb.Key(ReportRoot, customer.key.id())).fetch()
Thank you.