Pagination & Sorting in REST API using Spring Data JPA

Поделиться
HTML-код
  • Опубликовано: 4 окт 2024
  • Learn how to add pagination & sorting to your Spring Boot REST API using Spring Data JPA.
    We create a web application using the spring starter (start.spring.io/). We then expose an API for books. We then use Spring Data JPA to add pagination & sorting to the API.
    Check out the code on GitHub here: github.com/kri...
    Don't forget to Subscribe here: / @krisfoster1

Комментарии • 25

  • @FedericoPedemonte
    @FedericoPedemonte 2 года назад +7

    Nice tutorial, thank you! I just had to add "spring.jpa.defer-datasource-initialization=true" in application.properties in order to make it work with Spring Boot 2.6.3

    • @hillcountrydev
      @hillcountrydev 2 года назад +1

      thanks! I just spent the last 30 mins on stack over flow and I thought... "well now let me just check the comment section" haha. Good job.

  • @themrsupermanto
    @themrsupermanto 7 месяцев назад

    Wow, thank you so much. Paginating with spring boot seems a lot easier than in Node, even with Prisma ORM.

  • @sinurao1017
    @sinurao1017 3 года назад +3

    sweet and simple example to start with this concept, Hope you can cover complex with multiple table example

  • @HenrryWith2Rs
    @HenrryWith2Rs 2 года назад +1

    This was absolutely perfect. Exactly what I was looking for.

  • @xixReact
    @xixReact Год назад +1

    hey mate, thanks so much! This video was excellent, very clear and concise

  • @KaizokuOuOre
    @KaizokuOuOre 3 года назад

    I gotta commend you on your choice of books!! Awesome video too :)

  • @DaniilDenisov-ws5ov
    @DaniilDenisov-ws5ov 3 года назад +1

    That was very helpful for me! Thanks a lot!

  • @alanflynn3612
    @alanflynn3612 3 года назад

    Excellent well done Kris

  • @AfricanThinker86
    @AfricanThinker86 8 месяцев назад

    How would you make it so the getBooks method could be sorted in both descending or ascending order?

  • @michellecarter648
    @michellecarter648 2 года назад

    Great tutorial! Thank you.

  • @billionaires8123
    @billionaires8123 2 года назад

    Thank you this was a great tutorial and helped me a lot

    • @billionaires8123
      @billionaires8123 2 года назад

      How do you see what does the method accepts in 8:11

  • @gameplays997
    @gameplays997 2 года назад +1

    Thank you, that was helpful :)

  • @HorukTaras
    @HorukTaras 2 года назад +1

    Awesome video. Thanks!

    • @KrisFoster1
      @KrisFoster1  2 года назад +1

      Glad you enjoyed, thank you for watching!

  • @Nickel-W
    @Nickel-W 3 года назад

    Thank you, very helpful for me

  • @shubhammondal2803
    @shubhammondal2803 3 года назад

    Thank you, that was helpful.

  • @waldemarjankowski4090
    @waldemarjankowski4090 2 года назад

    Can you show example how to do pagination with Pageable as parameter of controller?

  • @TheSdoWn
    @TheSdoWn 3 года назад

    10:24 is there a way to customize what data that pageable return? for example only content, pageNumber and pageSize

  • @meshmuhammad6927
    @meshmuhammad6927 3 года назад

    I like your accent.

  • @JunxHead
    @JunxHead 2 года назад

    how can i custom the respon of this
    "pageable": {
    "sort": {
    "empty": true,
    "sorted": false,
    "unsorted": true
    },
    "offset": 4,
    "pageSize": 4,
    "pageNumber": 1,
    "unpaged": false,
    "paged": true
    },
    "last": true,
    "totalPages": 2,
    "totalElements": 8,
    "size": 4,
    "number": 1,
    "sort": {
    "empty": true,
    "sorted": false,
    "unsorted": true
    },
    "numberOfElements": 4,
    "first": false,
    "empty": false
    }

  • @chips4real1
    @chips4real1 2 года назад

    I assume if i have another Requestparameter i can set how many items we get per page right?

    • @danielmethner6847
      @danielmethner6847 2 года назад

      He showed that in the video...

    • @alexizhernandez8011
      @alexizhernandez8011 2 года назад

      Yes. He didn't actually show how to do that in the video but you can do it. You would need another Optional maybe called size or count. Then you would pass that in where he put the hardcoded 5. That 5 was the number he set for count as a default with no option to change it.