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:com.appuntivari.mylibrary.service.persistence.MyLibraryPersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the my libraries.
 *
 * <p>/*  w  w w .j  a v  a2s. 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.
 * </p>
 *
 * @param start the lower bound of the range of my libraries
 * @param end the upper bound of the range of my libraries (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of my libraries
 * @throws SystemException if a system exception occurred
 */
public List<MyLibrary> findAll(int start, int end, OrderByComparator orderByComparator) throws SystemException {
    FinderPath finderPath = null;
    Object[] finderArgs = new Object[] { start, end, orderByComparator };

    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) {
        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<MyLibrary> list = (List<MyLibrary>) 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_MYLIBRARY);

            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);

            sql = query.toString();
        } else {
            sql = _SQL_SELECT_MYLIBRARY.concat(MyLibraryModelImpl.ORDER_BY_JPQL);
        }

        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(sql);

            if (orderByComparator == null) {
                list = (List<MyLibrary>) QueryUtil.list(q, getDialect(), start, end, false);

                Collections.sort(list);
            } else {
                list = (List<MyLibrary>) QueryUtil.list(q, getDialect(), start, end);
            }
        } catch (Exception e) {
            throw processException(e);
        } finally {
            if (list == null) {
                FinderCacheUtil.removeResult(finderPath, finderArgs);
            } else {
                cacheResult(list);

                FinderCacheUtil.putResult(finderPath, finderArgs, list);
            }

            closeSession(session);
        }
    }

    return list;
}

From source file:com.apstamp.liferay.service.persistence.ClientePersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the clientes where clienteCC = &#63;.
 *
 * <p>/*from   w  w w. ja  va2  s  . 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 com.apstamp.liferay.model.impl.ClienteModelImpl}. 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 clienteCC the cliente c c
 * @param start the lower bound of the range of clientes
 * @param end the upper bound of the range of clientes (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of matching clientes
 * @throws SystemException if a system exception occurred
 */
@Override
public List<Cliente> findBybyCC(long clienteCC, 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_BYCC;
        finderArgs = new Object[] { clienteCC };
    } else {
        finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_BYCC;
        finderArgs = new Object[] { clienteCC, start, end, orderByComparator };
    }

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

    if ((list != null) && !list.isEmpty()) {
        for (Cliente cliente : list) {
            if ((clienteCC != cliente.getClienteCC())) {
                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_CLIENTE_WHERE);

        query.append(_FINDER_COLUMN_BYCC_CLIENTECC_2);

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

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

                Collections.sort(list);

                list = new UnmodifiableList<Cliente>(list);
            } else {
                list = (List<Cliente>) 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:com.apstamp.liferay.service.persistence.ClientePersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the clientes.
 *
 * <p>// w  w w . j  av  a  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 com.apstamp.liferay.model.impl.ClienteModelImpl}. 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 clientes
 * @param end the upper bound of the range of clientes (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of clientes
 * @throws SystemException if a system exception occurred
 */
@Override
public List<Cliente> 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<Cliente> list = (List<Cliente>) 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_CLIENTE);

            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);

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

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

        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(sql);

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

                Collections.sort(list);

                list = new UnmodifiableList<Cliente>(list);
            } else {
                list = (List<Cliente>) 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:com.apstamp.liferay.service.persistence.EmpresaPersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the empresas where empresaCC = &#63;.
 *
 * <p>//from  w w  w. j  a  v a2 s .  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 com.apstamp.liferay.model.impl.EmpresaModelImpl}. 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 empresaCC the empresa c c
 * @param start the lower bound of the range of empresas
 * @param end the upper bound of the range of empresas (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of matching empresas
 * @throws SystemException if a system exception occurred
 */
@Override
public List<Empresa> findBybyCC(long empresaCC, 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_BYCC;
        finderArgs = new Object[] { empresaCC };
    } else {
        finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_BYCC;
        finderArgs = new Object[] { empresaCC, start, end, orderByComparator };
    }

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

    if ((list != null) && !list.isEmpty()) {
        for (Empresa empresa : list) {
            if ((empresaCC != empresa.getEmpresaCC())) {
                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_EMPRESA_WHERE);

        query.append(_FINDER_COLUMN_BYCC_EMPRESACC_2);

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

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

                Collections.sort(list);

                list = new UnmodifiableList<Empresa>(list);
            } else {
                list = (List<Empresa>) 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:com.apstamp.liferay.service.persistence.EmpresaPersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the empresas.
 *
 * <p>/*from   ww w. jav 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 com.apstamp.liferay.model.impl.EmpresaModelImpl}. 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 empresas
 * @param end the upper bound of the range of empresas (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of empresas
 * @throws SystemException if a system exception occurred
 */
@Override
public List<Empresa> 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<Empresa> list = (List<Empresa>) 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_EMPRESA);

            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);

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

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

        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(sql);

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

                Collections.sort(list);

                list = new UnmodifiableList<Empresa>(list);
            } else {
                list = (List<Empresa>) 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:com.apstamp.liferay.service.persistence.EtiquetaPersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the etiquetas where etiquetaId = &#63;.
 *
 * <p>//from   www  .j av  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 com.apstamp.liferay.model.impl.EtiquetaModelImpl}. 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 etiquetaId the etiqueta ID
 * @param start the lower bound of the range of etiquetas
 * @param end the upper bound of the range of etiquetas (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of matching etiquetas
 * @throws SystemException if a system exception occurred
 */
@Override
public List<Etiqueta> findBybyId(long etiquetaId, 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_BYID;
        finderArgs = new Object[] { etiquetaId };
    } else {
        finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_BYID;
        finderArgs = new Object[] { etiquetaId, start, end, orderByComparator };
    }

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

    if ((list != null) && !list.isEmpty()) {
        for (Etiqueta etiqueta : list) {
            if ((etiquetaId != etiqueta.getEtiquetaId())) {
                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_ETIQUETA_WHERE);

        query.append(_FINDER_COLUMN_BYID_ETIQUETAID_2);

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

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

                Collections.sort(list);

                list = new UnmodifiableList<Etiqueta>(list);
            } else {
                list = (List<Etiqueta>) 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:com.apstamp.liferay.service.persistence.EtiquetaPersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the etiquetas.
 *
 * <p>//from   w  ww  .  ja v a2s  . 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 com.apstamp.liferay.model.impl.EtiquetaModelImpl}. 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 etiquetas
 * @param end the upper bound of the range of etiquetas (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of etiquetas
 * @throws SystemException if a system exception occurred
 */
@Override
public List<Etiqueta> 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<Etiqueta> list = (List<Etiqueta>) 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_ETIQUETA);

            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);

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

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

        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(sql);

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

                Collections.sort(list);

                list = new UnmodifiableList<Etiqueta>(list);
            } else {
                list = (List<Etiqueta>) 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:com.apstamp.liferay.service.persistence.ProjetoPersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the projetos where projetoNome = &#63;.
 *
 * <p>/*  w  ww.j  a v a2 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 com.apstamp.liferay.model.impl.ProjetoModelImpl}. 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 projetoNome the projeto nome
 * @param start the lower bound of the range of projetos
 * @param end the upper bound of the range of projetos (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of matching projetos
 * @throws SystemException if a system exception occurred
 */
@Override
public List<Projeto> findBybyNome(String projetoNome, 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_BYNOME;
        finderArgs = new Object[] { projetoNome };
    } else {
        finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_BYNOME;
        finderArgs = new Object[] { projetoNome, start, end, orderByComparator };
    }

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

    if ((list != null) && !list.isEmpty()) {
        for (Projeto projeto : list) {
            if (!Validator.equals(projetoNome, projeto.getProjetoNome())) {
                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_PROJETO_WHERE);

        boolean bindProjetoNome = false;

        if (projetoNome == null) {
            query.append(_FINDER_COLUMN_BYNOME_PROJETONOME_1);
        } else if (projetoNome.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_BYNOME_PROJETONOME_3);
        } else {
            bindProjetoNome = true;

            query.append(_FINDER_COLUMN_BYNOME_PROJETONOME_2);
        }

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

        String sql = query.toString();

        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(sql);

            QueryPos qPos = QueryPos.getInstance(q);

            if (bindProjetoNome) {
                qPos.add(projetoNome);
            }

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

                Collections.sort(list);

                list = new UnmodifiableList<Projeto>(list);
            } else {
                list = (List<Projeto>) 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:com.apstamp.liferay.service.persistence.ProjetoPersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the projetos.
 *
 * <p>//  w  ww.  java 2 s.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 com.apstamp.liferay.model.impl.ProjetoModelImpl}. 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 projetos
 * @param end the upper bound of the range of projetos (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of projetos
 * @throws SystemException if a system exception occurred
 */
@Override
public List<Projeto> 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<Projeto> list = (List<Projeto>) 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_PROJETO);

            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);

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

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

        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(sql);

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

                Collections.sort(list);

                list = new UnmodifiableList<Projeto>(list);
            } else {
                list = (List<Projeto>) 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:com.apstamp.liferay.service.persistence.TemplatePersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the templates where templateId = &#63;.
 *
 * <p>// w w  w.ja  v  a  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 com.apstamp.liferay.model.impl.TemplateModelImpl}. 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 templateId the template ID
 * @param start the lower bound of the range of templates
 * @param end the upper bound of the range of templates (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of matching templates
 * @throws SystemException if a system exception occurred
 */
@Override
public List<Template> findBybyId(long templateId, 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_BYID;
        finderArgs = new Object[] { templateId };
    } else {
        finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_BYID;
        finderArgs = new Object[] { templateId, start, end, orderByComparator };
    }

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

    if ((list != null) && !list.isEmpty()) {
        for (Template template : list) {
            if ((templateId != template.getTemplateId())) {
                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_TEMPLATE_WHERE);

        query.append(_FINDER_COLUMN_BYID_TEMPLATEID_2);

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

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

                Collections.sort(list);

                list = new UnmodifiableList<Template>(list);
            } else {
                list = (List<Template>) 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;
}