InterviewSolution
Saved Bookmarks
| 1. |
Can you tell something about the N+1 SELECT problem in Hibernate? |
|
Answer» N+1 SELECT problem is due to the result of using lazy loading and on-demand fetching STRATEGY. Let's take an example. If you have an N items list and each item from the list has a DEPENDENCY on a collection of another object, say bid. In order to FIND the highest bid for each item while using the lazy loading strategy, hibernate has to first fire 1 query to load all items and then subsequently fire N QUERIES to load big of each item. HENCE, hibernate actually ends up executing N+1 queries. |
|