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.contato.service.persistence.EnderecoPersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the enderecos.
 *
 * <p>//from w w w  . ja v  a2s . 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.contato.model.impl.EnderecoModelImpl}. 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 start the lower bound of the range of enderecos
 * @param end the upper bound of the range of enderecos (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of enderecos
 * @throws SystemException if a system exception occurred
 */
@Override
public List<Endereco> findAll(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_ALL;
        finderArgs = FINDER_ARGS_EMPTY;
    } else {
        finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
        finderArgs = new Object[] { start, end, orderByComparator };
    }

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

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

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

            query.append(_SQL_SELECT_ENDERECO);

            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);

            sql = query.toString();
        } else {
            sql = _SQL_SELECT_ENDERECO;

            if (pagination) {
                sql = sql.concat(EnderecoModelImpl.ORDER_BY_JPQL);
            }
        }

        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(sql);

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

                Collections.sort(list);

                list = new UnmodifiableList<Endereco>(list);
            } else {
                list = (List<Endereco>) 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.contato.service.persistence.TelefonePersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the telefones where uuid = &#63;.
 *
 * <p>//from  w  w  w  . j a va 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.contato.model.impl.TelefoneModelImpl}. 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 uuid the uuid
 * @param start the lower bound of the range of telefones
 * @param end the upper bound of the range of telefones (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of matching telefones
 * @throws SystemException if a system exception occurred
 */
@Override
public List<Telefone> findByUuid(String uuid, 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_UUID;
        finderArgs = new Object[] { uuid };
    } else {
        finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
        finderArgs = new Object[] { uuid, start, end, orderByComparator };
    }

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

    if ((list != null) && !list.isEmpty()) {
        for (Telefone telefone : list) {
            if (!Validator.equals(uuid, telefone.getUuid())) {
                list = null;

                break;
            }
        }
    }

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

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

        query.append(_SQL_SELECT_TELEFONE_WHERE);

        boolean bindUuid = false;

        if (uuid == null) {
            query.append(_FINDER_COLUMN_UUID_UUID_1);
        } else if (uuid.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_UUID_UUID_3);
        } else {
            bindUuid = true;

            query.append(_FINDER_COLUMN_UUID_UUID_2);
        }

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

        String sql = query.toString();

        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(sql);

            QueryPos qPos = QueryPos.getInstance(q);

            if (bindUuid) {
                qPos.add(uuid);
            }

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

                Collections.sort(list);

                list = new UnmodifiableList<Telefone>(list);
            } else {
                list = (List<Telefone>) 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.contato.service.persistence.TelefonePersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the telefones where uuid = &#63; and companyId = &#63;.
 *
 * <p>/*from  www. j a va 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 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.contato.model.impl.TelefoneModelImpl}. 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 uuid the uuid
 * @param companyId the company ID
 * @param start the lower bound of the range of telefones
 * @param end the upper bound of the range of telefones (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of matching telefones
 * @throws SystemException if a system exception occurred
 */
@Override
public List<Telefone> findByUuid_C(String uuid, long companyId, 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_UUID_C;
        finderArgs = new Object[] { uuid, companyId };
    } else {
        finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
        finderArgs = new Object[] { uuid, companyId,

                start, end, orderByComparator };
    }

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

    if ((list != null) && !list.isEmpty()) {
        for (Telefone telefone : list) {
            if (!Validator.equals(uuid, telefone.getUuid()) || (companyId != telefone.getCompanyId())) {
                list = null;

                break;
            }
        }
    }

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

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

        query.append(_SQL_SELECT_TELEFONE_WHERE);

        boolean bindUuid = false;

        if (uuid == null) {
            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
        } else if (uuid.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
        } else {
            bindUuid = true;

            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
        }

        query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);

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

        String sql = query.toString();

        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(sql);

            QueryPos qPos = QueryPos.getInstance(q);

            if (bindUuid) {
                qPos.add(uuid);
            }

            qPos.add(companyId);

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

                Collections.sort(list);

                list = new UnmodifiableList<Telefone>(list);
            } else {
                list = (List<Telefone>) 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.contato.service.persistence.TelefonePersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the telefones where companyId = &#63;.
 *
 * <p>//from   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.contato.model.impl.TelefoneModelImpl}. 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 start the lower bound of the range of telefones
 * @param end the upper bound of the range of telefones (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of matching telefones
 * @throws SystemException if a system exception occurred
 */
@Override
public List<Telefone> findByCompanyId(long companyId, 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_COMPANYID;
        finderArgs = new Object[] { companyId };
    } else {
        finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
        finderArgs = new Object[] { companyId, start, end, orderByComparator };
    }

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

    if ((list != null) && !list.isEmpty()) {
        for (Telefone telefone : list) {
            if ((companyId != telefone.getCompanyId())) {
                list = null;

                break;
            }
        }
    }

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

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

        query.append(_SQL_SELECT_TELEFONE_WHERE);

        query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);

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

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

                Collections.sort(list);

                list = new UnmodifiableList<Telefone>(list);
            } else {
                list = (List<Telefone>) 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.contato.service.persistence.TelefonePersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the telefones where companyId = &#63; and classNameId = &#63;.
 *
 * <p>/*www .  j ava2  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.contato.model.impl.TelefoneModelImpl}. 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 classNameId the class name ID
 * @param start the lower bound of the range of telefones
 * @param end the upper bound of the range of telefones (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of matching telefones
 * @throws SystemException if a system exception occurred
 */
@Override
public List<Telefone> findByC_C(long companyId, long classNameId, 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_C_C;
        finderArgs = new Object[] { companyId, classNameId };
    } else {
        finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C;
        finderArgs = new Object[] { companyId, classNameId,

                start, end, orderByComparator };
    }

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

    if ((list != null) && !list.isEmpty()) {
        for (Telefone telefone : list) {
            if ((companyId != telefone.getCompanyId()) || (classNameId != telefone.getClassNameId())) {
                list = null;

                break;
            }
        }
    }

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

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

        query.append(_SQL_SELECT_TELEFONE_WHERE);

        query.append(_FINDER_COLUMN_C_C_COMPANYID_2);

        query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);

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

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

                Collections.sort(list);

                list = new UnmodifiableList<Telefone>(list);
            } else {
                list = (List<Telefone>) 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.contato.service.persistence.TelefonePersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the telefones where companyId = &#63; and classNameId = &#63; and classPK = &#63;.
 *
 * <p>//from ww w. ja va2s. co 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.contato.model.impl.TelefoneModelImpl}. 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 classNameId the class name ID
 * @param classPK the class p k
 * @param start the lower bound of the range of telefones
 * @param end the upper bound of the range of telefones (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of matching telefones
 * @throws SystemException if a system exception occurred
 */
@Override
public List<Telefone> findByC_C_C(long companyId, long classNameId, long classPK, 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_C_C_C;
        finderArgs = new Object[] { companyId, classNameId, classPK };
    } else {
        finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_C;
        finderArgs = new Object[] { companyId, classNameId, classPK,

                start, end, orderByComparator };
    }

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

    if ((list != null) && !list.isEmpty()) {
        for (Telefone telefone : list) {
            if ((companyId != telefone.getCompanyId()) || (classNameId != telefone.getClassNameId())
                    || (classPK != telefone.getClassPK())) {
                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_TELEFONE_WHERE);

        query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);

        query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);

        query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);

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

            qPos.add(classPK);

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

                Collections.sort(list);

                list = new UnmodifiableList<Telefone>(list);
            } else {
                list = (List<Telefone>) 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.contato.service.persistence.TelefonePersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the telefones where companyId = &#63; and classNameId = &#63; and classPK = &#63; and principal = &#63;.
 *
 * <p>/*from   w  ww .  ja va 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.contato.model.impl.TelefoneModelImpl}. 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 classNameId the class name ID
 * @param classPK the class p k
 * @param principal the principal
 * @param start the lower bound of the range of telefones
 * @param end the upper bound of the range of telefones (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of matching telefones
 * @throws SystemException if a system exception occurred
 */
@Override
public List<Telefone> findByC_C_C_P(long companyId, long classNameId, long classPK, boolean principal,
        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_C_C_C_P;
        finderArgs = new Object[] { companyId, classNameId, classPK, principal };
    } else {
        finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_C_P;
        finderArgs = new Object[] { companyId, classNameId, classPK, principal,

                start, end, orderByComparator };
    }

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

    if ((list != null) && !list.isEmpty()) {
        for (Telefone telefone : list) {
            if ((companyId != telefone.getCompanyId()) || (classNameId != telefone.getClassNameId())
                    || (classPK != telefone.getClassPK()) || (principal != telefone.getPrincipal())) {
                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_TELEFONE_WHERE);

        query.append(_FINDER_COLUMN_C_C_C_P_COMPANYID_2);

        query.append(_FINDER_COLUMN_C_C_C_P_CLASSNAMEID_2);

        query.append(_FINDER_COLUMN_C_C_C_P_CLASSPK_2);

        query.append(_FINDER_COLUMN_C_C_C_P_PRINCIPAL_2);

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

            qPos.add(classPK);

            qPos.add(principal);

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

                Collections.sort(list);

                list = new UnmodifiableList<Telefone>(list);
            } else {
                list = (List<Telefone>) 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.contato.service.persistence.TelefonePersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the telefones.
 *
 * <p>//from www.  ja 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.contato.model.impl.TelefoneModelImpl}. 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 start the lower bound of the range of telefones
 * @param end the upper bound of the range of telefones (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of telefones
 * @throws SystemException if a system exception occurred
 */
@Override
public List<Telefone> findAll(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_ALL;
        finderArgs = FINDER_ARGS_EMPTY;
    } else {
        finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
        finderArgs = new Object[] { start, end, orderByComparator };
    }

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

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

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

            query.append(_SQL_SELECT_TELEFONE);

            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);

            sql = query.toString();
        } else {
            sql = _SQL_SELECT_TELEFONE;

            if (pagination) {
                sql = sql.concat(TelefoneModelImpl.ORDER_BY_JPQL);
            }
        }

        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(sql);

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

                Collections.sort(list);

                list = new UnmodifiableList<Telefone>(list);
            } else {
                list = (List<Telefone>) 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 uuid = &#63;.
 *
 * <p>//w  ww. java 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 uuid the uuid
 * @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> findByUuid(String uuid, 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_UUID;
        finderArgs = new Object[] { uuid };
    } else {
        finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
        finderArgs = new Object[] { uuid, start, end, orderByComparator };
    }

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

    if ((list != null) && !list.isEmpty()) {
        for (EventoAgenda eventoAgenda : list) {
            if (!Validator.equals(uuid, eventoAgenda.getUuid())) {
                list = null;

                break;
            }
        }
    }

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

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

        query.append(_SQL_SELECT_EVENTOAGENDA_WHERE);

        boolean bindUuid = false;

        if (uuid == null) {
            query.append(_FINDER_COLUMN_UUID_UUID_1);
        } else if (uuid.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_UUID_UUID_3);
        } else {
            bindUuid = true;

            query.append(_FINDER_COLUMN_UUID_UUID_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);

            if (bindUuid) {
                qPos.add(uuid);
            }

            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 uuid = &#63; and companyId = &#63;.
 *
 * <p>/*ww w. j av a2 s . 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 uuid the uuid
 * @param companyId the company ID
 * @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> findByUuid_C(String uuid, long companyId, 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_UUID_C;
        finderArgs = new Object[] { uuid, companyId };
    } else {
        finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
        finderArgs = new Object[] { uuid, companyId,

                start, end, orderByComparator };
    }

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

    if ((list != null) && !list.isEmpty()) {
        for (EventoAgenda eventoAgenda : list) {
            if (!Validator.equals(uuid, eventoAgenda.getUuid()) || (companyId != eventoAgenda.getCompanyId())) {
                list = null;

                break;
            }
        }
    }

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

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

        query.append(_SQL_SELECT_EVENTOAGENDA_WHERE);

        boolean bindUuid = false;

        if (uuid == null) {
            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
        } else if (uuid.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
        } else {
            bindUuid = true;

            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
        }

        query.append(_FINDER_COLUMN_UUID_C_COMPANYID_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);

            if (bindUuid) {
                qPos.add(uuid);
            }

            qPos.add(companyId);

            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;
}