Example usage for com.liferay.portal.kernel.util StringPool OPEN_PARENTHESIS

List of usage examples for com.liferay.portal.kernel.util StringPool OPEN_PARENTHESIS

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util StringPool OPEN_PARENTHESIS.

Prototype

String OPEN_PARENTHESIS

To view the source code for com.liferay.portal.kernel.util StringPool OPEN_PARENTHESIS.

Click Source Link

Usage

From source file:org.opencps.usermgt.service.persistence.EmployeePersistenceImpl.java

License:Open Source License

/**
 * Returns the number of employees where groupId = ? and fullName LIKE any ?.
 *
 * @param groupId the group ID/*from  w  w w.j  a  va 2 s . c o m*/
 * @param fullNames the full names
 * @return the number of matching employees
 * @throws SystemException if a system exception occurred
 */
@Override
public int countByG_N(long groupId, String[] fullNames) throws SystemException {
    Object[] finderArgs = new Object[] { groupId, StringUtil.merge(fullNames) };

    Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_N, finderArgs, this);

    if (count == null) {
        StringBundler query = new StringBundler();

        query.append(_SQL_COUNT_EMPLOYEE_WHERE);

        boolean conjunctionable = false;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_G_N_GROUPID_5);

        conjunctionable = true;

        if ((fullNames == null) || (fullNames.length > 0)) {
            if (conjunctionable) {
                query.append(WHERE_AND);
            }

            query.append(StringPool.OPEN_PARENTHESIS);

            for (int i = 0; i < fullNames.length; i++) {
                String fullName = fullNames[i];

                if (fullName == null) {
                    query.append(_FINDER_COLUMN_G_N_FULLNAME_4);
                } else if (fullName.equals(StringPool.BLANK)) {
                    query.append(_FINDER_COLUMN_G_N_FULLNAME_6);
                } else {
                    query.append(_FINDER_COLUMN_G_N_FULLNAME_5);
                }

                if ((i + 1) < fullNames.length) {
                    query.append(WHERE_OR);
                }
            }

            query.append(StringPool.CLOSE_PARENTHESIS);

            conjunctionable = true;
        }

        String sql = query.toString();

        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(sql);

            QueryPos qPos = QueryPos.getInstance(q);

            qPos.add(groupId);

            if (fullNames != null) {
                qPos.add(fullNames);
            }

            count = (Long) q.uniqueResult();

            FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_N, finderArgs, count);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_N, finderArgs);

            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    return count.intValue();
}

From source file:org.opencps.usermgt.service.persistence.EmployeePersistenceImpl.java

License:Open Source License

/**
 * Returns the number of employees that the user has permission to view where groupId = &#63; and fullName LIKE any &#63;.
 *
 * @param groupId the group ID//from   w  ww  . j a v  a 2 s  . co m
 * @param fullNames the full names
 * @return the number of matching employees that the user has permission to view
 * @throws SystemException if a system exception occurred
 */
@Override
public int filterCountByG_N(long groupId, String[] fullNames) throws SystemException {
    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
        return countByG_N(groupId, fullNames);
    }

    StringBundler query = new StringBundler();

    query.append(_FILTER_SQL_COUNT_EMPLOYEE_WHERE);

    boolean conjunctionable = false;

    if (conjunctionable) {
        query.append(WHERE_AND);
    }

    query.append(_FINDER_COLUMN_G_N_GROUPID_5);

    conjunctionable = true;

    if ((fullNames == null) || (fullNames.length > 0)) {
        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(StringPool.OPEN_PARENTHESIS);

        for (int i = 0; i < fullNames.length; i++) {
            String fullName = fullNames[i];

            if (fullName == null) {
                query.append(_FINDER_COLUMN_G_N_FULLNAME_4);
            } else if (fullName.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_G_N_FULLNAME_6);
            } else {
                query.append(_FINDER_COLUMN_G_N_FULLNAME_5);
            }

            if ((i + 1) < fullNames.length) {
                query.append(WHERE_OR);
            }
        }

        query.append(StringPool.CLOSE_PARENTHESIS);

        conjunctionable = true;
    }

    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), Employee.class.getName(),
            _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);

    Session session = null;

    try {
        session = openSession();

        SQLQuery q = session.createSQLQuery(sql);

        q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(groupId);

        if (fullNames != null) {
            qPos.add(fullNames);
        }

        Long count = (Long) q.uniqueResult();

        return count.intValue();
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}

From source file:tj.izvewenija.service.persistence.impl.IzvewenijaPersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the izvewenijas that the user has permission to view where companyId = &#63; and groupId = &#63; and sostojanie_id = any &#63; and status_id = any &#63;.
 *
 * <p>/*from   w w w. ja  va2s .  c  o m*/
 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link IzvewenijaModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
 * </p>
 *
 * @param companyId the company ID
 * @param groupId the group ID
 * @param sostojanie_ids the sostojanie_ids
 * @param status_ids the status_ids
 * @param start the lower bound of the range of izvewenijas
 * @param end the upper bound of the range of izvewenijas (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of matching izvewenijas that the user has permission to view
 */
@Override
public List<Izvewenija> filterFindByCompanyIdGroupIdSostojanieIdStatusId(long companyId, long groupId,
        long[] sostojanie_ids, long[] status_ids, int start, int end,
        OrderByComparator<Izvewenija> orderByComparator) {
    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
        return findByCompanyIdGroupIdSostojanieIdStatusId(companyId, groupId, sostojanie_ids, status_ids, start,
                end, orderByComparator);
    }

    if (sostojanie_ids == null) {
        sostojanie_ids = new long[0];
    } else if (sostojanie_ids.length > 1) {
        sostojanie_ids = ArrayUtil.unique(sostojanie_ids);

        Arrays.sort(sostojanie_ids);
    }

    if (status_ids == null) {
        status_ids = new long[0];
    } else if (status_ids.length > 1) {
        status_ids = ArrayUtil.unique(status_ids);

        Arrays.sort(status_ids);
    }

    StringBundler query = new StringBundler();

    if (getDB().isSupportsInlineDistinct()) {
        query.append(_FILTER_SQL_SELECT_IZVEWENIJA_WHERE);
    } else {
        query.append(_FILTER_SQL_SELECT_IZVEWENIJA_NO_INLINE_DISTINCT_WHERE_1);
    }

    query.append(_FINDER_COLUMN_COMPANYIDGROUPIDSOSTOJANIEIDSTATUSID_COMPANYID_2);

    query.append(_FINDER_COLUMN_COMPANYIDGROUPIDSOSTOJANIEIDSTATUSID_GROUPID_2);

    if (sostojanie_ids.length > 0) {
        query.append(StringPool.OPEN_PARENTHESIS);

        query.append(_FINDER_COLUMN_COMPANYIDGROUPIDSOSTOJANIEIDSTATUSID_SOSTOJANIE_ID_7);

        query.append(StringUtil.merge(sostojanie_ids));

        query.append(StringPool.CLOSE_PARENTHESIS);

        query.append(StringPool.CLOSE_PARENTHESIS);

        query.append(WHERE_AND);
    }

    if (status_ids.length > 0) {
        query.append(StringPool.OPEN_PARENTHESIS);

        query.append(_FINDER_COLUMN_COMPANYIDGROUPIDSOSTOJANIEIDSTATUSID_STATUS_ID_7);

        query.append(StringUtil.merge(status_ids));

        query.append(StringPool.CLOSE_PARENTHESIS);

        query.append(StringPool.CLOSE_PARENTHESIS);
    }

    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1);

    if (!getDB().isSupportsInlineDistinct()) {
        query.append(_FILTER_SQL_SELECT_IZVEWENIJA_NO_INLINE_DISTINCT_WHERE_2);
    }

    if (orderByComparator != null) {
        if (getDB().isSupportsInlineDistinct()) {
            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true);
        } else {
            appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
        }
    } else {
        if (getDB().isSupportsInlineDistinct()) {
            query.append(IzvewenijaModelImpl.ORDER_BY_JPQL);
        } else {
            query.append(IzvewenijaModelImpl.ORDER_BY_SQL);
        }
    }

    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), Izvewenija.class.getName(),
            _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);

    Session session = null;

    try {
        session = openSession();

        SQLQuery q = session.createSynchronizedSQLQuery(sql);

        if (getDB().isSupportsInlineDistinct()) {
            q.addEntity(_FILTER_ENTITY_ALIAS, IzvewenijaImpl.class);
        } else {
            q.addEntity(_FILTER_ENTITY_TABLE, IzvewenijaImpl.class);
        }

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(companyId);

        qPos.add(groupId);

        return (List<Izvewenija>) QueryUtil.list(q, getDialect(), start, end);
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}

From source file:tj.izvewenija.service.persistence.impl.IzvewenijaPersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the izvewenijas where companyId = &#63; and groupId = &#63; and sostojanie_id = &#63; and status_id = &#63;, optionally using the finder cache.
 *
 * <p>// ww w  . java 2 s . c o  m
 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link IzvewenijaModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
 * </p>
 *
 * @param companyId the company ID
 * @param groupId the group ID
 * @param sostojanie_id the sostojanie_id
 * @param status_id the status_id
 * @param start the lower bound of the range of izvewenijas
 * @param end the upper bound of the range of izvewenijas (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @param retrieveFromCache whether to retrieve from the finder cache
 * @return the ordered range of matching izvewenijas
 */
@Override
public List<Izvewenija> findByCompanyIdGroupIdSostojanieIdStatusId(long companyId, long groupId,
        long[] sostojanie_ids, long[] status_ids, int start, int end,
        OrderByComparator<Izvewenija> orderByComparator, boolean retrieveFromCache) {
    if (sostojanie_ids == null) {
        sostojanie_ids = new long[0];
    } else if (sostojanie_ids.length > 1) {
        sostojanie_ids = ArrayUtil.unique(sostojanie_ids);

        Arrays.sort(sostojanie_ids);
    }

    if (status_ids == null) {
        status_ids = new long[0];
    } else if (status_ids.length > 1) {
        status_ids = ArrayUtil.unique(status_ids);

        Arrays.sort(status_ids);
    }

    if ((sostojanie_ids.length == 1) && (status_ids.length == 1)) {
        return findByCompanyIdGroupIdSostojanieIdStatusId(companyId, groupId, sostojanie_ids[0], status_ids[0],
                start, end, orderByComparator);
    }

    boolean pagination = true;
    Object[] finderArgs = null;

    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) {
        pagination = false;
        finderArgs = new Object[] { companyId, groupId, StringUtil.merge(sostojanie_ids),
                StringUtil.merge(status_ids) };
    } else {
        finderArgs = new Object[] { companyId, groupId, StringUtil.merge(sostojanie_ids),
                StringUtil.merge(status_ids),

                start, end, orderByComparator };
    }

    List<Izvewenija> list = null;

    if (retrieveFromCache) {
        list = (List<Izvewenija>) finderCache.getResult(
                FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYIDGROUPIDSOSTOJANIEIDSTATUSID, finderArgs, this);

        if ((list != null) && !list.isEmpty()) {
            for (Izvewenija izvewenija : list) {
                if ((companyId != izvewenija.getCompanyId()) || (groupId != izvewenija.getGroupId())
                        || !ArrayUtil.contains(sostojanie_ids, izvewenija.getSostojanie_id())
                        || !ArrayUtil.contains(status_ids, izvewenija.getStatus_id())) {
                    list = null;

                    break;
                }
            }
        }
    }

    if (list == null) {
        StringBundler query = new StringBundler();

        query.append(_SQL_SELECT_IZVEWENIJA_WHERE);

        query.append(_FINDER_COLUMN_COMPANYIDGROUPIDSOSTOJANIEIDSTATUSID_COMPANYID_2);

        query.append(_FINDER_COLUMN_COMPANYIDGROUPIDSOSTOJANIEIDSTATUSID_GROUPID_2);

        if (sostojanie_ids.length > 0) {
            query.append(StringPool.OPEN_PARENTHESIS);

            query.append(_FINDER_COLUMN_COMPANYIDGROUPIDSOSTOJANIEIDSTATUSID_SOSTOJANIE_ID_7);

            query.append(StringUtil.merge(sostojanie_ids));

            query.append(StringPool.CLOSE_PARENTHESIS);

            query.append(StringPool.CLOSE_PARENTHESIS);

            query.append(WHERE_AND);
        }

        if (status_ids.length > 0) {
            query.append(StringPool.OPEN_PARENTHESIS);

            query.append(_FINDER_COLUMN_COMPANYIDGROUPIDSOSTOJANIEIDSTATUSID_STATUS_ID_7);

            query.append(StringUtil.merge(status_ids));

            query.append(StringPool.CLOSE_PARENTHESIS);

            query.append(StringPool.CLOSE_PARENTHESIS);
        }

        query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1);

        if (orderByComparator != null) {
            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
        } else if (pagination) {
            query.append(IzvewenijaModelImpl.ORDER_BY_JPQL);
        }

        String sql = query.toString();

        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(sql);

            QueryPos qPos = QueryPos.getInstance(q);

            qPos.add(companyId);

            qPos.add(groupId);

            if (!pagination) {
                list = (List<Izvewenija>) QueryUtil.list(q, getDialect(), start, end, false);

                Collections.sort(list);

                list = Collections.unmodifiableList(list);
            } else {
                list = (List<Izvewenija>) QueryUtil.list(q, getDialect(), start, end);
            }

            cacheResult(list);

            finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYIDGROUPIDSOSTOJANIEIDSTATUSID,
                    finderArgs, list);
        } catch (Exception e) {
            finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYIDGROUPIDSOSTOJANIEIDSTATUSID,
                    finderArgs);

            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    return list;
}

From source file:tj.izvewenija.service.persistence.impl.IzvewenijaPersistenceImpl.java

License:Open Source License

/**
 * Returns the number of izvewenijas where companyId = &#63; and groupId = &#63; and sostojanie_id = any &#63; and status_id = any &#63;.
 *
 * @param companyId the company ID//from  w  ww .  java2 s . c o m
 * @param groupId the group ID
 * @param sostojanie_ids the sostojanie_ids
 * @param status_ids the status_ids
 * @return the number of matching izvewenijas
 */
@Override
public int countByCompanyIdGroupIdSostojanieIdStatusId(long companyId, long groupId, long[] sostojanie_ids,
        long[] status_ids) {
    if (sostojanie_ids == null) {
        sostojanie_ids = new long[0];
    } else if (sostojanie_ids.length > 1) {
        sostojanie_ids = ArrayUtil.unique(sostojanie_ids);

        Arrays.sort(sostojanie_ids);
    }

    if (status_ids == null) {
        status_ids = new long[0];
    } else if (status_ids.length > 1) {
        status_ids = ArrayUtil.unique(status_ids);

        Arrays.sort(status_ids);
    }

    Object[] finderArgs = new Object[] { companyId, groupId, StringUtil.merge(sostojanie_ids),
            StringUtil.merge(status_ids) };

    Long count = (Long) finderCache.getResult(
            FINDER_PATH_WITH_PAGINATION_COUNT_BY_COMPANYIDGROUPIDSOSTOJANIEIDSTATUSID, finderArgs, this);

    if (count == null) {
        StringBundler query = new StringBundler();

        query.append(_SQL_COUNT_IZVEWENIJA_WHERE);

        query.append(_FINDER_COLUMN_COMPANYIDGROUPIDSOSTOJANIEIDSTATUSID_COMPANYID_2);

        query.append(_FINDER_COLUMN_COMPANYIDGROUPIDSOSTOJANIEIDSTATUSID_GROUPID_2);

        if (sostojanie_ids.length > 0) {
            query.append(StringPool.OPEN_PARENTHESIS);

            query.append(_FINDER_COLUMN_COMPANYIDGROUPIDSOSTOJANIEIDSTATUSID_SOSTOJANIE_ID_7);

            query.append(StringUtil.merge(sostojanie_ids));

            query.append(StringPool.CLOSE_PARENTHESIS);

            query.append(StringPool.CLOSE_PARENTHESIS);

            query.append(WHERE_AND);
        }

        if (status_ids.length > 0) {
            query.append(StringPool.OPEN_PARENTHESIS);

            query.append(_FINDER_COLUMN_COMPANYIDGROUPIDSOSTOJANIEIDSTATUSID_STATUS_ID_7);

            query.append(StringUtil.merge(status_ids));

            query.append(StringPool.CLOSE_PARENTHESIS);

            query.append(StringPool.CLOSE_PARENTHESIS);
        }

        query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1);

        String sql = query.toString();

        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(sql);

            QueryPos qPos = QueryPos.getInstance(q);

            qPos.add(companyId);

            qPos.add(groupId);

            count = (Long) q.uniqueResult();

            finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_COMPANYIDGROUPIDSOSTOJANIEIDSTATUSID,
                    finderArgs, count);
        } catch (Exception e) {
            finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_COMPANYIDGROUPIDSOSTOJANIEIDSTATUSID,
                    finderArgs);

            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    return count.intValue();
}

From source file:tj.izvewenija.service.persistence.impl.IzvewenijaPersistenceImpl.java

License:Open Source License

/**
 * Returns the number of izvewenijas that the user has permission to view where companyId = &#63; and groupId = &#63; and sostojanie_id = any &#63; and status_id = any &#63;.
 *
 * @param companyId the company ID/*from ww  w.  j  av a2s .c  o m*/
 * @param groupId the group ID
 * @param sostojanie_ids the sostojanie_ids
 * @param status_ids the status_ids
 * @return the number of matching izvewenijas that the user has permission to view
 */
@Override
public int filterCountByCompanyIdGroupIdSostojanieIdStatusId(long companyId, long groupId,
        long[] sostojanie_ids, long[] status_ids) {
    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
        return countByCompanyIdGroupIdSostojanieIdStatusId(companyId, groupId, sostojanie_ids, status_ids);
    }

    if (sostojanie_ids == null) {
        sostojanie_ids = new long[0];
    } else if (sostojanie_ids.length > 1) {
        sostojanie_ids = ArrayUtil.unique(sostojanie_ids);

        Arrays.sort(sostojanie_ids);
    }

    if (status_ids == null) {
        status_ids = new long[0];
    } else if (status_ids.length > 1) {
        status_ids = ArrayUtil.unique(status_ids);

        Arrays.sort(status_ids);
    }

    StringBundler query = new StringBundler();

    query.append(_FILTER_SQL_COUNT_IZVEWENIJA_WHERE);

    query.append(_FINDER_COLUMN_COMPANYIDGROUPIDSOSTOJANIEIDSTATUSID_COMPANYID_2);

    query.append(_FINDER_COLUMN_COMPANYIDGROUPIDSOSTOJANIEIDSTATUSID_GROUPID_2);

    if (sostojanie_ids.length > 0) {
        query.append(StringPool.OPEN_PARENTHESIS);

        query.append(_FINDER_COLUMN_COMPANYIDGROUPIDSOSTOJANIEIDSTATUSID_SOSTOJANIE_ID_7);

        query.append(StringUtil.merge(sostojanie_ids));

        query.append(StringPool.CLOSE_PARENTHESIS);

        query.append(StringPool.CLOSE_PARENTHESIS);

        query.append(WHERE_AND);
    }

    if (status_ids.length > 0) {
        query.append(StringPool.OPEN_PARENTHESIS);

        query.append(_FINDER_COLUMN_COMPANYIDGROUPIDSOSTOJANIEIDSTATUSID_STATUS_ID_7);

        query.append(StringUtil.merge(status_ids));

        query.append(StringPool.CLOSE_PARENTHESIS);

        query.append(StringPool.CLOSE_PARENTHESIS);
    }

    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1);

    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), Izvewenija.class.getName(),
            _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);

    Session session = null;

    try {
        session = openSession();

        SQLQuery q = session.createSynchronizedSQLQuery(sql);

        q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(companyId);

        qPos.add(groupId);

        Long count = (Long) q.uniqueResult();

        return count.intValue();
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}