public interface Batch
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.
|
void |
addWithDeferredIdAllocation(FullEntity<?>... entities)
Datastore add operation.
|
void |
delete(Key... keys)
A datastore delete operation.
|
Datastore |
getDatastore()
Returns the batch associated
Datastore. |
boolean |
isActive()
Returns
true if still active (write operations were not sent to the Datastore). |
List<Entity> |
put(FullEntity<?>... entities)
A Datastore put (a.k.a upsert) operation: creates an entity if it does not exist, updates it
otherwise.
|
Entity |
put(FullEntity<?> entity)
A Datastore put (a.k.a upsert) operation: inserts an entity if it does not exist, updates it
otherwise.
|
void |
putWithDeferredIdAllocation(FullEntity<?>... entities)
Datastore put operation.
|
Batch.Response |
submit()
Submit the batch to the Datastore.
|
void |
update(Entity... entities)
A Datastore update operation.
|
Entity add(FullEntity<?> entity)
entity has a complete key and was already marked for deletion in this writer, the
operation will be changed to 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".
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)
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.
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 activevoid addWithDeferredIdAllocation(FullEntity<?>... entities)
add(FullEntity) and add(FullEntity...), this method will
defer any necessary id allocation to submit time.IllegalArgumentException - if any of the given entities is missing a keyDatastoreException - if a given entity with a complete key was already added to this
writer or if not activevoid update(Entity... entities)
put(com.google.cloud.datastore.FullEntity<?>) operation for entities that were already
added or put in this writer.update in interface DatastoreWriterDatastoreException - if an entity is marked for deletion in this writer or if not activevoid delete(Key... keys)
delete in interface DatastoreWriterDatastoreException - if not activevoid putWithDeferredIdAllocation(FullEntity<?>... entities)
put(FullEntity) and put(FullEntity...), this method will
defer any necessary id allocation to submit time.IllegalArgumentException - if any of the given entities is missing a keyDatastoreException - if not activeEntity put(FullEntity<?> entity)
put in interface DatastoreWriterentity - the entity to putEntity with the same properties and a key that is either newly allocated
or the same one if key is already completeDatastoreException - if not active or if id allocation for an entity with an incomplete
key failedList<Entity> put(FullEntity<?>... entities)
put in interface DatastoreWriterEntity, ordered by input. Returned keys are
either newly allocated or the same one if was already complete.DatastoreException - if not active or if id allocation for an entity with an incomplete
key failedboolean isActive()
true if still active (write operations were not sent to the Datastore).Copyright © 2018 Google. All rights reserved.