[英]Objectify - getting children of a given parent using get?
I'm trying to get all the children of a given parent key. 我试图让一个给定的父项的所有子项。 I can achieve this using the query/ancestor methods as follows:
我可以使用查询/始祖方法如下做到这一点:
List<Tire> list= ofy.query(Tire.class).ancestor(new Key<Car(Car.class,carID))).list();
The problem with this is that it the query method doesn't go through the cache. 问题在于查询方法不会通过缓存。 How can I get the same list using get?
如何使用get获得相同的列表?
Thanks 谢谢
You can do a keys-only query, then perform a get() for the keys. 您可以执行仅键查询,然后对键执行get()。 This still hits the datastore, but it can reduce your costs to 1 read op + 1 small op per fetch (instead of 1 read op + 1 read op per fetch).
这仍然可以访问数据存储区,但可以将您的成本降低到每次读取1个读取操作+ 1个小操作(而不是每次读取1个读取操作+ 1个读取操作)。
If you use Objectify4, it does this for you automatically (see the Query.hybrid() method). 如果您使用Objectify4,它将自动为您执行此操作(请参阅Query.hybrid()方法)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.