Interface Batch

All Superinterfaces:
DatastoreBatchWriter, DatastoreWriter

@NotThreadSafe @InternalExtensionOnly public interface Batch extends DatastoreBatchWriter
An interface to represent a batch of write operations. Any write operation that is applied on a batch will only be sent to the Datastore upon 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();
 

WARNING: This class maintains an internal state in terms of LinkedHashMap and LinkedHashSet which gets updated on every method call performing CRUD operations to record the mutations. Since LinkedHashMap is not thread safe as per its documentation, This class too should not be treated as a thread safe class.