Send feedback
Class StructuredQuery<V> (2.12.3)
Stay organized with collections
Save and categorize content based on your preferences.
Version 2.12.3 keyboard_arrow_down
public abstract class StructuredQuery<V> extends Query<V> implements RecordQuery<V>
An implementation of a Google Cloud Datastore Query that can be constructed by providing all the
specific query elements.
A usage example:
A simple query that returns all entities for a specific kind
Query<Entity> query = Query . newEntityQueryBuilder (). setKind ( kind ). build ();
QueryResults<Entity> results = datastore . run ( query );
while ( results . hasNext ()) {
Entity entity = results . next ();
...
}
A simple key-only query of all entities for a specific kind
Query<Key> keyOnlyQuery = Query . newKeyQueryBuilder (). setKind ( KIND1 ). build ();
QueryResults<Key> results = datastore . run ( keyOnlyQuery );
...
A less trivial example of a projection query that returns the first 10 results of "age" and
"name" properties (sorted and grouped by "age") with an age greater than 18
Query<ProjectionEntity> query = Query . newProjectionEntityQueryBuilder ()
. setKind ( kind )
. setProjection ( Projection . property ( "age" ), Projection . first ( "name" ))
. setFilter ( PropertyFilter . gt ( "age" , 18 ))
. setGroupBy ( "age" )
. setOrderBy ( OrderBy . asc ( "age" ))
. setLimit ( 10 )
. build ();
QueryResults<ProjectionEntity> results = datastore . run ( query );
...
See Also: Datastore queries
Implements
com.google.cloud.datastore.RecordQuery<V>
Type Parameter
Methods
equals(Object obj)
public boolean equals ( Object obj )
Parameter
Returns
Overrides
getDistinctOn()
public List<String> getDistinctOn ()
Returns the distinct on clause for this query.
Returns
getEndCursor()
public Cursor getEndCursor ()
Returns the end cursor for this query.
Returns
getFilter()
public StructuredQuery . Filter getFilter ()
Returns the filter for this query.
Returns
getKind()
Returns the kind for this query.
Returns
getLimit()
public Integer getLimit ()
Returns the limit for this query.
Returns
getOffset()
Returns the offset for this query.
Returns
getOrderBy()
public List<StructuredQuery . OrderBy > getOrderBy ()
Returns the order by clause for this query.
Returns
getProjection()
public List<String> getProjection ()
Returns the projection for this query.
Returns
getStartCursor()
public Cursor getStartCursor ()
Returns the start cursor for this query.
Returns
getType()
public Query . ResultType<V> getType ()
Returns
hashCode()
Returns
Overrides
nextQuery(RunQueryResponse responsePb)
public StructuredQuery<V> nextQuery ( RunQueryResponse responsePb )
Parameter
Returns
populatePb(RunQueryRequest.Builder requestPb)
public void populatePb ( RunQueryRequest . Builder requestPb )
Parameter
toBuilder()
public abstract StructuredQuery . Builder<V> toBuilder ()
Returns
toString()
Returns
Overrides
Send feedback
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 2024-12-05 UTC.
Need to tell us more?
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-05 UTC."],[],[]]