V
- the type of the result values this query will producepublic final class GqlQuery<V> extends Query<V>
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();
...
}
}
Modifier and Type | Class and Description |
---|---|
static class |
GqlQuery.Builder<V>
A GQL query builder.
|
Query.ResultType<V>
Modifier and Type | Method and Description |
---|---|
boolean |
allowLiteral()
Returns whether the query string can contain literals.
|
boolean |
equals(Object obj) |
Map<String,Object> |
getNamedBindings()
Returns an immutable map of named bindings.
|
List<Object> |
getNumberArgs()
Returns an immutable list of positional bindings (using original order).
|
String |
getQueryString()
Returns the query string for this query.
|
int |
hashCode() |
String |
toString() |
getNamespace, newEntityQueryBuilder, newGqlQueryBuilder, newGqlQueryBuilder, newKeyQueryBuilder, newProjectionEntityQueryBuilder
public String getQueryString()
public boolean allowLiteral()
false
, the query string
must not contain any literals and instead must bind all values.public Map<String,Object> getNamedBindings()
public List<Object> getNumberArgs()
Copyright © 2019 Google LLC. All rights reserved.