Class AbstractTopiaDao.InnerTopiaQueryBuilderRunQueryStep<E extends TopiaEntity>
java.lang.Object
org.nuiton.topia.persistence.internal.AbstractTopiaDao.InnerTopiaQueryBuilderRunQueryStep<E>
- All Implemented Interfaces:
TopiaQueryBuilderRunQueryStep<E>,TopiaQueryBuilderRunQueryWithUniqueResultStep<E>
- Enclosing class:
- AbstractTopiaDao<E extends TopiaEntity>
public static class AbstractTopiaDao.InnerTopiaQueryBuilderRunQueryStep<E extends TopiaEntity>
extends Object
implements TopiaQueryBuilderRunQueryStep<E>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final booleanprotected final Stringprotected final Stringprotected final Stringprotected final AbstractTopiaDao<E>protected final boolean -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInnerTopiaQueryBuilderRunQueryStep(AbstractTopiaDao<E> topiaDao, boolean fromHql, boolean withOrderByClause, String hql, Map<String, Object> hqlParameters) protectedInnerTopiaQueryBuilderRunQueryStep(AbstractTopiaDao<E> topiaDao, boolean fromHql, boolean withOrderByClause, String hql, Map<String, Object> hqlParameters, String hqlForFetchStep1, String hqlForFetchStep2) -
Method Summary
Modifier and TypeMethodDescriptionlongcount()This method is equivalent as callingCollection.size()after doing aTopiaQueryBuilderRunQueryStep.findAll()but it may be faster.booleanexists()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.Get the first element of a single-element result set.Get the first element of a single-element result set or null if query result is empty.protected <O extends TopiaEntity>
List<O>sortAccordingToIds(List<O> entities, List<String> idsList) This method can be used when it is not possible to sort entities in SQL/HQL.stream()LikeTopiaQueryBuilderRunQueryStep.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.com.google.common.base.Optional<E>Get the first element of a single-element result set.
-
Field Details
-
hql
-
hqlParameters
-
topiaDao
-
fromHql
protected final boolean fromHql -
withOrderByClause
protected final boolean withOrderByClause -
hqlForFetchStep1
-
hqlForFetchStep2
-
-
Constructor Details
-
InnerTopiaQueryBuilderRunQueryStep
-
InnerTopiaQueryBuilderRunQueryStep
-
-
Method Details
-
exists
public boolean exists()- Specified by:
existsin interfaceTopiaQueryBuilderRunQueryWithUniqueResultStep<E extends TopiaEntity>- Returns:
- true if the query returns at least one element
-
count
public long count()Description copied from interface:TopiaQueryBuilderRunQueryStepThis method is equivalent as callingCollection.size()after doing aTopiaQueryBuilderRunQueryStep.findAll()but it may be faster.- Specified by:
countin interfaceTopiaQueryBuilderRunQueryStep<E extends TopiaEntity>- Returns:
- the number of that the query would have returned, if executed
-
findUnique
Description copied from interface:TopiaQueryBuilderRunQueryWithUniqueResultStepGet the first element of a single-element result set.- Specified by:
findUniquein interfaceTopiaQueryBuilderRunQueryWithUniqueResultStep<E extends TopiaEntity>- Returns:
- the first value from the set of result. Returned value can't be null
- Throws:
TopiaNoResultException- if the query does not return any result.TopiaNonUniqueResultException- if the query returns more than one element.
-
findUniqueOrNull
Description copied from interface:TopiaQueryBuilderRunQueryWithUniqueResultStepGet the first element of a single-element result set or null if query result is empty. This method duplicatesTopiaQueryBuilderRunQueryWithUniqueResultStep.tryFindUnique()but allows you to prevent using Guava in you project.- Specified by:
findUniqueOrNullin interfaceTopiaQueryBuilderRunQueryWithUniqueResultStep<E extends TopiaEntity>- Returns:
- the first value from the set of result, or null of result set for given query is empty.
- Throws:
TopiaNonUniqueResultException- if the query returns more than one element.
-
tryFindUnique
Description copied from interface:TopiaQueryBuilderRunQueryWithUniqueResultStepGet the first element of a single-element result set. If the call must return a result, preferTopiaQueryBuilderRunQueryWithUniqueResultStep.findUnique()- Specified by:
tryFindUniquein interfaceTopiaQueryBuilderRunQueryWithUniqueResultStep<E extends TopiaEntity>- Returns:
- the first value from the set of result. It's an optional because the query may return no result.
- Throws:
TopiaNonUniqueResultException- if the query returns more than one element.
-
findFirst
Description copied from interface:TopiaQueryBuilderRunQueryStepGet the first element of the non-empty result set.- Specified by:
findFirstin interfaceTopiaQueryBuilderRunQueryStep<E extends TopiaEntity>- 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
Description copied from interface:TopiaQueryBuilderRunQueryStepGet the first element of the result set or null if query result is empty. This method duplicatesTopiaQueryBuilderRunQueryStep.tryFindFirst()but allows you to prevent using Guava in you project.- Specified by:
findFirstOrNullin interfaceTopiaQueryBuilderRunQueryStep<E extends TopiaEntity>- 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
Description copied from interface:TopiaQueryBuilderRunQueryStepGet the first element of the result set. If the call must return a result, preferTopiaQueryBuilderRunQueryStep.findFirst()- Specified by:
tryFindFirstin interfaceTopiaQueryBuilderRunQueryStep<E extends TopiaEntity>- 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
Description copied from interface:TopiaQueryBuilderRunQueryStepGet the an element of the non-empty result set. This method does not guarantee any order as no ordering clause is mandatory- Specified by:
findAnyin interfaceTopiaQueryBuilderRunQueryStep<E extends TopiaEntity>- 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
Description copied from interface:TopiaQueryBuilderRunQueryStepGet 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 duplicatesTopiaQueryBuilderRunQueryStep.tryFindAny()but allows you to prevent using Guava in you project.- Specified by:
findAnyOrNullin interfaceTopiaQueryBuilderRunQueryStep<E extends TopiaEntity>- Returns:
- the first value from the set of result, without any order guarantee. Returned value can be null
-
tryFindAny
Description copied from interface:TopiaQueryBuilderRunQueryStepGet 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, preferTopiaQueryBuilderRunQueryStep.findAny()- Specified by:
tryFindAnyin interfaceTopiaQueryBuilderRunQueryStep<E extends TopiaEntity>- 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
Description copied from interface:TopiaQueryBuilderRunQueryStepGet all the elements of the result set.- Specified by:
findAllin interfaceTopiaQueryBuilderRunQueryStep<E extends TopiaEntity>- Returns:
- the full list of results.
-
stream
Description copied from interface:TopiaQueryBuilderRunQueryStepLikeTopiaQueryBuilderRunQueryStep.findAll()but getting a stream that may lazily fetch data. Actual behavior rely on implementation. Caller shouldBaseStream.close()the stream.- Specified by:
streamin interfaceTopiaQueryBuilderRunQueryStep<E extends TopiaEntity>
-
findAllLazy
Description copied from interface:TopiaQueryBuilderRunQueryStepGet 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, useTopiaQueryBuilderRunQueryStep.findAllLazy(int)- Specified by:
findAllLazyin interfaceTopiaQueryBuilderRunQueryStep<E extends TopiaEntity>- Returns:
- the full list of results which will be loaded gradually.
-
findAllLazy
Description copied from interface:TopiaQueryBuilderRunQueryStepGet 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, useTopiaQueryBuilderRunQueryStep.findAllLazy()- Specified by:
findAllLazyin interfaceTopiaQueryBuilderRunQueryStep<E extends TopiaEntity>- Parameters:
batchSize- the number of elements to load per request- Returns:
- the full list of results which will be loaded gradually.
-
find
Description copied from interface:TopiaQueryBuilderRunQueryStepGet the elements with the given bounds.- Specified by:
findin interfaceTopiaQueryBuilderRunQueryStep<E extends TopiaEntity>- 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
Description copied from interface:TopiaQueryBuilderRunQueryStepGet the elements according to the givenPaginationParameter. UseTopiaQueryBuilderRunQueryStep.findPage(PaginationParameter)to get aPaginationResultinstead of a list.- Specified by:
findin interfaceTopiaQueryBuilderRunQueryStep<E extends TopiaEntity>- Parameters:
page- information about the page to load.- Returns:
- the list of loaded results.
- See Also:
-
PaginationParameter
-
findPage
public org.nuiton.util.pagination.PaginationResult<E> findPage(org.nuiton.util.pagination.PaginationParameter page) Description copied from interface:TopiaQueryBuilderRunQueryStepGet the elements according to the givenPaginationParameter. UseTopiaQueryBuilderRunQueryStep.find(PaginationParameter)to get a list instead ofPaginationResult. Note: compared toTopiaQueryBuilderRunQueryStep.find(PaginationParameter), this method performs an additional statement to get the total elements count.- Specified by:
findPagein interfaceTopiaQueryBuilderRunQueryStep<E extends TopiaEntity>- Parameters:
page- information about the page to load.- Returns:
- the list of loaded results.
- See Also:
-
PaginationParameterPaginationResult
-
sortAccordingToIds
protected <O extends TopiaEntity> List<O> sortAccordingToIds(List<O> entities, List<String> idsList) This method can be used when it is not possible to sort entities in SQL/HQL. The list of entities will be sorted according to the given list of topiaId.- Type Parameters:
O- must be a TopiaEntity- Parameters:
entities- the list en entities (unsorted)idsList- the list of ids (sorted)- Returns:
- FIXME
-
findAllIds
Description copied from interface:TopiaQueryBuilderRunQueryStepGet all the elements identifiers of the result set. Note: compared toTopiaQueryBuilderRunQueryStep.findAll(), this method will not load entities, only its identifier.- Specified by:
findAllIdsin interfaceTopiaQueryBuilderRunQueryStep<E extends TopiaEntity>- Returns:
- the full list of results ids.
-
findIds
Description copied from interface:TopiaQueryBuilderRunQueryStepGet the elements identifiers with the given bounds. Note: compared toTopiaQueryBuilderRunQueryStep.find(int, int), this method will not load entities, only its identifier.- Specified by:
findIdsin interfaceTopiaQueryBuilderRunQueryStep<E extends TopiaEntity>- 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
Description copied from interface:TopiaQueryBuilderRunQueryStepGet the elements identifiers according to the givenPaginationParameter. UseTopiaQueryBuilderRunQueryStep.findIdsPage(PaginationParameter)to get aPaginationResultinstead of a list. Note: compared toTopiaQueryBuilderRunQueryStep.find(PaginationParameter), this method will not load entities, only its identifier.- Specified by:
findIdsin interfaceTopiaQueryBuilderRunQueryStep<E extends TopiaEntity>- Parameters:
page- information about the page to load.- Returns:
- the list of loaded results ids.
- See Also:
-
PaginationParameter
-
findIdsPage
public org.nuiton.util.pagination.PaginationResult<String> findIdsPage(org.nuiton.util.pagination.PaginationParameter page) Description copied from interface:TopiaQueryBuilderRunQueryStepGet the elements identifiers according to the givenPaginationParameter. UseTopiaQueryBuilderRunQueryStep.findIds(PaginationParameter)to get a list instead ofPaginationResult. Note: compared toTopiaQueryBuilderRunQueryStep.findIds(PaginationParameter), this method performs an additional statement to get the total elements identifiers count. Note: compared toTopiaQueryBuilderRunQueryStep.findPage(PaginationParameter), this method will not load entities, only its identifier- Specified by:
findIdsPagein interfaceTopiaQueryBuilderRunQueryStep<E extends TopiaEntity>- Parameters:
page- information about the page to load.- Returns:
- the list of loaded results.
- See Also:
-
PaginationParameterPaginationResult
-