Interface WebQueryRepository<T>

Type Parameters:
T - entity type backing the repository
All Known Implementing Classes:
WebQueryRepositoryImpl

public interface WebQueryRepository<T>
Repository fragment for executing Specification-based tuple selections.
  • Method Summary

    Modifier and Type
    Method
    Description
    List<jakarta.persistence.Tuple>
    findAll(org.springframework.data.jpa.domain.Specification<T> specification, org.springframework.data.domain.Pageable pageable, SelectionsProvider<T> selectionsProvider)
    Executes a tuple query for the given specification, sort/page request, and selection definition.
    <U> List<U>
    findAll(org.springframework.data.jpa.domain.Specification<T> specification, org.springframework.data.domain.Pageable pageable, SelectionsProvider<T> selectionsProvider, Class<U> dtoClass)
    Executes a tuple query and converts each result row into an instance of the requested DTO type.
    org.springframework.data.domain.Page<jakarta.persistence.Tuple>
    findAllPaged(org.springframework.data.jpa.domain.Specification<T> specification, org.springframework.data.domain.Pageable pageable, SelectionsProvider<T> selectionsProvider)
    Executes a tuple query and wraps the results in a page.
    <U> org.springframework.data.domain.Page<U>
    findAllPaged(org.springframework.data.jpa.domain.Specification<T> specification, org.springframework.data.domain.Pageable pageable, SelectionsProvider<T> selectionsProvider, Class<U> dtoClass)
    Executes a tuple query, converts each result row into an instance of the requested DTO type, and wraps the converted results in a page.
  • Method Details

    • findAll

      List<jakarta.persistence.Tuple> findAll(org.springframework.data.jpa.domain.Specification<T> specification, org.springframework.data.domain.Pageable pageable, SelectionsProvider<T> selectionsProvider)
      Executes a tuple query for the given specification, sort/page request, and selection definition.

      The selection callback receives the live result CriteriaQuery so it can build correlated subqueries or inspect query state while defining projected columns.

      Parameters:
      specification - filtering criteria to apply
      pageable - paging and sorting information; sorting is always applied and limits are applied when paged
      selectionsProvider - callback that defines the tuple selections for the query
      Returns:
      tuples matching the requested filter, sort, and selection set
    • findAllPaged

      org.springframework.data.domain.Page<jakarta.persistence.Tuple> findAllPaged(org.springframework.data.jpa.domain.Specification<T> specification, org.springframework.data.domain.Pageable pageable, SelectionsProvider<T> selectionsProvider)
      Executes a tuple query and wraps the results in a page.

      When pageable is unpaged, the returned page contains all matching tuples without issuing a separate count query.

      The selection callback receives the live result CriteriaQuery. For paged execution, avoid mutating the outer query in ways that change row cardinality, such as enabling distinct results or adding grouping, because the total count is derived from a separate count query built from the Specification.

      Parameters:
      specification - filtering criteria to apply
      pageable - paging and sorting information; sorting is always applied and limits are applied when paged
      selectionsProvider - callback that defines the tuple selections for the query
      Returns:
      a page of tuples matching the requested filter, sort, and selection set
    • findAll

      <U> List<U> findAll(org.springframework.data.jpa.domain.Specification<T> specification, org.springframework.data.domain.Pageable pageable, SelectionsProvider<T> selectionsProvider, Class<U> dtoClass)
      Executes a tuple query and converts each result row into an instance of the requested DTO type.

      Use this overload when the caller wants constructor-backed DTO projection instead of working with raw Tuple instances. The provided SelectionsProvider still defines the tuple projection, but each resulting row is converted into dtoClass immediately before being returned to the caller.

      Conversion is positional. The selected tuple elements are passed to the DTO constructor in the same order as they are returned by SelectionsProvider.getSelections(jakarta.persistence.criteria.Root<T>, jakarta.persistence.criteria.CriteriaQuery<?>, jakarta.persistence.criteria.CriteriaBuilder). Tuple aliases or selection names are ignored.

      A constructor is considered compatible when it has the same number of parameters as projected tuple elements and each parameter type is assignable from the corresponding tuple element runtime Java type after primitive types are normalized to their wrapper equivalents. When multiple constructors are compatible, a constructor annotated with PersistenceCreator is preferred. Callers should define at most one such annotated constructor; if more than one constructor is annotated, or if multiple compatible constructors exist and selection is not uniquely determined, behavior is unpredictable.

      If no compatible constructor can be found, or if reflective instantiation fails for any row, the conversion fails at runtime.

      Type Parameters:
      U - DTO projection type
      Parameters:
      specification - filtering criteria to apply
      pageable - paging and sorting information; sorting is always applied and limits are applied when paged
      selectionsProvider - callback that defines the tuple selections for the query
      dtoClass - target DTO type to instantiate for each tuple row
      Returns:
      DTO instances matching the requested filter, sort, selection set, and constructor mapping rules
    • findAllPaged

      <U> org.springframework.data.domain.Page<U> findAllPaged(org.springframework.data.jpa.domain.Specification<T> specification, org.springframework.data.domain.Pageable pageable, SelectionsProvider<T> selectionsProvider, Class<U> dtoClass)
      Executes a tuple query, converts each result row into an instance of the requested DTO type, and wraps the converted results in a page.

      Use this overload when the caller wants constructor-backed DTO projection together with Spring Data paging metadata. The provided SelectionsProvider still defines the tuple projection, and each tuple row is converted into dtoClass before being exposed in the returned page.

      Conversion is positional. The selected tuple elements are supplied to the DTO constructor in the same order as they are returned by SelectionsProvider.getSelections(jakarta.persistence.criteria.Root<T>, jakarta.persistence.criteria.CriteriaQuery<?>, jakarta.persistence.criteria.CriteriaBuilder). Tuple aliases or selection names do not participate in constructor binding.

      A constructor is considered compatible when it has the same number of parameters as projected tuple elements and each parameter type is assignable from the corresponding tuple element runtime Java type after primitive types are normalized to their wrapper equivalents. When multiple constructors are compatible, a constructor annotated with PersistenceCreator is preferred. Callers should define at most one such annotated constructor; if more than one constructor is annotated, or if multiple compatible constructors exist and selection is not uniquely determined, behavior is unpredictable.

      This method inherits the same count-query caveats as findAllPaged(Specification, Pageable, SelectionsProvider). In particular, callers should avoid mutating the outer query in ways that change row cardinality, because the total count is derived from a separate count query built from the Specification.

      If no compatible constructor can be found, or if reflective instantiation fails for any row, the conversion fails at runtime.

      Type Parameters:
      U - DTO projection type
      Parameters:
      specification - filtering criteria to apply
      pageable - paging and sorting information; sorting is always applied and limits are applied when paged
      selectionsProvider - callback that defines the tuple selections for the query
      dtoClass - target DTO type to instantiate for each tuple row
      Returns:
      a page of DTO instances matching the requested filter, sort, selection set, and constructor mapping rules