title: Why this loop only save in DB the last em.persist()?
body: <pre><code>                   for (long i = 0; i &lt; 12; i++) {
                      t.setnewerDate(sql);  
                      em.persist(t);
                      sql = new java.sql.Date( sql.getTime() + 24*60*60*1000);
                      System.out.println(sql); 
                     }
                  em.flush();
                  em.getTransaction().commit();
                  em.close();
  </code></pre>
  
  <p>Any idea of how could I save diferent "t" objects 12 times?</p>
  
  <p>Thanks in advance ;)</p>
  
  <p>This either works:</p>
  
  <pre><code> tx.begin();
                  tres t = new tres();
                  for (long i = 0; i &lt; diffDays+1; i++) {
                  t.setnwerDate(sql);  
                  em.persist(t);
                  sql = new java.sql.Date( sql.getTime() + 24*60*60*1000);
                  System.out.println(sql);
                  em.flush();
                  tx.commit();
                  tx.begin();
  
              }
  </code></pre>