Class Query<T>
- java.lang.Object
-
- io.objectbox.query.Query<T>
-
- Type Parameters:
T- Entity class for which results are returned.
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class Query<T> extends java.lang.Object implements java.io.CloseableA repeatable Query returning the latest matching objects.Use
find()or related methods to fetch the latest results from theBoxStore.Use
property(Property)to only return values or an aggregate of a single Property.Make sure to
close()this query once done with it to reclaim resources immediately.See the Queries documentation for details.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) Box<T>boxprivate java.util.Comparator<T>comparatorprivate java.util.List<EagerRelation<T,?>>eagerRelationsprivate QueryFilter<T>filter(package private) longhandleprivate static intINITIAL_RETRY_BACK_OFF_IN_MSprivate QueryPublisher<T>publisherprivate intqueryAttemptsprivate BoxStorestore
-
Constructor Summary
Constructors Modifier Constructor Description (package private)Query(Box<T> box, long queryHandle, java.util.List<EagerRelation<T,?>> eagerRelations, QueryFilter<T> filter, java.util.Comparator<T> comparator)privateQuery(Query<T> originalQuery, long handle)Creates a copy of theoriginalQuery, but pointing to a different native query usinghandle.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description (package private) <R> RcallInReadTx(java.util.concurrent.Callable<R> callable)private voidcheckOpen()Throws ifclose()has been called for this.voidclose()Closes this query and frees used resources.Query<T>copy()Creates a copy of this for use in another thread.longcount()Returns the count of Objects matching the query.(package private) longcursorHandle()To be called inside a read TXjava.lang.Stringdescribe()For logging and testing, returns a string describing this query like "Query for entity Example with 4 conditions with properties prop1, prop2".java.lang.StringdescribeParameters()For logging and testing, returns a string describing the conditions of this query like "(prop1 == A AND prop2 is null)".private voidensureNoComparator()private voidensureNoFilter()private voidensureNoFilterNoComparator()protected voidfinalize()Explicitly callclose()instead to avoid expensive finalization.java.util.List<T>find()Finds objects matching the query.java.util.List<T>find(long offset, long limit)Likefind(), but can skip and limit results.TfindFirst()Finds the first object matching this query.longfindFirstId()LikefindFirst(), but returns just the ID of the object.long[]findIds()Likefind(), but returns just the IDs of the objects.long[]findIds(long offset, long limit)LikefindIds(), but can skip and limit results.java.util.List<IdWithScore>findIdsWithScores()Finds IDs of objects matching the query associated to their query score (e.g.java.util.List<IdWithScore>findIdsWithScores(long offset, long limit)LikefindIdsWithScores(), but can skip and limit results.LazyList<T>findLazy()LazyList<T>findLazyCached()TfindUnique()Finds the only object matching this query.longfindUniqueId()LikefindUnique(), but returns just the ID of the object.java.util.List<ObjectWithScore<T>>findWithScores()Finds objects matching the query associated to their query score (e.g.java.util.List<ObjectWithScore<T>>findWithScores(long offset, long limit)LikefindWithScores(), but can skip and limit results.voidforEach(QueryConsumer<T> consumer)Emits query results one by one to the given consumer (synchronously).(package private) longnativeClone(long handle)Clones the native query, incl.(package private) longnativeCount(long handle, long cursorHandle)(package private) java.lang.StringnativeDescribeParameters(long handle)(package private) voidnativeDestroy(long handle)(package private) java.util.List<T>nativeFind(long handle, long cursorHandle, long offset, long limit)(package private) java.lang.ObjectnativeFindFirst(long handle, long cursorHandle)(package private) longnativeFindFirstId(long handle, long cursorHandle)(package private) long[]nativeFindIds(long handle, long cursorHandle, long offset, long limit)(package private) java.util.List<IdWithScore>nativeFindIdsWithScores(long handle, long cursorHandle, long offset, long limit)(package private) java.lang.ObjectnativeFindUnique(long handle, long cursorHandle)(package private) longnativeFindUniqueId(long handle, long cursorHandle)(package private) java.util.List<ObjectWithScore<T>>nativeFindWithScores(long handle, long cursorHandle, long offset, long limit)(package private) longnativeRemove(long handle, long cursorHandle)(package private) voidnativeSetParameter(long handle, int entityId, int propertyId, java.lang.String parameterAlias, byte[] value)(package private) voidnativeSetParameter(long handle, int entityId, int propertyId, java.lang.String parameterAlias, double value)(package private) voidnativeSetParameter(long handle, int entityId, int propertyId, java.lang.String parameterAlias, float[] values)(package private) voidnativeSetParameter(long handle, int entityId, int propertyId, java.lang.String parameterAlias, long value)(package private) voidnativeSetParameter(long handle, int entityId, int propertyId, java.lang.String parameterAlias, java.lang.String value)(package private) voidnativeSetParameters(long handle, int entityId, int propertyId, java.lang.String parameterAlias, double value1, double value2)(package private) voidnativeSetParameters(long handle, int entityId, int propertyId, java.lang.String parameterAlias, int[] values)(package private) voidnativeSetParameters(long handle, int entityId, int propertyId, java.lang.String parameterAlias, long[] values)(package private) voidnativeSetParameters(long handle, int entityId, int propertyId, java.lang.String parameterAlias, long value1, long value2)(package private) voidnativeSetParameters(long handle, int entityId, int propertyId, java.lang.String parameterAlias, java.lang.String[] values)private voidnativeSetParameters(long handle, int entityId, int propertyId, java.lang.String parameterAlias, java.lang.String value, java.lang.String value2)(package private) java.lang.StringnativeToString(long handle)PropertyQueryproperty(Property<T> property)Creates aPropertyQueryfor the given property.voidpublish()Publishes the current data to all subscribed @DataObservers.longremove()Removes (deletes) all Objects matching the query(package private) voidresolveEagerRelation(T entity)(package private) voidresolveEagerRelation(T entity, EagerRelation<T,?> eagerRelation)(package private) voidresolveEagerRelationForNonNullEagerRelations(T entity, int entityIndex)Note: no null check on eagerRelations!(package private) voidresolveEagerRelations(java.util.List<T> entities)Query<T>setParameter(Property<?> property, boolean value)Sets a parameter previously given to theQueryBuilderto a new value.Query<T>setParameter(Property<?> property, byte[] value)Sets a parameter previously given to theQueryBuilderto new values.Query<T>setParameter(Property<?> property, double value)Sets a parameter previously given to theQueryBuilderto a new value.Query<T>setParameter(Property<?> property, float[] value)Changes the parameter of the query condition forpropertyto a newvalue.Query<T>setParameter(Property<?> property, int[] value)Changes the parameter of the query condition forpropertyto a newvalue.Query<T>setParameter(Property<?> property, long value)Sets a parameter previously given to theQueryBuilderto a new value.Query<T>setParameter(Property<?> property, long[] value)Changes the parameter of the query condition forpropertyto a newvalue.Query<T>setParameter(Property<?> property, java.lang.String value)Sets a parameter previously given to theQueryBuilderto a new value.Query<T>setParameter(Property<?> property, java.lang.String[] value)Changes the parameter of the query condition forpropertyto a newvalue.Query<T>setParameter(Property<?> property, java.util.Date value)Sets a parameter previously given to theQueryBuilderto a new value.Query<T>setParameter(java.lang.String alias, boolean value)Changes the parameter of the query condition with the matchingaliasto a newvalue.Query<T>setParameter(java.lang.String alias, byte[] value)Changes the parameter of the query condition with the matchingaliasto a newvalue.Query<T>setParameter(java.lang.String alias, double value)Changes the parameter of the query condition with the matchingaliasto a newvalue.Query<T>setParameter(java.lang.String alias, float[] value)Changes the parameter of the query condition with the matchingaliasto a newvalue.Query<T>setParameter(java.lang.String alias, int[] value)Changes the parameter of the query condition with the matchingaliasto a newvalue.Query<T>setParameter(java.lang.String alias, long value)Changes the parameter of the query condition with the matchingaliasto a newvalue.Query<T>setParameter(java.lang.String alias, long[] value)Changes the parameter of the query condition with the matchingaliasto a newvalue.Query<T>setParameter(java.lang.String alias, java.lang.String value)Changes the parameter of the query condition with the matchingaliasto a newvalue.Query<T>setParameter(java.lang.String alias, java.lang.String[] value)Changes the parameter of the query condition with the matchingaliasto a newvalue.Query<T>setParameter(java.lang.String alias, java.util.Date value)Changes the parameter of the query condition with the matchingaliasto a newvalue.Query<T>setParameters(Property<?> property, double value1, double value2)Sets a parameter previously given to theQueryBuilderto new values.Query<T>setParameters(Property<?> property, int[] values)Deprecated.UsesetParameter(Property, int[])instead.Query<T>setParameters(Property<?> property, long[] values)Deprecated.UsesetParameter(Property, long[])instead.Query<T>setParameters(Property<?> property, long value1, long value2)Sets a parameter previously given to theQueryBuilderto new values.Query<T>setParameters(Property<?> property, java.lang.String[] values)Deprecated.UsesetParameter(Property, String[])instead.Query<T>setParameters(Property<?> property, java.lang.String key, java.lang.String value)Sets a parameter previously given to theQueryBuilderto new values.Query<T>setParameters(java.lang.String alias, double value1, double value2)Changes the parameters of the query condition with the matchingaliasto the new values.Query<T>setParameters(java.lang.String alias, int[] values)Deprecated.UsesetParameter(String, int[])instead.Query<T>setParameters(java.lang.String alias, long[] values)Deprecated.UsesetParameter(String, long[])instead.Query<T>setParameters(java.lang.String alias, long value1, long value2)Changes the parameters of the query condition with the matchingaliasto the new values.Query<T>setParameters(java.lang.String alias, java.lang.String[] values)Deprecated.UsesetParameter(String, String[])instead.Query<T>setParameters(java.lang.String alias, java.lang.String key, java.lang.String value)Changes the parameters of the query condition with the matchingaliasto the new values.SubscriptionBuilder<java.util.List<T>>subscribe()ADataObservercan be subscribed to data changes using the returned builder.SubscriptionBuilder<java.util.List<T>>subscribe(DataSubscriptionList dataSubscriptionList)Convenience forsubscribe()with a subsequent call toSubscriptionBuilder.dataSubscriptionList(DataSubscriptionList).
-
-
-
Field Detail
-
store
private final BoxStore store
-
publisher
private final QueryPublisher<T> publisher
-
eagerRelations
@Nullable private final java.util.List<EagerRelation<T,?>> eagerRelations
-
filter
@Nullable private final QueryFilter<T> filter
-
comparator
@Nullable private final java.util.Comparator<T> comparator
-
queryAttempts
private final int queryAttempts
-
INITIAL_RETRY_BACK_OFF_IN_MS
private static final int INITIAL_RETRY_BACK_OFF_IN_MS
- See Also:
- Constant Field Values
-
handle
volatile long handle
-
-
Constructor Detail
-
Query
Query(Box<T> box, long queryHandle, @Nullable java.util.List<EagerRelation<T,?>> eagerRelations, @Nullable QueryFilter<T> filter, @Nullable java.util.Comparator<T> comparator)
-
-
Method Detail
-
nativeDestroy
void nativeDestroy(long handle)
-
nativeClone
long nativeClone(long handle)
Clones the native query, incl. conditions and parameters, and returns a handle to the clone.
-
nativeFindFirst
java.lang.Object nativeFindFirst(long handle, long cursorHandle)
-
nativeFindUnique
java.lang.Object nativeFindUnique(long handle, long cursorHandle)
-
nativeFind
java.util.List<T> nativeFind(long handle, long cursorHandle, long offset, long limit) throws java.lang.Exception
- Throws:
java.lang.Exception
-
nativeFindFirstId
long nativeFindFirstId(long handle, long cursorHandle)
-
nativeFindUniqueId
long nativeFindUniqueId(long handle, long cursorHandle)
-
nativeFindIds
long[] nativeFindIds(long handle, long cursorHandle, long offset, long limit)
-
nativeFindWithScores
java.util.List<ObjectWithScore<T>> nativeFindWithScores(long handle, long cursorHandle, long offset, long limit)
-
nativeFindIdsWithScores
java.util.List<IdWithScore> nativeFindIdsWithScores(long handle, long cursorHandle, long offset, long limit)
-
nativeCount
long nativeCount(long handle, long cursorHandle)
-
nativeRemove
long nativeRemove(long handle, long cursorHandle)
-
nativeToString
java.lang.String nativeToString(long handle)
-
nativeDescribeParameters
java.lang.String nativeDescribeParameters(long handle)
-
nativeSetParameter
void nativeSetParameter(long handle, int entityId, int propertyId, @Nullable java.lang.String parameterAlias, java.lang.String value)
-
nativeSetParameters
private void nativeSetParameters(long handle, int entityId, int propertyId, @Nullable java.lang.String parameterAlias, java.lang.String value, java.lang.String value2)
-
nativeSetParameter
void nativeSetParameter(long handle, int entityId, int propertyId, @Nullable java.lang.String parameterAlias, long value)
-
nativeSetParameters
void nativeSetParameters(long handle, int entityId, int propertyId, @Nullable java.lang.String parameterAlias, int[] values)
-
nativeSetParameters
void nativeSetParameters(long handle, int entityId, int propertyId, @Nullable java.lang.String parameterAlias, long[] values)
-
nativeSetParameters
void nativeSetParameters(long handle, int entityId, int propertyId, @Nullable java.lang.String parameterAlias, long value1, long value2)
-
nativeSetParameter
void nativeSetParameter(long handle, int entityId, int propertyId, @Nullable java.lang.String parameterAlias, double value)
-
nativeSetParameters
void nativeSetParameters(long handle, int entityId, int propertyId, @Nullable java.lang.String parameterAlias, double value1, double value2)
-
nativeSetParameters
void nativeSetParameters(long handle, int entityId, int propertyId, @Nullable java.lang.String parameterAlias, java.lang.String[] values)
-
nativeSetParameter
void nativeSetParameter(long handle, int entityId, int propertyId, @Nullable java.lang.String parameterAlias, byte[] value)
-
nativeSetParameter
void nativeSetParameter(long handle, int entityId, int propertyId, @Nullable java.lang.String parameterAlias, float[] values)
-
finalize
protected void finalize() throws java.lang.ThrowableExplicitly callclose()instead to avoid expensive finalization.- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
close
public void close()
Closes this query and frees used resources.If possible, call this always once done with this. Otherwise, will be called once this is finalized (e.g. garbage collected).
Calling any other methods of this afterwards will throw an
IllegalStateException.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
cursorHandle
long cursorHandle()
To be called inside a read TX
-
findFirst
@Nullable public T findFirst()
Finds the first object matching this query.Note: if no
QueryBuilder.order(io.objectbox.Property<T>)conditions are present, which object is the first one might be arbitrary (sometimes the one with the lowest ID, but never guaranteed to be).- Returns:
- The first object if there are matches.
nullif no object matches.
-
ensureNoFilterNoComparator
private void ensureNoFilterNoComparator()
-
ensureNoFilter
private void ensureNoFilter()
-
ensureNoComparator
private void ensureNoComparator()
-
findUnique
@Nullable public T findUnique()
Finds the only object matching this query.- Returns:
- The object if a single object matches.
nullif no object matches. ThrowsNonUniqueResultExceptionif there are multiple objects matching the query.
-
find
@Nonnull public java.util.List<T> find()
Finds objects matching the query.Note: if no
QueryBuilder.order(io.objectbox.Property<T>)conditions are present, the order is arbitrary (sometimes ordered by ID, but never guaranteed to).- Returns:
- A list of matching objects. An empty list if no object matches.
-
find
@Nonnull public java.util.List<T> find(long offset, long limit)
Likefind(), but can skip and limit results.Use to get a slice of the whole result, e.g. for "result paging".
- Parameters:
offset- If greater than 0, skips this many results.limit- If greater than 0, returns at most this many results.
-
findFirstId
public long findFirstId()
LikefindFirst(), but returns just the ID of the object.This is more efficient as no object is created.
Ignores any
query filter.- Returns:
- The ID of the first matching object.
0if no object matches.
-
findUniqueId
public long findUniqueId()
LikefindUnique(), but returns just the ID of the object.This is more efficient as no object is created.
Ignores any
query filter.- Returns:
- The ID of the object, if a single object matches.
0if no object matches. ThrowsNonUniqueResultExceptionif there are multiple objects matching the query.
-
findIds
@Nonnull public long[] findIds()
Likefind(), but returns just the IDs of the objects.IDs can later be used to
Box.get(long)objects.This is very efficient as no objects are created.
Note: a filter set with
QueryBuilder.filter(QueryFilter)will be silently ignored!- Returns:
- An array of IDs of matching objects. An empty array if no objects match.
-
findIds
@Nonnull public long[] findIds(long offset, long limit)LikefindIds(), but can skip and limit results.Use to get a slice of the whole result, e.g. for "result paging".
Note: a filter set with
QueryBuilder.filter(QueryFilter)will be silently ignored!- Parameters:
offset- If greater than 0, skips this many results.limit- If greater than 0, returns at most this many results.
-
findIdsWithScores
@Nonnull public java.util.List<IdWithScore> findIdsWithScores(long offset, long limit)
LikefindIdsWithScores(), but can skip and limit results.Use to get a slice of the whole result, e.g. for "result paging".
- Parameters:
offset- If greater than 0, skips this many results.limit- If greater than 0, returns at most this many results.
-
findIdsWithScores
@Nonnull public java.util.List<IdWithScore> findIdsWithScores()
Finds IDs of objects matching the query associated to their query score (e.g. distance in NN search).This only works on objects with a property with an
HnswIndex.- Returns:
- A list of
IdWithScorethat wraps IDs of matching objects and their score, sorted by score in ascending order.
-
findWithScores
@Nonnull public java.util.List<ObjectWithScore<T>> findWithScores(long offset, long limit)
LikefindWithScores(), but can skip and limit results.Use to get a slice of the whole result, e.g. for "result paging".
- Parameters:
offset- If greater than 0, skips this many results.limit- If greater than 0, returns at most this many results.
-
findWithScores
@Nonnull public java.util.List<ObjectWithScore<T>> findWithScores()
Finds objects matching the query associated to their query score (e.g. distance in NN search).This only works on objects with a property with an
HnswIndex.- Returns:
- A list of
ObjectWithScorethat wraps matching objects and their score, sorted by score in ascending order.
-
property
public PropertyQuery property(Property<T> property)
Creates aPropertyQueryfor the given property.A
PropertyQueryuses the same conditions as this Query object, but returns only the value(s) of a single property (not an entity objects).- Parameters:
property- the property for which to return values
-
callInReadTx
<R> R callInReadTx(java.util.concurrent.Callable<R> callable)
-
forEach
public void forEach(QueryConsumer<T> consumer)
Emits query results one by one to the given consumer (synchronously). Once this method returns, the consumer will have received all result object). It "streams" each object from the database to the consumer, which is very memory efficient. Because this is run in a read transaction, the consumer gets a consistent view on the data. LikefindLazy(), this method can be used for a high amount of data.Note: because the consumer is called within a read transaction it may not write to the database.
-
resolveEagerRelations
void resolveEagerRelations(java.util.List<T> entities)
-
resolveEagerRelationForNonNullEagerRelations
void resolveEagerRelationForNonNullEagerRelations(@Nonnull T entity, int entityIndex)Note: no null check on eagerRelations!
-
resolveEagerRelation
void resolveEagerRelation(@Nullable T entity)
-
resolveEagerRelation
void resolveEagerRelation(@Nonnull T entity, EagerRelation<T,?> eagerRelation)
-
count
public long count()
Returns the count of Objects matching the query.
-
setParameter
public Query<T> setParameter(Property<?> property, java.lang.String value)
Sets a parameter previously given to theQueryBuilderto a new value.
-
setParameter
public Query<T> setParameter(java.lang.String alias, java.lang.String value)
Changes the parameter of the query condition with the matchingaliasto a newvalue.- Parameters:
alias- as defined usingPropertyQueryCondition.alias(String).value- The new value to use for the query condition.
-
setParameter
public Query<T> setParameter(Property<?> property, long value)
Sets a parameter previously given to theQueryBuilderto a new value.
-
setParameter
public Query<T> setParameter(java.lang.String alias, long value)
Changes the parameter of the query condition with the matchingaliasto a newvalue.- Parameters:
alias- as defined usingPropertyQueryCondition.alias(String).value- The new value to use for the query condition.
-
setParameter
public Query<T> setParameter(Property<?> property, double value)
Sets a parameter previously given to theQueryBuilderto a new value.
-
setParameter
public Query<T> setParameter(java.lang.String alias, double value)
Changes the parameter of the query condition with the matchingaliasto a newvalue.- Parameters:
alias- as defined usingPropertyQueryCondition.alias(String).value- The new value to use for the query condition.
-
setParameter
public Query<T> setParameter(Property<?> property, java.util.Date value)
Sets a parameter previously given to theQueryBuilderto a new value.- Throws:
java.lang.NullPointerException- if given date is null
-
setParameter
public Query<T> setParameter(java.lang.String alias, java.util.Date value)
Changes the parameter of the query condition with the matchingaliasto a newvalue.- Parameters:
alias- as defined usingPropertyQueryCondition.alias(String).value- The new value to use for the query condition.- Throws:
java.lang.NullPointerException- if given date is null
-
setParameter
public Query<T> setParameter(Property<?> property, boolean value)
Sets a parameter previously given to theQueryBuilderto a new value.
-
setParameter
public Query<T> setParameter(java.lang.String alias, boolean value)
Changes the parameter of the query condition with the matchingaliasto a newvalue.- Parameters:
alias- as defined usingPropertyQueryCondition.alias(String).value- The new value to use for the query condition.
-
setParameter
public Query<T> setParameter(Property<?> property, int[] value)
Changes the parameter of the query condition forpropertyto a newvalue.- Parameters:
property- Property reference from generated entity underscore class, likeExample_.example.value- The newint[]value to use for the query condition.
-
setParameter
public Query<T> setParameter(java.lang.String alias, int[] value)
Changes the parameter of the query condition with the matchingaliasto a newvalue.- Parameters:
alias- as defined usingPropertyQueryCondition.alias(String).value- The newint[]value to use for the query condition.
-
setParameter
public Query<T> setParameter(Property<?> property, long[] value)
Changes the parameter of the query condition forpropertyto a newvalue.- Parameters:
property- Property reference from generated entity underscore class, likeExample_.example.value- The newlong[]value to use for the query condition.
-
setParameter
public Query<T> setParameter(java.lang.String alias, long[] value)
Changes the parameter of the query condition with the matchingaliasto a newvalue.- Parameters:
alias- as defined usingPropertyQueryCondition.alias(String).value- The newlong[]value to use for the query condition.
-
setParameter
public Query<T> setParameter(Property<?> property, float[] value)
Changes the parameter of the query condition forpropertyto a newvalue.- Parameters:
property- Property reference from generated entity underscore class, likeExample_.example.value- The newfloat[]value to use for the query condition.
-
setParameter
public Query<T> setParameter(java.lang.String alias, float[] value)
Changes the parameter of the query condition with the matchingaliasto a newvalue.- Parameters:
alias- as defined usingPropertyQueryCondition.alias(String).value- The newfloat[]value to use for the query condition.
-
setParameter
public Query<T> setParameter(Property<?> property, java.lang.String[] value)
Changes the parameter of the query condition forpropertyto a newvalue.- Parameters:
property- Property reference from generated entity underscore class, likeExample_.example.value- The newString[]value to use for the query condition.
-
setParameter
public Query<T> setParameter(java.lang.String alias, java.lang.String[] value)
Changes the parameter of the query condition with the matchingaliasto a newvalue.- Parameters:
alias- as defined usingPropertyQueryCondition.alias(String).value- The newString[]value to use for the query condition.
-
setParameters
public Query<T> setParameters(Property<?> property, long value1, long value2)
Sets a parameter previously given to theQueryBuilderto new values.
-
setParameters
public Query<T> setParameters(java.lang.String alias, long value1, long value2)
Changes the parameters of the query condition with the matchingaliasto the new values.- Parameters:
alias- as defined usingPropertyQueryCondition.alias(String).value1- The first value to use for the query condition.value2- The second value to use for the query condition.
-
setParameters
@Deprecated public Query<T> setParameters(Property<?> property, int[] values)
Deprecated.UsesetParameter(Property, int[])instead.Sets a parameter previously given to theQueryBuilderto new values.
-
setParameters
@Deprecated public Query<T> setParameters(java.lang.String alias, int[] values)
Deprecated.UsesetParameter(String, int[])instead.Sets a parameter previously given to theQueryBuilderto new values.- Parameters:
alias- as defined usingQueryBuilder.parameterAlias(String).
-
setParameters
@Deprecated public Query<T> setParameters(Property<?> property, long[] values)
Deprecated.UsesetParameter(Property, long[])instead.Sets a parameter previously given to theQueryBuilderto new values.
-
setParameters
@Deprecated public Query<T> setParameters(java.lang.String alias, long[] values)
Deprecated.UsesetParameter(String, long[])instead.Sets a parameter previously given to theQueryBuilderto new values.- Parameters:
alias- as defined usingQueryBuilder.parameterAlias(String).
-
setParameters
public Query<T> setParameters(Property<?> property, double value1, double value2)
Sets a parameter previously given to theQueryBuilderto new values.
-
setParameters
public Query<T> setParameters(java.lang.String alias, double value1, double value2)
Changes the parameters of the query condition with the matchingaliasto the new values.- Parameters:
alias- as defined usingPropertyQueryCondition.alias(String).value1- The first value to use for the query condition.value2- The second value to use for the query condition.
-
setParameters
@Deprecated public Query<T> setParameters(Property<?> property, java.lang.String[] values)
Deprecated.UsesetParameter(Property, String[])instead.Sets a parameter previously given to theQueryBuilderto new values.
-
setParameters
@Deprecated public Query<T> setParameters(java.lang.String alias, java.lang.String[] values)
Deprecated.UsesetParameter(String, String[])instead.Sets a parameter previously given to theQueryBuilderto new values.- Parameters:
alias- as defined usingQueryBuilder.parameterAlias(String).
-
setParameters
public Query<T> setParameters(Property<?> property, java.lang.String key, java.lang.String value)
Sets a parameter previously given to theQueryBuilderto new values.
-
setParameters
public Query<T> setParameters(java.lang.String alias, java.lang.String key, java.lang.String value)
Changes the parameters of the query condition with the matchingaliasto the new values.- Parameters:
alias- as defined usingPropertyQueryCondition.alias(String).key- The first value to use for the query condition.value- The second value to use for the query condition.
-
setParameter
public Query<T> setParameter(Property<?> property, byte[] value)
Sets a parameter previously given to theQueryBuilderto new values.
-
setParameter
public Query<T> setParameter(java.lang.String alias, byte[] value)
Changes the parameter of the query condition with the matchingaliasto a newvalue.- Parameters:
alias- as defined usingPropertyQueryCondition.alias(String).value- The new value to use for the query condition.
-
remove
public long remove()
Removes (deletes) all Objects matching the query- Returns:
- count of removed Objects
-
subscribe
public SubscriptionBuilder<java.util.List<T>> subscribe()
ADataObservercan be subscribed to data changes using the returned builder. The observer is supplied viaSubscriptionBuilder.observer(DataObserver)and will be notified once the query results have (potentially) changed.With subscribing, the observer will immediately get current query results. The query is run for the subscribing observer.
Threading notes: Query observers are notified from a thread pooled. Observers may be notified in parallel. The notification order is the same as the subscription order, although this may not always be guaranteed in the future.
Stale observers: you must hold on to the Query or
DataSubscriptionobjects to keep yourDataObservers active. If this Query is not referenced anymore (along with itsDataSubscriptions, which hold a reference to the Query internally), it may be GCed and observers may become stale (won't receive anymore data).
-
subscribe
public SubscriptionBuilder<java.util.List<T>> subscribe(DataSubscriptionList dataSubscriptionList)
Convenience forsubscribe()with a subsequent call toSubscriptionBuilder.dataSubscriptionList(DataSubscriptionList).- Parameters:
dataSubscriptionList- the resultingDataSubscriptionwill be added to it
-
publish
public void publish()
Publishes the current data to all subscribed @DataObservers. This is useful triggering observers when new parameters have been set. Note, that setParameter methods will NOT be propagated to observers.
-
describe
public java.lang.String describe()
For logging and testing, returns a string describing this query like "Query for entity Example with 4 conditions with properties prop1, prop2".Note: the format of the returned string may change without notice.
-
describeParameters
public java.lang.String describeParameters()
For logging and testing, returns a string describing the conditions of this query like "(prop1 == A AND prop2 is null)".Note: the format of the returned string may change without notice.
-
checkOpen
private void checkOpen()
Throws ifclose()has been called for this.
-
-