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.contato.service.persistence.EnderecoPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the enderecos where bairro LIKE ?. * * <p>/*from ww w. j a v a 2 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.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 bairro the bairro * @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 matching enderecos * @throws SystemException if a system exception occurred */ @Override public List<Endereco> findByBAIRRO(String bairro, int start, int end, OrderByComparator orderByComparator) throws SystemException { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_BAIRRO; finderArgs = new Object[] { bairro, start, end, orderByComparator }; List<Endereco> list = (List<Endereco>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Endereco endereco : list) { if (!StringUtil.wildcardMatches(endereco.getBairro(), bairro, CharPool.UNDERLINE, CharPool.PERCENT, CharPool.BACK_SLASH, true)) { 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_ENDERECO_WHERE); boolean bindBairro = false; if (bairro == null) { query.append(_FINDER_COLUMN_BAIRRO_BAIRRO_1); } else if (bairro.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_BAIRRO_BAIRRO_3); } else { bindBairro = true; query.append(_FINDER_COLUMN_BAIRRO_BAIRRO_2); } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(EnderecoModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindBairro) { qPos.add(bairro); } 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.EnderecoPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the enderecos where companyId = ? and cidade LIKE ?. * * <p>//from w w w . j av a 2s . c om * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link br.com.prodevelopment.lapidarios.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 companyId the company ID * @param cidade the cidade * @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 matching enderecos * @throws SystemException if a system exception occurred */ @Override public List<Endereco> findByC_CIDADE(long companyId, String cidade, int start, int end, OrderByComparator orderByComparator) throws SystemException { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_CIDADE; finderArgs = new Object[] { companyId, cidade, start, end, orderByComparator }; List<Endereco> list = (List<Endereco>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Endereco endereco : list) { if ((companyId != endereco.getCompanyId()) || !StringUtil.wildcardMatches(endereco.getCidade(), cidade, CharPool.UNDERLINE, CharPool.PERCENT, CharPool.BACK_SLASH, true)) { 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_ENDERECO_WHERE); query.append(_FINDER_COLUMN_C_CIDADE_COMPANYID_2); boolean bindCidade = false; if (cidade == null) { query.append(_FINDER_COLUMN_C_CIDADE_CIDADE_1); } else if (cidade.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_C_CIDADE_CIDADE_3); } else { bindCidade = true; query.append(_FINDER_COLUMN_C_CIDADE_CIDADE_2); } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(EnderecoModelImpl.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 (bindCidade) { qPos.add(cidade); } 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.EnderecoPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the enderecos where companyId = ? and groupId = ? and cidade LIKE ?. * * <p>/*from www . j a 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 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 companyId the company ID * @param groupId the group ID * @param cidade the cidade * @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 matching enderecos * @throws SystemException if a system exception occurred */ @Override public List<Endereco> findByC_G_CIDADE(long companyId, long groupId, String cidade, int start, int end, OrderByComparator orderByComparator) throws SystemException { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_G_CIDADE; finderArgs = new Object[] { companyId, groupId, cidade, start, end, orderByComparator }; List<Endereco> list = (List<Endereco>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Endereco endereco : list) { if ((companyId != endereco.getCompanyId()) || (groupId != endereco.getGroupId()) || !StringUtil.wildcardMatches(endereco.getCidade(), cidade, CharPool.UNDERLINE, CharPool.PERCENT, CharPool.BACK_SLASH, true)) { 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_ENDERECO_WHERE); query.append(_FINDER_COLUMN_C_G_CIDADE_COMPANYID_2); query.append(_FINDER_COLUMN_C_G_CIDADE_GROUPID_2); boolean bindCidade = false; if (cidade == null) { query.append(_FINDER_COLUMN_C_G_CIDADE_CIDADE_1); } else if (cidade.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_C_G_CIDADE_CIDADE_3); } else { bindCidade = true; query.append(_FINDER_COLUMN_C_G_CIDADE_CIDADE_2); } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(EnderecoModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(groupId); if (bindCidade) { qPos.add(cidade); } 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.EnderecoPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the enderecos where cidade LIKE ?. * * <p>//from w ww .j a va2s .c o m * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link 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 cidade the cidade * @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 matching enderecos * @throws SystemException if a system exception occurred */ @Override public List<Endereco> findByCIDADE(String cidade, int start, int end, OrderByComparator orderByComparator) throws SystemException { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_CIDADE; finderArgs = new Object[] { cidade, start, end, orderByComparator }; List<Endereco> list = (List<Endereco>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Endereco endereco : list) { if (!StringUtil.wildcardMatches(endereco.getCidade(), cidade, CharPool.UNDERLINE, CharPool.PERCENT, CharPool.BACK_SLASH, true)) { 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_ENDERECO_WHERE); boolean bindCidade = false; if (cidade == null) { query.append(_FINDER_COLUMN_CIDADE_CIDADE_1); } else if (cidade.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_CIDADE_CIDADE_3); } else { bindCidade = true; query.append(_FINDER_COLUMN_CIDADE_CIDADE_2); } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(EnderecoModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindCidade) { qPos.add(cidade); } 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.EnderecoPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the enderecos where companyId = ? and uf = ?. * * <p>//from w w w . jav 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. 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 companyId the company ID * @param uf the uf * @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 matching enderecos * @throws SystemException if a system exception occurred */ @Override public List<Endereco> findByC_UF(long companyId, String uf, 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_UF; finderArgs = new Object[] { companyId, uf }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_UF; finderArgs = new Object[] { companyId, uf, start, end, orderByComparator }; } List<Endereco> list = (List<Endereco>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Endereco endereco : list) { if ((companyId != endereco.getCompanyId()) || !Validator.equals(uf, endereco.getUf())) { 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_ENDERECO_WHERE); query.append(_FINDER_COLUMN_C_UF_COMPANYID_2); boolean bindUf = false; if (uf == null) { query.append(_FINDER_COLUMN_C_UF_UF_1); } else if (uf.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_C_UF_UF_3); } else { bindUf = true; query.append(_FINDER_COLUMN_C_UF_UF_2); } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(EnderecoModelImpl.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 (bindUf) { qPos.add(uf); } 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.EnderecoPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the enderecos where companyId = ? and groupId = ? and uf = ?. * * <p>// w w w . j a v a 2 s . c om * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link br.com.prodevelopment.lapidarios.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 companyId the company ID * @param groupId the group ID * @param uf the uf * @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 matching enderecos * @throws SystemException if a system exception occurred */ @Override public List<Endereco> findByC_G_UF(long companyId, long groupId, String uf, 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_G_UF; finderArgs = new Object[] { companyId, groupId, uf }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_G_UF; finderArgs = new Object[] { companyId, groupId, uf, start, end, orderByComparator }; } List<Endereco> list = (List<Endereco>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Endereco endereco : list) { if ((companyId != endereco.getCompanyId()) || (groupId != endereco.getGroupId()) || !Validator.equals(uf, endereco.getUf())) { 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_ENDERECO_WHERE); query.append(_FINDER_COLUMN_C_G_UF_COMPANYID_2); query.append(_FINDER_COLUMN_C_G_UF_GROUPID_2); boolean bindUf = false; if (uf == null) { query.append(_FINDER_COLUMN_C_G_UF_UF_1); } else if (uf.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_C_G_UF_UF_3); } else { bindUf = true; query.append(_FINDER_COLUMN_C_G_UF_UF_2); } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(EnderecoModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(groupId); if (bindUf) { qPos.add(uf); } 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.EnderecoPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the enderecos where uf = ?. * * <p>//w w w .ja v a 2s . c o m * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link br.com.prodevelopment.lapidarios.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 uf the uf * @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 matching enderecos * @throws SystemException if a system exception occurred */ @Override public List<Endereco> findByUF(String uf, 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_UF; finderArgs = new Object[] { uf }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UF; finderArgs = new Object[] { uf, start, end, orderByComparator }; } List<Endereco> list = (List<Endereco>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Endereco endereco : list) { if (!Validator.equals(uf, endereco.getUf())) { 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_ENDERECO_WHERE); boolean bindUf = false; if (uf == null) { query.append(_FINDER_COLUMN_UF_UF_1); } else if (uf.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UF_UF_3); } else { bindUf = true; query.append(_FINDER_COLUMN_UF_UF_2); } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(EnderecoModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindUf) { qPos.add(uf); } 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.EnderecoPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the enderecos where companyId = ? and paisId = ?. * * <p>//from w w w . 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.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 companyId the company ID * @param paisId the pais ID * @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 matching enderecos * @throws SystemException if a system exception occurred */ @Override public List<Endereco> findByC_PAIS(long companyId, long paisId, 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_PAIS; finderArgs = new Object[] { companyId, paisId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_PAIS; finderArgs = new Object[] { companyId, paisId, start, end, orderByComparator }; } List<Endereco> list = (List<Endereco>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Endereco endereco : list) { if ((companyId != endereco.getCompanyId()) || (paisId != endereco.getPaisId())) { 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_ENDERECO_WHERE); query.append(_FINDER_COLUMN_C_PAIS_COMPANYID_2); query.append(_FINDER_COLUMN_C_PAIS_PAISID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(EnderecoModelImpl.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(paisId); 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.EnderecoPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the enderecos where companyId = ? and groupId = ? and paisId = ?. * * <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.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 companyId the company ID * @param groupId the group ID * @param paisId the pais ID * @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 matching enderecos * @throws SystemException if a system exception occurred */ @Override public List<Endereco> findByC_G_PAIS(long companyId, long groupId, long paisId, 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_G_PAIS; finderArgs = new Object[] { companyId, groupId, paisId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_G_PAIS; finderArgs = new Object[] { companyId, groupId, paisId, start, end, orderByComparator }; } List<Endereco> list = (List<Endereco>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Endereco endereco : list) { if ((companyId != endereco.getCompanyId()) || (groupId != endereco.getGroupId()) || (paisId != endereco.getPaisId())) { 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_ENDERECO_WHERE); query.append(_FINDER_COLUMN_C_G_PAIS_COMPANYID_2); query.append(_FINDER_COLUMN_C_G_PAIS_GROUPID_2); query.append(_FINDER_COLUMN_C_G_PAIS_PAISID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(EnderecoModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(groupId); qPos.add(paisId); 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.EnderecoPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the enderecos where paisId = ?. * * <p>//from w ww. j ava 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.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 paisId the pais ID * @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 matching enderecos * @throws SystemException if a system exception occurred */ @Override public List<Endereco> findByPAIS(long paisId, 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_PAIS; finderArgs = new Object[] { paisId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PAIS; finderArgs = new Object[] { paisId, start, end, orderByComparator }; } List<Endereco> list = (List<Endereco>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Endereco endereco : list) { if ((paisId != endereco.getPaisId())) { 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_ENDERECO_WHERE); query.append(_FINDER_COLUMN_PAIS_PAISID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(EnderecoModelImpl.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(paisId); 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; }