0
0
Spring Bootframework~10 mins

JpaRepository interface 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 declare a repository interface that extends JpaRepository.

Spring Boot
public interface UserRepository extends [1]<User, Long> {}
Drag options to blanks, or click blank then click option'
ARepository
BCrudRepository
CJpaRepository
DService
Attempts:
3 left
💡 Hint
Common Mistakes
Using CrudRepository instead of JpaRepository loses some JPA-specific features.
Using Repository directly does not provide method implementations.
2fill in blank
medium

Complete the code to add a method that finds users by their email in the repository interface.

Spring Boot
List<User> findBy[1](String email);
Drag options to blanks, or click blank then click option'
AId
BName
CUsername
DEmail
Attempts:
3 left
💡 Hint
Common Mistakes
Using a field name that does not exist in the entity.
Not capitalizing the first letter of the field in the method name.
3fill in blank
hard

Fix the error in the repository method declaration to correctly find users by status.

Spring Boot
List<User> findByStatus[1](String status);
Drag options to blanks, or click blank then click option'
AWith
BIs
CBy
DEquals
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'By' after 'findByStatus' is redundant and causes errors.
Using 'With' is not recognized by Spring Data JPA.
4fill in blank
hard

Complete the code to create a repository method that finds users with age greater than a value.

Spring Boot
List<User> findByAge[1](int age);
Drag options to blanks, or click blank then click option'
AGreaterThan
BLessThan
C, Pageable pageable
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'LessThan' instead of 'GreaterThan' changes the query logic.
Adding Pageable parameter when not needed.
5fill in blank
hard

Fill all three blanks to define a repository method that finds users by last name and orders by first name ascending.

Spring Boot
List<User> findBy[1]OrderBy[2][3](String lastName);
Drag options to blanks, or click blank then click option'
ALastName
BFirstName
CAsc
DDesc
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Desc' instead of 'Asc' changes the order direction.
Mixing up the filter and order fields.