batch fetching is useful incase of ?
-
a) lazy="true"
-
b) lazy="false"
-
c) lazy="on"
-
d) lazy="off"
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.
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.