List of usage examples for com.liferay.portal.kernel.dao.orm QueryUtil list
public static List<?> list(Query query, Dialect dialect, int start, int end, boolean unmodifiable)
From source file:br.com.prodevelopment.lapidarios.municipio.service.persistence.MunicipioPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the municipios. * * <p>//from w w w .ja v a 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 br.com.prodevelopment.lapidarios.municipio.model.impl.MunicipioModelImpl}. 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 municipios * @param end the upper bound of the range of municipios (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of municipios * @throws SystemException if a system exception occurred */ @Override public List<Municipio> 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<Municipio> list = (List<Municipio>) 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_MUNICIPIO); appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = query.toString(); } else { sql = _SQL_SELECT_MUNICIPIO; if (pagination) { sql = sql.concat(MunicipioModelImpl.ORDER_BY_JPQL); } } Session session = null; try { session = openSession(); Query q = session.createQuery(sql); if (!pagination) { list = (List<Municipio>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = new UnmodifiableList<Municipio>(list); } else { list = (List<Municipio>) 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.seatecnologia.banner.service.persistence.BannerPersistenceImpl.java
License:Open Source License
/** * Finds an ordered range of all the banners. * * <p>/*from ww w.j av 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. * </p> * * @param start the lower bound of the range of banners to return * @param end the upper bound of the range of banners to return (not inclusive) * @param orderByComparator the comparator to order the results by * @return the ordered range of banners * @throws SystemException if a system exception occurred */ public List<Banner> findAll(int start, int end, OrderByComparator orderByComparator) throws SystemException { Object[] finderArgs = new Object[] { String.valueOf(start), String.valueOf(end), String.valueOf(orderByComparator) }; List<Banner> list = (List<Banner>) FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL, 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_BANNER); appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = query.toString(); } else { sql = _SQL_SELECT_BANNER.concat(BannerModelImpl.ORDER_BY_JPQL); } Session session = null; try { session = openSession(); Query q = session.createQuery(sql); if (orderByComparator == null) { list = (List<Banner>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); } else { list = (List<Banner>) QueryUtil.list(q, getDialect(), start, end); } } catch (Exception e) { throw processException(e); } finally { if (list == null) { FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL, finderArgs); } else { cacheResult(list); FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list); } closeSession(session); } } return list; }
From source file:br.com.seatecnologia.cldf.enquetenoticia.service.persistence.EnqueteNoticiaPersistenceImpl.java
License:Open Source License
/** * Finds an ordered range of all the enquete noticias. * * <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. * </p> * * @param start the lower bound of the range of enquete noticias to return * @param end the upper bound of the range of enquete noticias to return (not inclusive) * @param orderByComparator the comparator to order the results by * @return the ordered range of enquete noticias * @throws SystemException if a system exception occurred */ public List<EnqueteNoticia> findAll(int start, int end, OrderByComparator orderByComparator) throws SystemException { Object[] finderArgs = new Object[] { String.valueOf(start), String.valueOf(end), String.valueOf(orderByComparator) }; List<EnqueteNoticia> list = (List<EnqueteNoticia>) FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL, 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_ENQUETENOTICIA); appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = query.toString(); } else { sql = _SQL_SELECT_ENQUETENOTICIA; } Session session = null; try { session = openSession(); Query q = session.createQuery(sql); if (orderByComparator == null) { list = (List<EnqueteNoticia>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); } else { list = (List<EnqueteNoticia>) QueryUtil.list(q, getDialect(), start, end); } } catch (Exception e) { throw processException(e); } finally { if (list == null) { FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL, finderArgs); } else { cacheResult(list); FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list); } closeSession(session); } } return list; }
From source file:br.com.seatecnologia.treinamento.service.persistence.ModeloPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the modelos where nome = ? and groupId = ?. * * <p>//from w ww .j a v a 2s .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.seatecnologia.treinamento.model.impl.ModeloModelImpl}. 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 nome the nome * @param groupId the group ID * @param start the lower bound of the range of modelos * @param end the upper bound of the range of modelos (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching modelos * @throws SystemException if a system exception occurred */ @Override public List<Modelo> findByNomeAndGroupId(String nome, long groupId, 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_NOMEANDGROUPID; finderArgs = new Object[] { nome, groupId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_NOMEANDGROUPID; finderArgs = new Object[] { nome, groupId, start, end, orderByComparator }; } List<Modelo> list = (List<Modelo>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Modelo modelo : list) { if (!Validator.equals(nome, modelo.getNome()) || (groupId != modelo.getGroupId())) { 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_MODELO_WHERE); boolean bindNome = false; if (nome == null) { query.append(_FINDER_COLUMN_NOMEANDGROUPID_NOME_1); } else if (nome.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_NOMEANDGROUPID_NOME_3); } else { bindNome = true; query.append(_FINDER_COLUMN_NOMEANDGROUPID_NOME_2); } query.append(_FINDER_COLUMN_NOMEANDGROUPID_GROUPID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(ModeloModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindNome) { qPos.add(nome); } qPos.add(groupId); if (!pagination) { list = (List<Modelo>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = new UnmodifiableList<Modelo>(list); } else { list = (List<Modelo>) 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.seatecnologia.treinamento.service.persistence.ModeloPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the modelos. * * <p>/* www . ja 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.seatecnologia.treinamento.model.impl.ModeloModelImpl}. 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 modelos * @param end the upper bound of the range of modelos (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of modelos * @throws SystemException if a system exception occurred */ @Override public List<Modelo> 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<Modelo> list = (List<Modelo>) 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_MODELO); appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = query.toString(); } else { sql = _SQL_SELECT_MODELO; if (pagination) { sql = sql.concat(ModeloModelImpl.ORDER_BY_JPQL); } } Session session = null; try { session = openSession(); Query q = session.createQuery(sql); if (!pagination) { list = (List<Modelo>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = new UnmodifiableList<Modelo>(list); } else { list = (List<Modelo>) 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.thiagomoreira.liferay.plugins.notfound.services.service.persistence.NotFoundPersistenceImpl.java
License:Apache License
/** * Returns an ordered range of all the not founds. * * <p>/*ww w . j a va2 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.thiagomoreira.liferay.plugins.notfound.services.model.impl.NotFoundModelImpl}. 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 not founds * @param end the upper bound of the range of not founds (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of not founds * @throws SystemException if a system exception occurred */ @Override public List<NotFound> 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<NotFound> list = (List<NotFound>) 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_NOTFOUND); appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = query.toString(); } else { sql = _SQL_SELECT_NOTFOUND; if (pagination) { sql = sql.concat(NotFoundModelImpl.ORDER_BY_JPQL); } } Session session = null; try { session = openSession(); Query q = session.createQuery(sql); if (!pagination) { list = (List<NotFound>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = new UnmodifiableList<NotFound>(list); } else { list = (List<NotFound>) 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.gov.demoiselle.portal.evento.service.persistence.EventoConfiguracaoPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the evento configuracaos. * * <p>//from 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. * </p> * * @param start the lower bound of the range of evento configuracaos * @param end the upper bound of the range of evento configuracaos (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of evento configuracaos * @throws SystemException if a system exception occurred */ public List<EventoConfiguracao> 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<EventoConfiguracao> list = (List<EventoConfiguracao>) 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_EVENTOCONFIGURACAO); appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = query.toString(); } else { sql = _SQL_SELECT_EVENTOCONFIGURACAO.concat(EventoConfiguracaoModelImpl.ORDER_BY_JPQL); } Session session = null; try { session = openSession(); Query q = session.createQuery(sql); if (orderByComparator == null) { list = (List<EventoConfiguracao>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); } else { list = (List<EventoConfiguracao>) 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:br.gov.demoiselle.portal.evento.service.persistence.EventoConvitePersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the evento convites. * * <p>/*from w w w. j a 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. * </p> * * @param start the lower bound of the range of evento convites * @param end the upper bound of the range of evento convites (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of evento convites * @throws SystemException if a system exception occurred */ public List<EventoConvite> 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<EventoConvite> list = (List<EventoConvite>) 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_EVENTOCONVITE); appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = query.toString(); } else { sql = _SQL_SELECT_EVENTOCONVITE.concat(EventoConviteModelImpl.ORDER_BY_JPQL); } Session session = null; try { session = openSession(); Query q = session.createQuery(sql); if (orderByComparator == null) { list = (List<EventoConvite>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); } else { list = (List<EventoConvite>) 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:br.gov.demoiselle.portal.evento.service.persistence.EventoParticipantePersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the evento participantes. * * <p>/* www .j a v a 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. * </p> * * @param start the lower bound of the range of evento participantes * @param end the upper bound of the range of evento participantes (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of evento participantes * @throws SystemException if a system exception occurred */ public List<EventoParticipante> 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<EventoParticipante> list = (List<EventoParticipante>) 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_EVENTOPARTICIPANTE); appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = query.toString(); } else { sql = _SQL_SELECT_EVENTOPARTICIPANTE.concat(EventoParticipanteModelImpl.ORDER_BY_JPQL); } Session session = null; try { session = openSession(); Query q = session.createQuery(sql); if (orderByComparator == null) { list = (List<EventoParticipante>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); } else { list = (List<EventoParticipante>) 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:br.ufpe.cin.da.salada.service.persistence.SorteioPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the sorteios. * * <p>/* w ww. ja va2 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.ufpe.cin.da.salada.model.impl.SorteioModelImpl}. 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 sorteios * @param end the upper bound of the range of sorteios (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of sorteios * @throws SystemException if a system exception occurred */ @Override public List<Sorteio> 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<Sorteio> list = (List<Sorteio>) 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_SORTEIO); appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = query.toString(); } else { sql = _SQL_SELECT_SORTEIO; if (pagination) { sql = sql.concat(SorteioModelImpl.ORDER_BY_JPQL); } } Session session = null; try { session = openSession(); Query q = session.createQuery(sql); if (!pagination) { list = (List<Sorteio>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = new UnmodifiableList<Sorteio>(list); } else { list = (List<Sorteio>) 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; }