Multiple choice technology programming languages

batch fetching is useful incase of ?

  1. a) lazy="true"

  2. b) lazy="false"

  3. c) lazy="on"

  4. d) lazy="off"

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Batch fetching in Hibernate is specifically useful when lazy loading is enabled (lazy="true"). It allows Hibernate to load multiple lazy associations in batches rather than one at a time, reducing the number of database queries and improving performance.

AI explanation

Batch fetching is a Hibernate optimization that applies when associations are lazily loaded (lazy="true"): instead of issuing one SQL SELECT per proxy/collection as each is accessed, Hibernate groups several pending lazy loads together and fetches them in a single batch query (controlled by the batch-size attribute), reducing the N+1 select problem. If lazy loading is turned off (lazy="false"), the data is fetched eagerly upfront via a join, so there's no lazy-load queue for batch fetching to optimize — the 'on'/'off' options aren't valid Hibernate mapping values for the lazy attribute at all.