Package org.nuiton.topia.persistence
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 TypeMethodDescriptionlongcount()This method is equivalent as callingCollection.size()after doing afindAll()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 givenPaginationParameter.findAll()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.findAny()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 givenPaginationParameter.org.nuiton.util.pagination.PaginationResult<String>findIdsPage(org.nuiton.util.pagination.PaginationParameter page) Get the elements identifiers according to the givenPaginationParameter.org.nuiton.util.pagination.PaginationResult<E>findPage(org.nuiton.util.pagination.PaginationParameter page) Get the elements according to the givenPaginationParameter.stream()LikefindAll()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 callingCollection.size()after doing afindAll()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 clauseTopiaNoResultException- if the query does not return any result
-
findFirstOrNull
Get the first element of the result set or null if query result is empty. This method duplicatestryFindFirst()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
Get the first element of the result set. If the call must return a result, preferfindFirst()- 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
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 duplicatestryFindAny()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, preferfindAny()- 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
Get all the elements of the result set.- Returns:
- the full list of results.
-
stream
LikefindAll()but getting a stream that may lazily fetch data. Actual behavior rely on implementation. Caller shouldBaseStream.close()the stream.- Since:
- 3.4
-
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, usefindAllLazy(int)- Returns:
- the full list of results which will be loaded gradually.
-
findAllLazy
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, usefindAllLazy()- Parameters:
batchSize- the number of elements to load per request- Returns:
- the full list of results which will be loaded gradually.
-
find
Get the elements with the given bounds.- Parameters:
startIndex- inclusive index of the first element to return. This value is 0-basedendIndex- inclusive index of the last element to return. A value lower than 0 means infinite upper bound.- Returns:
- the list of loaded results.
-
find
Get the elements according to the givenPaginationParameter. UsefindPage(PaginationParameter)to get aPaginationResultinstead 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 givenPaginationParameter. Usefind(PaginationParameter)to get a list instead ofPaginationResult. Note: compared tofind(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:
-
PaginationParameterPaginationResult
-
findAllIds
Get all the elements identifiers of the result set. Note: compared tofindAll(), this method will not load entities, only its identifier.- Returns:
- the full list of results ids.
-
findIds
Get the elements identifiers with the given bounds. Note: compared tofind(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-basedendIndex- 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
Get the elements identifiers according to the givenPaginationParameter. UsefindIdsPage(PaginationParameter)to get aPaginationResultinstead of a list. Note: compared tofind(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 givenPaginationParameter. UsefindIds(PaginationParameter)to get a list instead ofPaginationResult. Note: compared tofindIds(PaginationParameter), this method performs an additional statement to get the total elements identifiers count. Note: compared tofindPage(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:
-
PaginationParameterPaginationResult
-