Package com.querydsl.core
Interface Fetchable<T>
- Type Parameters:
T- result type
- All Known Subinterfaces:
FetchableQuery<T,Q>
- All Known Implementing Classes:
FetchableQueryBase,FetchableSubQueryBase
public interface Fetchable<T>
Fetchable defines default projection methods for Query implementations.
All Querydsl query implementations should implement this interface.- Author:
- tiwe
-
Method Summary
Modifier and TypeMethodDescriptionfetch()Get the projection as a typed ListlongGet the count of matched elements Note: not all QueryDSL modules might optimize fetchCount using a count query.Get the first result of Get the projection or null if no result is foundfetchOne()Get the projection as a unique result or null if no result is foundGet the projection inQueryResultsform.com.mysema.commons.lang.CloseableIterator<T>iterate()Get the projection as a typed closeable Iteratorstream()Get the projection as a typed closeable Stream.
-
Method Details
-
fetch
Get the projection as a typed List- Returns:
- results in list form
-
fetchFirst
Get the first result of Get the projection or null if no result is found- Returns:
- first result or null
-
fetchOne
Get the projection as a unique result or null if no result is found- Returns:
- first result or null
- Throws:
NonUniqueResultException- if there is more than one matching result
-
iterate
com.mysema.commons.lang.CloseableIterator<T> iterate()Get the projection as a typed closeable Iterator- Returns:
- closeable iterator
-
stream
Get the projection as a typed closeable Stream.- Returns:
- closeable stream
-
fetchResults
QueryResults<T> fetchResults()Get the projection inQueryResultsform. Make sure to usefetch()instead if you do not rely on theQueryResults.getOffset()orQueryResults.getLimit(), because it will be more performant. Also, count queries cannot be properly generated for all dialects. For example: in JPA count queries can't be generated for queries that have multiple group by expressions or a having clause. Get the projection inQueryResultsform. Usefetch()instead if you do not need the total count of rows in the query result.- Returns:
- results
- See Also:
-
fetchCount
long fetchCount()Get the count of matched elements Note: not all QueryDSL modules might optimize fetchCount using a count query. An implementation is allowed to fall back tofetch().size().- Returns:
- row count
-