Class Query<T>

  • Type Parameters:
    T - The entity class the query will return results for.

    public class Query<T>
    extends java.lang.Object
    A repeatable query returning entities.
    • Field Detail

      • limitPosition

        protected final int limitPosition
      • offsetPosition

        protected final int offsetPosition
      • 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 in QueryBuilder.
      • 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).
      • __internalRxPlain

        @Internal
        public RxQuery __internalRxPlain()
        DO NOT USE. The returned RxTransaction allows getting query results using Rx Observables without any Scheduler set for subscribeOn.
        See Also:
        __InternalRx()
      • 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()