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 Type
    Method
    Description
    Get the projection as a typed List
    long
    Get 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 found
    Get the projection as a unique result or null if no result is found
    Get the projection in QueryResults form.
    com.mysema.commons.lang.CloseableIterator<T>
    Get the projection as a typed closeable Iterator
    default Stream<T>
    Get the projection as a typed closeable Stream.
  • Method Details

    • fetch

      List<T> fetch()
      Get the projection as a typed List
      Returns:
      results in list form
    • fetchFirst

      @Nullable T fetchFirst()
      Get the first result of Get the projection or null if no result is found
      Returns:
      first result or null
    • fetchOne

      @Nullable T fetchOne() throws NonUniqueResultException
      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

      default Stream<T> stream()
      Get the projection as a typed closeable Stream.
      Returns:
      closeable stream
    • fetchResults

      QueryResults<T> fetchResults()
      Get the projection in QueryResults form. Make sure to use fetch() instead if you do not rely on the QueryResults.getOffset() or QueryResults.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 in QueryResults form. Use fetch() 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 to fetch().size().
      Returns:
      row count