Class GqlQuery<V> (2.22.0)

publicfinalclass GqlQuery<V>extendsQuery<V>implementsRecordQuery<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()){
Entityentity=results.next();
...
}

When the type of the results is unknown you can use this approach:


Queryquery=Query.newGqlQueryBuilder("select __key__ from kind").build();
QueryResultsresults=datastore.run(query);
if(Key.class.isAssignableFrom(results.getResultClass())){
QueryResults<Key>keys=(QueryResults<Key>)results;
while(keys.hasNext()){
Keykey=keys.next();
...
}
}

See Also: GQL Reference

Inheritance

Object > Query > GqlQuery<V>

Implements

RecordQuery<V>

Type Parameter

Name Description
V

Methods

allowLiteral()

publicbooleanallowLiteral()

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
boolean

equals(Object obj)

publicbooleanequals(Objectobj)
Parameter
Name Description
obj Object
Returns
Type Description
boolean
Overrides

getNamedBindings()

publicMap<String,Object>getNamedBindings()

Returns an immutable map of named bindings.

Returns
Type Description
Map<String,Object>

getNamedBindingsMap()

publicMap<String,GqlQuery.Binding>getNamedBindingsMap()
Returns
Type Description
Map<String,com.google.cloud.datastore.GqlQuery.Binding>

getNumberArgs()

publicList<Object>getNumberArgs()

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

Returns
Type Description
List<Object>

getPositionalBindingsMap()

publicList<GqlQuery.Binding>getPositionalBindingsMap()
Returns
Type Description
List<com.google.cloud.datastore.GqlQuery.Binding>

getQueryString()

publicStringgetQueryString()

Returns the query string for this query.

Returns
Type Description
String

getType()

publicQuery.ResultType<V>getType()
Returns
Type Description
ResultType<V>

hashCode()

publicinthashCode()
Returns
Type Description
int
Overrides

nextQuery(RunQueryResponse responsePb)

publicRecordQuery<V>nextQuery(RunQueryResponseresponsePb)
Parameter
Name Description
responsePb RunQueryResponse
Returns
Type Description
RecordQuery<V>

populatePb(RunQueryRequest.Builder requestPb)

publicvoidpopulatePb(RunQueryRequest.BuilderrequestPb)
Parameter
Name Description
requestPb RunQueryRequest.Builder

toString()

publicStringtoString()
Returns
Type Description
String
Overrides

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年11月19日 UTC.