Class WebQueryRepositoryImpl<E>
- Type Parameters:
E- entity type handled by the repository
- All Implemented Interfaces:
WebQueryRepository<E>,org.springframework.data.repository.core.support.RepositoryMetadataAccess
WebQueryRepository repository fragment implementation
backed by Criteria queries and rsql-jpa.
This implementation handles filtering, sorting, pagination, and
projection for a repository method invocation. It builds tuple-based select
queries through the supplied SelectionsProvider, validates and maps
filter and sort paths against the supplied DTO type, delegates predicate
creation to rsql-jpa, and converts the resulting tuples into the
requested DTO type.
When page metadata is needed, the same filter rules are reused for a separate count query. The interface Javadoc remains the main public API description; the helper methods in this class explain how the JPA-backed implementation realizes that behavior.
The repository-wide defaults used by the overloads that do not accept
explicit validation settings are sourced from the properties
spring-web-query.filtering.allow-and-operation,
spring-web-query.filtering.allow-or-operation, and
spring-web-query.filtering.max-ast-depth.
-
Constructor Summary
ConstructorsConstructorDescriptionWebQueryRepositoryImpl(@NonNull jakarta.persistence.EntityManager entityManager, @NonNull cz.jirutka.rsql.parser.RSQLParser rsqlParser, @NonNull ValidationRSQLVisitorFactory validationRSQLVisitorFactory, @NonNull List<io.github.perplexhub.rsql.RSQLCustomPredicate<?>> customPredicates, @NonNull DTOToEntityPathMapperFactory pathMapperFactory, @NonNull SortableFieldValidator sortableFieldValidator, boolean globalAllowAndOperation, boolean globalAllowOrOperation, int globalMaxASTDepth) Creates the repository implementation with all collaborating components and global validation defaults. -
Method Summary
Modifier and TypeMethodDescriptionlongcount(@Nullable String rsqlQuery, @Nullable SpecificationCustomizer<E> specificationCustomizer, @NonNull Class<?> dtoClass) Counts rows matching the supplied filter using repository defaults.longcount(@Nullable String rsqlQuery, @Nullable SpecificationCustomizer<E> specificationCustomizer, @NonNull Class<?> dtoClass, boolean allowAndOperation, boolean allowOrOperation, int maxASTDepth) Counts rows matching the supplied filter using explicit validation settings.<D> List<D>findAll(@Nullable String rsqlQuery, @NonNull org.springframework.data.domain.Pageable pageable, @NonNull SelectionsProvider<E> selectionsProvider, @Nullable SpecificationCustomizer<E> specificationCustomizer, @NonNull Class<D> dtoClass) Executes a projected result query using repository defaults.<D> List<D>findAll(@Nullable String rsqlQuery, @NonNull org.springframework.data.domain.Pageable pageable, @NonNull SelectionsProvider<E> selectionsProvider, @Nullable SpecificationCustomizer<E> specificationCustomizer, @NonNull Class<D> dtoClass, boolean allowAndOperation, boolean allowOrOperation, int maxASTDepth) Executes a projected result query using explicit validation settings.<D> org.springframework.data.domain.Page<D>findAllPaged(@Nullable String rsqlQuery, @NonNull org.springframework.data.domain.Pageable pageable, @NonNull SelectionsProvider<E> selectionsProvider, @Nullable SpecificationCustomizer<E> specificationCustomizer, @NonNull Class<D> dtoClass) Executes a paged projected query using repository defaults.<D> org.springframework.data.domain.Page<D>findAllPaged(@Nullable String rsqlQuery, @NonNull org.springframework.data.domain.Pageable pageable, @NonNull SelectionsProvider<E> selectionsProvider, @Nullable SpecificationCustomizer<E> specificationCustomizer, @NonNull Class<D> dtoClass, boolean allowAndOperation, boolean allowOrOperation, int maxASTDepth) Executes a paged projected query using explicit validation settings.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface in.co.akshitbansal.springwebquery.repository.WebQueryRepository
count, findAll, findAllPaged
-
Constructor Details
-
WebQueryRepositoryImpl
public WebQueryRepositoryImpl(@NonNull @NonNull jakarta.persistence.EntityManager entityManager, @NonNull @NonNull cz.jirutka.rsql.parser.RSQLParser rsqlParser, @NonNull @NonNull ValidationRSQLVisitorFactory validationRSQLVisitorFactory, @NonNull @NonNull List<io.github.perplexhub.rsql.RSQLCustomPredicate<?>> customPredicates, @NonNull @NonNull DTOToEntityPathMapperFactory pathMapperFactory, @NonNull @NonNull SortableFieldValidator sortableFieldValidator, @Value("${spring-web-query.filtering.allow-and-operation:true}") boolean globalAllowAndOperation, @Value("${spring-web-query.filtering.allow-or-operation:false}") boolean globalAllowOrOperation, @Value("${spring-web-query.filtering.max-ast-depth:1}") int globalMaxASTDepth) Creates the repository implementation with all collaborating components and global validation defaults.
-
-
Method Details
-
findAll
public <D> List<D> findAll(@Nullable String rsqlQuery, @NonNull @NonNull org.springframework.data.domain.Pageable pageable, @NonNull @NonNull SelectionsProvider<E> selectionsProvider, @Nullable SpecificationCustomizer<E> specificationCustomizer, @NonNull @NonNull Class<D> dtoClass, boolean allowAndOperation, boolean allowOrOperation, int maxASTDepth) Executes a projected result query using explicit validation settings.- Specified by:
findAllin interfaceWebQueryRepository<E>- Type Parameters:
D- projected DTO type- Parameters:
rsqlQuery- optional RSQL filter expressionpageable- requested paging and sorting informationselectionsProvider- callback that defines the tuple projectionspecificationCustomizer- optional hook to amend the generated filter specification before it is applieddtoClass- DTO type whose fields are used for filtering and sorting and whose shape is used for result projectionallowAndOperation- whether logicalANDis allowed in the RSQL expressionallowOrOperation- whether logicalORis allowed in the RSQL expressionmaxASTDepth- maximum RSQL AST depth accepted during validation- Returns:
- projected results for the requested page window, ordered according to the translated sort instructions
-
findAll
public <D> List<D> findAll(@Nullable String rsqlQuery, @NonNull @NonNull org.springframework.data.domain.Pageable pageable, @NonNull @NonNull SelectionsProvider<E> selectionsProvider, @Nullable SpecificationCustomizer<E> specificationCustomizer, @NonNull @NonNull Class<D> dtoClass) Executes a projected result query using repository defaults.- Specified by:
findAllin interfaceWebQueryRepository<E>- Type Parameters:
D- projected DTO type- Parameters:
rsqlQuery- optional RSQL filter expressionpageable- requested paging and sorting informationselectionsProvider- callback that defines the tuple projectionspecificationCustomizer- optional hook to amend the generated filterdtoClass- DTO type whose fields are used for filtering and sorting and whose shape is used for result projection- Returns:
- projected results for the requested page window, ordered according to the translated sort instructions
-
count
public long count(@Nullable String rsqlQuery, @Nullable SpecificationCustomizer<E> specificationCustomizer, @NonNull @NonNull Class<?> dtoClass, boolean allowAndOperation, boolean allowOrOperation, int maxASTDepth) Counts rows matching the supplied filter using explicit validation settings.- Specified by:
countin interfaceWebQueryRepository<E>- Parameters:
rsqlQuery- optional RSQL filter expressionspecificationCustomizer- optional hook to amend the generated filterdtoClass- DTO type whose fields are used for filter validation and path translationallowAndOperation- whether logicalANDis allowed in the RSQL expressionallowOrOperation- whether logicalORis allowed in the RSQL expressionmaxASTDepth- maximum RSQL AST depth accepted during validation- Returns:
- number of matching rows after the generated and customized filter specification has been applied
-
count
public long count(@Nullable String rsqlQuery, @Nullable SpecificationCustomizer<E> specificationCustomizer, @NonNull @NonNull Class<?> dtoClass) Counts rows matching the supplied filter using repository defaults.- Specified by:
countin interfaceWebQueryRepository<E>- Parameters:
rsqlQuery- optional RSQL filter expressionspecificationCustomizer- optional hook to amend the generated filterdtoClass- DTO type whose fields are used for filter validation and path translation- Returns:
- number of matching rows after the generated and customized filter specification has been applied
-
findAllPaged
public <D> org.springframework.data.domain.Page<D> findAllPaged(@Nullable String rsqlQuery, @NonNull @NonNull org.springframework.data.domain.Pageable pageable, @NonNull @NonNull SelectionsProvider<E> selectionsProvider, @Nullable SpecificationCustomizer<E> specificationCustomizer, @NonNull @NonNull Class<D> dtoClass, boolean allowAndOperation, boolean allowOrOperation, int maxASTDepth) Executes a paged projected query using explicit validation settings.- Specified by:
findAllPagedin interfaceWebQueryRepository<E>- Type Parameters:
D- projected DTO type- Parameters:
rsqlQuery- optional RSQL filter expressionpageable- requested paging and sorting informationselectionsProvider- callback that defines the tuple projectionspecificationCustomizer- optional hook to amend the generated filterdtoClass- DTO type whose fields are used for filtering and sorting and whose shape is used for result projectionallowAndOperation- whether logicalANDis allowed in the RSQL expressionallowOrOperation- whether logicalORis allowed in the RSQL expressionmaxASTDepth- maximum RSQL AST depth accepted during validation- Returns:
- page of projected results together with paging metadata derived from the matching-row count
-
findAllPaged
public <D> org.springframework.data.domain.Page<D> findAllPaged(@Nullable String rsqlQuery, @NonNull @NonNull org.springframework.data.domain.Pageable pageable, @NonNull @NonNull SelectionsProvider<E> selectionsProvider, @Nullable SpecificationCustomizer<E> specificationCustomizer, @NonNull @NonNull Class<D> dtoClass) Executes a paged projected query using repository defaults.- Specified by:
findAllPagedin interfaceWebQueryRepository<E>- Type Parameters:
D- projected DTO type- Parameters:
rsqlQuery- optional RSQL filter expressionpageable- requested paging and sorting informationselectionsProvider- callback that defines the tuple projectionspecificationCustomizer- optional hook to amend the generated filterdtoClass- DTO type whose fields are used for filtering and sorting and whose shape is used for result projection- Returns:
- page of projected results together with paging metadata derived from the matching-row count
-