code: public static boolean isCompleted(Transaction tx)
     {
        if (tx == null)
           return true;
        
        try
        {
           int status = tx.getStatus();
  
           return status == Status.STATUS_COMMITTED ||
              status == Status.STATUS_ROLLEDBACK ||
              status == Status.STATUS_NO_TRANSACTION;
        }
        catch (SystemException error)
        {
           throw new RuntimeException("Error during isCompleted()", error);
        }
     }
docs: Is the transaction completed
  @param tx The transaction
  @return True if completed; otherwise false