如何使用Java在Google云数据存储中一次放置/获取多个实体 [英] How to put/get multiple entities at once in Google cloud Datastore using java
问题描述
在文档中,我没有找到自己的方式一次放置或检索多个实体。 ('key1','key2','key3')。
通过使用GQL,我无法执行select *请问任何人都可以帮助我,我如何使用java一次插入/检索多个实体?
谢谢,
CommitRequest
允许多个键和实体分别被指定。例如:$ b $ pre $
LookupRequest请求= 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_eity b $ b https://cloud.google.com/datastore/docs/concepts/实体#Datastore_Creating_an_entity
云数据存储GQL目前不支持 IN
或写入。
In the documentation, I didn't find how I can put or retrieve multiple entities at once. further, by using GQL, I was not able to execute queries such select * from k where __ key __ in ('key1','key2','key3').
Can any one help me please, how I can insert/ retrieve multiple entities at once using java??
Thanks,
In Cloud Datastore, a LookupRequest
and CommitRequest
allow multiple keys and entities, respectively, to be specified. For example:
LookupRequest request = LookupRequest.newBuilder()
.addKey(key1)
.addKey(key2)
.build();
or:
CommitRequest request = CommitRequest.newBuilder()
.setMode(CommitRequest.Mode.NON_TRANSACTIONAL)
.setMutation(Mutation.newBuilder()
.addInsert(entity1)
.addInsert(entity2))
.build();
These are slight variations on the examples given on these pages: 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 does not currently support IN
or writes.
这篇关于如何使用Java在Google云数据存储中一次放置/获取多个实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!