Multiple choice technology packaged enterprise solutions

If instances are not in the session or second-level cache which will give better performance?

  1. Query.list()

  2. Query.iterate()

  3. Both are same

  4. None of the above

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

When instances are not cached, Query.iterate() can cause the N+1 select problem - it issues one query for the initial list and then additional queries for each uninitialized object proxy. Query.list() loads all data in a single query, making it more efficient for uncached data.