如何使用Java在Google云数据存储中一次放置/获取多个实体 [英] How to put/get multiple entities at once in Google cloud Datastore using java

查看:225
本文介绍了如何使用Java在Google云数据存储中一次放置/获取多个实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

文档中,我没有找到自己的方式一次放置或检索多个实体。 ('key1','key2','key3')。

通过使用GQL,我无法执行select *请问任何人都可以帮助我,我如何使用java一次插入/检索多个实体?



谢谢,

LookupRequest 和 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆