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

Paged findAll(…) with Specification does not work with join fetch

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.0 GA, 1.0.1
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None

      Description

      The method Page<T> findAll(Specification<T>, Pageable) in the JpaSpecificationExecutor interface throws an exception if the Specification uses a join fetch. The problem is that in order to do the pagination, the library has to first perform a count query, but when the count query is performed, the join fetches are not eliminated or changed to regular joins.

      The error is:

      org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select list

      The attached zip file is a simple Maven project which demonstrates this problem (mvn test).

        Attachments

          Activity

            People

            • Assignee:
              olivergierke Oliver Drotbohm
              Reporter:
              ageery Andrew Geery
              Last updater:
              Trevor Marshall
            • Votes:
              14 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

              • Created:
                Updated: