Datastore add operation: inserts the provided entity. This method will automatically allocate
an id if necessary. If entity has a complete key and was already marked for deletion in this
writer, the operation will be changed to #put.
Datastore add operation: inserts the provided entities. This method will automatically allocate
id for any entity with an incomplete key. For entities with complete keys that were marked for deletion in this writer the
operation will be changed to #put.
Datastore add operation. This method will also allocate id for any entity with an incomplete
key. As opposed to #add(FullEntity) and #add(FullEntity...), this method will
defer any necessary id allocation to submit time.
A datastore delete operation. It is OK to request the deletion of a non-existing key. This operation will also remove from this batch any prior writes for entities
with the same keys.
A Datastore put (a.k.a upsert) operation: inserts an entity if it does not exist, updates it
otherwise. This method will automatically allocate an id if necessary. This operation will also remove from this writer any prior writes for the same
entity.
A Datastore put (a.k.a upsert) operation: creates an entity if it does not exist, updates it
otherwise. This method will automatically allocate id for any entity with an incomplete key. This operation will also remove from this writer any prior writes for the same
entities.
Datastore put operation. This method will also allocate id for any entity with an incomplete
key. As opposed to #put(FullEntity) and #put(FullEntity...), this method will
defer any necessary id allocation to submit time.
A Datastore update operation. The operation will fail if an entity with the same key does not
already exist. This operation will be converted to #put operation for entities that were
already added or put in this writer.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Class BaseDatastoreBatchWriter (2.31.2)\n\nVersion latestkeyboard_arrow_down\n\n- [2.31.2 (latest)](/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.BaseDatastoreBatchWriter)\n- [2.31.1](/java/docs/reference/google-cloud-datastore/2.31.1/com.google.cloud.datastore.BaseDatastoreBatchWriter)\n- [2.30.0](/java/docs/reference/google-cloud-datastore/2.30.0/com.google.cloud.datastore.BaseDatastoreBatchWriter)\n- [2.29.1](/java/docs/reference/google-cloud-datastore/2.29.1/com.google.cloud.datastore.BaseDatastoreBatchWriter)\n- [2.28.2](/java/docs/reference/google-cloud-datastore/2.28.2/com.google.cloud.datastore.BaseDatastoreBatchWriter)\n- [2.27.1](/java/docs/reference/google-cloud-datastore/2.27.1/com.google.cloud.datastore.BaseDatastoreBatchWriter)\n- [2.26.4](/java/docs/reference/google-cloud-datastore/2.26.4/com.google.cloud.datastore.BaseDatastoreBatchWriter)\n- [2.25.2](/java/docs/reference/google-cloud-datastore/2.25.2/com.google.cloud.datastore.BaseDatastoreBatchWriter)\n- [2.24.3](/java/docs/reference/google-cloud-datastore/2.24.3/com.google.cloud.datastore.BaseDatastoreBatchWriter)\n- [2.23.0](/java/docs/reference/google-cloud-datastore/2.23.0/com.google.cloud.datastore.BaseDatastoreBatchWriter)\n- [2.22.0](/java/docs/reference/google-cloud-datastore/2.22.0/com.google.cloud.datastore.BaseDatastoreBatchWriter)\n- [2.21.3](/java/docs/reference/google-cloud-datastore/2.21.3/com.google.cloud.datastore.BaseDatastoreBatchWriter)\n- [2.20.2](/java/docs/reference/google-cloud-datastore/2.20.2/com.google.cloud.datastore.BaseDatastoreBatchWriter)\n- [2.19.2](/java/docs/reference/google-cloud-datastore/2.19.2/com.google.cloud.datastore.BaseDatastoreBatchWriter)\n- [2.18.5](/java/docs/reference/google-cloud-datastore/2.18.5/com.google.cloud.datastore.BaseDatastoreBatchWriter)\n- [2.17.6](/java/docs/reference/google-cloud-datastore/2.17.6/com.google.cloud.datastore.BaseDatastoreBatchWriter) \n\n public abstract class BaseDatastoreBatchWriter implements DatastoreBatchWriter\n\nBase class for DatastoreBatchWriter. \n\nInheritance\n-----------\n\n[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e BaseDatastoreBatchWriter \n\nImplements\n----------\n\n[DatastoreBatchWriter](/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.DatastoreBatchWriter) \n\nInherited Members\n-----------------\n\n[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) \n[Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) \n[Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) \n[Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) \n[Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) \n[Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) \n[Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) \n[Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)\n\nMethods\n-------\n\n### add(FullEntity\\\u003c?\\\u003e entity)\n\n public final Entity add(FullEntity\u003c?\u003e entity)\n\nDatastore add operation: inserts the provided entity. This method will automatically allocate\nan id if necessary. If `entity` has a complete key and was already marked for deletion in this\nwriter, the operation will be changed to [#put](/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.BaseDatastoreBatchWriter#com_google_cloud_datastore_BaseDatastoreBatchWriter_put_).\n\n### add(FullEntity\\\u003c?\\\u003e\\[\\] entities)\n\n public final List\u003cEntity\u003e add(FullEntity\u003c?\u003e[] entities)\n\nDatastore add operation: inserts the provided entities. This method will automatically allocate\nid for any entity with an incomplete key. For entities with complete keys that were marked for deletion in this writer the\noperation will be changed to [#put](/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.BaseDatastoreBatchWriter#com_google_cloud_datastore_BaseDatastoreBatchWriter_put_).\n\n### addWithDeferredIdAllocation(FullEntity\\\u003c?\\\u003e\\[\\] entities)\n\n public final void addWithDeferredIdAllocation(FullEntity\u003c?\u003e[] entities)\n\nDatastore add operation. This method will also allocate id for any entity with an incomplete\nkey. As opposed to [#add(FullEntity)](/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.BaseDatastoreBatchWriter#com_google_cloud_datastore_BaseDatastoreBatchWriter_add_com_google_cloud_datastore_FullEntity____) and [#add(FullEntity...)](/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.BaseDatastoreBatchWriter#com_google_cloud_datastore_BaseDatastoreBatchWriter_add_), this method will\ndefer any necessary id allocation to submit time.\n\n### deactivate()\n\n protected void deactivate()\n\n### delete(Key\\[\\] keys)\n\n public final void delete(Key[] keys)\n\nA datastore delete operation. It is OK to request the deletion of a non-existing key. This operation will also remove from this batch any prior writes for entities\nwith the same keys.\n\n### getDatastore()\n\n protected abstract Datastore getDatastore()\n\n### getName()\n\n protected String getName()\n\n### isActive()\n\n public boolean isActive()\n\nReturns `true` if still active (write operations were not sent to the Datastore).\n\n### newInvalidRequest(String msg, Object\\[\\] params)\n\n protected DatastoreException newInvalidRequest(String msg, Object[] params)\n\n### put(FullEntity\\\u003c?\\\u003e entity)\n\n public final Entity put(FullEntity\u003c?\u003e entity)\n\nA Datastore put (a.k.a upsert) operation: inserts an entity if it does not exist, updates it\notherwise. This method will automatically allocate an id if necessary. This operation will also remove from this writer any prior writes for the same\nentity.\n\n### put(FullEntity\\\u003c?\\\u003e\\[\\] entities)\n\n public final List\u003cEntity\u003e put(FullEntity\u003c?\u003e[] entities)\n\nA Datastore put (a.k.a upsert) operation: creates an entity if it does not exist, updates it\notherwise. This method will automatically allocate id for any entity with an incomplete key. This operation will also remove from this writer any prior writes for the same\nentities.\n\n### putWithDeferredIdAllocation(FullEntity\\\u003c?\\\u003e\\[\\] entities)\n\n public final void putWithDeferredIdAllocation(FullEntity\u003c?\u003e[] entities)\n\nDatastore put operation. This method will also allocate id for any entity with an incomplete\nkey. As opposed to [#put(FullEntity)](/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.BaseDatastoreBatchWriter#com_google_cloud_datastore_BaseDatastoreBatchWriter_put_com_google_cloud_datastore_FullEntity____) and [#put(FullEntity...)](/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.BaseDatastoreBatchWriter#com_google_cloud_datastore_BaseDatastoreBatchWriter_put_), this method will\ndefer any necessary id allocation to submit time.\n\n### toAdd()\n\n protected Map\u003cKey,FullEntity\u003cKey\u003e\u003e toAdd()\n\n### toAddAutoId()\n\n protected List\u003cFullEntity\u003cIncompleteKey\u003e\u003e toAddAutoId()\n\n### toDelete()\n\n protected Set\u003cKey\u003e toDelete()\n\n### toMutationPbList()\n\n protected List\u003cMutation\u003e toMutationPbList()\n\n### toPut()\n\n protected Map\u003cKey,FullEntity\u003cKey\u003e\u003e toPut()\n\n### toUpdate()\n\n protected Map\u003cKey,FullEntity\u003cKey\u003e\u003e toUpdate()\n\n### update(Entity\\[\\] entities)\n\n public final void update(Entity[] entities)\n\nA Datastore update operation. The operation will fail if an entity with the same key does not\nalready exist. This operation will be converted to [#put](/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.BaseDatastoreBatchWriter#com_google_cloud_datastore_BaseDatastoreBatchWriter_put_) operation for entities that were\nalready added or put in this writer.\n\n### validateActive()\n\n protected void validateActive()"]]