【发布时间】:2015-01-19 15:47:20
【问题描述】:
祖先密钥和父密钥的明显区别是什么?
基本一样吗? 它对 get() 方法和 Query 方法有何不同影响?
从 GAE KeyFactory 类中,我们只能看到 Key 父级,而没有这样的祖先 Key。
public static Key createKey(Key parent, String kind, String name) {
return createKey(parent, kind, name, (AppIdNamespace)null);
}
然后像这样使用密钥:
Entity e = new Entity(key); // key may include a parent Key
在典型的查询中,例如在留言簿应用中。我们可以将 Key 作为祖先,这样我们就可以有不同的留言簿来保存实体,例如:
Key guestbookKey = KeyFactory.createKey("Guestbook", guestbookName);
Query q = new Query(kind, guestbookKey); // guestbookKey = ancestor
那么 Parent 和 Ancestor 有什么区别,它们基本上是一样的,没有任何区别,是一样的,只是符号不同?
【问题讨论】:
标签: google-app-engine google-cloud-datastore