title: Pagination - UnsupportedOperationException while accessing to the second page using Spring Data JPA
body: <p>I want to add pagination to my current application. To do that, I have the following code:</p>
  
  <p>MyEntity.java</p>
  
  <pre><code>@Entity
  @Table(name="MY_ENTITY_1")
  public class MyEntity {
  
      @Id
      @GeneratedValue
      @Column(name="P_ID")
      private Integer id;
  
      @Column(name = "C_CODEBRANCHE")
      private Integer codeBranche;
  
      // ...
  }
  </code></pre>
  
  <p>MyEntityRepository.java</p>
  
  <pre><code>@Repository
  public interface MyEntityRepository extends JpaRepository&lt;MyEntity, Integer&gt; {
  }
  </code></pre>
  
  <p>MyServiceImpl.java</p>
  
  <pre><code>@Service
  @Transactional
  public class MyServiceImpl implements MyService {    
      @Autowired
      private MyEntityRepository myEntityRepository;
  
      @Override
      public Page&lt;MyEntity&gt; getEntities(Pageable pageable) {
          return myEntityRepository.findAll(pageable);
      }
  }
  </code></pre>
  
  <p>And MyResource.java</p>
  
  <pre><code>@RestController
  @RequestMapping("/")
  public class MyResource {
      @Autowired
      private MyService myService;
  
      @GetMapping(path = "/myentity")
      public Page&lt;MyEntity&gt; getEntities(Pageable pageable) {
          return myService.getEntities(pageable);
      }
  }
  </code></pre>
  
  <p>When I call "/myentity", I have 20 results, and that's normal.</p>
  
  <p>When I call "/myentity?page=0&amp;size=10", I have 10 results.</p>
  
  <p>But, when I call "/myentity?page=1&amp;size=10", I have the following issue:</p>
  
  <blockquote>
    <p>ERROR 6864 --- [nio-8082-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]
    : Servlet.service() for servlet [dispatcherServlet] in context with
    path [] threw exception [Request processing failed; nested exception
    is java.lang.UnsupportedOperationException: query result offset is not
    supported] with root cause</p>
    
    <p>java.lang.UnsupportedOperationException: query result offset is not
    supported     at
    org.hibernate.dialect.DB2400Dialect$1.processSql(DB2400Dialect.java:26)
    ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]   at
    org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1893)
    ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    ...</p>
  </blockquote>
  
  <p>I really have no idea what's going wrong.</p>