开发者

Batch put with pre-defined keys on Google App Engine

开发者 https://www.devze.com 2023-01-06 05:29 出处:网络
I would like to do a batch put of entities with pre-defined keys using the l开发者_如何学JAVAow-level api for Java.

I would like to do a batch put of entities with pre-defined keys using the l开发者_如何学JAVAow-level api for Java.

You can do a batch get:

 Map<Key,Entity> get(.Iterable<Key> keys) 

However the batch puts all seem to want to allocate their own keys:

List<Key> put(Iterable<Entity> entities)

Documentation page: http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/DatastoreService.html#put(java.lang.Iterable)

I'm trying to batch get on a collection of entities, update them, and then batch put them back into the datastore. It makes sense that I should be able to do this without changing the values of their keys, doesn't it?


Looks like I brain farted by posting this question, but maybe this will help someone else in the future. All you have to do is set the keys when you allocate the entities:

Entity entity = new Entity(key);

Or if you had previously pulled the entities from the datastore, the keys should already be set.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号