public int searchCount(
      long companyId,
      String keywords,
      Boolean configured,
      Long paymentMethodId,
      boolean withPermissionCheck)
      throws SystemException {

    Session session = null;

    SQLQuery q = null;

    try {
      session = openSession();

      q =
          buildSearchQuery(
              session,
              companyId,
              keywords,
              configured,
              paymentMethodId,
              null,
              true,
              withPermissionCheck);

      Iterator<Long> itr = q.list().iterator();

      if (itr.hasNext()) {
        Long count = itr.next();

        if (count != null) {
          return count.intValue();
        }
      }

      return 0;

    } catch (Exception e) {
      if (q != null) _log.error("Query failed : " + q.toString());

      throw new SystemException(e);

    } finally {
      closeSession(session);
    }
  }
  public List<PaymentPlugin> search(
      long companyId,
      String keywords,
      Boolean configured,
      Long paymentMethodId,
      int start,
      int end,
      OrderByComparator obc,
      boolean withPermissionCheck)
      throws SystemException {

    Session session = null;

    SQLQuery q = null;

    try {
      session = openSession();

      q =
          buildSearchQuery(
              session,
              companyId,
              keywords,
              configured,
              paymentMethodId,
              obc,
              false,
              withPermissionCheck);

      return (List<PaymentPlugin>) QueryUtil.list(q, getDialect(), start, end);

    } catch (Exception e) {
      if (q != null) _log.error("Query failed : " + q.toString());

      throw new SystemException(e);

    } finally {
      closeSession(session);
    }
  }