{"id":88230,"date":"2019-02-12T13:00:03","date_gmt":"2019-02-12T11:00:03","guid":{"rendered":"https:\/\/www.javacodegeeks.com\/?p=88230"},"modified":"2019-02-18T14:16:55","modified_gmt":"2019-02-18T12:16:55","slug":"pagination-sorting-spring-data-jpa","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2019\/02\/pagination-sorting-spring-data-jpa.html","title":{"rendered":"Pagination and Sorting with Spring Data JPA"},"content":{"rendered":"<p>Learn <strong>Pagination and Sorting with Spring Data JPA<\/strong> with code examples. Understand how to get Paginated and Sorted results using Springs PagingAndSortingRepository interface.<\/p>\n<h3 class=\"wp-block-heading\">1 Overview<\/h3>\n<p>While dealing with large amount of data the lazy processing is often essential. Even if a service returns a huge amount of data the consumer is less likely using it. Consider a shopping website, where customer searches for a product and the website has thousands of products to display. Fetching thousands of products and displaying it on a web page will be very time consuming. In most of the cases the customer may not even look at all of the products.<\/p>\n<p>For such cases a technique called as <em>Pagination<\/em> is used. Only a small subset of products (page) is displayed at first and customer can ask to see the next subset (page) and so on. This is called as Pagination.<\/p>\n<p><b>Want to learn using Java Persistence API (JPA) with Spring and Spring Boot ? <\/b><\/p>\n<p>Read this:<\/p>\n<ul class=\"wp-block-list\">\n<li><a href=\"http:\/\/www.amitph.com\/spring-boot-with-spring-data-jpa\/\">Spring Boot with Spring Data JPA<\/a><\/li>\n<li><a href=\"http:\/\/www.amitph.com\/spring-data-jpa-embeddedid\/\">Spring Data JPA Composite Key with @EmbeddedId<\/a><\/li>\n<li><a href=\"http:\/\/www.amitph.com\/spring-data-jpa-embeddedid-partially\/\">Spring Data JPA find by @EmbeddedId Partially<\/a><\/li>\n<li><a href=\"http:\/\/www.amitph.com\/java-persistence-api-guide\/\">Java Persistence API Guide <\/a><\/li>\n<li><a href=\"http:\/\/www.amitph.com\/spring-data-jpa-query-methods\/\">Spring Data JPA Query Methods<\/a><\/li>\n<\/ul>\n<h3 class=\"wp-block-heading\">2 Entity<\/h3>\n<p>For the sake of this tutorial, we will consider the simplest example of \u2018<em>Employee<\/em>\u2018 entity. Below is the <em>Employee<\/em> entity class.<\/p>\n<pre class=\"brush:java\">@Entity\npublic class Employee {\n    @Id private Long name;\n \n    private String firstName;\n    private String lastName;\n    private Date dateOfBirth;\n    private Integer age;\n    private String designation;\n    private double salary;\n    private Date dateOfJoining;\n \n    public Long getName() {\n        return name;\n    }\n \n    public void setName(Long name) {\n        this.name = name;\n    }\n \n    public String getFirstName() {\n        return firstName;\n    }\n \n    public void setFirstName(String firstName) {\n        this.firstName = firstName;\n    }\n \n    public String getLastName() {\n        return lastName;\n    }\n \n    public void setLastName(String lastName) {\n        this.lastName = lastName;\n    }\n \n    public Date getDateOfBirth() {\n        return dateOfBirth;\n    }\n \n    public void setDateOfBirth(Date dateOfBirth) {\n        this.dateOfBirth = dateOfBirth;\n    }\n \n    public Integer getAge() {\n        return age;\n    }\n \n    public void setAge(Integer age) {\n        this.age = age;\n    }\n \n    public String getDesignation() {\n        return designation;\n    }\n \n    public void setDesignation(String designation) {\n        this.designation = designation;\n    }\n \n    public double getSalary() {\n        return salary;\n    }\n \n    public void setSalary(double salary) {\n        this.salary = salary;\n    }\n \n    public Date getDateOfJoining() {\n        return dateOfJoining;\n    }\n \n    public void setDateOfJoining(Date dateOfJoining) {\n        this.dateOfJoining = dateOfJoining;\n    }\n}\n<\/pre>\n<h3 class=\"wp-block-heading\">3 Employee Repository<\/h3>\n<p>In article <a href=\"http:\/\/www.amitph.com\/spring-data-jpa-query-methods\/\">Spring Data JPA Query Methods<\/a>, we have already learnt about Spring repository interfaces and query methods. Here, we have to learn <strong>Pagination<\/strong>, so we will use Spring\u2019s <em>PagingAndSortingRepository<\/em>.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\"brush:java\">@Repository\npublic interface EmployeeRepository extends PagingAndSortingRepository&lt;Employee, Long&gt; {\n \n    Page&lt;Employee&gt; findAll(Pageable pageable);\n \n    Page&lt;Employee&gt; findByFirstName(String firstName, Pageable pageable);\n \n    Slice&lt;Employee&gt; findByFirstNameAndLastName(String firstName, String lastName, Pageable pageable);\n}\n<\/pre>\n<h3 class=\"wp-block-heading\">4 Pagination<\/h3>\n<p>Have a look at the <em>EmployeeRepository<\/em>, the method accepts <em>Pageable<\/em> arguments. Pageable is an interface defined by Spring which holds a <em>Page<\/em> request. Let\u2019s see how to create a Page Request.<\/p>\n<pre class=\"brush:java\">Pageable pageable = PageRequest.of(0, 10);\nPage&lt;Employee&gt; page = employeeRepository.findAll(pageable);\n<\/pre>\n<p>In the first line we created a Page request of 10 employees and asked for first (0) page. The page request the passed to <em>findAll<\/em> to get a Page of Employees as response.<\/p>\n<p>If we want to access next set of subsequent pages we can increase the page number every time.<\/p>\n<pre class=\"brush:bash\">PageRequest.of(1, 10);\nPageRequest.of(2, 10);\nPageRequest.of(3, 10);\n...\n<\/pre>\n<h3 class=\"wp-block-heading\">5 Sorting<\/h3>\n<p>The <strong>Spring Data JPA<\/strong> provides a <em>Sort<\/em> object in order to provide a sorting mechanism. Lets have a look at the ways of sorting.<\/p>\n<pre class=\"brush:java\">employeeRepository.findAll(Sort.by(\"fistName\"));\n \nemployeeRepository.findAll(Sort.by(\"fistName\").ascending().and(Sort.by(\"lastName\").descending());\n<\/pre>\n<p>Obviously, the first one simply sorts by \u2018firstName\u2019 and the other one sorts by \u2018firstName\u2019 ascending and \u2018lastName\u2019 descending.<\/p>\n<p><strong>Pagination and Sort together<\/strong><\/p>\n<pre class=\"brush:java\">Pageable pageable = PageRequest.of(0, 20, Sort.by(\"firstName\"));\n        \n        \nPageable pageable = PageRequest.of(0, 20, Sort.by(\"fistName\").ascending().and(Sort.by(\"lastName\").descending());\n<\/pre>\n<h3 class=\"wp-block-heading\">6 Slice vs Page<\/h3>\n<p>In the <em>EmployeeRepository<\/em> we saw one of the method returns <em>Slice<\/em> and the other returns <em>Page<\/em>. Both of them are <strong>Spring&nbsp;Data&nbsp;JPA<\/strong>, where <em>Page<\/em> is a sub-interface of <em>Slice<\/em>. Both of them are used to hold and return a subset of data. Let\u2019s have a look at them one by one<\/p>\n<p><strong>Slice<\/strong><\/p>\n<p>The <em>Slice<\/em> knows if it has content, if it is first or the last slice. It is also capable of returning <em>Pageable<\/em> used in the current and previous slices. Lets have a look at some important methods of <em>Slice<\/em>.<\/p>\n<pre class=\"brush:java\">List&lt;T&gt; getContent(); \/\/ get content of the slice\n \nPageable getPageable(); \/\/ get current pageable\n \nboolean hasContent(); \n \nboolean isFirst();\n \nboolean isLast();\n \nPageable nextPageable(); \/\/ pageable of the next slice\n \nPageable previousPageable(); \/\/ pageable of the previous slice\n<\/pre>\n<p><strong>Page<\/strong><\/p>\n<p>The <em>Page<\/em> is a sub-interface of <em>Slice<\/em> and has couple of additional methods. It knows the number of total pages in the table as well as total number of records. Below are some important methods from <em>Page<\/em>.<\/p>\n<pre class=\"brush:java\">static &lt;T&gt; Page&lt;T&gt; empty; \/\/create an empty page\n \nlong getTotalElements(); \/\/ number of total elements in the table\n \nint totalPages() \/\/ number of total pages in the table\n<\/pre>\n<h3 class=\"wp-block-heading\">7 Summary<\/h3>\n<p>In this <strong>Pagination and Sorting with Spring Data JPA<\/strong> article we learnt why pagination is required. We learnt how to get paginated as well as sorted subsets of data. We have also seen the <em>Slice<\/em> and <em>Page<\/em> interfaces and their differences.<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>Published on Java Code Geeks with permission by Amit Phaltankar, partner at our <a href=\"\/\/www.javacodegeeks.com\/join-us\/jcg\/\" target=\"_blank\" rel=\"noopener\">JCG program<\/a>. See the original article here: <a href=\"http:\/\/www.amitph.com\/pagination-sorting-spring-data-jpa\/\" target=\"_blank\" rel=\"noopener\">Pagination and Sorting with Spring Data JPA<\/a><\/p>\n<p>Opinions expressed by Java Code Geeks contributors are their own.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Learn Pagination and Sorting with Spring Data JPA with code examples. Understand how to get Paginated and Sorted results using Springs PagingAndSortingRepository interface. 1 Overview While dealing with large amount of data the lazy processing is often essential. Even if a service returns a huge amount of data the consumer is less likely using it. &hellip;<\/p>\n","protected":false},"author":75543,"featured_media":112,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[33,321],"class_list":["post-88230","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-jpa","tag-spring-data"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Pagination and Sorting with Spring Data JPA - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Interested to learn about Pagination and Sorting? Check our article explaining how to get Paginated and Sorted results using Springs interface\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2019\/02\/pagination-sorting-spring-data-jpa.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Pagination and Sorting with Spring Data JPA - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Interested to learn about Pagination and Sorting? Check our article explaining how to get Paginated and Sorted results using Springs interface\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2019\/02\/pagination-sorting-spring-data-jpa.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/amit.ph01\" \/>\n<meta property=\"article:published_time\" content=\"2019-02-12T11:00:03+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-02-18T12:16:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Amit Phaltankar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@amitrph\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Amit Phaltankar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/02\\\/pagination-sorting-spring-data-jpa.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/02\\\/pagination-sorting-spring-data-jpa.html\"},\"author\":{\"name\":\"Amit Phaltankar\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/11579ea8a790900129c1010a304fe1a9\"},\"headline\":\"Pagination and Sorting with Spring Data JPA\",\"datePublished\":\"2019-02-12T11:00:03+00:00\",\"dateModified\":\"2019-02-18T12:16:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/02\\\/pagination-sorting-spring-data-jpa.html\"},\"wordCount\":595,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/02\\\/pagination-sorting-spring-data-jpa.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"keywords\":[\"JPA\",\"Spring Data\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/02\\\/pagination-sorting-spring-data-jpa.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/02\\\/pagination-sorting-spring-data-jpa.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/02\\\/pagination-sorting-spring-data-jpa.html\",\"name\":\"Pagination and Sorting with Spring Data JPA - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/02\\\/pagination-sorting-spring-data-jpa.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/02\\\/pagination-sorting-spring-data-jpa.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"datePublished\":\"2019-02-12T11:00:03+00:00\",\"dateModified\":\"2019-02-18T12:16:55+00:00\",\"description\":\"Interested to learn about Pagination and Sorting? Check our article explaining how to get Paginated and Sorted results using Springs interface\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/02\\\/pagination-sorting-spring-data-jpa.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/02\\\/pagination-sorting-spring-data-jpa.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/02\\\/pagination-sorting-spring-data-jpa.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"java-interview-questions-answers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/02\\\/pagination-sorting-spring-data-jpa.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Pagination and Sorting with Spring Data JPA\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/11579ea8a790900129c1010a304fe1a9\",\"name\":\"Amit Phaltankar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/414fb2f44cac7c1d28c9f0e9f0532036dc1bb60eda56a77c0285459f1dea8df8?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/414fb2f44cac7c1d28c9f0e9f0532036dc1bb60eda56a77c0285459f1dea8df8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/414fb2f44cac7c1d28c9f0e9f0532036dc1bb60eda56a77c0285459f1dea8df8?s=96&d=mm&r=g\",\"caption\":\"Amit Phaltankar\"},\"description\":\"Amit Phaltankar is a Technology enthusiast who has huge passion for sharing what he knows. Amit works as a Java Technology Lead and has huge experience in Programming, Unit Testing, OOAD, Functional Programming, Big Data Technologies, micro-services, and Databases.\",\"sameAs\":[\"http:\\\/\\\/www.amitph.com\\\/\",\"https:\\\/\\\/www.facebook.com\\\/amit.ph01\",\"https:\\\/\\\/au.linkedin.com\\\/in\\\/amitph\",\"https:\\\/\\\/x.com\\\/amitrph\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/amit-phaltankar\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Pagination and Sorting with Spring Data JPA - Java Code Geeks","description":"Interested to learn about Pagination and Sorting? Check our article explaining how to get Paginated and Sorted results using Springs interface","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2019\/02\/pagination-sorting-spring-data-jpa.html","og_locale":"en_US","og_type":"article","og_title":"Pagination and Sorting with Spring Data JPA - Java Code Geeks","og_description":"Interested to learn about Pagination and Sorting? Check our article explaining how to get Paginated and Sorted results using Springs interface","og_url":"https:\/\/www.javacodegeeks.com\/2019\/02\/pagination-sorting-spring-data-jpa.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_author":"https:\/\/www.facebook.com\/amit.ph01","article_published_time":"2019-02-12T11:00:03+00:00","article_modified_time":"2019-02-18T12:16:55+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","type":"image\/jpeg"}],"author":"Amit Phaltankar","twitter_card":"summary_large_image","twitter_creator":"@amitrph","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Amit Phaltankar","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2019\/02\/pagination-sorting-spring-data-jpa.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/02\/pagination-sorting-spring-data-jpa.html"},"author":{"name":"Amit Phaltankar","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/11579ea8a790900129c1010a304fe1a9"},"headline":"Pagination and Sorting with Spring Data JPA","datePublished":"2019-02-12T11:00:03+00:00","dateModified":"2019-02-18T12:16:55+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/02\/pagination-sorting-spring-data-jpa.html"},"wordCount":595,"commentCount":2,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/02\/pagination-sorting-spring-data-jpa.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","keywords":["JPA","Spring Data"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2019\/02\/pagination-sorting-spring-data-jpa.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2019\/02\/pagination-sorting-spring-data-jpa.html","url":"https:\/\/www.javacodegeeks.com\/2019\/02\/pagination-sorting-spring-data-jpa.html","name":"Pagination and Sorting with Spring Data JPA - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/02\/pagination-sorting-spring-data-jpa.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/02\/pagination-sorting-spring-data-jpa.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","datePublished":"2019-02-12T11:00:03+00:00","dateModified":"2019-02-18T12:16:55+00:00","description":"Interested to learn about Pagination and Sorting? Check our article explaining how to get Paginated and Sorted results using Springs interface","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/02\/pagination-sorting-spring-data-jpa.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2019\/02\/pagination-sorting-spring-data-jpa.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2019\/02\/pagination-sorting-spring-data-jpa.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","width":150,"height":150,"caption":"java-interview-questions-answers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2019\/02\/pagination-sorting-spring-data-jpa.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Pagination and Sorting with Spring Data JPA"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/11579ea8a790900129c1010a304fe1a9","name":"Amit Phaltankar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/414fb2f44cac7c1d28c9f0e9f0532036dc1bb60eda56a77c0285459f1dea8df8?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/414fb2f44cac7c1d28c9f0e9f0532036dc1bb60eda56a77c0285459f1dea8df8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/414fb2f44cac7c1d28c9f0e9f0532036dc1bb60eda56a77c0285459f1dea8df8?s=96&d=mm&r=g","caption":"Amit Phaltankar"},"description":"Amit Phaltankar is a Technology enthusiast who has huge passion for sharing what he knows. Amit works as a Java Technology Lead and has huge experience in Programming, Unit Testing, OOAD, Functional Programming, Big Data Technologies, micro-services, and Databases.","sameAs":["http:\/\/www.amitph.com\/","https:\/\/www.facebook.com\/amit.ph01","https:\/\/au.linkedin.com\/in\/amitph","https:\/\/x.com\/amitrph"],"url":"https:\/\/www.javacodegeeks.com\/author\/amit-phaltankar"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/88230","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/75543"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=88230"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/88230\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/112"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=88230"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=88230"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=88230"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}