0
0
Spring Bootframework~10 mins

Why JPA matters for database access in Spring Boot - Test Your Understanding

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

Complete the code to declare a JPA repository interface.

Spring Boot
public interface UserRepository extends [1]<User, Long> {}
Drag options to blanks, or click blank then click option'
AList
BService
CJpaRepository
DComponent
Attempts:
3 left
💡 Hint
Common Mistakes
Using List instead of JpaRepository
Using Service or Component which are unrelated
2fill in blank
medium

Complete the code to annotate an entity class for JPA.

Spring Boot
@[1]
public class Product {
  @Id
  private Long id;
}
Drag options to blanks, or click blank then click option'
AComponent
BRepository
CService
DEntity
Attempts:
3 left
💡 Hint
Common Mistakes
Using @Component or @Service instead of @Entity
Forgetting @Entity causes no table mapping
3fill in blank
hard

Fix the error in the repository method to find by name.

Spring Boot
List<User> findBy[1](String name);
Drag options to blanks, or click blank then click option'
AName
Bname
Cusername
DNameIgnoreCase
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'name' instead of 'Name'
Using unrelated field names
4fill in blank
hard

Complete the code to create a JPA query method that finds products cheaper than a price.

Spring Boot
List<Product> findByPrice[1](Double price);
Drag options to blanks, or click blank then click option'
ALessThan
BGreaterThan
C, Pageable pageable
Attempts:
3 left
💡 Hint
Common Mistakes
Using GreaterThan instead of LessThan
Adding unnecessary parameters
5fill in blank
hard

Fill all three blanks to write a JPA query method that finds users by email containing a keyword and orders by id descending.

Spring Boot
List<User> findByEmail[1][2]OrderById[3](String keyword);
Drag options to blanks, or click blank then click option'
AContaining
BAsc
CDesc
DIgnoreCase
Attempts:
3 left
💡 Hint
Common Mistakes
Using Asc instead of Desc for ordering
Forgetting IgnoreCase for case-insensitive search