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

Pagination does not work with eager join fetch of association

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0 M1
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None

      Description

      Query like "SELECT u FROM User u JOIN FETCH u.roles r" doesn't work if repository/DAO method returns org.springframework.data.domain.Page - library tries to calculate total count with additional query "select count(u) FROM foo.bar.User u JOIN FETCH u.roles r" which throws "org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select list".

        Activity

        Hide
        pioter Piotr Jagielski added a comment -

        On second thought it could probably remove the fetch part altogether instead of just the keyword because fetching shouldn't affect the number of results.

        Show
        pioter Piotr Jagielski added a comment - On second thought it could probably remove the fetch part altogether instead of just the keyword because fetching shouldn't affect the number of results.
        Hide
        shuklamp Manish Shukla added a comment -

        I am using Specifications to form Predicates dynamically. Using countQuery is not possible, is there any other workaround to this issue for Specification ?

        Show
        shuklamp Manish Shukla added a comment - I am using Specifications to form Predicates dynamically. Using countQuery is not possible, is there any other workaround to this issue for Specification ?
        Hide
        minneyar P. J. Reed added a comment -

        I just run into this issue; I'm using .findAll on a repository and passing in a Specification, and it's fairly frustrating that I am apparently unable to specify fetches because it breaks the count query.

        Show
        minneyar P. J. Reed added a comment - I just run into this issue; I'm using .findAll on a repository and passing in a Specification, and it's fairly frustrating that I am apparently unable to specify fetches because it breaks the count query.
        Hide
        olivergierke Oliver Gierke added a comment -

        Please open a dedicated ticket. This one here is not involving specifications at all.

        Show
        olivergierke Oliver Gierke added a comment - Please open a dedicated ticket. This one here is not involving specifications at all.
        Hide
        minneyar P. J. Reed added a comment -

        Done; see DATAJPA-278.

        Show
        minneyar P. J. Reed added a comment - Done; see DATAJPA-278 .

          People

          • Assignee:
            olivergierke Oliver Gierke
            Reporter:
            sslavic Stevo Slavić
            Last updater:
            Trevor Marshall
          • Votes:
            4 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: