de.greenrobot.dao
Class Query<T>

java.lang.Object
  extended by de.greenrobot.dao.Query<T>
Type Parameters:
T - The enitity class the query will return results for.

public class Query<T>
extends java.lang.Object

    

A repeatable query returning entities.


Method Summary
 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).
 void setLimit(int limit)
          Sets the limit of the maximum number of results returned by this Query.
 void setOffset(int offset)
          Sets the offset for results returned by this Query.
 void setParameter(int index, java.lang.Object parameter)
          Sets the parameter (0 based) using the position in which it was added during building the query.
 T unique()
          Executes the query and returns the unique result or null.
 T uniqueOrThrow()
          Executes the query and returns the unique result (never null).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setParameter

public void setParameter(int index,
                         java.lang.Object parameter)
Sets the parameter (0 based) using the position in which it was added during building the query.


setLimit

public void setLimit(int limit)
Sets the limit of the maximum number of results returned by this Query. {@link 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. {@link QueryBuilder#offset(int) must have been called on the QueryBuilder that created this Query object.


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


Copyright © 2011-2012 greenrobot.de. All Rights Reserved.