public interface Batch extends DatastoreBatchWriter
submit()
. A usage example:
Entity entity1 = datastore.get(key1);
Batch batch = datastore.newBatch();
Entity entity2 = Entity.newBuilder(key2).set("name", "John").build();
entity1 = Entity.newBuilder(entity1).clear().setNull("bla").build();
Entity entity3 = Entity.newBuilder(key3).set("title", "title").build();
batch.update(entity1);
batch.add(entity2, entity3);
batch.submit();
Modifier and Type | Interface and Description |
---|---|
static interface |
Batch.Response |
Modifier and Type | Method and Description |
---|---|
List<Entity> |
add(FullEntity<?>... entities)
Datastore add operation: inserts the provided entities.
|
Entity |
add(FullEntity<?> entity)
Datastore add operation: inserts the provided entity.
|
Datastore |
getDatastore()
Returns the batch associated
Datastore . |
Batch.Response |
submit()
Submit the batch to the Datastore.
|
addWithDeferredIdAllocation, delete, isActive, put, put, putWithDeferredIdAllocation, update
Entity add(FullEntity<?> entity)
entity
has a complete key and was already marked for deletion in this
writer, the operation will be changed to DatastoreBatchWriter.put(com.google.cloud.datastore.FullEntity<?>)
.
If an entity for entity.getKey()
does not exists, entity
is inserted.
Otherwise, submit()
will throw a DatastoreException
with BaseServiceException.getReason()
equal to "ALREADY_EXISTS"
.
add
in interface DatastoreBatchWriter
add
in interface DatastoreWriter
entity
- the entity to addEntity
with the same properties and a key that is either newly allocated or
the same one if key is already completeList<Entity> add(FullEntity<?>... entities)
DatastoreBatchWriter.put(com.google.cloud.datastore.FullEntity<?>)
.
If none of entities' keys exist, all entities are inserted. If any of entities' keys already
exists, submit()
will throw a DatastoreException
with BaseServiceException.getReason()
equal to "ALREADY_EXISTS"
. All entities in entities
whose key did not exist are inserted.
add
in interface DatastoreBatchWriter
add
in interface DatastoreWriter
Entity
ordered by input with the same properties and a key that is
either newly allocated or the same one if was already completeDatastoreWriter.add(FullEntity)
Batch.Response submit()
DatastoreException
- if there was any failure or if batch is not longer activeCopyright © 2019 Google LLC. All rights reserved.