9.7.6. Roll Back a Transaction
Before you can roll back a transaction, it must have been begun. For information about beginning a transaction, see Section 9.7.3, “Begin a Transaction”.
Call
UserTransaction.rollback().When you call methodUserTransaction.rollback(), the Transaction Manager attempts to roll back the transaction.... UserTransaction.rollback(); catch (Exception ex) { ex.printStackTrace(); System.exit(0); }If you are using an EJB, you do not need to manually roll back.
If you use an EJB, you do not need to callrollback(), because the container handles the transaction lifecycle.
Your transaction is rolled back by the Transaction Manager.
Note

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.