Example usage for com.liferay.portal.kernel.dao.orm QueryUtil list

List of usage examples for com.liferay.portal.kernel.dao.orm QueryUtil list

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.dao.orm QueryUtil list.

Prototype

public static List<?> list(Query query, Dialect dialect, int start, int end, boolean unmodifiable) 

Source Link

Usage

From source file:br.com.prodevelopment.lapidarios.evento.service.persistence.EventoAgendaPersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the evento agendas where companyId = &#63; and groupId = &#63; and status = &#63;.
 *
 * <p>/*  w w w . j a  v a 2 s .c  om*/
 * 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 com.liferay.portal.kernel.dao.orm.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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link br.com.prodevelopment.lapidarios.evento.model.impl.EventoAgendaModelImpl}. 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 status the status
 * @param start the lower bound of the range of evento agendas
 * @param end the upper bound of the range of evento agendas (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of matching evento agendas
 * @throws SystemException if a system exception occurred
 */
@Override
public List<EventoAgenda> findByCG(long companyId, long groupId, int status, int start, int end,
        OrderByComparator orderByComparator) throws SystemException {
    boolean pagination = true;
    FinderPath finderPath = null;
    Object[] finderArgs = null;

    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) {
        pagination = false;
        finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CG;
        finderArgs = new Object[] { companyId, groupId, status };
    } else {
        finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_CG;
        finderArgs = new Object[] { companyId, groupId, status,

                start, end, orderByComparator };
    }

    List<EventoAgenda> list = (List<EventoAgenda>) FinderCacheUtil.getResult(finderPath, finderArgs, this);

    if ((list != null) && !list.isEmpty()) {
        for (EventoAgenda eventoAgenda : list) {
            if ((companyId != eventoAgenda.getCompanyId()) || (groupId != eventoAgenda.getGroupId())
                    || (status != eventoAgenda.getStatus())) {
                list = null;

                break;
            }
        }
    }

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

        if (orderByComparator != null) {
            query = new StringBundler(5 + (orderByComparator.getOrderByFields().length * 3));
        } else {
            query = new StringBundler(5);
        }

        query.append(_SQL_SELECT_EVENTOAGENDA_WHERE);

        query.append(_FINDER_COLUMN_CG_COMPANYID_2);

        query.append(_FINDER_COLUMN_CG_GROUPID_2);

        query.append(_FINDER_COLUMN_CG_STATUS_2);

        if (orderByComparator != null) {
            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
        } else if (pagination) {
            query.append(EventoAgendaModelImpl.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);

            qPos.add(status);

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

                Collections.sort(list);

                list = new UnmodifiableList<EventoAgenda>(list);
            } else {
                list = (List<EventoAgenda>) QueryUtil.list(q, getDialect(), start, end);
            }

            cacheResult(list);

            FinderCacheUtil.putResult(finderPath, finderArgs, list);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(finderPath, finderArgs);

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

    return list;
}

From source file:br.com.prodevelopment.lapidarios.evento.service.persistence.EventoAgendaPersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the evento agendas where companyId = &#63; and groupId = &#63; and status = any &#63;.
 *
 * <p>/*  w  w w  .j  a  v a 2s. 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 com.liferay.portal.kernel.dao.orm.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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link br.com.prodevelopment.lapidarios.evento.model.impl.EventoAgendaModelImpl}. 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 statuses the statuses
 * @param start the lower bound of the range of evento agendas
 * @param end the upper bound of the range of evento agendas (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of matching evento agendas
 * @throws SystemException if a system exception occurred
 */
@Override
public List<EventoAgenda> findByCG(long companyId, long groupId, int[] statuses, int start, int end,
        OrderByComparator orderByComparator) throws SystemException {
    if ((statuses != null) && (statuses.length == 1)) {
        return findByCG(companyId, groupId, statuses[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(statuses) };
    } else {
        finderArgs = new Object[] { companyId, groupId, StringUtil.merge(statuses),

                start, end, orderByComparator };
    }

    List<EventoAgenda> list = (List<EventoAgenda>) FinderCacheUtil
            .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG, finderArgs, this);

    if ((list != null) && !list.isEmpty()) {
        for (EventoAgenda eventoAgenda : list) {
            if ((companyId != eventoAgenda.getCompanyId()) || (groupId != eventoAgenda.getGroupId())
                    || !ArrayUtil.contains(statuses, eventoAgenda.getStatus())) {
                list = null;

                break;
            }
        }
    }

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

        query.append(_SQL_SELECT_EVENTOAGENDA_WHERE);

        boolean conjunctionable = false;

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

        query.append(_FINDER_COLUMN_CG_COMPANYID_5);

        conjunctionable = true;

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

        query.append(_FINDER_COLUMN_CG_GROUPID_5);

        conjunctionable = true;

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

            query.append(StringPool.OPEN_PARENTHESIS);

            for (int i = 0; i < statuses.length; i++) {
                query.append(_FINDER_COLUMN_CG_STATUS_5);

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

            query.append(StringPool.CLOSE_PARENTHESIS);

            conjunctionable = true;
        }

        if (orderByComparator != null) {
            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
        } else if (pagination) {
            query.append(EventoAgendaModelImpl.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 (statuses != null) {
                qPos.add(statuses);
            }

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

                Collections.sort(list);

                list = new UnmodifiableList<EventoAgenda>(list);
            } else {
                list = (List<EventoAgenda>) QueryUtil.list(q, getDialect(), start, end);
            }

            cacheResult(list);

            FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG, finderArgs, list);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG, finderArgs);

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

    return list;
}

From source file:br.com.prodevelopment.lapidarios.evento.service.persistence.EventoAgendaPersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the evento agendas where companyId = &#63; and groupId = &#63; and dataEvento = &#63; and status = &#63;.
 *
 * <p>//from   ww w .  j  a  va 2s .  com
 * 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 com.liferay.portal.kernel.dao.orm.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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link br.com.prodevelopment.lapidarios.evento.model.impl.EventoAgendaModelImpl}. 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 dataEvento the data evento
 * @param status the status
 * @param start the lower bound of the range of evento agendas
 * @param end the upper bound of the range of evento agendas (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of matching evento agendas
 * @throws SystemException if a system exception occurred
 */
@Override
public List<EventoAgenda> findByCG_Data(long companyId, long groupId, Date dataEvento, int status, int start,
        int end, OrderByComparator orderByComparator) throws SystemException {
    boolean pagination = true;
    FinderPath finderPath = null;
    Object[] finderArgs = null;

    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) {
        pagination = false;
        finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CG_DATA;
        finderArgs = new Object[] { companyId, groupId, dataEvento, status };
    } else {
        finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_DATA;
        finderArgs = new Object[] { companyId, groupId, dataEvento, status,

                start, end, orderByComparator };
    }

    List<EventoAgenda> list = (List<EventoAgenda>) FinderCacheUtil.getResult(finderPath, finderArgs, this);

    if ((list != null) && !list.isEmpty()) {
        for (EventoAgenda eventoAgenda : list) {
            if ((companyId != eventoAgenda.getCompanyId()) || (groupId != eventoAgenda.getGroupId())
                    || !Validator.equals(dataEvento, eventoAgenda.getDataEvento())
                    || (status != eventoAgenda.getStatus())) {
                list = null;

                break;
            }
        }
    }

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

        if (orderByComparator != null) {
            query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 3));
        } else {
            query = new StringBundler(6);
        }

        query.append(_SQL_SELECT_EVENTOAGENDA_WHERE);

        query.append(_FINDER_COLUMN_CG_DATA_COMPANYID_2);

        query.append(_FINDER_COLUMN_CG_DATA_GROUPID_2);

        boolean bindDataEvento = false;

        if (dataEvento == null) {
            query.append(_FINDER_COLUMN_CG_DATA_DATAEVENTO_1);
        } else {
            bindDataEvento = true;

            query.append(_FINDER_COLUMN_CG_DATA_DATAEVENTO_2);
        }

        query.append(_FINDER_COLUMN_CG_DATA_STATUS_2);

        if (orderByComparator != null) {
            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
        } else if (pagination) {
            query.append(EventoAgendaModelImpl.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 (bindDataEvento) {
                qPos.add(CalendarUtil.getTimestamp(dataEvento));
            }

            qPos.add(status);

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

                Collections.sort(list);

                list = new UnmodifiableList<EventoAgenda>(list);
            } else {
                list = (List<EventoAgenda>) QueryUtil.list(q, getDialect(), start, end);
            }

            cacheResult(list);

            FinderCacheUtil.putResult(finderPath, finderArgs, list);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(finderPath, finderArgs);

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

    return list;
}

From source file:br.com.prodevelopment.lapidarios.evento.service.persistence.EventoAgendaPersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the evento agendas where companyId = &#63; and groupId = &#63; and dataEvento = &#63; and status = any &#63;.
 *
 * <p>/*from ww  w .j av a  2  s  . c om*/
 * 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 com.liferay.portal.kernel.dao.orm.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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link br.com.prodevelopment.lapidarios.evento.model.impl.EventoAgendaModelImpl}. 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 dataEvento the data evento
 * @param statuses the statuses
 * @param start the lower bound of the range of evento agendas
 * @param end the upper bound of the range of evento agendas (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of matching evento agendas
 * @throws SystemException if a system exception occurred
 */
@Override
public List<EventoAgenda> findByCG_Data(long companyId, long groupId, Date dataEvento, int[] statuses,
        int start, int end, OrderByComparator orderByComparator) throws SystemException {
    if ((statuses != null) && (statuses.length == 1)) {
        return findByCG_Data(companyId, groupId, dataEvento, statuses[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, dataEvento, StringUtil.merge(statuses) };
    } else {
        finderArgs = new Object[] { companyId, groupId, dataEvento, StringUtil.merge(statuses),

                start, end, orderByComparator };
    }

    List<EventoAgenda> list = (List<EventoAgenda>) FinderCacheUtil
            .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_DATA, finderArgs, this);

    if ((list != null) && !list.isEmpty()) {
        for (EventoAgenda eventoAgenda : list) {
            if ((companyId != eventoAgenda.getCompanyId()) || (groupId != eventoAgenda.getGroupId())
                    || !Validator.equals(dataEvento, eventoAgenda.getDataEvento())
                    || !ArrayUtil.contains(statuses, eventoAgenda.getStatus())) {
                list = null;

                break;
            }
        }
    }

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

        query.append(_SQL_SELECT_EVENTOAGENDA_WHERE);

        boolean conjunctionable = false;

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

        query.append(_FINDER_COLUMN_CG_DATA_COMPANYID_5);

        conjunctionable = true;

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

        query.append(_FINDER_COLUMN_CG_DATA_GROUPID_5);

        conjunctionable = true;

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

        boolean bindDataEvento = false;

        if (dataEvento == null) {
            query.append(_FINDER_COLUMN_CG_DATA_DATAEVENTO_4);
        } else {
            bindDataEvento = true;

            query.append(_FINDER_COLUMN_CG_DATA_DATAEVENTO_5);
        }

        conjunctionable = true;

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

            query.append(StringPool.OPEN_PARENTHESIS);

            for (int i = 0; i < statuses.length; i++) {
                query.append(_FINDER_COLUMN_CG_DATA_STATUS_5);

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

            query.append(StringPool.CLOSE_PARENTHESIS);

            conjunctionable = true;
        }

        if (orderByComparator != null) {
            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
        } else if (pagination) {
            query.append(EventoAgendaModelImpl.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 (bindDataEvento) {
                qPos.add(CalendarUtil.getTimestamp(dataEvento));
            }

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

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

                Collections.sort(list);

                list = new UnmodifiableList<EventoAgenda>(list);
            } else {
                list = (List<EventoAgenda>) QueryUtil.list(q, getDialect(), start, end);
            }

            cacheResult(list);

            FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_DATA, finderArgs, list);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_DATA, finderArgs);

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

    return list;
}

From source file:br.com.prodevelopment.lapidarios.evento.service.persistence.EventoAgendaPersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the evento agendas where companyId = &#63; and groupId = &#63; and eventoId = &#63; and dataEvento = &#63; and status = &#63;.
 *
 * <p>//from w  w w.ja  v  a  2s  .  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 com.liferay.portal.kernel.dao.orm.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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link br.com.prodevelopment.lapidarios.evento.model.impl.EventoAgendaModelImpl}. 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 eventoId the evento ID
 * @param dataEvento the data evento
 * @param status the status
 * @param start the lower bound of the range of evento agendas
 * @param end the upper bound of the range of evento agendas (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of matching evento agendas
 * @throws SystemException if a system exception occurred
 */
@Override
public List<EventoAgenda> findByCG_Evento_Data(long companyId, long groupId, long eventoId, Date dataEvento,
        int status, int start, int end, OrderByComparator orderByComparator) throws SystemException {
    boolean pagination = true;
    FinderPath finderPath = null;
    Object[] finderArgs = null;

    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) {
        pagination = false;
        finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CG_EVENTO_DATA;
        finderArgs = new Object[] { companyId, groupId, eventoId, dataEvento, status };
    } else {
        finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_EVENTO_DATA;
        finderArgs = new Object[] { companyId, groupId, eventoId, dataEvento, status,

                start, end, orderByComparator };
    }

    List<EventoAgenda> list = (List<EventoAgenda>) FinderCacheUtil.getResult(finderPath, finderArgs, this);

    if ((list != null) && !list.isEmpty()) {
        for (EventoAgenda eventoAgenda : list) {
            if ((companyId != eventoAgenda.getCompanyId()) || (groupId != eventoAgenda.getGroupId())
                    || (eventoId != eventoAgenda.getEventoId())
                    || !Validator.equals(dataEvento, eventoAgenda.getDataEvento())
                    || (status != eventoAgenda.getStatus())) {
                list = null;

                break;
            }
        }
    }

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

        if (orderByComparator != null) {
            query = new StringBundler(7 + (orderByComparator.getOrderByFields().length * 3));
        } else {
            query = new StringBundler(7);
        }

        query.append(_SQL_SELECT_EVENTOAGENDA_WHERE);

        query.append(_FINDER_COLUMN_CG_EVENTO_DATA_COMPANYID_2);

        query.append(_FINDER_COLUMN_CG_EVENTO_DATA_GROUPID_2);

        query.append(_FINDER_COLUMN_CG_EVENTO_DATA_EVENTOID_2);

        boolean bindDataEvento = false;

        if (dataEvento == null) {
            query.append(_FINDER_COLUMN_CG_EVENTO_DATA_DATAEVENTO_1);
        } else {
            bindDataEvento = true;

            query.append(_FINDER_COLUMN_CG_EVENTO_DATA_DATAEVENTO_2);
        }

        query.append(_FINDER_COLUMN_CG_EVENTO_DATA_STATUS_2);

        if (orderByComparator != null) {
            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
        } else if (pagination) {
            query.append(EventoAgendaModelImpl.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);

            qPos.add(eventoId);

            if (bindDataEvento) {
                qPos.add(CalendarUtil.getTimestamp(dataEvento));
            }

            qPos.add(status);

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

                Collections.sort(list);

                list = new UnmodifiableList<EventoAgenda>(list);
            } else {
                list = (List<EventoAgenda>) QueryUtil.list(q, getDialect(), start, end);
            }

            cacheResult(list);

            FinderCacheUtil.putResult(finderPath, finderArgs, list);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(finderPath, finderArgs);

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

    return list;
}

From source file:br.com.prodevelopment.lapidarios.evento.service.persistence.EventoAgendaPersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the evento agendas where companyId = &#63; and groupId = &#63; and eventoId = &#63; and dataEvento = &#63; and status = any &#63;.
 *
 * <p>// ww w  .j  a  v a  2s. 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 com.liferay.portal.kernel.dao.orm.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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link br.com.prodevelopment.lapidarios.evento.model.impl.EventoAgendaModelImpl}. 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 eventoId the evento ID
 * @param dataEvento the data evento
 * @param statuses the statuses
 * @param start the lower bound of the range of evento agendas
 * @param end the upper bound of the range of evento agendas (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of matching evento agendas
 * @throws SystemException if a system exception occurred
 */
@Override
public List<EventoAgenda> findByCG_Evento_Data(long companyId, long groupId, long eventoId, Date dataEvento,
        int[] statuses, int start, int end, OrderByComparator orderByComparator) throws SystemException {
    if ((statuses != null) && (statuses.length == 1)) {
        return findByCG_Evento_Data(companyId, groupId, eventoId, dataEvento, statuses[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, eventoId, dataEvento, StringUtil.merge(statuses) };
    } else {
        finderArgs = new Object[] { companyId, groupId, eventoId, dataEvento, StringUtil.merge(statuses),

                start, end, orderByComparator };
    }

    List<EventoAgenda> list = (List<EventoAgenda>) FinderCacheUtil
            .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_EVENTO_DATA, finderArgs, this);

    if ((list != null) && !list.isEmpty()) {
        for (EventoAgenda eventoAgenda : list) {
            if ((companyId != eventoAgenda.getCompanyId()) || (groupId != eventoAgenda.getGroupId())
                    || (eventoId != eventoAgenda.getEventoId())
                    || !Validator.equals(dataEvento, eventoAgenda.getDataEvento())
                    || !ArrayUtil.contains(statuses, eventoAgenda.getStatus())) {
                list = null;

                break;
            }
        }
    }

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

        query.append(_SQL_SELECT_EVENTOAGENDA_WHERE);

        boolean conjunctionable = false;

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

        query.append(_FINDER_COLUMN_CG_EVENTO_DATA_COMPANYID_5);

        conjunctionable = true;

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

        query.append(_FINDER_COLUMN_CG_EVENTO_DATA_GROUPID_5);

        conjunctionable = true;

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

        query.append(_FINDER_COLUMN_CG_EVENTO_DATA_EVENTOID_5);

        conjunctionable = true;

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

        boolean bindDataEvento = false;

        if (dataEvento == null) {
            query.append(_FINDER_COLUMN_CG_EVENTO_DATA_DATAEVENTO_4);
        } else {
            bindDataEvento = true;

            query.append(_FINDER_COLUMN_CG_EVENTO_DATA_DATAEVENTO_5);
        }

        conjunctionable = true;

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

            query.append(StringPool.OPEN_PARENTHESIS);

            for (int i = 0; i < statuses.length; i++) {
                query.append(_FINDER_COLUMN_CG_EVENTO_DATA_STATUS_5);

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

            query.append(StringPool.CLOSE_PARENTHESIS);

            conjunctionable = true;
        }

        if (orderByComparator != null) {
            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
        } else if (pagination) {
            query.append(EventoAgendaModelImpl.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);

            qPos.add(eventoId);

            if (bindDataEvento) {
                qPos.add(CalendarUtil.getTimestamp(dataEvento));
            }

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

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

                Collections.sort(list);

                list = new UnmodifiableList<EventoAgenda>(list);
            } else {
                list = (List<EventoAgenda>) QueryUtil.list(q, getDialect(), start, end);
            }

            cacheResult(list);

            FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_EVENTO_DATA, finderArgs, list);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_EVENTO_DATA, finderArgs);

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

    return list;
}

From source file:br.com.prodevelopment.lapidarios.evento.service.persistence.EventoAgendaPersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the evento agendas where companyId = &#63; and groupId = &#63; and eventoNome LIKE &#63; and status = &#63;.
 *
 * <p>// w  ww .j av a 2s.com
 * 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 com.liferay.portal.kernel.dao.orm.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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link br.com.prodevelopment.lapidarios.evento.model.impl.EventoAgendaModelImpl}. 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 eventoNome the evento nome
 * @param status the status
 * @param start the lower bound of the range of evento agendas
 * @param end the upper bound of the range of evento agendas (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of matching evento agendas
 * @throws SystemException if a system exception occurred
 */
@Override
public List<EventoAgenda> findByCG_EventoNome(long companyId, long groupId, String eventoNome, int status,
        int start, int end, OrderByComparator orderByComparator) throws SystemException {
    boolean pagination = true;
    FinderPath finderPath = null;
    Object[] finderArgs = null;

    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_EVENTONOME;
    finderArgs = new Object[] { companyId, groupId, eventoNome, status,

            start, end, orderByComparator };

    List<EventoAgenda> list = (List<EventoAgenda>) FinderCacheUtil.getResult(finderPath, finderArgs, this);

    if ((list != null) && !list.isEmpty()) {
        for (EventoAgenda eventoAgenda : list) {
            if ((companyId != eventoAgenda.getCompanyId()) || (groupId != eventoAgenda.getGroupId())
                    || !StringUtil.wildcardMatches(eventoAgenda.getEventoNome(), eventoNome, CharPool.UNDERLINE,
                            CharPool.PERCENT, CharPool.BACK_SLASH, true)
                    || (status != eventoAgenda.getStatus())) {
                list = null;

                break;
            }
        }
    }

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

        if (orderByComparator != null) {
            query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 3));
        } else {
            query = new StringBundler(6);
        }

        query.append(_SQL_SELECT_EVENTOAGENDA_WHERE);

        query.append(_FINDER_COLUMN_CG_EVENTONOME_COMPANYID_2);

        query.append(_FINDER_COLUMN_CG_EVENTONOME_GROUPID_2);

        boolean bindEventoNome = false;

        if (eventoNome == null) {
            query.append(_FINDER_COLUMN_CG_EVENTONOME_EVENTONOME_1);
        } else if (eventoNome.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_CG_EVENTONOME_EVENTONOME_3);
        } else {
            bindEventoNome = true;

            query.append(_FINDER_COLUMN_CG_EVENTONOME_EVENTONOME_2);
        }

        query.append(_FINDER_COLUMN_CG_EVENTONOME_STATUS_2);

        if (orderByComparator != null) {
            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
        } else if (pagination) {
            query.append(EventoAgendaModelImpl.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 (bindEventoNome) {
                qPos.add(eventoNome);
            }

            qPos.add(status);

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

                Collections.sort(list);

                list = new UnmodifiableList<EventoAgenda>(list);
            } else {
                list = (List<EventoAgenda>) QueryUtil.list(q, getDialect(), start, end);
            }

            cacheResult(list);

            FinderCacheUtil.putResult(finderPath, finderArgs, list);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(finderPath, finderArgs);

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

    return list;
}

From source file:br.com.prodevelopment.lapidarios.evento.service.persistence.EventoAgendaPersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the evento agendas where companyId = &#63; and groupId = &#63; and eventoNome LIKE &#63; and status = any &#63;.
 *
 * <p>//w  w w .j a v a2 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 com.liferay.portal.kernel.dao.orm.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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link br.com.prodevelopment.lapidarios.evento.model.impl.EventoAgendaModelImpl}. 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 eventoNome the evento nome
 * @param statuses the statuses
 * @param start the lower bound of the range of evento agendas
 * @param end the upper bound of the range of evento agendas (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of matching evento agendas
 * @throws SystemException if a system exception occurred
 */
@Override
public List<EventoAgenda> findByCG_EventoNome(long companyId, long groupId, String eventoNome, int[] statuses,
        int start, int end, OrderByComparator orderByComparator) throws SystemException {
    if ((statuses != null) && (statuses.length == 1)) {
        return findByCG_EventoNome(companyId, groupId, eventoNome, statuses[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, eventoNome, StringUtil.merge(statuses) };
    } else {
        finderArgs = new Object[] { companyId, groupId, eventoNome, StringUtil.merge(statuses),

                start, end, orderByComparator };
    }

    List<EventoAgenda> list = (List<EventoAgenda>) FinderCacheUtil
            .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_EVENTONOME, finderArgs, this);

    if ((list != null) && !list.isEmpty()) {
        for (EventoAgenda eventoAgenda : list) {
            if ((companyId != eventoAgenda.getCompanyId()) || (groupId != eventoAgenda.getGroupId())
                    || !StringUtil.wildcardMatches(eventoAgenda.getEventoNome(), eventoNome, CharPool.UNDERLINE,
                            CharPool.PERCENT, CharPool.BACK_SLASH, true)
                    || !ArrayUtil.contains(statuses, eventoAgenda.getStatus())) {
                list = null;

                break;
            }
        }
    }

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

        query.append(_SQL_SELECT_EVENTOAGENDA_WHERE);

        boolean conjunctionable = false;

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

        query.append(_FINDER_COLUMN_CG_EVENTONOME_COMPANYID_5);

        conjunctionable = true;

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

        query.append(_FINDER_COLUMN_CG_EVENTONOME_GROUPID_5);

        conjunctionable = true;

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

        boolean bindEventoNome = false;

        if (eventoNome == null) {
            query.append(_FINDER_COLUMN_CG_EVENTONOME_EVENTONOME_4);
        } else if (eventoNome.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_CG_EVENTONOME_EVENTONOME_6);
        } else {
            bindEventoNome = true;

            query.append(_FINDER_COLUMN_CG_EVENTONOME_EVENTONOME_5);
        }

        conjunctionable = true;

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

            query.append(StringPool.OPEN_PARENTHESIS);

            for (int i = 0; i < statuses.length; i++) {
                query.append(_FINDER_COLUMN_CG_EVENTONOME_STATUS_5);

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

            query.append(StringPool.CLOSE_PARENTHESIS);

            conjunctionable = true;
        }

        if (orderByComparator != null) {
            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
        } else if (pagination) {
            query.append(EventoAgendaModelImpl.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 (bindEventoNome) {
                qPos.add(eventoNome);
            }

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

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

                Collections.sort(list);

                list = new UnmodifiableList<EventoAgenda>(list);
            } else {
                list = (List<EventoAgenda>) QueryUtil.list(q, getDialect(), start, end);
            }

            cacheResult(list);

            FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_EVENTONOME, finderArgs, list);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_EVENTONOME, finderArgs);

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

    return list;
}

From source file:br.com.prodevelopment.lapidarios.evento.service.persistence.EventoAgendaPersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the evento agendas where companyId = &#63; and groupId = &#63; and eventoId = &#63; and status = &#63;.
 *
 * <p>/*w  w w  . j a v  a2  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 com.liferay.portal.kernel.dao.orm.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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link br.com.prodevelopment.lapidarios.evento.model.impl.EventoAgendaModelImpl}. 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 eventoId the evento ID
 * @param status the status
 * @param start the lower bound of the range of evento agendas
 * @param end the upper bound of the range of evento agendas (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of matching evento agendas
 * @throws SystemException if a system exception occurred
 */
@Override
public List<EventoAgenda> findByCG_EventoID(long companyId, long groupId, long eventoId, int status, int start,
        int end, OrderByComparator orderByComparator) throws SystemException {
    boolean pagination = true;
    FinderPath finderPath = null;
    Object[] finderArgs = null;

    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) {
        pagination = false;
        finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CG_EVENTOID;
        finderArgs = new Object[] { companyId, groupId, eventoId, status };
    } else {
        finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_EVENTOID;
        finderArgs = new Object[] { companyId, groupId, eventoId, status,

                start, end, orderByComparator };
    }

    List<EventoAgenda> list = (List<EventoAgenda>) FinderCacheUtil.getResult(finderPath, finderArgs, this);

    if ((list != null) && !list.isEmpty()) {
        for (EventoAgenda eventoAgenda : list) {
            if ((companyId != eventoAgenda.getCompanyId()) || (groupId != eventoAgenda.getGroupId())
                    || (eventoId != eventoAgenda.getEventoId()) || (status != eventoAgenda.getStatus())) {
                list = null;

                break;
            }
        }
    }

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

        if (orderByComparator != null) {
            query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 3));
        } else {
            query = new StringBundler(6);
        }

        query.append(_SQL_SELECT_EVENTOAGENDA_WHERE);

        query.append(_FINDER_COLUMN_CG_EVENTOID_COMPANYID_2);

        query.append(_FINDER_COLUMN_CG_EVENTOID_GROUPID_2);

        query.append(_FINDER_COLUMN_CG_EVENTOID_EVENTOID_2);

        query.append(_FINDER_COLUMN_CG_EVENTOID_STATUS_2);

        if (orderByComparator != null) {
            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
        } else if (pagination) {
            query.append(EventoAgendaModelImpl.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);

            qPos.add(eventoId);

            qPos.add(status);

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

                Collections.sort(list);

                list = new UnmodifiableList<EventoAgenda>(list);
            } else {
                list = (List<EventoAgenda>) QueryUtil.list(q, getDialect(), start, end);
            }

            cacheResult(list);

            FinderCacheUtil.putResult(finderPath, finderArgs, list);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(finderPath, finderArgs);

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

    return list;
}

From source file:br.com.prodevelopment.lapidarios.evento.service.persistence.EventoAgendaPersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the evento agendas where companyId = &#63; and groupId = &#63; and eventoId = &#63; and status = any &#63;.
 *
 * <p>// ww  w  .  j  a  v  a  2s . c om
 * 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 com.liferay.portal.kernel.dao.orm.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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link br.com.prodevelopment.lapidarios.evento.model.impl.EventoAgendaModelImpl}. 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 eventoId the evento ID
 * @param statuses the statuses
 * @param start the lower bound of the range of evento agendas
 * @param end the upper bound of the range of evento agendas (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of matching evento agendas
 * @throws SystemException if a system exception occurred
 */
@Override
public List<EventoAgenda> findByCG_EventoID(long companyId, long groupId, long eventoId, int[] statuses,
        int start, int end, OrderByComparator orderByComparator) throws SystemException {
    if ((statuses != null) && (statuses.length == 1)) {
        return findByCG_EventoID(companyId, groupId, eventoId, statuses[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, eventoId, StringUtil.merge(statuses) };
    } else {
        finderArgs = new Object[] { companyId, groupId, eventoId, StringUtil.merge(statuses),

                start, end, orderByComparator };
    }

    List<EventoAgenda> list = (List<EventoAgenda>) FinderCacheUtil
            .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_EVENTOID, finderArgs, this);

    if ((list != null) && !list.isEmpty()) {
        for (EventoAgenda eventoAgenda : list) {
            if ((companyId != eventoAgenda.getCompanyId()) || (groupId != eventoAgenda.getGroupId())
                    || (eventoId != eventoAgenda.getEventoId())
                    || !ArrayUtil.contains(statuses, eventoAgenda.getStatus())) {
                list = null;

                break;
            }
        }
    }

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

        query.append(_SQL_SELECT_EVENTOAGENDA_WHERE);

        boolean conjunctionable = false;

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

        query.append(_FINDER_COLUMN_CG_EVENTOID_COMPANYID_5);

        conjunctionable = true;

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

        query.append(_FINDER_COLUMN_CG_EVENTOID_GROUPID_5);

        conjunctionable = true;

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

        query.append(_FINDER_COLUMN_CG_EVENTOID_EVENTOID_5);

        conjunctionable = true;

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

            query.append(StringPool.OPEN_PARENTHESIS);

            for (int i = 0; i < statuses.length; i++) {
                query.append(_FINDER_COLUMN_CG_EVENTOID_STATUS_5);

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

            query.append(StringPool.CLOSE_PARENTHESIS);

            conjunctionable = true;
        }

        if (orderByComparator != null) {
            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
        } else if (pagination) {
            query.append(EventoAgendaModelImpl.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);

            qPos.add(eventoId);

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

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

                Collections.sort(list);

                list = new UnmodifiableList<EventoAgenda>(list);
            } else {
                list = (List<EventoAgenda>) QueryUtil.list(q, getDialect(), start, end);
            }

            cacheResult(list);

            FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_EVENTOID, finderArgs, list);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_EVENTOID, finderArgs);

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

    return list;
}