entity manager, you need to demarcate your transaction boundaries through the EntityTransaction API. You can get an
This
EntityTransaction API provides the regular begin(), commit(), rollback() and isActive() methods. It also provide a way to mark a transaction as rollback only, ie force the transaction to rollback. This is very similar to the JTA operation setRollbackOnly(). When a commit() operation fail and/or if the transaction is marked as
setRollbackOnly(), the
commit() method will try to rollback the transaction and raise a
javax.transaction.RollbackException.
In a JTA environment, you don't need any extra API to interact with the transaction in your environment. Simply use transaction declaration or the JTA APIs.
In a JTA entity manager, entityManager.getTransaction() calls are not permitted.