title: How to fetch lazy attributes in collection of entities, by not doing N calls to database
body: <p>How to fetch lazy attributes in collection of entities, by not doing N calls to database. Example:</p>
  
  <pre class="lang-java prettyprint-override"><code>transactions = getTransactionsBySomeCriteriaApiQuery(..); // n transactions
  // this make 3*n calls to DB, I want to do only a few calls
  transactions.forEach(res -&gt; {
    res.getLazyCollection1().size();
    res.getLazyCollection2().size();
    res.getLazyCollection3().size();
  });
  return transactions;
  </code></pre>
  
  <p>Assume n is big number.
  I would like to know if it is possible to fetch that lazy data by not making huge amount of calls to DB. I am using JPA (eclipselink), relational database.</p>
  
  <p><strong>EDIT</strong>: Indeed it is N+1 selects problem, and i would like to know how it can be resolved in eclipselink. Note that I do not want to change entity mappings from lazy to eager, because it is needed in other places. I have tried to use fetch joins (fetch on criteriaAPI), but this not working when used more than one.</p>