# Class GqlQuery&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 final class GqlQuery<V> extends Query<V> implements RecordQuery<V>

A Google Cloud Datastore GQL query.

A usage example:

When the type of the results is known the preferred usage would be:


     Query<Entity> query =
         Query.newGqlQueryBuilder(Query.ResultType.ENTITY, "select * from kind").build();
     QueryResults<Entity> results = datastore.run(query);
     while (results.hasNext()) {
       Entity entity = results.next();
       ...
     }
     
When the type of the results is unknown you can use this approach:


     Query query = Query.newGqlQueryBuilder("select __key__ from kind").build();
     QueryResults results = datastore.run(query);
     if (Key.class.isAssignableFrom(results.getResultClass())) {
       QueryResults<Key> keys = (QueryResults<Key>) results;
       while (keys.hasNext()) {
         Key key = keys.next();
         ...
       }
     }
     
See Also: [GQL Reference](https://cloud.google.com/datastore/docs/apis/gql/gql_reference)

## Inheritance

[Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> [Query](https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.Query) \> GqlQuery\<V\>

## Implements

[RecordQuery](https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.RecordQuery)\<V\>

## Inherited Members

[Query.\<V\>newGqlQueryBuilder(Query.ResultType\<V\>,String)](https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.Query#com_google_cloud_datastore_Query__V_newGqlQueryBuilder_com_google_cloud_datastore_Query_ResultType_V__java_lang_String_) [Query.getNamespace()](https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.Query#com_google_cloud_datastore_Query_getNamespace__) [Query.newAggregationQueryBuilder()](https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.Query#com_google_cloud_datastore_Query_newAggregationQueryBuilder__) [Query.newEntityQueryBuilder()](https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.Query#com_google_cloud_datastore_Query_newEntityQueryBuilder__) [Query.newGqlQueryBuilder(String)](https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.Query#com_google_cloud_datastore_Query_newGqlQueryBuilder_java_lang_String_) [Query.newKeyQueryBuilder()](https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.Query#com_google_cloud_datastore_Query_newKeyQueryBuilder__) [Query.newProjectionEntityQueryBuilder()](https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.Query#com_google_cloud_datastore_Query_newProjectionEntityQueryBuilder__) [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-)

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

## Methods

### allowLiteral()

    public boolean allowLiteral()

Returns whether the query string can contain literals. When `false`, the query string
must not contain any literals and instead must bind all values.

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

### equals(Object obj)

    public boolean equals(Object obj)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `obj` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` |

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

**Overrides** [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-)

### getNamedBindings()

    public Map<String,Object> getNamedBindings()

Returns an immutable map of named bindings.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/Map.html<https://docs.oracle.com/javase/8/docs/api/java/lang/String.html,https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html>` |   |

### getNamedBindingsMap()

    public Map<String,GqlQuery.Binding> getNamedBindingsMap()

> [!WARNING]
> **Internal Only**: This feature is not stable for application use.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/Map.html<https://docs.oracle.com/javase/8/docs/api/java/lang/String.html,com.google.cloud.datastore.GqlQuery.Binding>` |   |

### getNumberArgs()

    public List<Object> getNumberArgs()

Returns an immutable list of positional bindings (using original order).

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

### getPositionalBindingsMap()

    public List<GqlQuery.Binding> getPositionalBindingsMap()

> [!WARNING]
> **Internal Only**: This feature is not stable for application use.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/List.html<com.google.cloud.datastore.GqlQuery.Binding>` |   |

### getQueryString()

    public String getQueryString()

Returns the query string for this query.

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

### getType()

    public Query.ResultType<V> getType()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.Query.ResultType<V>` |   |

### hashCode()

    public int hashCode()

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

**Overrides** [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--)

### nextQuery(RunQueryResponse responsePb)

    public RecordQuery<V> nextQuery(RunQueryResponse responsePb)

> [!WARNING]
> **Internal Only**: This feature is not stable for application use.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `responsePb` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.datastore.v1.RunQueryResponse` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.RecordQuery<V>` |   |

### populatePb(RunQueryRequest.Builder requestPb)

    public void populatePb(RunQueryRequest.Builder requestPb)

> [!WARNING]
> **Internal Only**: This feature is not stable for application use.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `requestPb` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.datastore.v1.RunQueryRequest.Builder` |

### toString()

    public String toString()

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

**Overrides** [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--)