QuizzesEntity Graphs — Concept Check
intermediate
hibernate

Entity Graphs — Concept Check

Questions on Entity Graphs. @EntityGraph specifies which associations to load for a specific query without changing the mapping's default fetch type; load hints override EAGER/LAZY per query.

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 Entity Graphs — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.You have a Spring Data JPA repository method that needs to fetch an Order with its customer and items eagerly. Which approach should you use?

    • ASet fetch type to EAGER in the entity
    • BUse @EntityGraph with a named graph
    • CUse a native SQL query with JOIN
    • DUse JOIN FETCH in a custom query
  2. 2.A developer notices that a query with JOIN FETCH is causing memory issues during pagination. What is likely happening?

    • AJOIN FETCH doesn't support eager loading
    • BJOIN FETCH loads all rows before paginating
    • CJOIN FETCH causes N+1 problem
    • DJOIN FETCH ignores entity mappings
  3. 3.What is the role of @NamedEntityGraph in JPA?

    • ASpecifies lazy loading for all associations
    • BOverrides default fetch type globally
    • CDefines reusable entity graphs on an entity
    • DAutomatically optimizes query performance
  4. 4.A service uses an ad-hoc entity graph with GraphType.FETCH. What is the behavior for unlisted associations?

    • AThey are treated as EAGER
    • BThey are ignored in the query
    • CThey use default mapping
    • DThey are treated as LAZY
  5. 5.Why might a developer choose @EntityGraph over JOIN FETCH for a Spring Data JPA method?

    • A@EntityGraph supports pagination
    • BJOIN FETCH doesn't support eager loading
    • CJOIN FETCH is faster
    • D@EntityGraph is easier to write
  6. 6.A developer uses @EntityGraph with attributePaths set to 'customer' and 'items.product'. What happens if 'items' is not listed?

    • A'items' is ignored completely
    • B'items' is loaded lazily
    • C'items' causes a query error
    • D'items' is eagerly loaded by default
  7. 7.What is a potential issue when using JOIN FETCH with multiple bag collections?

    • AIt can cause a Cartesian product
    • BIt does not support eager loading
    • CIt automatically optimizes queries
    • DIt only fetches one collection
  8. 8.A developer wants to load only the customer association eagerly for an Order entity. Which named entity graph should they use?

    • AOrder.defaultGraph
    • BOrder.withCustomerAndItems
    • COrder.withCustomerOnly
    • DOrder.lazyLoadGraph