code: public static void rollbackQuietly(EntityManager entityManager) {
          if (entityManager.getTransaction().isActive()/* && entityManager.getTransaction().getRollbackOnly()*/) {
              try {
                  entityManager.getTransaction().rollback();
              } catch (Exception e) {
                  logger.error(e.getMessage(), e);
              }
          }
      }
docs: Rolls back a transaction.  Tries to be smart and quiet about it.
  @param entityManager the entity manager