title: Spring Specification and Pageable
body: <p>How can I use <code>Specification</code> and <code>Pageable</code> together?</p>
  
  <p><strong>personelRepository.java</strong></p>
  
  <pre><code>@Query("SELECT e FROM PersonelEntity e ")
  List&lt;PersonelEntity&gt; findData(Specification&lt;PersonelEntity&gt;  test, Pageable pageable);
  </code></pre>
  
  <p><strong>personelService.java</strong></p>
  
  <pre><code>public List&lt;PersonelEntity&gt; filteredData(Specification&lt;PersonelEntity&gt; filter,Pageable  pageable){
      List&lt;PersonelEntity&gt; filteredData = personelRepository.findData(filter,pageable);
      return filteredData;
  }
  </code></pre>
  
  <p><strong>personelController.java</strong></p>
  
  <pre><code>Pageable reqCount = new PageRequest(0, 10);
  Specification&lt;PersonelEntity&gt; filter = new FilterSpecification&lt;PersonelEntity&gt;(new SearchCriteria("name", "=","lux"));
  personels = personelService.findData(filter,reqCount);
  </code></pre>
  
  <p>When I run it I get an error like this. But if I call findAll() function separately like findAll(Pageable page) and findAll(Specification filter) it works. But I can not use it together.</p>
  
  <pre><code>java.lang.IllegalArgumentException: Parameter with that position [1] did not exist
      at org.hibernate.jpa.spi.BaseQueryImpl.findParameterRegistration(BaseQueryImpl.java:502) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
      at org.hibernate.jpa.spi.BaseQueryImpl.setParameter(BaseQueryImpl.java:692) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
      at org.hibernate.jpa.spi.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:181) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
      at org.hibernate.jpa.spi.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:32) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
      at org.springframework.data.jpa.repository.query.ParameterBinder.bind(ParameterBinder.java:141) ~[spring-data-jpa-1.11.1.RELEASE.jar:na]
      at org.springframework.data.jpa.repository.query.StringQueryParameterBinder.bind(StringQueryParameterBinder.java:61) ~[spring-data-jpa-1.11.1.RELEASE.jar:na]
      at org.springframework.data.jpa.repository.query.ParameterBinder.bind(ParameterBinder.java:101) ~[spring-data-jpa-1.11.1.RELEASE.jar:na]
      at org.springframework.data.jpa.repository.query.SpelExpressionStringQueryParameterBinder.bind(SpelExpressionStringQueryParameterBinder.java:69) ~[spring-data-jpa-1.11.1.RELEASE.jar:na]
      at org.springframework.data.jpa.repository.query.ParameterBinder.bindAndPrepare(ParameterBinder.java:161) ~[spring-data-jpa-1.11.1.RELEASE.jar:na]
      at org.springframework.data.jpa.repository.query.ParameterBinder.bindAndPrepare(ParameterBinder.java:152) ~[spring-data-jpa-1.11.1.RELEASE.jar:na]
      at org.springframework.data.jpa.repository.query.AbstractStringBasedJpaQuery.doCreateQuery(AbstractStringBasedJpaQuery.java:81) ~[spring-data-jpa-1.11.1.RELEASE.jar:na]
      at org.springframework.data.jpa.repository.query.AbstractJpaQuery.createQuery(AbstractJpaQuery.java:190) ~[spring-data-jpa-1.11.1.RELEASE.jar:na]
      at org.springframework.data.jpa.repository.query.JpaQueryExecution$CollectionExecution.doExecute(JpaQueryExecution.java:121) ~[spring-data-jpa-1.11.1.RELEASE.jar:na]
      at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:85) ~[spring-data-jpa-1.11.1.RELEASE.jar:na]
  </code></pre>