Code
try {
this.em.getTransaction().begin();
// JPA tasks
this.em.getTransaction().commit();
LOGGER.info("All good");
} catch (Exception e) {
LOGGER.warning("Oeps Exception");
this.em.getTransaction().rollback();
}
Support
Transaction rolled back because transaction was set to RollbackOnly.
This is caused when you commit a transaction that was not successful. Just use the rollback function in your catch block in order to restore the transaction.