code: public static boolean beginOrJoinTransaction()
     {
        boolean newTransaction = false;
        try {
           newTransaction = userTransaction.getStatus() == Status.STATUS_NO_TRANSACTION;
           if (newTransaction) {
              userTransaction.begin();
           }
        }
        catch (Exception e) {
           throw new RuntimeException("Unable to start transaction.", e);
        }
  
        return newTransaction;
     }
docs: Start or join a transaction.
  
  @return true if a new transaction was started (this means the caller "owns"
  the commit()), false if a transaction was joined.