# Class DatastoreServiceConfig (5.0.3)

    public final class DatastoreServiceConfig

User-configurable properties of the datastore.

Notes on usage:  

The recommended way to instantiate a `DatastoreServiceConfig` object is to statically
import 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);
     
## Inheritance

[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> DatastoreServiceConfig

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## Static Fields

### DATASTORE_EMPTY_LIST_SUPPORT

    public static final 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](https://docs.oracle.com/javase/8/docs/api/java/util/Collection.html).

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());
`

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

## Static Methods

### getEmptyListSupport()

    public static boolean getEmptyListSupport()

Returns whether or not empty list support is enabled; see [#DATASTORE_EMPTY_LIST_SUPPORT](https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.datastore.DatastoreServiceConfig#com_google_appengine_api_datastore_DatastoreServiceConfig_DATASTORE_EMPTY_LIST_SUPPORT).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

## Methods

### deadline(double deadline)

    public DatastoreServiceConfig deadline(double deadline)

Sets the deadline, in seconds, for all rpcs initiated by the [DatastoreService](https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.datastore.DatastoreService) with
which this config is associated.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `deadline` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` the deadline to set. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.datastore.DatastoreServiceConfig` | `this` (for chaining) |

### getDeadline()

    public Double getDeadline()

Returns the deadline, in seconds, to use. Can be `null`.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/Double.html` |   |

### getImplicitTransactionManagementPolicy()

    public ImplicitTransactionManagementPolicy getImplicitTransactionManagementPolicy()

Returns the `ImplicitTransactionManagementPolicy` to use.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.datastore.ImplicitTransactionManagementPolicy` |   |

### getMaxEntityGroupsPerRpc()

    public Integer getMaxEntityGroupsPerRpc()

Returns the maximum number of entity groups per rpc.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html` |   |

### getReadPolicy()

    public ReadPolicy getReadPolicy()

Returns the `ReadPolicy` to use.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.datastore.ReadPolicy` |   |

### implicitTransactionManagementPolicy(ImplicitTransactionManagementPolicy p)

    public DatastoreServiceConfig implicitTransactionManagementPolicy(ImplicitTransactionManagementPolicy p)

Sets the implicit transaction management policy.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `p` | `https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.datastore.ImplicitTransactionManagementPolicy` the implicit transaction management policy to set. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.datastore.DatastoreServiceConfig` | `this` (for chaining) |

### maxEntityGroupsPerRpc(int 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.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `maxEntityGroupsPerRpc` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` the maximum number of entity groups per rpc |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.datastore.DatastoreServiceConfig` | `this` (for chaining) |

### readPolicy(ReadPolicy readPolicy)

    public DatastoreServiceConfig readPolicy(ReadPolicy readPolicy)

Sets the read policy.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `readPolicy` | `https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.datastore.ReadPolicy` the read policy to set. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.datastore.DatastoreServiceConfig` | `this` (for chaining) |