Demo: projections for paged listings
On This Lesson 3 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
build the paged, filtered product list; prepares JNR-029-LAB1.
Draft outline details
Step by step
- Define
ProductListItem(id, name, price, category name). - Write one
@Querywith optional name, category, and price-range filters and aPageableparameter. - Call it from the service with
PageRequest.of(page, size, Sort.by("name")). - Planned mistake: return the entity from the controller; show the extra columns and lazy-loading trouble, then switch to the projection.
- Check the SQL log: only the listed columns are selected, plus a count query.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.