在 documentation ,我没有找到如何一次放置或检索多个实体。此外,通过使用 GQL,我无法执行诸如 select * from k where __ key __ in ('key1','key2','key3') 之类的查询。
有人可以帮我吗,我如何使用 java 一次插入/检索多个实体?
谢谢
最佳答案
在 Cloud Datastore 中,LookupRequest
和 CommitRequest
允许分别指定多个键和实体。例如:
LookupRequest request = LookupRequest.newBuilder()
.addKey(key1)
.addKey(key2)
.build();
或者:
CommitRequest request = CommitRequest.newBuilder()
.setMode(CommitRequest.Mode.NON_TRANSACTIONAL)
.setMutation(Mutation.newBuilder()
.addInsert(entity1)
.addInsert(entity2))
.build();
这些页面上给出的示例略有不同: https://cloud.google.com/datastore/docs/concepts/entities#Datastore_Retrieving_an_entity https://cloud.google.com/datastore/docs/concepts/entities#Datastore_Creating_an_entity
Cloud Datastore GQL 目前不支持 IN
或写入。
关于java - 如何使用 java 在 Google 云数据存储中一次放入/获取多个实体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26259068/