QuizzesJpaRepository & CrudRepository — Concept Check
intermediate
spring-boot

JpaRepository & CrudRepository — Concept Check

Questions on JpaRepository & CrudRepository. JpaRepository extends PagingAndSortingRepository adding flush, batch-delete, and JPA-specific bulk operations on top of basic CRUD.

8 minutes 8 questions Pass at 70%
Time Limit
8 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

8 questions on JpaRepository & CrudRepository — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.A developer needs to perform a batch delete operation on a list of orders. Which JpaRepository method should they use?

    • AdeleteAll(orders)
    • BdeleteById(orders)
    • CdeleteAllInBatch(orders)
    • Ddelete(orders)
  2. 2.In a Spring Boot application, a service method annotated with @Transactional is used to save an order. What will happen if the save operation fails?

    • AThe transaction will roll back
    • BThe transaction will commit partially
    • CThe transaction will ignore the failure
    • DThe transaction will retry automatically
  3. 3.A developer wants to retrieve all orders with a status of 'PENDING' and sort them by creation date in descending order. Which method should they use?

    • AfindByStatusAndSortByCreatedAt
    • BfindAllByStatusOrderByCreatedAtAsc
    • CfindByStatusOrderByCreatedAtDesc
    • DfindAllSortedByCreatedAtDesc
  4. 4.Which method would you use to check if an order with a specific ID exists in the database using JpaRepository?

    • AcheckById(id)
    • BfindById(id)
    • CcountById(id)
    • DexistsById(id)
  5. 5.A developer mistakenly believes that JpaRepository's findAll() method automatically sorts the results. What is the correct understanding?

    • AfindAll() sorts results by ID
    • BfindAll() sorts results alphabetically
    • CfindAll() returns unsorted results
    • DfindAll() sorts results by creation date
  6. 6.When using derived query methods, what will happen if a method name is incorrectly specified?

    • AThe method will return null
    • BThe application will crash
    • CA runtime error will occur
    • DThe method will execute with default settings
  7. 7.A developer wants to retrieve orders placed by a specific customer using pagination. Which method should they use?

    • AfindByCustomerId(Long customerId, Pageable pageable)
    • BfindByCustomerIdWithPagination(Long customerId)
    • CfindOrdersByCustomerId(Long customerId)
    • DfindAllByCustomerId(Long customerId)
  8. 8.What is a benefit of using projections in Spring Data JPA?

    • AEnsures all fields are fetched
    • BIncreases database load
    • CReduces memory and serialization overhead
    • DAutomatically updates entities