Interface TopiaQueryBuilderRunQueryStep<E extends TopiaEntity>

All Superinterfaces:
TopiaQueryBuilderRunQueryWithUniqueResultStep<E>
All Known Subinterfaces:
TopiaQueryBuilderAddCriteriaOrRunQueryStep<E>
All Known Implementing Classes:
AbstractTopiaDao.InnerTopiaQueryBuilderAddCriteriaOrRunQueryStep, AbstractTopiaDao.InnerTopiaQueryBuilderRunQueryStep

public interface TopiaQueryBuilderRunQueryStep<E extends TopiaEntity> extends TopiaQueryBuilderRunQueryWithUniqueResultStep<E>
This interface represents different common operations that a user may do after a query is defined (using the TopiaQueryBuilderAddCriteriaStep) There are different methods according to the supposed existence or uniqueness of the result. Also some methods may be used only if order is defined in query. Some methods return an Optional, but since it's not yet available in JDK, we use Guava's. If you don't want your project to require Guava dependency, we provide equivalent method named XXXOrNull() for the same purpose.
Since:
3.0
Author:
bleny, Arnaud Thimel (Code Lutin)
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    This method is equivalent as calling Collection.size() after doing a findAll() but it may be faster.
    find(int startIndex, int endIndex)
    Get the elements with the given bounds.
    find(org.nuiton.util.pagination.PaginationParameter page)
    Get the elements according to the given PaginationParameter.
    Get all the elements of the result set.
    Get all the elements identifiers of the result set.
    Get all the elements in a lazy loading list.
    findAllLazy(int batchSize)
    Get all the elements in a lazy loading list.
    Get the an element of the non-empty result set.
    Get the an element of the result set or null if query result is empty.
    Get the first element of the non-empty result set.
    Get the first element of the result set or null if query result is empty.
    findIds(int startIndex, int endIndex)
    Get the elements identifiers with the given bounds.
    findIds(org.nuiton.util.pagination.PaginationParameter page)
    Get the elements identifiers according to the given PaginationParameter.
    org.nuiton.util.pagination.PaginationResult<String>
    findIdsPage(org.nuiton.util.pagination.PaginationParameter page)
    Get the elements identifiers according to the given PaginationParameter.
    org.nuiton.util.pagination.PaginationResult<E>
    findPage(org.nuiton.util.pagination.PaginationParameter page)
    Get the elements according to the given PaginationParameter.
    Like findAll() but getting a stream that may lazily fetch data.
    com.google.common.base.Optional<E>
    Get the an element of the result set.
    com.google.common.base.Optional<E>
    Get the first element of the result set.

    Methods inherited from interface org.nuiton.topia.persistence.TopiaQueryBuilderRunQueryWithUniqueResultStep

    exists, findUnique, findUniqueOrNull, tryFindUnique
  • Method Details

    • count

      long count()
      This method is equivalent as calling Collection.size() after doing a findAll() but it may be faster.
      Returns:
      the number of that the query would have returned, if executed
    • findFirst

      Get the first element of the non-empty result set.
      Returns:
      the first value from the set of result, according to given order. Returned value can't be null
      Throws:
      QueryMissingOrderException - if you the query misses an order clause
      TopiaNoResultException - if the query does not return any result
    • findFirstOrNull

      E findFirstOrNull() throws QueryMissingOrderException
      Get the first element of the result set or null if query result is empty. This method duplicates tryFindFirst() but allows you to prevent using Guava in you project.
      Returns:
      the first value from the set of result, according to given order, or null of result set for given query is empty
      Throws:
      QueryMissingOrderException - if you the query misses an order clause
    • tryFindFirst

      com.google.common.base.Optional<E> tryFindFirst() throws QueryMissingOrderException
      Get the first element of the result set. If the call must return a result, prefer findFirst()
      Returns:
      the first value from the set of result, according to given order. It's an optional because the query may return no result.
      Throws:
      QueryMissingOrderException - if you the query misses an order clause
    • findAny

      E findAny() throws TopiaNoResultException
      Get the an element of the non-empty result set. This method does not guarantee any order as no ordering clause is mandatory
      Returns:
      the first value from the set of result, without any order guarantee. Returned value can't be null
      Throws:
      TopiaNoResultException - if the query does not return any result
    • findAnyOrNull

      E findAnyOrNull()
      Get the an element of the result set or null if query result is empty. This method does not guarantee any order as no ordering clause is mandatory. This method duplicates tryFindAny() but allows you to prevent using Guava in you project.
      Returns:
      the first value from the set of result, without any order guarantee. Returned value can be null
    • tryFindAny

      com.google.common.base.Optional<E> tryFindAny()
      Get the an element of the result set. This method does not guarantee any order as no ordering clause is mandatory. If the call must return a result, prefer findAny()
      Returns:
      the first value from the set of result, without any order guarantee. It's an optional because the query may return no result.
    • findAll

      List<E> findAll()
      Get all the elements of the result set.
      Returns:
      the full list of results.
    • stream

      Stream<E> stream()
      Like findAll() but getting a stream that may lazily fetch data. Actual behavior rely on implementation. Caller should BaseStream.close() the stream.
      Since:
      3.4
    • findAllLazy

      Iterable<E> findAllLazy()
      Get all the elements in a lazy loading list. The entities will be loaded gradually when the returned Iterable is iterated. If you wish to specify a batch size, use findAllLazy(int)
      Returns:
      the full list of results which will be loaded gradually.
    • findAllLazy

      Iterable<E> findAllLazy(int batchSize)
      Get all the elements in a lazy loading list. The entities will be loaded gradually when the returned Iterable is iterated. If you do not need to specify a batch size, use findAllLazy()
      Parameters:
      batchSize - the number of elements to load per request
      Returns:
      the full list of results which will be loaded gradually.
    • find

      List<E> find(int startIndex, int endIndex)
      Get the elements with the given bounds.
      Parameters:
      startIndex - inclusive index of the first element to return. This value is 0-based
      endIndex - inclusive index of the last element to return. A value lower than 0 means infinite upper bound.
      Returns:
      the list of loaded results.
    • find

      List<E> find(org.nuiton.util.pagination.PaginationParameter page)
      Get the elements according to the given PaginationParameter. Use findPage(PaginationParameter) to get a PaginationResult instead of a list.
      Parameters:
      page - information about the page to load.
      Returns:
      the list of loaded results.
      See Also:
      • PaginationParameter
    • findPage

      org.nuiton.util.pagination.PaginationResult<E> findPage(org.nuiton.util.pagination.PaginationParameter page)
      Get the elements according to the given PaginationParameter. Use find(PaginationParameter) to get a list instead of PaginationResult. Note: compared to find(PaginationParameter), this method performs an additional statement to get the total elements count.
      Parameters:
      page - information about the page to load.
      Returns:
      the list of loaded results.
      See Also:
      • PaginationParameter
      • PaginationResult
    • findAllIds

      List<String> findAllIds()
      Get all the elements identifiers of the result set. Note: compared to findAll(), this method will not load entities, only its identifier.
      Returns:
      the full list of results ids.
    • findIds

      List<String> findIds(int startIndex, int endIndex)
      Get the elements identifiers with the given bounds. Note: compared to find(int, int), this method will not load entities, only its identifier.
      Parameters:
      startIndex - inclusive index of the first element to return. This value is 0-based
      endIndex - inclusive index of the last element to return. A value lower than 0 means infinite upper bound.
      Returns:
      the list of loaded results ids.
    • findIds

      List<String> findIds(org.nuiton.util.pagination.PaginationParameter page)
      Get the elements identifiers according to the given PaginationParameter. Use findIdsPage(PaginationParameter) to get a PaginationResult instead of a list. Note: compared to find(PaginationParameter), this method will not load entities, only its identifier.
      Parameters:
      page - information about the page to load.
      Returns:
      the list of loaded results ids.
      See Also:
      • PaginationParameter
    • findIdsPage

      org.nuiton.util.pagination.PaginationResult<String> findIdsPage(org.nuiton.util.pagination.PaginationParameter page)
      Get the elements identifiers according to the given PaginationParameter. Use findIds(PaginationParameter) to get a list instead of PaginationResult. Note: compared to findIds(PaginationParameter), this method performs an additional statement to get the total elements identifiers count. Note: compared to findPage(PaginationParameter), this method will not load entities, only its identifier
      Parameters:
      page - information about the page to load.
      Returns:
      the list of loaded results.
      See Also:
      • PaginationParameter
      • PaginationResult