T - The query result typeX - The concrete builder typeBaseQueryBuilder<T,X>, BaseWhereBuilder<T>, CommonQueryBuilder<T>, ConfigurationSource, CorrelationQueryBuilder<T>, FetchBuilder<X>, FromBaseBuilder<T>, FromBuilder<T>, FromProvider, KeysetQueryBuilder<T>, OrderByBuilder<T>, ParameterHolder<T>, Queryable<T,X>, QueryBuilder<T,X>, SelectBuilder<T>, ServiceProvider, WhereBuilder<T>, WindowContainerBuilder<T>CriteriaBuilder<T>, PaginatedCriteriaBuilder<T>public interface FullQueryBuilder<T,X extends FullQueryBuilder<T,X>> extends QueryBuilder<T,X>, FetchBuilder<X>
| Modifier and Type | Method | Description |
|---|---|---|
<Y> FullQueryBuilder<Y,?> |
copy(Class<Y> resultClass) |
Copies this query builder into a new one, using it's projection as an overridable default.
|
CriteriaBuilder<Object[]> |
createPageIdQuery(int firstResult,
int maxResults,
String identifierExpression) |
Like calling
pageBy(int, int, String) and then PaginatedCriteriaBuilder.createPageIdQuery() but more efficient. |
CriteriaBuilder<Object[]> |
createPageIdQuery(int firstResult,
int maxResults,
String identifierExpression,
String... identifierExpressions) |
Like calling
pageBy(int, int, String, String...) and then PaginatedCriteriaBuilder.createPageIdQuery() but more efficient. |
CriteriaBuilder<Object[]> |
createPageIdQuery(KeysetPage keysetPage,
int firstResult,
int maxResults,
String identifierExpression) |
Like calling
pageBy(KeysetPage, int, int, String) and then PaginatedCriteriaBuilder.createPageIdQuery() but more efficient. |
CriteriaBuilder<Object[]> |
createPageIdQuery(KeysetPage keysetPage,
int firstResult,
int maxResults,
String identifierExpression,
String... identifierExpressions) |
Like calling
pageBy(KeysetPage, int, int, String, String...) and then PaginatedCriteriaBuilder.createPageIdQuery() but more efficient. |
javax.persistence.TypedQuery<Long> |
getCountQuery() |
Returns a query that counts the results that would be produced if the current query was run.
|
String |
getCountQueryString() |
Returns the query string that selects the count of elements.
|
X |
innerJoinFetch(String path,
String alias) |
Like
join(java.lang.String, java.lang.String, com.blazebit.persistence.JoinType, boolean) but with
JoinType.INNER and fetch set to true. |
X |
innerJoinFetchDefault(String path,
String alias) |
Like
joinDefault(java.lang.String, java.lang.String, com.blazebit.persistence.JoinType, boolean) but with
JoinType.INNER and fetch set to true. |
X |
join(String path,
String alias,
JoinType type,
boolean fetch) |
Adds a join to the query, possibly specializing implicit joins, and giving the joined element an alias.
|
X |
joinDefault(String path,
String alias,
JoinType type,
boolean fetch) |
Adds a join to the query, possibly specializing implicit joins, and giving the joined element an alias.
|
X |
leftJoinFetch(String path,
String alias) |
Like
join(java.lang.String, java.lang.String, com.blazebit.persistence.JoinType, boolean) but with
JoinType.LEFT and fetch set to true. |
X |
leftJoinFetchDefault(String path,
String alias) |
Like
joinDefault(java.lang.String, java.lang.String, com.blazebit.persistence.JoinType, boolean) but with
JoinType.LEFT and fetch set to true. |
PaginatedCriteriaBuilder<T> |
page(int firstResult,
int maxResults) |
Invokes
pageBy(int, int, String, String...) with the identifiers of the query root entity. |
PaginatedCriteriaBuilder<T> |
page(KeysetPage keysetPage,
int firstResult,
int maxResults) |
Invokes
pageBy(KeysetPage, int, int, String, String...) with the identifiers of the query root entity. |
PaginatedCriteriaBuilder<T> |
page(Object entityId,
int maxResults) |
Deprecated.
This method causes a method resolution ambiguity. Use {
pageAndNavigate(Object, int)} instead. |
PaginatedCriteriaBuilder<T> |
pageAndNavigate(Object entityId,
int maxResults) |
Invokes
pageByAndNavigate(Object, int, String, String...) with the identifiers of the query root entity. |
PaginatedCriteriaBuilder<T> |
pageBy(int firstResult,
int maxResults,
String identifierExpression) |
Like
pageBy(int, int, String, String...) but lacks the varargs parameter to avoid heap pollution. |
PaginatedCriteriaBuilder<T> |
pageBy(int firstResult,
int maxResults,
String identifierExpression,
String... identifierExpressions) |
Paginates the results of this query based on the given identifier expressions.
|
PaginatedCriteriaBuilder<T> |
pageBy(KeysetPage keysetPage,
int firstResult,
int maxResults,
String identifierExpression) |
Like
pageBy(KeysetPage, int, int, String, String...) but lacks the varargs parameter to avoid heap pollution. |
PaginatedCriteriaBuilder<T> |
pageBy(KeysetPage keysetPage,
int firstResult,
int maxResults,
String identifierExpression,
String... identifierExpressions) |
Like
page(int, int) but additionally uses key set pagination when possible. |
PaginatedCriteriaBuilder<T> |
pageByAndNavigate(Object entityId,
int maxResults,
String identifierExpression) |
Like
pageByAndNavigate(Object, int, String, String...) but lacks the varargs parameter to avoid heap pollution. |
PaginatedCriteriaBuilder<T> |
pageByAndNavigate(Object entityId,
int maxResults,
String identifierExpression,
String... identifierExpressions) |
Paginates the results of this query and navigates to the page on which
the object with the given identifier is located.
|
X |
rightJoinFetch(String path,
String alias) |
Like
join(java.lang.String, java.lang.String, com.blazebit.persistence.JoinType, boolean) but with
JoinType.RIGHT and fetch set to true. |
X |
rightJoinFetchDefault(String path,
String alias) |
Like
joinDefault(java.lang.String, java.lang.String, com.blazebit.persistence.JoinType, boolean) but with
JoinType.RIGHT and fetch set to true. |
<Y> FullQueryBuilder<Y,?> |
selectNew(ObjectBuilder<Y> builder) |
Applies the given object builder to this query.
|
<Y> SelectObjectBuilder<? extends FullQueryBuilder<Y,?>> |
selectNew(Class<Y> clazz) |
Starts a
SelectObjectBuilder for the given class. |
<Y> SelectObjectBuilder<? extends FullQueryBuilder<Y,?>> |
selectNew(Constructor<Y> constructor) |
Starts a
SelectObjectBuilder for the given constructor. |
getResultTypewhere, whereCase, whereExists, whereExists, whereExpression, whereExpressionSubqueries, whereNotExists, whereNotExists, whereSimpleCase, whereSubqueries, whereSubquery, whereSubquery, whereSubquery, whereSubquerygetCriteriaBuilderFactory, getMetamodel, isCacheable, registerMacro, setCacheable, setProperties, setPropertygetProperties, getPropertyfetch, fetchfromEntitySubquery, fromEntitySubquery, fromEntitySubquery, fromSubquery, fromSubqueryfrom, from, from, from, fromIdentifiableValues, fromIdentifiableValues, fromIdentifiableValues, fromIdentifiableValues, fromNew, fromNew, fromOld, fromOld, fromValues, fromValues, fromValues, fromValues, getFrom, getFromByPath, getPath, getRoots, innerJoin, innerJoinDefault, innerJoinDefaultOn, innerJoinLateralEntitySubquery, innerJoinLateralEntitySubquery, innerJoinLateralEntitySubquery, innerJoinLateralOnEntitySubquery, innerJoinLateralOnEntitySubquery, innerJoinLateralOnEntitySubquery, innerJoinLateralOnSubquery, innerJoinLateralOnSubquery, innerJoinLateralOnSubquery, innerJoinLateralSubquery, innerJoinLateralSubquery, innerJoinLateralSubquery, innerJoinOn, innerJoinOn, innerJoinOn, innerJoinOn, innerJoinOn, innerJoinOnEntitySubquery, innerJoinOnEntitySubquery, innerJoinOnEntitySubquery, innerJoinOnEntitySubquery, innerJoinOnSubquery, innerJoinOnSubquery, join, joinDefault, joinDefaultOn, joinLateralEntitySubquery, joinLateralEntitySubquery, joinLateralEntitySubquery, joinLateralOnEntitySubquery, joinLateralOnEntitySubquery, joinLateralOnEntitySubquery, joinLateralOnSubquery, joinLateralOnSubquery, joinLateralOnSubquery, joinLateralSubquery, joinLateralSubquery, joinLateralSubquery, joinOn, joinOn, joinOn, joinOn, joinOn, joinOnEntitySubquery, joinOnEntitySubquery, joinOnEntitySubquery, joinOnEntitySubquery, joinOnSubquery, joinOnSubquery, leftJoin, leftJoinDefault, leftJoinDefaultOn, leftJoinLateralEntitySubquery, leftJoinLateralEntitySubquery, leftJoinLateralEntitySubquery, leftJoinLateralOnEntitySubquery, leftJoinLateralOnEntitySubquery, leftJoinLateralOnEntitySubquery, leftJoinLateralOnSubquery, leftJoinLateralOnSubquery, leftJoinLateralOnSubquery, leftJoinLateralSubquery, leftJoinLateralSubquery, leftJoinLateralSubquery, leftJoinOn, leftJoinOn, leftJoinOn, leftJoinOn, leftJoinOn, leftJoinOnEntitySubquery, leftJoinOnEntitySubquery, leftJoinOnEntitySubquery, leftJoinOnEntitySubquery, leftJoinOnSubquery, leftJoinOnSubquery, rightJoin, rightJoinDefault, rightJoinDefaultOn, rightJoinOn, rightJoinOn, rightJoinOn, rightJoinOn, rightJoinOn, rightJoinOnEntitySubquery, rightJoinOnEntitySubquery, rightJoinOnEntitySubquery, rightJoinOnEntitySubquery, rightJoinOnSubquery, rightJoinOnSubqueryafterKeyset, afterKeyset, afterKeyset, beforeKeyset, beforeKeyset, beforeKeysetorderBy, orderBy, orderByAsc, orderByAsc, orderByDesc, orderByDesccontainsParameter, getParameter, getParameters, getParameterValue, isParameterSet, setParameter, setParameter, setParameter, setParameterTypegetQuery, getQueryString, getResultList, getSingleResultgetEntityManagerselect, select, selectCase, selectCase, selectSimpleCase, selectSimpleCase, selectSubqueries, selectSubqueries, selectSubquery, selectSubquery, selectSubquery, selectSubquery, selectSubquery, selectSubquery, selectSubquery, selectSubquerygetServicesetWhereExpression, setWhereExpressionSubqueries, whereOrwindow<Y> FullQueryBuilder<Y,?> copy(Class<Y> resultClass)
Y - The type of the result classresultClass - The result class of the queryjavax.persistence.TypedQuery<Long> getCountQuery()
String getCountQueryString()
PaginatedCriteriaBuilder<T> page(int firstResult, int maxResults)
pageBy(int, int, String, String...) with the identifiers of the query root entity.firstResult - The position of the first result to retrieve, numbered from 0maxResults - The maximum number of results to retrieve@Deprecated PaginatedCriteriaBuilder<T> page(Object entityId, int maxResults)
pageAndNavigate(Object, int)} instead.pageByAndNavigate(Object, int, String, String...) with the identifiers of the query root entity.entityId - The id of the entity which should be located on the pagemaxResults - The maximum number of results to retrievePaginatedCriteriaBuilder<T> pageAndNavigate(Object entityId, int maxResults)
pageByAndNavigate(Object, int, String, String...) with the identifiers of the query root entity.entityId - The id of the entity which should be located on the pagemaxResults - The maximum number of results to retrievePaginatedCriteriaBuilder<T> page(KeysetPage keysetPage, int firstResult, int maxResults)
pageBy(KeysetPage, int, int, String, String...) with the identifiers of the query root entity.keysetPage - The key set from a previous result, may be nullfirstResult - The position of the first result to retrieve, numbered from 0maxResults - The maximum number of results to retrievePagedList.getKeysetPage()PaginatedCriteriaBuilder<T> pageBy(int firstResult, int maxResults, String identifierExpression)
pageBy(int, int, String, String...) but lacks the varargs parameter to avoid heap pollution.firstResult - The position of the first result to retrieve, numbered from 0maxResults - The maximum number of results to retrieveidentifierExpression - The first identifier expressionPaginatedCriteriaBuilder<T> pageByAndNavigate(Object entityId, int maxResults, String identifierExpression)
pageByAndNavigate(Object, int, String, String...) but lacks the varargs parameter to avoid heap pollution.entityId - The id of the entity which should be located on the pagemaxResults - The maximum number of results to retrieveidentifierExpression - The first identifier expressionPaginatedCriteriaBuilder<T> pageBy(KeysetPage keysetPage, int firstResult, int maxResults, String identifierExpression)
pageBy(KeysetPage, int, int, String, String...) but lacks the varargs parameter to avoid heap pollution.keysetPage - The key set from a previous result, may be nullfirstResult - The position of the first result to retrieve, numbered from 0maxResults - The maximum number of results to retrieveidentifierExpression - The first identifier expressionPagedList.getKeysetPage()PaginatedCriteriaBuilder<T> pageBy(int firstResult, int maxResults, String identifierExpression, String... identifierExpressions)
setFirstResult and setMaxResults is not defined when involving fetch joins for collections.
When no collection joins are involved, this is fine as rows essentially represent objects, but when collections are joined, this is no longer true.
JPA providers usually fall back to querying all data and doing pagination in-memory based on objects or simply don't support that kind of query.
This API allows to specify the identifier expressions to use for pagination and transparently handles collection join support.
The big advantage of this API over plain setFirstResult and setMaxResults can also be seen when doing scalar queries.
An example for such queries would be a query that joins a collection:
SELECT d.id, contacts.name FROM Document d LEFT JOIN d.contacts contacts
If one Document has associated multiple contacts, the above query will produce multiple result set rows for that document.
Paginating via setFirstResult and setMaxResults would produce unexpected results whereas using this API, will produce the expected results.
When paginating on the identifier i.e. d.id, the results are implicitly grouped by the document id and distinct. Therefore calling
distinct() on a PaginatedCriteriaBuilder is not allowed.
firstResult - The position of the first result to retrieve, numbered from 0maxResults - The maximum number of results to retrieveidentifierExpression - The first identifier expressionidentifierExpressions - The other identifier expressionsPaginatedCriteriaBuilder<T> pageByAndNavigate(Object entityId, int maxResults, String identifierExpression, String... identifierExpressions)
page(int, int) apply.
If the object with the given identifier does not exist in the result list:
PaginatedCriteriaBuilder.getResultList() will contain the first pagePagedList.getFirstResult() will return -1entityId - The id of the object which should be located on the pagemaxResults - The maximum number of results to retrieveidentifierExpression - The first identifier expressionidentifierExpressions - The other identifier expressionsPaginatedCriteriaBuilder<T> pageBy(KeysetPage keysetPage, int firstResult, int maxResults, String identifierExpression, String... identifierExpressions)
page(int, int) but additionally uses key set pagination when possible.
Beware that keyset pagination should not be used as a direct replacement for offset pagination.
Since entries that have a lower rank than some keyset might be added or removed, the calculations
for the firstResult might be wrong. If strict pagination is required, then the KeysetPage should
not be used when the count of lower ranked items changes which will result in the use of offset pagination for that request.
Key set pagination is possible if and only if the following conditions are met:
KeysetPage.getMaxResults() and maxResults evaluate to the same value ANDKeysetPage.getFirstResult() - firstResult is 0KeysetPage.getFirstResult() - firstResult is equal to the value of
maxResultskeysetPage - The key set from a previous result, may be nullfirstResult - The position of the first result to retrieve, numbered from 0maxResults - The maximum number of results to retrieveidentifierExpression - The first identifier expressionidentifierExpressions - The other identifier expressionsPagedList.getKeysetPage()CriteriaBuilder<Object[]> createPageIdQuery(int firstResult, int maxResults, String identifierExpression)
pageBy(int, int, String) and then PaginatedCriteriaBuilder.createPageIdQuery() but more efficient.firstResult - The position of the first result to retrieve, numbered from 0maxResults - The maximum number of results to retrieveidentifierExpression - The first identifier expressionCriteriaBuilder to query id valuesCriteriaBuilder<Object[]> createPageIdQuery(KeysetPage keysetPage, int firstResult, int maxResults, String identifierExpression)
pageBy(KeysetPage, int, int, String) and then PaginatedCriteriaBuilder.createPageIdQuery() but more efficient.keysetPage - The key set from a previous result, may be nullfirstResult - The position of the first result to retrieve, numbered from 0maxResults - The maximum number of results to retrieveidentifierExpression - The first identifier expressionCriteriaBuilder to query id valuesCriteriaBuilder<Object[]> createPageIdQuery(int firstResult, int maxResults, String identifierExpression, String... identifierExpressions)
pageBy(int, int, String, String...) and then PaginatedCriteriaBuilder.createPageIdQuery() but more efficient.firstResult - The position of the first result to retrieve, numbered from 0maxResults - The maximum number of results to retrieveidentifierExpression - The first identifier expressionidentifierExpressions - The other identifier expressionsCriteriaBuilder to query id valuesCriteriaBuilder<Object[]> createPageIdQuery(KeysetPage keysetPage, int firstResult, int maxResults, String identifierExpression, String... identifierExpressions)
pageBy(KeysetPage, int, int, String, String...) and then PaginatedCriteriaBuilder.createPageIdQuery() but more efficient.keysetPage - The key set from a previous result, may be nullfirstResult - The position of the first result to retrieve, numbered from 0maxResults - The maximum number of results to retrieveidentifierExpression - The first identifier expressionidentifierExpressions - The other identifier expressionsCriteriaBuilder to query id valuesX join(String path, String alias, JoinType type, boolean fetch)
path - The path to joinalias - The alias for the joined elementtype - The join typefetch - True if a join fetch should be addedX joinDefault(String path, String alias, JoinType type, boolean fetch)
path - The path to joinalias - The alias for the joined elementtype - The join typefetch - True if a join fetch should be addedX innerJoinFetch(String path, String alias)
join(java.lang.String, java.lang.String, com.blazebit.persistence.JoinType, boolean) but with
JoinType.INNER and fetch set to true.path - The path to joinalias - The alias for the joined elementX innerJoinFetchDefault(String path, String alias)
joinDefault(java.lang.String, java.lang.String, com.blazebit.persistence.JoinType, boolean) but with
JoinType.INNER and fetch set to true.path - The path to joinalias - The alias for the joined elementX leftJoinFetch(String path, String alias)
join(java.lang.String, java.lang.String, com.blazebit.persistence.JoinType, boolean) but with
JoinType.LEFT and fetch set to true.path - The path to joinalias - The alias for the joined elementX leftJoinFetchDefault(String path, String alias)
joinDefault(java.lang.String, java.lang.String, com.blazebit.persistence.JoinType, boolean) but with
JoinType.LEFT and fetch set to true.path - The path to joinalias - The alias for the joined elementX rightJoinFetch(String path, String alias)
join(java.lang.String, java.lang.String, com.blazebit.persistence.JoinType, boolean) but with
JoinType.RIGHT and fetch set to true.path - The path to joinalias - The alias for the joined elementX rightJoinFetchDefault(String path, String alias)
joinDefault(java.lang.String, java.lang.String, com.blazebit.persistence.JoinType, boolean) but with
JoinType.RIGHT and fetch set to true.path - The path to joinalias - The alias for the joined element<Y> SelectObjectBuilder<? extends FullQueryBuilder<Y,?>> selectNew(Class<Y> clazz)
SelectObjectBuilder for the given class. The types of the parameter arguments used in the
SelectObjectBuilder must match a constructor of the given class.Y - The new query result type specified by the given classclazz - The class which should be used for the select new select clause<Y> SelectObjectBuilder<? extends FullQueryBuilder<Y,?>> selectNew(Constructor<Y> constructor)
SelectObjectBuilder for the given constructor. The types of the parameter arguments used in the
SelectObjectBuilder must match the given constructor.Y - The new query result type specified by the given classconstructor - The constructor which should be used for the select new select clause<Y> FullQueryBuilder<Y,?> selectNew(ObjectBuilder<Y> builder)
Y - The new query result type specified by the given classbuilder - The object builder which transforms the result set into objects of type YCopyright © 2014–2020 Blazebit. All rights reserved.