# Interface QueryResults&lt;V&gt; (3.1.0)

3.1.0 (latest) 2.40.0 2.37.0 2.36.0 2.34.0 2.33.3 2.32.3 2.31.4 2.30.0 2.29.1 2.28.2 2.27.1 2.26.4 2.25.2 2.24.3 2.23.0 2.22.0 2.21.3 2.20.2 2.19.2 2.18.5 2.17.6

    public interface QueryResults<V> extends Iterator<V>

The result of a Google Cloud Datastore query submission. When the result is not typed it is
possible to cast it to its appropriate type according to the #getResultClass value.
Results are loaded lazily in batches, where batch size is set by Cloud Datastore. As a result, it
is possible to get a `DatastoreException` upon hasNext or next calls.

## Implements

[Iterator\<V\>](https://docs.oracle.com/javase/8/docs/api/java/util/Iterator<V>.html)

| ## Type Parameter ||
|---|---|
| **Name** | **Description** |
| `V` |   |

## Methods

### getCursorAfter()

    public abstract Cursor getCursorAfter()

Returns the Cursor for the point after the value returned in the last #next call. This
cursor can be used to issue subsequent queries (with the same constraints) that may return
additional results.

A simple use case:


     Query<Entity> query = Query.newEntityQueryBuilder()
         .setKind("Person")
         .setFilter(PropertyFilter.eq("favoriteFood", "pizza"))
         .build();
     QueryResults<Entity> results = datastore.run(query);
     // Consume some results (using results.next()) and do any other actions as necessary.
     query = query.toBuilder().setStartCursor(results.getCursorAfter()).build();
     results = datastore.run(query); // now we will iterate over all entities not yet consumed
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.Cursor` |   |

### getExplainMetrics()

    public abstract Optional<ExplainMetrics> getExplainMetrics()

> [!WARNING]
> **Beta**
>
> This feature is covered by the [Pre-GA Offerings Terms](https://docs.cloud.google.com/terms/service-terms#1) of the Terms of Service. Pre-GA libraries might have limited support, and changes to pre-GA libraries might not be compatible with other pre-GA versions. For more information, see the launch stage descriptions.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.models.ExplainMetrics>` |   |

### getMoreResults()

    public abstract QueryResultBatch.MoreResultsType getMoreResults()

Returns MoreResults state of the query after the current batch.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.datastore.v1.QueryResultBatch.MoreResultsType` |   |

### getResultClass()

    public abstract Class<?> getResultClass()

Returns the actual class of the result's values.

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

### getSkippedResults()

    public abstract int getSkippedResults()

Returns the number of results skipped, typically because of an offset.

A simple use case to count entities:


     Query<Key> query = Query.newKeyQueryBuilder().setOffset(Integer.MAX_VALUE).build();
     QueryResults<Key> result = datasore.datastore.run(query);
     if (!result.hasNext()) {
      int numberOfEntities = result.getSkippedResults();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |