Q
- the effective type of the queryE
- the type of entities being queriedC
- the type of constraints accepted by this querypublic abstract class Query<Q,E extends BaseEntity<?>,C extends Constraint> extends BaseQuery<Q,E>
mapper
.descriptor, limit, MAX_LIST_SIZE, mixing, skip
Modifier | Constructor and Description |
---|---|
protected |
Query(EntityDescriptor descriptor) |
Modifier and Type | Method and Description |
---|---|
abstract long |
count()
Executes the query and counts the number of results.
|
abstract void |
delete()
Deletes all matches using the
BaseMapper.delete(BaseEntity) of the appropriate mapper. |
Q |
eq(Mapping field,
Object value)
Adds a constraint which ensures that the given field contains the given value.
|
Q |
eqIgnoreNull(Mapping field,
Object value)
Adds a constraint which ensures that the given field contains the given value.
|
abstract boolean |
exists()
Determines if the query would have at least one matching entity.
|
abstract FilterFactory<C> |
filters() |
Q |
ne(Mapping field,
Object value)
Adds a constraint which ensures that the given field does not contain the given value.
|
abstract Q |
orderAsc(Mapping field)
Adds a sort constraint to order by the given field ascending.
|
abstract Q |
orderDesc(Mapping field)
Adds a sort constraint to order by the given field descending.
|
Q |
queryString(String query,
QueryField... fields)
Adds a query string filter to the given query.
|
abstract void |
truncate()
Deletes all matches using the capabilities of the underlying database.
|
abstract Q |
where(C constraint)
Applies the given contraints to the query.
|
failOnOverflow, first, getDescriptor, getLimit, iterate, iterateAll, limit, one, queryFirst, queryList, queryOne, skip
protected Query(EntityDescriptor descriptor)
public abstract Q where(C constraint)
constraint
- the constraint which has to be fullfilledpublic abstract FilterFactory<C> filters()
public Q eq(Mapping field, Object value)
field
- the name of the field to filter onvalue
- the value to filter onpublic Q ne(Mapping field, Object value)
field
- the name of the field to filter onvalue
- the value to filter onpublic Q eqIgnoreNull(Mapping field, Object value)
If the given value is null, the constraint is skipped.
field
- the field to checkvalue
- the value to filter onpublic Q queryString(String query, QueryField... fields)
query
- the query to search forfields
- the fields to search inFilterFactory.queryString(EntityDescriptor, String, QueryField...)
public abstract Q orderAsc(Mapping field)
field
- the field to order by.public abstract Q orderDesc(Mapping field)
field
- the field to order by.public abstract long count()
public abstract boolean exists()
public abstract void delete()
BaseMapper.delete(BaseEntity)
of the appropriate mapper.
Be aware that this might be slow for very large result sets.
public abstract void truncate()
Therefore no checks or anything will be invoked for the deleted entities.
Use this for larger result sets where integrity and constraints do not matter or are managed manually.
Copyright © 2018. All rights reserved.