Skip to content
Support projections with JpaSpecificationExecutor.findAll(Specification,Pageable) for Spring Data JPA
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
.mvn/wrapper initial project Sep 29, 2016
src add support for open projection (projection that use SpringEL on inte… May 28, 2019
.gitignore initial project Sep 29, 2016
LICENSE Create LICENSE Feb 28, 2017 Update May 9, 2018
mvnw initial project Sep 29, 2016
mvnw.cmd initial project Sep 29, 2016
pom.xml use TypeQuery<Tuple> for selection projection May 16, 2019


Support Projections with JpaSpecificationExecutor.findAll(Specification,Pageable) for Spring Data JPA

version 2.x.x for Spring Data JPA 2.x (Spring Boot 2.x)

version 1.x.x Spring Data JPA 1.x

How to use

  • add dependency to pom
<!-- for Spring Data 2.x -->
<!-- for Spring Data 1.x -->
  • add annotation @EnableJpaRepositories(repositoryBaseClass = JpaSpecificationExecutorWithProjectionImpl.class) on Application class (Spring Boot)
  • create your repository and extends JpaSpecificationExecutorWithProjection
public interface DocumentRepository extends JpaRepository<Document,Integer>,JpaSpecificationExecutorWithProjection<Document,Integer> {
    * projection interface
    public static interface DocumentWithoutParent{
        Long getId();
        String getDescription();
        String getDocumentType();
        String getDocumentCategory();
        List<DocumentWithoutParent> getChild();
  • use it

      public void specificationWithProjection() {
          Specifications<Document> where = Specifications.where(DocumentSpecs.idEq(1L));
          Page<DocumentRepository.DocumentWithoutParent> all = documentRepository.findAll(where, DocumentRepository.DocumentWithoutParent.class, new PageRequest(0,10));
JpaEntityGraph jpaEntityGraph = new JpaEntityGraph(
    new String[]{"sistRecvTm","birth","transfer","merger"}
  BirthWithoutChild birth = birthRepository.findAll(createSpecBirth(searchData, type.toUpperCase()), BirthWithoutChild.class,jpaEntityGraph,pageable);
You can’t perform that action at this time.