title: Why would the size of a looped list decrease in another class?
body: <p>I connected to a database and printed a list of results from a query, after a loop. Three records were returned as expected and stored in a variable.</p>
  <p>Now, I tried to use that variable containing the three records in another class, however, only one of the records in the looped list was printed in that new class. The first two records were missing. Only the last one remained. Why would the size of a looped list decrease when called in another class?</p>
  <pre><code> @Data
   public class ClassA{
   Crud crud = new Crud();
   static EntityManager entityManager;
   private String dbDemo;
      
      
   public void myMethodOne() {
   entityManager = crud.begin();
   Query query =
   entityManager.createQuery(&quot;select b from Table b order by b.createdDateTime desc&quot;).setMaxResults(3); // give me three records
      
        
    List&lt;EntityClass&gt; queryResultlist = query.getResultList();
    for (EntityClass resultRow : queryResultlist) {
    dbDemo = resultRow.getId();
    System.out.println(dbDemo);
    }
    }
  </code></pre>
  <p>Output:</p>
  <p>Test1
  Test2
  Test3</p>
  <pre><code>public class ClassB{
  
  ClassA ca = new ClassA();
   
   public void verifyMyMethodTwo() {
   ca.myMethodOne();
   System.out.println(ca.dbDemo());
      
    }
  
  }
  </code></pre>
  <p>Output:</p>
  <pre><code>Test3
  </code></pre>