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() |
Map<String,Object> |
namedBindings()
Deprecated.
|
List<Object> |
numberArgs()
Deprecated.
|
String |
queryString()
Deprecated.
|
String |
toString() |
entityQueryBuilder, getNamespace, gqlQueryBuilder, gqlQueryBuilder, keyQueryBuilder, namespace, newEntityQueryBuilder, newGqlQueryBuilder, newGqlQueryBuilder, newKeyQueryBuilder, newProjectionEntityQueryBuilder, projectionEntityQueryBuilder@Deprecated public String queryString()
public String getQueryString()
public boolean allowLiteral()
false, the query string
must not contain any literals and instead must bind all values.@Deprecated public Map<String,Object> namedBindings()
public Map<String,Object> getNamedBindings()
@Deprecated public List<Object> numberArgs()
public List<Object> getNumberArgs()
Copyright © 2016 Google. All rights reserved.