|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.greenrobot.dao.QueryBuilder
T
- Entity class to create an query for.public class QueryBuilder
Builds custom entity queries using constraints and parameters and without SQL (QueryBuilder creates SQL for you). To acquire an QueryBuilder, use AbstractDao.queryBuilder()
or AbstractDaoSession.queryBuilder(Class)
. Entity properties are referenced by Fields in the "Properties" inner class of the generated DAOs. This approach allows compile time checks and prevents typo errors occuring at build time.
Example: Query for all users with the first name "Joe" ordered by their last name. (The class Properties is an inner class of UserDao and should be imported before.)
List joes = dao.queryBuilder().where(Properties.FirstName.eq("Joe")).orderAsc(Properties.LastName).list();
Field Summary | |
---|---|
static boolean |
LOG_SQL Set to true to debug the SQL. |
static boolean |
LOG_VALUES Set to see the given values. |
Method Summary | ||
---|---|---|
WhereCondition |
and(WhereCondition cond1, WhereCondition cond2, WhereCondition... condMore) |
|
Query<T> |
build() Builds a reusable query object (Query objects can be executed more efficiently than creating a QueryBuilder for each execution. |
|
DeleteQuery<T> |
buildDelete() Builds a reusable query object for deletion (Query objects can be executed more efficiently than creating a QueryBuilder for each execution. |
|
|
join(java.lang.Class Not supported yet. |
|
|
joinToMany(java.lang.Class Not supported yet. |
|
QueryBuilder<T> |
limit(int limit) Limits the number of results returned by queries. |
|
java.util.List<T> |
list() Shorthand for build() . |
|
CloseableListIterator<T> |
listIterator() Shorthand for build() . |
|
LazyList<T> |
listLazy() Shorthand for build() . |
|
LazyList<T> |
listLazyUncached() Shorthand for build() . |
|
QueryBuilder<T> |
offset(int offset) Sets the offset for query results in combination with limit(int) . |
|
WhereCondition |
or(WhereCondition cond1, WhereCondition cond2, WhereCondition... condMore) |
|
QueryBuilder<T> |
orderAsc(Property... properties) Adds the given properties to the ORDER BY section using ascending order. |
|
QueryBuilder<T> |
orderCustom(Property property, java.lang.String customOrderForProperty) Adds the given properties to the ORDER BY section using the given custom order. |
|
QueryBuilder<T> |
orderDesc(Property... properties) Adds the given properties to the ORDER BY section using descending order. |
|
QueryBuilder<T> |
orderRaw(java.lang.String rawOrder) Adds the given raw SQL string to the ORDER BY section. |
|
T |
unique() Shorthand for build() . |
|
T |
uniqueOrThrow() Shorthand for build() . |
|
QueryBuilder<T> |
where(WhereCondition cond, WhereCondition... condMore) Adds the given conditions to the where clause using an logical AND. |
|
QueryBuilder<T> |
whereOr(WhereCondition cond1, WhereCondition cond2, WhereCondition... condMore) Adds the given conditions to the where clause using an logical OR. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static boolean LOG_SQL
public static boolean LOG_VALUES
Method Detail |
---|
public QueryBuilder<T> where(WhereCondition cond, WhereCondition... condMore)
public QueryBuilder<T> whereOr(WhereCondition cond1, WhereCondition cond2, WhereCondition... condMore)
public WhereCondition or(WhereCondition cond1, WhereCondition cond2, WhereCondition... condMore)
public WhereCondition and(WhereCondition cond1, WhereCondition cond2, WhereCondition... condMore)
publicQueryBuilder join(java.lang.Class entityClass, Property toOneProperty)
publicQueryBuilder joinToMany(java.lang.Class entityClass, Property toManyProperty)
public QueryBuilder<T> orderAsc(Property... properties)
public QueryBuilder<T> orderDesc(Property... properties)
public QueryBuilder<T> orderCustom(Property property, java.lang.String customOrderForProperty)
public QueryBuilder<T> orderRaw(java.lang.String rawOrder)
public QueryBuilder<T> limit(int limit)
public QueryBuilder<T> offset(int offset)
limit(int)
. The first limit
results are skipped and the total number of results will be limited by limit
. You cannot use offset without limit.
public Query<T> build()
public DeleteQuery<T> buildDelete()
public java.util.List<T> list()
build()
.list()
; see Query.list()
for details. To execute a query more than once, you should build the query and keep the Query
object for efficiency reasons.
public LazyList<T> listLazy()
build()
.listLazy()
; see Query.listLazy()
for details. To execute a query more than once, you should build the query and keep the Query
object for efficiency reasons.
public LazyList<T> listLazyUncached()
build()
.listLazyUncached()
; see Query.listLazyUncached()
for details. To execute a query more than once, you should build the query and keep the Query
object for efficiency reasons.
public CloseableListIterator<T> listIterator()
build()
.listIterator()
; see Query.listIterator()
for details. To execute a query more than once, you should build the query and keep the Query
object for efficiency reasons.
public T unique()
build()
.unique()
; see Query.unique()
for details. To execute a query more than once, you should build the query and keep the Query
object for efficiency reasons.
public T uniqueOrThrow()
build()
.uniqueOrThrow()
; see Query.uniqueOrThrow()
for details. To execute a query more than once, you should build the query and keep the Query
object for efficiency reasons.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |