Package com.google.cloud.datastore
Class GqlQuery<V>
- java.lang.Object
-
- com.google.cloud.datastore.Query<V>
-
- com.google.cloud.datastore.GqlQuery<V>
-
- Type Parameters:
V- the type of the result values this query will produce
- All Implemented Interfaces:
RecordQuery<V>,Serializable
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, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGqlQuery.Builder<V>A GQL query builder.-
Nested classes/interfaces inherited from class com.google.cloud.datastore.Query
Query.ResultType<V>
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanallowLiteral()Returns whether the query string can contain literals.booleanequals(Object obj)Map<String,Object>getNamedBindings()Returns an immutable map of named bindings.Map<String,com.google.cloud.datastore.GqlQuery.Binding>getNamedBindingsMap()List<Object>getNumberArgs()Returns an immutable list of positional bindings (using original order).List<com.google.cloud.datastore.GqlQuery.Binding>getPositionalBindingsMap()StringgetQueryString()Returns the query string for this query.Query.ResultType<V>getType()inthashCode()RecordQuery<V>nextQuery(RunQueryResponse responsePb)voidpopulatePb(RunQueryRequest.Builder requestPb)StringtoString()-
Methods inherited from class com.google.cloud.datastore.Query
getNamespace, newAggregationQueryBuilder, newEntityQueryBuilder, newGqlQueryBuilder, newGqlQueryBuilder, newKeyQueryBuilder, newProjectionEntityQueryBuilder
-
-
-
-
Method Detail
-
getQueryString
public String getQueryString()
Returns the query string for this query.
-
allowLiteral
public boolean allowLiteral()
Returns whether the query string can contain literals. Whenfalse, the query string must not contain any literals and instead must bind all values.
-
getNamedBindings
public Map<String,Object> getNamedBindings()
Returns an immutable map of named bindings.
-
getNamedBindingsMap
@InternalApi public Map<String,com.google.cloud.datastore.GqlQuery.Binding> getNamedBindingsMap()
-
getPositionalBindingsMap
@InternalApi public List<com.google.cloud.datastore.GqlQuery.Binding> getPositionalBindingsMap()
-
getNumberArgs
public List<Object> getNumberArgs()
Returns an immutable list of positional bindings (using original order).
-
getType
public Query.ResultType<V> getType()
- Specified by:
getTypein interfaceRecordQuery<V>
-
populatePb
@InternalApi public void populatePb(RunQueryRequest.Builder requestPb)
- Specified by:
populatePbin interfaceRecordQuery<V>
-
nextQuery
@InternalApi public RecordQuery<V> nextQuery(RunQueryResponse responsePb)
- Specified by:
nextQueryin interfaceRecordQuery<V>
-
-