Class Query<R>
- All Implemented Interfaces:
Serializable
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionCopy ConstructorQuery
(Selectable<?>[] selects, Type<?> type, Condition condition) Deprecated.Query
(Selectable<? extends R> select) Query
(Selectable<? extends R> select, Condition condition) Query
(Selectable<? extends R> select, Query<?> query) Copy ConstructorQuery
(Selectable<R> select, Type<?> type, Condition condition) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addOrderBy
(Function<?> orderBy) void
addOrderBy
(Function<?> orderBy, boolean ascending) void
addOrderBy
(Selectable<?> orderBy) void
addOrderBy
(Selectable<?> orderBy, boolean ascending) void
addOrderByDescending
(Function<?> orderBy) void
addOrderByDescending
(Selectable<?> orderBy) int
Deprecated.Usetotal()
insteadstatic <R> Query.Result<R>
Deprecated.UseQuery.Result.empty()
insteadList<Selectable<?>>
getJoins()
int
getLimit()
Deprecated.UsegetPageLimitOrMinusOne()
instead.int
Deprecated.UsegetPageOffset()
instead.List<Selectable<?>>
int
int
int
int
Selectable<? extends R>
Type<?>
getType()
boolean
Does an inner join with the given type without any join condition.Does an inner join with the given type on the given join condition.joinOuterLeft
(Type<?> type, Condition condition) joinOuterRight
(Type<?> type, Condition condition) void
If there is already a condition set for this query, this is equivalent to{@link #setCondition(Condition) setCondition}({@link #getCondition()}.{@link Condition#and(Condition) and}(narrowingCondition))
.newQuery
(Selectable<?>[] selects, Type<?> type, Condition condition) void
search()
Searches for items matching this query.Deprecated.UsesearchAndTotal()
insteadSearches for items matching this query.Searches equivalently tosearch()
, but assumes that the search result has at most one element.Searches equivalently tosearch()
, but assumes that the search result has exactly one element.Deprecated.renamed tosearchSingleton()
.void
setCondition
(Condition condition) void
setDistinct
(boolean distinct) void
setGroupBy
(Selectable<?>... groupBy) void
void
setLimit
(int offset) Deprecated.UsesetPageUnlimited(int)
instead.void
setLimit
(int offset, int limit) Deprecated.UsesetPage(int, int)
instead.void
setOrderBy
(Function<?>[] orderBy, boolean[] ascending) void
setOrderBy
(Function<?> orderBy, boolean ascending) void
setOrderBy
(Selectable<?>[] orderBy, boolean[] ascending) void
setOrderBy
(Selectable<?> orderBy, boolean ascending) void
setOrderByAndThis
(Function<?> orderBy, boolean ascending) void
setOrderByAndThis
(Selectable<?> orderBy, boolean ascending) void
setOrderByThis
(boolean ascending) void
setPage
(int offset, int limit) void
setPageUnlimited
(int offset) void
setSearchSizeCacheLimit
(int searchSizeCacheLimit) Sets the search size cache limit for this query.void
setSearchSizeLimit
(int searchSizeLimit) Sets the search size limit for this query.void
setSelect
(Selectable<? extends R> select) void
setSelects
(Selectable<?>... selects) toString()
int
total()
Counts the items matching this query.
-
Constructor Details
-
Query
-
Query
-
Query
Copy Constructor -
Query
Copy Constructor -
Query
-
Query
Deprecated.UsenewQuery(Selectable[], Type, Condition)
instead
-
-
Method Details
-
newQuery
-
getSelectSingle
-
setSelect
-
setSelects
-
isDistinct
public boolean isDistinct() -
setDistinct
public void setDistinct(boolean distinct) -
getType
-
setCondition
-
getCondition
-
narrow
If there is already a condition set for this query, this is equivalent to{@link #setCondition(Condition) setCondition}({@link #getCondition()}.{@link Condition#and(Condition) and}(narrowingCondition))
. -
join
Does an inner join with the given type without any join condition. -
join
Does an inner join with the given type on the given join condition. -
joinOuterLeft
-
joinOuterRight
-
getJoins
-
getGroupBy
-
setGroupBy
-
setHaving
-
getHaving
-
getOrderByFunctions
-
getOrderByAscending
-
setOrderByThis
public void setOrderByThis(boolean ascending) -
setOrderBy
-
setOrderByAndThis
-
setOrderBy
- Throws:
IllegalArgumentException
- iforderBy.length!=ascending.length
-
addOrderBy
-
addOrderByDescending
-
addOrderBy
-
resetOrderBy
public void resetOrderBy() -
getPageOffset
public int getPageOffset() -
getPageLimitOrMinusOne
public int getPageLimitOrMinusOne() -
setPage
public void setPage(int offset, int limit) - Parameters:
limit
- the maximum number of items to be found. For specifying offset but no limit usesetPageUnlimited(int)
instead.- Throws:
IllegalArgumentException
- if offset is a negative valueIllegalArgumentException
- if limit is a negative value- See Also:
-
setPageUnlimited
public void setPageUnlimited(int offset) - Throws:
IllegalArgumentException
- if offset is a negative value- See Also:
-
getSearchSizeLimit
public int getSearchSizeLimit()- See Also:
-
setSearchSizeLimit
public void setSearchSizeLimit(int searchSizeLimit) Sets the search size limit for this query.Method
search()
will fail with anIllegalStateException
as soon as the size of the result set exceeds the search size limit. Methodtotal()
is not affected by this limit.Setting the search size limit does not guarantee, that
search()
actually fails when exceeding the limit. But it is guaranteed, that it does not fail when not exceeding the limit. In particular, it may not fail, if the result is fetched from the query cache.If search size limit is not set, it defaults to
ConnectProperties.getQuerySearchSizeLimit()
.- See Also:
-
getSearchSizeCacheLimit
public int getSearchSizeCacheLimit()- See Also:
-
setSearchSizeCacheLimit
public void setSearchSizeCacheLimit(int searchSizeCacheLimit) Sets the search size cache limit for this query.Results of method
search()
will not be considered for inclusion into query cache as soon as the size of the result set exceeds the search size cache limit. Methodtotal()
is not affected by this limit.Setting the search size cache limit does not guarantee, that
search()
is not satisfied from the cache.If search size cache limit is not set, it defaults to
ConnectProperties.getQueryCacheSizeLimit()
.- See Also:
-
search
Searches for items matching this query.Returns an unmodifiable collection. Any attempts to modify the returned collection, whether direct or via its iterator, result in an
UnsupportedOperationException
. -
total
public int total()Counts the items matching this query.Returns the
size
of whatsearch()
would have returned for this query withsetPageUnlimited(int)
reset set to(0)
. -
searchAndTotal
Searches for items matching this query.Returns a
Query.Result
containing thedata
and thetotal
. Thedata
is equal to whatsearch()
would have returned for this query. Thetotal
is equal to whattotal()
would have returned for this query.This method does it's best to avoid issuing two queries for searching and totaling.
-
searchSingleton
Searches equivalently tosearch()
, but assumes that the search result has at most one element.Returns null, if the search result is
empty
, returns the only element of the search result, if the resultsize
is exactly one.- Throws:
IllegalArgumentException
- if the search result size is greater than one.- See Also:
-
searchSingletonStrict
Searches equivalently tosearch()
, but assumes that the search result has exactly one element.Returns the only element of the search result, if the result
size
is exactly one.- Throws:
IllegalArgumentException
- if the search result size is not exactly one.- See Also:
-
toString
-
setOrderBy
-
setOrderByAndThis
-
setOrderBy
-
addOrderBy
-
addOrderByDescending
-
addOrderBy
-
getOffset
Deprecated.UsegetPageOffset()
instead. -
getLimit
Deprecated.UsegetPageLimitOrMinusOne()
instead. -
setLimit
Deprecated.UsesetPage(int, int)
instead. -
setLimit
Deprecated.UsesetPageUnlimited(int)
instead. -
searchAndCountWithoutLimit
Deprecated.UsesearchAndTotal()
instead -
countWithoutLimit
Deprecated.Usetotal()
instead -
searchUnique
Deprecated.renamed tosearchSingleton()
. -
emptyResult
Deprecated.UseQuery.Result.empty()
instead
-
newQuery(Selectable[], Type, Condition)
instead