title: Batch Insert with JTA (EntityManager cannot use getTransaction)
body: <p>I'm working in a project with spring data and apache camel, we have 2 databases, Sql Server and Oracle with JTA. The problem arises because I need to insert data from a large file (about 10000000 records), so I decided to do using batch insert as:</p>
  
  <pre><code>@PersistenceContext(unitName="persistenceUnitSql")
  EntityManager em;
  
  public void insertBatch() {
      em.getTransaction().begin();
      for (int i = 1; i &lt;= 1000000; i++) {
        Point point = new Point(i, i);
        em.persist(point);
        if ((i % 10000) == 0) {
            em.getTransaction().commit();
            em.clear();          
            em.getTransaction().begin();
        }
      }
      em.getTransaction().commit();
  }
  </code></pre>
  
  <p>but this problem happened:</p>
  
  <pre><code>    A JTA EntityManager cannot use getTransaction()
  </code></pre>
  
  <p>Any help...</p>