T - the entity class to manage in the repositorypublic class QueryDslRepositorySupportExt<T>
extends org.springframework.data.jpa.repository.support.QueryDslRepositorySupport
| Modifier and Type | Class and Description |
|---|---|
static class |
QueryDslRepositorySupportExt.AttributeMappingBuilder
Factory to create a mapping between simulated attributes and the entity
real ones.
|
| Constructor and Description |
|---|
QueryDslRepositorySupportExt(Class<T> domainClass)
Creates a new
QueryDslRepositorySupport instance for the given domain type. |
| Modifier and Type | Method and Description |
|---|---|
protected com.querydsl.jpa.JPQLQuery<T> |
applyGlobalSearch(GlobalSearch globalSearch,
com.querydsl.jpa.JPQLQuery<T> query,
com.querydsl.core.types.Path<?>... globalSearchAttributes)
Adds a global contains text filter on the provided attributes.
|
protected com.querydsl.jpa.JPQLQuery<T> |
applyGlobalSearch(String text,
com.querydsl.jpa.JPQLQuery<T> query,
com.querydsl.core.types.Path<?>... globalSearchAttributes)
Adds a global contains text filter on the provided attributes.
|
protected com.querydsl.jpa.JPQLQuery<T> |
applyOrderById(com.querydsl.jpa.JPQLQuery<T> query)
Adds to a query an order by the entity identifier related to this repository.
|
protected com.querydsl.jpa.JPQLQuery<T> |
applyPagination(org.springframework.data.domain.Pageable pageable,
com.querydsl.jpa.JPQLQuery<T> query)
Applies the given
Pageable to the given JPQLQuery. |
protected com.querydsl.jpa.JPQLQuery<T> |
applyPagination(org.springframework.data.domain.Pageable pageable,
com.querydsl.jpa.JPQLQuery<T> query,
Map<String,com.querydsl.core.types.Path<?>[]> attributeMapping)
Applies the given
Pageable to the given JPQLQuery. |
protected com.querydsl.jpa.JPQLQuery<T> |
applyPagination(org.springframework.data.domain.Pageable pageable,
com.querydsl.jpa.JPQLQuery<T> query,
QueryDslRepositorySupportExt.AttributeMappingBuilder mapping)
Applies the given
Pageable to the given JPQLQuery. |
protected QueryDslRepositorySupportExt.AttributeMappingBuilder |
buildMapper()
Creates a factory to easily build an attribute mapping to
real entity attribute names.
|
protected com.querydsl.core.types.dsl.PathBuilder<Object> |
getEntityId()
Returns the path of entity identifier field
|
protected <M> org.springframework.data.domain.Page<M> |
loadPage(com.querydsl.jpa.JPQLQuery<T> query,
org.springframework.data.domain.Pageable pageable,
com.querydsl.core.types.Expression<M> expression)
Loads a page of data with the provided pagination criteria.
|
protected com.querydsl.jpa.JPQLQuery<T> applyPagination(org.springframework.data.domain.Pageable pageable, com.querydsl.jpa.JPQLQuery<T> query)
Pageable to the given JPQLQuery.pageable - the ordering and paging informationquery - the query to apply toprotected com.querydsl.jpa.JPQLQuery<T> applyPagination(org.springframework.data.domain.Pageable pageable, com.querydsl.jpa.JPQLQuery<T> query, QueryDslRepositorySupportExt.AttributeMappingBuilder mapping)
Pageable to the given JPQLQuery.
Allows to map the attributes to order as provided in the Pageable
to real entity attributes. This might be used to work with projections
or DTOs whose attributes don't have the same name as the entity ones.
It allows to map to more than one entity attribute. As an example, if
the DTO used to create the Pageable has a fullName attribute, you
could map that attribute to two entity attributes: name and surname.
In this case, the Pageable defines an order by a fullName
attribute, but que query will order by name and surname instead.pageable - the ordering and pagingquery - mapping - definition of a mapping of order attribute names to
real entity onesprotected com.querydsl.jpa.JPQLQuery<T> applyPagination(org.springframework.data.domain.Pageable pageable, com.querydsl.jpa.JPQLQuery<T> query, Map<String,com.querydsl.core.types.Path<?>[]> attributeMapping)
Pageable to the given JPQLQuery.
Allows to map the attributes to order as provided in the Pageable
to real entity attributes. This might be used to work with projections
or DTOs whose attributes don't have the same name as the entity ones.
It allows to map to more than one entity attribute. As an example, if
the DTO used to create the Pageable has a fullName attribute, you
could map that attribute to two entity attributes: name and surname.
In this case, the Pageable defines an order by a fullName
attribute, but que query will order by name and surname instead.pageable - the ordering and pagingquery - attributeMapping - definition of a mapping of order attribute names
to real entity onesprotected QueryDslRepositorySupportExt.AttributeMappingBuilder buildMapper()
protected com.querydsl.jpa.JPQLQuery<T> applyOrderById(com.querydsl.jpa.JPQLQuery<T> query)
query - protected com.querydsl.core.types.dsl.PathBuilder<Object> getEntityId()
protected com.querydsl.jpa.JPQLQuery<T> applyGlobalSearch(String text, com.querydsl.jpa.JPQLQuery<T> query, com.querydsl.core.types.Path<?>... globalSearchAttributes)
text - the text to look forquery - globalSearchAttributes - the list of attributes to perform the
filter onprotected com.querydsl.jpa.JPQLQuery<T> applyGlobalSearch(GlobalSearch globalSearch, com.querydsl.jpa.JPQLQuery<T> query, com.querydsl.core.types.Path<?>... globalSearchAttributes)
globalSearch - Contains the text to look forquery - globalSearchAttributes - the list of attributes to perform the
filter onprotected <M> org.springframework.data.domain.Page<M> loadPage(com.querydsl.jpa.JPQLQuery<T> query, org.springframework.data.domain.Pageable pageable, com.querydsl.core.types.Expression<M> expression)
loadPage(query, pageable, QEmployee.employee);Sample with a projection:
loadPage(query, pageable, Projections.constructor(EmployeeInfo.class,
employee.id, employee.firstName, employee.lastName, employee.phone, employee.extension,
employee.supervisor.id, employee.supervisor.firstName, employee.supervisor.lastName));
M - the data type to load, usually a JPA Entity or a projection beanquery - the query with the pagination and ordering criteria already appliedpageable - the already applied pagination and ordering criteriaexpression - the entity or projection to build with the query dataCopyright © 2018 DISID Corporation. All rights reserved.