title: JPA - When to use getTransaction() when persisting objects
body: <p>I've recently started working with JPA on the Google App Engine. In reading some examples, I've noticed a couple of variations in the way objects are persisted. In one case, I've seen something like this:</p>
  
  <pre class="lang-java prettyprint-override"><code>entityManager.getTransaction().begin();
  entityManager.persist(object);
  entityManager.getTransaction().commit();
  </code></pre>
  
  <p>In other cases, I don't see the use of <code>getTransaction()</code>. I simply see <code>entityManager.persist(object)</code>. When is it appropriate to use <code>getTransaction()</code>?</p>