Uploaded image for project: 'Spring Data JPA'
  1. Spring Data JPA
  2. DATAJPA-1033

Support projections on query methods that take a dynamic query type (Specification or Querydsl Predicate)

    Details

    • Type: New Feature
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0 M1 (Kay), 1.11 RC1 (Ingalls), 1.10.6 (Hopper SR6)
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
    • Environment:
      Spring 4.3.5, Hibernate 5.1.3

      Description

      Currently there seems no (at least no obvious) way to mix projections and specifications.

      class ExampleRepository extends JpaRepository<Example, Integer>, JpaSpecificationExecutor<Example> {
      
          // Overriden from JpaRepository, just to show the whole picture
          // Works without problems
          @Override
          List<Example> findAll();
      
          // A bit odd, due to the "By", but works - see DATAJPA-680
          List<ExampleProjection> findAllProjectedBy();
      
          // Overriden from JpaRepository, just to show the whole picture
          // Works without problems
          @Override
          List<Example> findAll(Specification<Example> spec);
      
          // This would be great, but doesn't work.
          List<ExampleProjection> findAllProjectedBy(Specification<Example> spec);
      
      }
      

      A query method like the last above causes a java.util.NoSuchElementException inside org.springframework.data.jpa.repository.query.CriteriaQueryParameterBinder#bind during query. (Which may be another problem on its own.)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                olivergierke Oliver Drotbohm
                Reporter:
                koraktor Sebastian Staudt
                Last updater:
                Matija Folnović
              • Votes:
                45 Vote for this issue
                Watchers:
                41 Start watching this issue

                Dates

                • Created:
                  Updated: