title: JPA : insert and delete object in same transaction
body: <p>I want to insert an object into database in a transaction and after that object is saved in the database, I'd like to delete that it once a specific operation is done. Can I restart the transaction again and perform deletion and then commit? Is this a correct way of doing it?</p>
  
  <p>Example : </p>
  
  <pre><code>Employee employee = new Employee();
  String name = "Ronnie";
  entityManager.getTransaction.begin();
  employee.setName(name);
  entityManager.persist(employee);
  entityManager.getTransaction.commit();
  
  //After few steps
  
  entityManager.getTransaction.begin();
  entityManager.remove(employee);
  entityManager.getTransaction.commit();
  </code></pre>