# Pagination and sorting using hibernate

**URL:** <https://discourse.hibernate.org/t/pagination-and-sorting-using-hibernate/237>\
**Category:** Hibernate ORM\
**Created:** [February 14, 2018, 4:06pm UTC](https://discourse.hibernate.org/t/pagination-and-sorting-using-hibernate/237 "2018-02-14T16:06:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajithpmenon3](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@ajithpmenon3](https://discourse.hibernate.org/u/ajithpmenon3)\
**Post date:** [February 14, 2018, 4:06pm UTC](https://discourse.hibernate.org/t/pagination-and-sorting-using-hibernate/237/1 "2018-02-14T16:06:46Z")

</div>

I need to implement pagination and sorting in an application for entities from one table.Do we have any hibernate feature available for this?

---

<div class="post-metadata">

**Author:** ![vlad](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/vlad/32/658_2.png) [@vlad](https://discourse.hibernate.org/u/vlad)\
**Post date:** [February 14, 2018, 5:02pm UTC](https://discourse.hibernate.org/t/pagination-and-sorting-using-hibernate/237/2 "2018-02-14T17:02:44Z")

</div>

The JPA `Query` interface offers these two methods for pagination:

- `setFirstResult(int)`
- `setMaxResults(int)`

And for sorting, you can use ORDER BY in JPQL or [`@OrderColumn`](http://docs.jboss.org/hibernate/orm/5.2/userguide/html_single/Hibernate_User_Guide.html#annotations-jpa-ordercolumn) or [`@OrderBy`](http://docs.jboss.org/hibernate/orm/5.2/userguide/html_single/Hibernate_User_Guide.html#annotations-jpa-orderby) for collections.
