QueryDslRepository
Provides default implementation and convenience methods for querying a specific entity (hierarchy), using QueryDSL to construct the queries.
Internally, delegates to QueryDslSupport to actually submit the queries.
API
class QueryDslRepository<T, Q> {
public static final OrderSpecifier<Comparable> ID_ORDER_SPECIFIER;
Class<T> getEntityClass() (1)
Q getEntityPath() (2)
Q q() (3)
Q entity() (4)
List<T> findAll(Function<Q, OrderSpecifier<?>>... orderSpecifiers) (5)
List<T> findAllUsingDefaultOrder() (6)
Optional<T> findUnique(Function<Q, Predicate>... predicates) (7)
Optional<T> findAny(Function<Q, Predicate>[] predicates, Function<Q, OrderSpecifier<?>>... orderSpecifiers) (8)
Optional<T> findAny(Function<Q, Predicate> predicate, Function<Q, OrderSpecifier<?>>... orderSpecifiers) (9)
Optional<T> findAnyUsingDefaultOrder(Function<Q, Predicate>... predicates) (10)
Optional<T> findFirst(Function<Q, Predicate>[] predicates, Function<Q, OrderSpecifier<?>>... orderSpecifiers) (11)
Optional<T> findFirst(Function<Q, Predicate> predicate, Function<Q, OrderSpecifier<?>>... orderSpecifiers) (12)
Optional<T> findFirstUsingDefaultOrder(Function<Q, Predicate>... predicates) (13)
List<F> findFieldsDistinct(Function<Q, Expression<F>> projection, Function<Q, Predicate>[] predicates, Function<Q, OrderSpecifier<?>>... orderSpecifiers) (14)
List<F> findFieldsDistinct(Function<Q, Expression<F>> projection, Function<Q, Predicate> predicate, Function<Q, OrderSpecifier<?>>... orderSpecifiers) (15)
List<F> findFieldsDistinctUsingDefaultOrder(Function<Q, Expression<F>> projection, Function<Q, Predicate>... predicates) (16)
Optional<F> findFirstFields(Function<Q, Expression<F>> projection, Function<Q, Predicate>[] predicates, Function<Q, OrderSpecifier<?>>... orderSpecifiers) (17)
Optional<F> findFirstFields(Function<Q, Expression<F>> projection, Function<Q, Predicate> predicate, Function<Q, OrderSpecifier<?>>... orderSpecifiers) (18)
Optional<F> findFirstFieldsUsingDefaultOrder(Function<Q, Expression<F>> projection, Function<Q, Predicate>... predicates) (19)
Optional<F> findUniqueFields(Function<Q, Expression<F>> projection, Function<Q, Predicate>... predicates) (20)
List<T> find(Function<Q, Predicate>[] predicates, Function<Q, OrderSpecifier<?>>... orderSpecifiers) (21)
List<T> find(Function<Q, Predicate> predicate, Function<Q, OrderSpecifier<?>>... orderSpecifiers) (22)
List<T> findUsingDefaultOrder(Function<Q, Predicate>... predicates) (23)
List<B> findAsBean(Function<Q, Expression<?>>[] projections, Class<? extends B> bean, Function<Q, Predicate>[] predicates, Function<Q, OrderSpecifier<?>>... orderSpecifiers) (24)
List<B> findAsBean(Function<Q, Predicate> predicate, Function<Q, OrderSpecifier<?>> orderSpecifier, Class<? extends B> bean, Function<Q, Expression<?>>... projections) (25)
List<T> newList(T... objs)
ArrayList<T> newArrayList(T... objs)
}
1 | getEntityClass() |
2 | getEntityPath()
The main entity Q instance for which this repository implementation operates. |
3 | q() |
4 | entity() |
5 | findAll(Function)
Returns all the instances of this entity, in the preferred OrderSpecifier ordering . |
6 | findAllUsingDefaultOrder()
Returns all the instances of this entity, in the #getDefaultOrders() default order . |
7 | findUnique(Function)
Based on the given predicate(s), search for exactly zero or one entity instance. |
8 | findAny(Function, Function)
Based on the given predicates search for the first entity instance based on the provided ordering. |
9 | findAny(Function, Function)
Based on the given predicate, search for the first entity instance based on the provided ordering. |
10 | findAnyUsingDefaultOrder(Function)
Based on the given predicate function search for the first entity instance based on the #getDefaultOrders() default ordering . |
11 | findFirst(Function, Function)
Based on the given predicate(s), search for the first entity instance based on specified OrderSpecifier ordering . |
12 | findFirst(Function, Function)
Based on the given predicate, search for the first entity instance based on specified OrderSpecifier ordering . |
13 | findFirstUsingDefaultOrder(Function)
Based on the given predicate(s) search for the first entity instance based on specified OrderSpecifier ordering . |
14 | findFieldsDistinct(Function, Function, Function)
Based on the given predicate(s), search for applicable entity instances and return the distinct projection (a subset of fields). |
15 | findFieldsDistinct(Function, Function, Function)
Based on the given predicate, search for applicable entity instances and return the distinct projection (a subset of fields). |
16 | findFieldsDistinctUsingDefaultOrder(Function, Function)
Based on the given predicate function search for applicable entity instances and return the distinct projection, using the #getDefaultOrders() default ordering . |
17 | findFirstFields(Function, Function, Function)
Based on the given predicate function search for applicable entity instances and return the first projection based on specified OrderSpecifier ordering . |
18 | findFirstFields(Function, Function, Function)
Based on the given predicate function search for applicable entity instances and return the first projection based on specified OrderSpecifier ordering . |
19 | findFirstFieldsUsingDefaultOrder(Function, Function)
Based on the given predicate function search for applicable entity instances and return the first projection based on the #getDefaultOrders() default ordering . |
20 | findUniqueFields(Function, Function)
Based on the given predicates search for exactly one or zero entity instance and return the projection. |
21 | find(Function, Function)
Based on the given predicate(s), search for applicable entity instances and apply the given OrderSpecifier ordering . |
22 | find(Function, Function)
Based on the given predicate(s), search for applicable entity instances and apply the given OrderSpecifier ordering . |
23 | findUsingDefaultOrder(Function)
Based on the given predicate function search for applicable entity instances and apply the #getDefaultOrders() default ordering . |
24 | findAsBean(Function, Class, Function, Function)
Based on the given predicate search for applicable entity instances, then transform the results to the given bean using the given projections and apply the given ordering. |
25 | findAsBean(Function, Function, Class, Function)
Based on the given predicate search for applicable entity instances, then transform the results to the given bean using the given projections and apply the given ordering. |
Members
getEntityPath()
The main entity Q instance for which this repository implementation operates.
The default implementation instantiates this reflectively, based on the conventions of the query-dsl annotation processor; eg QCustomer
has a 1-arg string constructor. In most cases there is no reason to override this.
However, for some complicated orderings, we have found it necessary to instead use the Q instance created by the annotation processor, called eg QCustomer.customer
. It is perfectly acceptable to override this method and just return the appropriate for the entity in question.
findAll(Function)
Returns all the instances of this entity, in the preferred OrderSpecifier ordering .
findAllUsingDefaultOrder()
Returns all the instances of this entity, in the #getDefaultOrders() default order .
the default implementation of #getDefaultOrders() requires that the id field exists. If this is not the case, then the method must be overridden.
|
findUnique(Function)
Based on the given predicate(s), search for exactly zero or one entity instance.
findAny(Function, Function)
Based on the given predicates search for the first entity instance based on the provided ordering.
findAny(Function, Function)
Based on the given predicate, search for the first entity instance based on the provided ordering.
findAnyUsingDefaultOrder(Function)
Based on the given predicate function search for the first entity instance based on the #getDefaultOrders() default ordering .
the default implementation of #getDefaultOrders() requires that the id field exists. If this is not the case, then that method must be overridden.
|
findFirst(Function, Function)
Based on the given predicate(s), search for the first entity instance based on specified OrderSpecifier ordering .
findFirst(Function, Function)
Based on the given predicate, search for the first entity instance based on specified OrderSpecifier ordering .
findFirstUsingDefaultOrder(Function)
Based on the given predicate(s) search for the first entity instance based on specified OrderSpecifier ordering .
findFieldsDistinct(Function, Function, Function)
Based on the given predicate(s), search for applicable entity instances and return the distinct projection (a subset of fields).
*CAUTION* : when the supplied _OrderSpecifier ordering_ is not aligned to the projection one might get unexpected results, because the elimination of duplicates is based on the ordering, not the projection!
findFieldsDistinct(Function, Function, Function)
Based on the given predicate, search for applicable entity instances and return the distinct projection (a subset of fields).
*CAUTION* : when the supplied _OrderSpecifier ordering_ is not aligned to the projection one might get unexpected results, because the elimination of duplicates is based on the ordering, not the projection!
findFieldsDistinctUsingDefaultOrder(Function, Function)
Based on the given predicate function search for applicable entity instances and return the distinct projection, using the #getDefaultOrders() default ordering .
*CAUTION* : when the _#getDefaultOrders() ordering_ is not aligned to the projection one might get unexpected results, because the elimination of duplicates is based on the ordering, not the projection!
the default implementation of #getDefaultOrders() requires that the id field exists. If this is not the case, then that method must be overridden.
|
findFirstFields(Function, Function, Function)
Based on the given predicate function search for applicable entity instances and return the first projection based on specified OrderSpecifier ordering .
*CAUTION* : when the supplied _OrderSpecifier ordering_ is not aligned to the projection one might get unexpected results, because the elimination of duplicates is based on the ordering, not the projection!
findFirstFields(Function, Function, Function)
Based on the given predicate function search for applicable entity instances and return the first projection based on specified OrderSpecifier ordering .
*CAUTION* : when the supplied _OrderSpecifier ordering_ is not aligned to the projection one might get unexpected results, because the elimination of duplicates is based on the ordering, not the projection!
findFirstFieldsUsingDefaultOrder(Function, Function)
Based on the given predicate function search for applicable entity instances and return the first projection based on the #getDefaultOrders() default ordering .
*CAUTION* : when the _#getDefaultOrders() ordering_ is not aligned to the projection one might get unexpected results, because the elimination of duplicates is based on the ordering, not the projection!
the default implementation of #getDefaultOrders() requires that the id field exists. If this is not the case, then that method must be overridden.
|
findUniqueFields(Function, Function)
Based on the given predicates search for exactly one or zero entity instance and return the projection.
find(Function, Function)
Based on the given predicate(s), search for applicable entity instances and apply the given OrderSpecifier ordering .
find(Function, Function)
Based on the given predicate(s), search for applicable entity instances and apply the given OrderSpecifier ordering .
findUsingDefaultOrder(Function)
Based on the given predicate function search for applicable entity instances and apply the #getDefaultOrders() default ordering .
the default implementation of #getDefaultOrders() requires that the id field exists. If this is not the case, then that method must be overridden.
|