Java 8 has reached end of support
and will be
deprecated
on January 31, 2026. After deprecation, you won't be able to deploy Java 8
applications, even if your organization previously used an organization policy to
re-enable deployments of legacy runtimes. Your existing Java
8 applications will continue to run and receive traffic after their
deprecation date. We recommend that
you
migrate to the latest supported version of Java.
DatastoreServiceConfig (Google App Engine API for Java)
Stay organized with collections
Save and categorize content based on your preferences.
- java.lang.Object
-
- com.google.appengine.api.datastore.DatastoreServiceConfig
-
public final class DatastoreServiceConfig
extends java.lang.Object
User-configurable properties of the datastore.
Notes on usage:
The recommended way to instantiate a DatastoreServiceConfig
object is to statically
import DatastoreServiceConfig.Builder
.* and invoke a static creation method followed by an instance mutator (if
needed):
import static com.google.appengine.api.datastore.DatastoreServiceConfig.Builder.*;
import com.google.appengine.api.datastore.ReadPolicy.Consistency;
...
// eventually consistent reads
DatastoreServiceConfig config = withReadPolicy(new ReadPolicy(Consistency.EVENTUAL));
// eventually consistent reads with a 5 second deadline
DatastoreServiceConfig config =
withReadPolicy(new ReadPolicy(Consistency.EVENTUAL)).deadline(5.0);
-
-
Field Summary
Fields
Modifier and Type |
Field and Description |
static java.lang.String |
DATASTORE_EMPTY_LIST_SUPPORT
This is the name of a system property that determines how the Java SDK writes/reads empty lists
to/from Datastore.
|
-
Method Summary
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Field Detail
-
DATASTORE_EMPTY_LIST_SUPPORT
public static final java.lang.String DATASTORE_EMPTY_LIST_SUPPORT
This is the name of a system property that determines how the Java SDK writes/reads empty lists
to/from Datastore.
Historically Datastore has not had the ability to represent an empty list in its persistent
store. Different SDKs have made different decisions on what to write to Datastore when a client
attempts to insert an empty list to the persistent store. The Java SDK has historically written
both empty lists and null values as null values to the persistent store.
With the release of this flag, Datastore can now represent empty lists within its persistent
store. This means that Datastore SDKs can distinguish between empty lists and null values. This
property controls whether this SDK writes an empty list as empty list or null to the persistent
store.
A note on queries: Null values can be indexed by Datastore which means they can interact
with queries. For example queries that find all entities with null values or order by a
property will include null values. Empty lists are not indexable by Datastore and so cannot
appear in similar queries.
Thus, if this flag was unset (the old behavior) and an empty list was stored into the
persistent store, it could appear in query results because it was really stored as a null
value.
If this flag is set (the new behavior) and an empty list is stored into the persistent
store, it will not appear it query results because it is stored as an empty list.
When this variable is set to anything other than "true" the system provides legacy behavior.
- Null properties are written as null to Datastore
- Empty collections are written as null to Datastore
- A null is read as null from Datastore
- An empty collection is read as null. Note that a read modify write of an entity with
an empty list will cause that list to be turned into a null value.
When this variable is set to "true":
- Null properties are written as null to Datastore
- Empty collections (#
Collection.isEmpty()
) are written as empty list to Datastore
- A null is read as null from Datastore
- An empty collection is read as null
- When reading from Datastore an empty list is returned as an empty
Collection
.
It is strongly recommended that this property be set to true in order to provide
compatibility with other Datastore SDK's, as well as future versions of Datastore.
To set the flag:
System.setProperty(DatastoreServiceConfig.DATASTORE_EMPTY_LIST_SUPPORT,
Boolean.TRUE.toString());
- See Also:
- Constant Field Values
-
Method Detail
-
getEmptyListSupport
public static boolean getEmptyListSupport()
-
readPolicy
public DatastoreServiceConfig readPolicy(ReadPolicy readPolicy)
Sets the read policy.
- Parameters:
readPolicy
- the read policy to set.
- Returns:
this
(for chaining)
-
deadline
public DatastoreServiceConfig deadline(double deadline)
Sets the deadline, in seconds, for all rpcs initiated by the
DatastoreService
with
which this config is associated.
- Parameters:
deadline
- the deadline to set.
- Returns:
this
(for chaining)
- Throws:
java.lang.IllegalArgumentException
- if deadline is not positive
-
maxEntityGroupsPerRpc
public DatastoreServiceConfig maxEntityGroupsPerRpc(int maxEntityGroupsPerRpc)
Sets the maximum number of entity groups that can be represented in a single rpc.
For a non-transactional operation that involves more entity groups than the maximum, the
operation will be performed by executing multiple, asynchronous rpcs to the datastore, each of
which has no more entity groups represented than the maximum. So, if a put() operation has 8
entity groups and the maximum is 3, we will send 3 rpcs, 2 with 3 entity groups and 1 with 2
entity groups. This is a performance optimization - in many cases multiple, small, asynchronous
rpcs will finish faster than a single large asynchronous rpc. The optimal value for this
property will be application-specific, so experimentation is encouraged.
- Parameters:
maxEntityGroupsPerRpc
- the maximum number of entity groups per rpc
- Returns:
this
(for chaining)
- Throws:
java.lang.IllegalArgumentException
- if maxEntityGroupsPerRpc is not greater than zero
-
getImplicitTransactionManagementPolicy
public ImplicitTransactionManagementPolicy getImplicitTransactionManagementPolicy()
- Returns:
- The
ImplicitTransactionManagementPolicy
to use.
-
getReadPolicy
public ReadPolicy getReadPolicy()
- Returns:
- The
ReadPolicy
to use.
-
getMaxEntityGroupsPerRpc
public java.lang.Integer getMaxEntityGroupsPerRpc()
- Returns:
- The maximum number of entity groups per rpc.
-
getDeadline
public java.lang.Double getDeadline()
- Returns:
- The deadline, in seconds, to use. Can be
null
.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-06-16 UTC.
[[["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-06-16 UTC."],[[["\u003cp\u003e\u003ccode\u003eDatastoreServiceConfig\u003c/code\u003e allows users to configure properties for the datastore, including read policies, deadlines, and transaction management.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eDatastoreServiceConfig.Builder\u003c/code\u003e class provides static methods for easily creating instances of \u003ccode\u003eDatastoreServiceConfig\u003c/code\u003e with specific settings.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eDATASTORE_EMPTY_LIST_SUPPORT\u003c/code\u003e field controls how empty lists are handled, offering legacy behavior (treating them as null) or new behavior (distinctly representing them).\u003c/p\u003e\n"],["\u003cp\u003eYou can set the deadline for all RPCs initiated by the \u003ccode\u003eDatastoreService\u003c/code\u003e using the \u003ccode\u003edeadline()\u003c/code\u003e method, providing control over the time allowed for operations.\u003c/p\u003e\n"],["\u003cp\u003eThe maximum number of entity groups in a single RPC can be set with the \u003ccode\u003emaxEntityGroupsPerRpc()\u003c/code\u003e method, which is a performance optimization for non-transactional operations.\u003c/p\u003e\n"]]],[],null,["# DatastoreServiceConfig (Google App Engine API for Java)\n\ncom.google.appengine.api.datastore\n\nClass DatastoreServiceConfig\n----------------------------\n\n- java.lang.Object\n-\n - com.google.appengine.api.datastore.DatastoreServiceConfig\n\n-\n\n *** ** * ** ***\n\n \u003cbr /\u003e\n\n ```\n public final class DatastoreServiceConfig\n extends java.lang.Object\n ``` \n User-configurable properties of the datastore.\n\n Notes on usage: \n\n The recommended way to instantiate a `DatastoreServiceConfig` object is to statically\n import [`DatastoreServiceConfig.Builder`](../../../../../com/google/appengine/api/datastore/DatastoreServiceConfig.Builder.html \"class in com.google.appengine.api.datastore\").\\* and invoke a static creation method followed by an instance mutator (if\n needed):\n\n ```\n import static com.google.appengine.api.datastore.DatastoreServiceConfig.Builder.*;\n import com.google.appengine.api.datastore.ReadPolicy.Consistency;\n\n ...\n\n // eventually consistent reads\n DatastoreServiceConfig config = withReadPolicy(new ReadPolicy(Consistency.EVENTUAL));\n\n // eventually consistent reads with a 5 second deadline\n DatastoreServiceConfig config =\n withReadPolicy(new ReadPolicy(Consistency.EVENTUAL)).deadline(5.0);\n \n ```\n\n \u003cbr /\u003e\n\n-\n -\n\n ### Nested Class Summary\n\n \u003c!-- --\u003e\n\n -\n\n ### Field Summary\n\n \u003c!-- --\u003e\n\n -\n\n ### Method Summary\n\n -\n\n ### Methods inherited from class java.lang.Object\n\n`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait` \n-\n -\n\n ### Field Detail\n\n\n -\n\n #### DATASTORE_EMPTY_LIST_SUPPORT\n\n ```\n public static final java.lang.String DATASTORE_EMPTY_LIST_SUPPORT\n ``` \n This is the name of a system property that determines how the Java SDK writes/reads empty lists to/from Datastore.\n\n Historically Datastore has not had the ability to represent an empty list in its persistent\n store. Different SDKs have made different decisions on what to write to Datastore when a client\n attempts to insert an empty list to the persistent store. The Java SDK has historically written\n both empty lists and null values as null values to the persistent store.\n\n With the release of this flag, Datastore can now represent empty lists within its persistent\n store. This means that Datastore SDKs can distinguish between empty lists and null values. This\n property controls whether this SDK writes an empty list as empty list or null to the persistent\n store.\n\n A note on queries: Null values can be indexed by Datastore which means they can interact\n with queries. For example queries that find all entities with null values or order by a\n property will include null values. Empty lists are not indexable by Datastore and so cannot\n appear in similar queries.\n\n Thus, if this flag was unset (the old behavior) and an empty list was stored into the\n persistent store, it could appear in query results because it was really stored as a null\n value.\n\n If this flag is set (the new behavior) and an empty list is stored into the persistent\n store, it will not appear it query results because it is stored as an empty list.\n\n When this variable is set to anything other than \"true\" the system provides legacy behavior.\n\n - Null properties are written as null to Datastore\n - Empty collections are written as null to Datastore\n - A null is read as null from Datastore\n - An empty collection is read as null. **Note that a read modify write of an entity with\n an empty list will cause that list to be turned into a null value.**\n\n When this variable is set to \"true\":\n\n - Null properties are written as null to Datastore\n - Empty collections (#`Collection.isEmpty()`) are written as empty list to Datastore\n - A null is read as null from Datastore\n - An empty collection is read as null\n - When reading from Datastore an empty list is returned as an empty `Collection`.\n\n It is strongly recommended that this property be set to true in order to provide\n compatibility with other Datastore SDK's, as well as future versions of Datastore.\n\n To set the flag: `\n System.setProperty(DatastoreServiceConfig.DATASTORE_EMPTY_LIST_SUPPORT,\n Boolean.TRUE.toString());\n `\n\n \u003cbr /\u003e\n\n \u003cbr /\u003e\n\n \u003cbr /\u003e\n\n \u003cbr /\u003e\n\n \u003cbr /\u003e\n\n \u003cbr /\u003e\n\n \u003cbr /\u003e\n\n \u003cbr /\u003e\n\n See Also:\n : [Constant Field Values](../../../../../constant-values.html#com.google.appengine.api.datastore.DatastoreServiceConfig.DATASTORE_EMPTY_LIST_SUPPORT)\n\n \u003c!-- --\u003e\n\n -\n\n ### Method Detail\n\n\n -\n\n #### getEmptyListSupport\n\n ```\n public static boolean getEmptyListSupport()\n ``` \n Returns whether or not empty list support is enabled; see [`DATASTORE_EMPTY_LIST_SUPPORT`](../../../../../com/google/appengine/api/datastore/DatastoreServiceConfig.html#DATASTORE_EMPTY_LIST_SUPPORT).\n\n\n -\n\n #### implicitTransactionManagementPolicy\n\n ```\n public DatastoreServiceConfig implicitTransactionManagementPolicy(ImplicitTransactionManagementPolicy p)\n ``` \n Sets the implicit transaction management policy.\n\n Parameters:\n : `p` - the implicit transaction management policy to set.\n\n Returns:\n : `this` (for chaining)\n\n\n -\n\n #### readPolicy\n\n ```\n public DatastoreServiceConfig readPolicy(ReadPolicy readPolicy)\n ``` \n Sets the read policy.\n\n Parameters:\n : `readPolicy` - the read policy to set.\n\n Returns:\n : `this` (for chaining)\n\n\n -\n\n #### deadline\n\n ```\n public DatastoreServiceConfig deadline(double deadline)\n ``` \n Sets the deadline, in seconds, for all rpcs initiated by the [`DatastoreService`](../../../../../com/google/appengine/api/datastore/DatastoreService.html \"interface in com.google.appengine.api.datastore\") with which this config is associated.\n\n Parameters:\n : `deadline` - the deadline to set.\n\n Returns:\n : `this` (for chaining)\n\n Throws:\n : `java.lang.IllegalArgumentException` - if deadline is not positive\n\n\n -\n\n #### maxEntityGroupsPerRpc\n\n ```\n public DatastoreServiceConfig maxEntityGroupsPerRpc(int maxEntityGroupsPerRpc)\n ``` \n Sets the maximum number of entity groups that can be represented in a single rpc.\n\n For a non-transactional operation that involves more entity groups than the maximum, the\n operation will be performed by executing multiple, asynchronous rpcs to the datastore, each of\n which has no more entity groups represented than the maximum. So, if a put() operation has 8\n entity groups and the maximum is 3, we will send 3 rpcs, 2 with 3 entity groups and 1 with 2\n entity groups. This is a performance optimization - in many cases multiple, small, asynchronous\n rpcs will finish faster than a single large asynchronous rpc. The optimal value for this\n property will be application-specific, so experimentation is encouraged.\n\n Parameters:\n : `maxEntityGroupsPerRpc` - the maximum number of entity groups per rpc\n\n Returns:\n : `this` (for chaining)\n\n Throws:\n : `java.lang.IllegalArgumentException` - if maxEntityGroupsPerRpc is not greater than zero\n\n\n -\n\n #### getImplicitTransactionManagementPolicy\n\n ```\n public ImplicitTransactionManagementPolicy getImplicitTransactionManagementPolicy()\n ```\n\n Returns:\n : The `ImplicitTransactionManagementPolicy` to use.\n\n\n -\n\n #### getReadPolicy\n\n ```\n public ReadPolicy getReadPolicy()\n ```\n\n Returns:\n : The `ReadPolicy` to use.\n\n\n -\n\n #### getMaxEntityGroupsPerRpc\n\n ```\n public java.lang.Integer getMaxEntityGroupsPerRpc()\n ```\n\n Returns:\n : The maximum number of entity groups per rpc.\n\n\n -\n\n #### getDeadline\n\n ```\n public java.lang.Double getDeadline()\n ```\n\n Returns:\n : The deadline, in seconds, to use. Can be `null`."]]