title: how to commit a transaction in EJB?
body: <p>I have the following scenario,</p>
  
  <pre><code>public void someEjbMethod1()
  {
      for (int i=0; i=10; i++)
      {
          em.merge(arr[i]);
          em.flush();
      }
  }
  </code></pre>
  
  <p>I need to merge each object of (<code>arr[i]</code>) separately. as the above code will commit all the <code>arr[i]</code> instances at the end of the function.</p>
  
  <p>I am thinking to do the following:</p>
  
  <pre><code>public void someEjbMethod1()
  {
      for (int i=0; i=10; i++)
      {
          saveObj(arr[i]);
      }
  }
  
  // should I use a transaction attribute here??
  public void saveObj(SomeObject obj)
  {
      em.merge(arr[i]);
      em.flush();
  }
  </code></pre>