Java Pagination

  • Spring Data Pagination

@Query(value = "SELECT\n" +
" t.* FROM schema.TABLE t\n" +
" WHERE t.DATETIME >= ?1 AND t.DATETIME < ?2\n" +
" ORDER BY ?#{#pageable}",
countQuery = "SELECT\n" +
" COUNT(*) FROM schema.TABLE t\n" +
" WHERE t.DATETIME >= ?1 AND t.DATETIME < ?2",
nativeQuery = true)
Page<Entity> getEntityPageable(String startDate, String endDate, Pageable pageable);

Page<Entity> findByDatetimeAfterAndDatetimeBefore(Timestamp startDate, Timestamp endDate, Pageable pageable);