I\'m not able to use Spring Data JPA projections and specifications together. I have the following setup:
Entity:
@Entity
public cla
I found this https://github.com/pramoth/specification-with-projection and it seems to work which does exactly what you're looking for. I've included it in my own project and so far no problems. Big thanks to Pramoth.
Basically you extend JpaSpecificationExecutorWithProjection instead of JpaSpecificationExecutor.
public interface DocumentRepository extends JpaRepository< Country,Long>,JpaSpecificationExecutorWithProjection
and you get findall() method with projections and specifications
Page findAll(Specification spec, Class projectionClass, Pageable pageable);