Uploaded image for project: 'Spring Data Commons'
  1. Spring Data Commons
  2. DATACMNS-865

PageRequest parameter not recognized as Pageable in Paging query

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Works as Designed
    • Affects Version/s: 1.9.4 (Evans SR4)
    • Fix Version/s: None
    • Component/s: Repositories
    • Labels:
      None

      Description

      Given the following method signature

      @Override
          public Page<SolrMediaEntity> findMediaByFilter(String type, PageRequest pageRequest);
      

      I receive the following error:

      Caused by: java.lang.IllegalArgumentException: Paging query needs to have a Pageable parameter! Offending method public abstract org.springframework.data.domain.Page <package>.ICustomSolrMediaRepository.findMediaByFilter(java.lang.String,org.springframework.data.domain.PageRequest)
      	at org.springframework.util.Assert.isTrue(Assert.java:65)
      	at org.springframework.data.repository.query.QueryMethod.<init>(QueryMethod.java:84)
      

      Debugging into class Parameters suggests the cause may be due to this line:

              this.pageableIndex = types.indexOf(Pageable.class);
      

      one of the parameter types is org.springframework.data.domain.PageRequest, which implements Pageable, but since indexOf will not match on PageRequest, property pageableIndex becomes -1 which causes o.s.d.r.q.Parameters#hasPageableParameter to return false in the constructor of QueryMethod:

      	Assert.isTrue(this.parameters.hasPageableParameter(), ...
      

      and triggers the exception.

      I would expect iterating the parameter types and checking for Pageable.class.isAssignableFrom(parameterType) might be required.

      But maybe I am missing something?

        Attachments

          Activity

            People

            Assignee:
            olivergierke Oliver Drotbohm
            Reporter:
            dave David Rekowski
            Last updater:
            Oliver Drotbohm
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: