Class GqlQuery<V> (2.18.5)

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

Inheritance

Object > Query > GqlQuery<V>

Implements

RecordQuery<V>

Type Parameter

NameDescription
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
TypeDescription
boolean

equals(Object obj)

public boolean equals(Object obj)
Parameter
NameDescription
objObject
Returns
TypeDescription
boolean
Overrides

getNamedBindings()

public Map<String,Object> getNamedBindings()

Returns an immutable map of named bindings.

Returns
TypeDescription
Map<String,Object>

getNamedBindingsMap()

public Map<String,GqlQuery.Binding> getNamedBindingsMap()
Returns
TypeDescription
Map<String,com.google.cloud.datastore.GqlQuery.Binding>

getNumberArgs()

public List<Object> getNumberArgs()

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

Returns
TypeDescription
List<Object>

getPositionalBindingsMap()

public List<GqlQuery.Binding> getPositionalBindingsMap()
Returns
TypeDescription
List<com.google.cloud.datastore.GqlQuery.Binding>

getQueryString()

public String getQueryString()

Returns the query string for this query.

Returns
TypeDescription
String

getType()

public Query.ResultType<V> getType()
Returns
TypeDescription
ResultType<V>

hashCode()

public int hashCode()
Returns
TypeDescription
int
Overrides

nextQuery(RunQueryResponse responsePb)

public RecordQuery<V> nextQuery(RunQueryResponse responsePb)
Parameter
NameDescription
responsePbRunQueryResponse
Returns
TypeDescription
RecordQuery<V>

populatePb(RunQueryRequest.Builder requestPb)

public void populatePb(RunQueryRequest.Builder requestPb)
Parameter
NameDescription
requestPbRunQueryRequest.Builder

toString()

public String toString()
Returns
TypeDescription
String
Overrides