Package org.greenrobot.greendao.query
Class Query<T>
- java.lang.Object
-
- org.greenrobot.greendao.query.Query<T>
-
- Type Parameters:
T- The entity class the query will return results for.
public class Query<T> extends java.lang.ObjectA repeatable query returning entities.
-
-
Field Summary
Fields Modifier and Type Field Description protected AbstractDao<T,?>daoprotected InternalQueryDaoAccess<T>daoAccessprotected intlimitPositionprotected intoffsetPositionprotected java.lang.ThreadownerThreadprotected java.lang.String[]parametersprotected java.lang.Stringsql
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description RxQuery__InternalRx()DO NOT USE.RxQuery__internalRxPlain()DO NOT USE.protected voidcheckThread()Query<T>forCurrentThread()Note: all parameters are reset to their initial values specified inQueryBuilder.static <T2> Query<T2>internalCreate(AbstractDao<T2,?> dao, java.lang.String sql, java.lang.Object[] initialValues)For internal use by greenDAO only.java.util.List<T>list()Executes the query and returns the result as a list containing all entities loaded into memory.CloseableListIterator<T>listIterator()Executes the query and returns the result as a list iterator; make sure to close it to close the underlying cursor.LazyList<T>listLazy()Executes the query and returns the result as a list that lazy loads the entities on first access.LazyList<T>listLazyUncached()Executes the query and returns the result as a list that lazy loads the entities on every access (uncached).voidsetLimit(int limit)Sets the limit of the maximum number of results returned by this Query.voidsetOffset(int offset)Sets the offset for results returned by this Query.Query<T>setParameter(int index, java.lang.Boolean parameter)Query<T>setParameter(int index, java.lang.Object parameter)Sets the parameter (0 based) using the position in which it was added during building the query.Query<T>setParameter(int index, java.util.Date parameter)protected static java.lang.String[]toStringArray(java.lang.Object[] values)Tunique()Executes the query and returns the unique result or null.TuniqueOrThrow()Executes the query and returns the unique result (never null).
-
-
-
Field Detail
-
limitPosition
protected final int limitPosition
-
offsetPosition
protected final int offsetPosition
-
dao
protected final AbstractDao<T,?> dao
-
daoAccess
protected final InternalQueryDaoAccess<T> daoAccess
-
sql
protected final java.lang.String sql
-
parameters
protected final java.lang.String[] parameters
-
ownerThread
protected final java.lang.Thread ownerThread
-
-
Method Detail
-
internalCreate
public static <T2> Query<T2> internalCreate(AbstractDao<T2,?> dao, java.lang.String sql, java.lang.Object[] initialValues)
For internal use by greenDAO only.
-
forCurrentThread
public Query<T> forCurrentThread()
Note: all parameters are reset to their initial values specified inQueryBuilder.
-
list
public java.util.List<T> list()
Executes the query and returns the result as a list containing all entities loaded into memory.
-
listLazy
public LazyList<T> listLazy()
Executes the query and returns the result as a list that lazy loads the entities on first access. Entities are cached, so accessing the same entity more than once will not result in loading an entity from the underlying cursor again.Make sure to close it to close the underlying cursor.
-
listLazyUncached
public LazyList<T> listLazyUncached()
Executes the query and returns the result as a list that lazy loads the entities on every access (uncached). Make sure to close the list to close the underlying cursor.
-
listIterator
public CloseableListIterator<T> listIterator()
Executes the query and returns the result as a list iterator; make sure to close it to close the underlying cursor. The cursor is closed once the iterator is fully iterated through.
-
unique
public T unique()
Executes the query and returns the unique result or null.- Returns:
- Entity or null if no matching entity was found
- Throws:
DaoException- if the result is not unique
-
uniqueOrThrow
public T uniqueOrThrow()
Executes the query and returns the unique result (never null).- Returns:
- Entity
- Throws:
DaoException- if the result is not unique or no entity was found
-
setParameter
public Query<T> setParameter(int index, java.lang.Object parameter)
Sets the parameter (0 based) using the position in which it was added during building the query. Note: all standard WHERE parameters come first. After that come the WHERE parameters of joins (if any).
-
setParameter
public Query<T> setParameter(int index, java.util.Date parameter)
- See Also:
setParameter(int, Object)
-
setParameter
public Query<T> setParameter(int index, java.lang.Boolean parameter)
- See Also:
setParameter(int, Object)
-
__internalRxPlain
@Internal public RxQuery __internalRxPlain()
DO NOT USE. The returnedRxTransactionallows getting query results using Rx Observables without any Scheduler set for subscribeOn.- See Also:
__InternalRx()
-
__InternalRx
@Internal public RxQuery __InternalRx()
DO NOT USE. The returnedRxTransactionallows getting query results using Rx Observables using RX's IO scheduler for subscribeOn.- See Also:
__internalRxPlain()
-
setLimit
public void setLimit(int limit)
Sets the limit of the maximum number of results returned by this Query.QueryBuilder.limit(int)must have been called on the QueryBuilder that created this Query object.
-
setOffset
public void setOffset(int offset)
Sets the offset for results returned by this Query.QueryBuilder.offset(int)must have been called on the QueryBuilder that created this Query object.
-
toStringArray
protected static java.lang.String[] toStringArray(java.lang.Object[] values)
-
checkThread
protected void checkThread()
-
-