Skip to content

Commit af6bce7

Browse files
Update outdated QueryBuilder and Query docs.
1 parent 1121f19 commit af6bce7

File tree

2 files changed

+29
-14
lines changed

2 files changed

+29
-14
lines changed

objectbox-java/src/main/java/io/objectbox/query/Query.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,15 @@
3838
import io.objectbox.relation.ToOne;
3939

4040
/**
41-
* A repeatable query returning entities.
41+
* A repeatable Query returning the latest matching Objects.
42+
* <p>
43+
* Use {@link #find()} or related methods to fetch the latest results from the BoxStore.
44+
* <p>
45+
* Use {@link #property(Property)} to only return values or an aggregate of a single Property.
46+
* <p>
47+
* See the <a href="https://docs.objectbox.io/queries">Queries documentation</a> for details.
4248
*
43-
* @param <T> The entity class the query will return results for.
44-
* @author Markus
45-
* @see QueryBuilder
49+
* @param <T> Entity class for which results are returned.
4650
*/
4751
@SuppressWarnings({"SameParameterValue", "UnusedReturnValue", "WeakerAccess"})
4852
public class Query<T> implements Closeable {

objectbox-java/src/main/java/io/objectbox/query/QueryBuilder.java

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,35 @@
2727
import io.objectbox.Box;
2828
import io.objectbox.EntityInfo;
2929
import io.objectbox.Property;
30-
import io.objectbox.annotation.apihint.Experimental;
3130
import io.objectbox.annotation.apihint.Internal;
3231
import io.objectbox.exception.DbException;
3332
import io.objectbox.relation.RelationInfo;
3433

3534
/**
36-
* With QueryBuilder you define custom queries returning matching entities. Using the methods of this class you can
37-
* select (filter) results for specific data (for example #{@link #equal(Property, String)} and
38-
* {@link #isNull(Property)}) and select an sort order for the resulting list (see {@link #order(Property)} and its
39-
* overloads).
35+
* Builds a {@link Query Query} using conditions which can then be used to return a list of matching Objects.
4036
* <p>
41-
* Use {@link #build()} to conclude your query definitions and to get a {@link Query} object, which is used to actually
42-
* get results.
37+
* A simple example:
38+
*
39+
* <pre>
40+
* userBox.query()
41+
* .equal(User_.firstName, "Joe")
42+
* .order(User_.lastName)
43+
* .build()
44+
* .find()
45+
* </pre>
46+
*
47+
* <p>
48+
* To add a condition use the appropriate method, for example {@link #equal(Property, String)} or
49+
* {@link #isNull(Property)}. To order results use {@link #order(Property)} and its related methods.
50+
* <p>
51+
* Use {@link #build()} to create a {@link Query} object, which is used to actually get the results.
52+
* <p>
53+
* Note: by default Query returns full Objects. To return only values or an aggregate value for a single Property,
54+
* use {@link Query#property(Property)}.
4355
* <p>
44-
* Note: Currently you can only query for complete entities. Returning individual property values or aggregates are
45-
* currently not available. Keep in mind that ObjectBox is very fast and the overhead to create an entity is very low.
56+
* See the <a href="https://docs.objectbox.io/queries">Queries documentation</a> for details.
4657
*
47-
* @param <T> Entity class associated with this query builder.
58+
* @param <T> Entity class for which the Query is built.
4859
*/
4960
@SuppressWarnings({"WeakerAccess", "UnusedReturnValue", "unused"})
5061
public class QueryBuilder<T> implements Closeable {

0 commit comments

Comments
 (0)