0
0
Spring Bootframework~10 mins

Pagination and sorting with Pageable in Spring Boot - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the Pageable interface for pagination.

Spring Boot
import org.springframework.data.domain.[1];
Drag options to blanks, or click blank then click option'
APage
BPageable
CSort
DPageRequest
Attempts:
3 left
💡 Hint
Common Mistakes
Importing Page instead of Pageable
Importing Sort which is for sorting, not pagination
Importing PageRequest which is a class, not the interface
2fill in blank
medium

Complete the method signature to accept pagination and sorting parameters using Pageable.

Spring Boot
public Page<User> getUsers([1] pageable) {
Drag options to blanks, or click blank then click option'
APageRequest
BSort
CPageable
DPage
Attempts:
3 left
💡 Hint
Common Mistakes
Using PageRequest as parameter type instead of Pageable
Using Sort which only handles sorting
Using Page which is a return type, not parameter
3fill in blank
hard

Fix the error in the repository method to support pagination.

Spring Boot
Page<User> findAll([1] pageable);
Drag options to blanks, or click blank then click option'
APageable
BSort
CList
DPageRequest
Attempts:
3 left
💡 Hint
Common Mistakes
Using PageRequest which is a class, not interface
Using Sort which is only for sorting
Using List which does not support pagination
4fill in blank
hard

Fill both blanks to create a PageRequest with page number 0 and size 10 sorted by 'name' ascending.

Spring Boot
PageRequest [1] = PageRequest.[2](0, 10, Sort.by("name").ascending());
Drag options to blanks, or click blank then click option'
ApageRequest
Bof
Ccreate
Dbuild
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'create' or 'build' instead of 'of' method
Using variable names that don't follow camelCase
5fill in blank
hard

Fill all three blanks to return a paged and sorted list of users by calling repository with pageable.

Spring Boot
Page<User> users = userRepository.[1]([2]); return users.[3]();
Drag options to blanks, or click blank then click option'
AfindAll
BpageRequest
CgetContent
DfindById
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'findById' which returns a single entity
Calling 'getContent' on repository instead of Page object
Passing wrong variable instead of pageable