List of usage examples for com.liferay.portal.kernel.util StringPool CLOSE_PARENTHESIS
String CLOSE_PARENTHESIS
To view the source code for com.liferay.portal.kernel.util StringPool CLOSE_PARENTHESIS.
Click Source Link
From source file:br.com.prodevelopment.lapidarios.loja.service.persistence.LojaPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the lojas where companyId = ? and groupId = ? and ordemIndicada = ? and status = any ?. * * <p>// ww w .j av 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 br.com.prodevelopment.lapidarios.loja.model.impl.LojaModelImpl}. 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 ordemIndicada the ordem indicada * @param statuses the statuses * @param start the lower bound of the range of lojas * @param end the upper bound of the range of lojas (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching lojas * @throws SystemException if a system exception occurred */ @Override public List<Loja> findByCG_OrdemIndicada(long companyId, long groupId, int ordemIndicada, int[] statuses, int start, int end, OrderByComparator orderByComparator) throws SystemException { if ((statuses != null) && (statuses.length == 1)) { return findByCG_OrdemIndicada(companyId, groupId, ordemIndicada, statuses[0], start, end, orderByComparator); } boolean pagination = true; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderArgs = new Object[] { companyId, groupId, ordemIndicada, StringUtil.merge(statuses) }; } else { finderArgs = new Object[] { companyId, groupId, ordemIndicada, StringUtil.merge(statuses), start, end, orderByComparator }; } List<Loja> list = (List<Loja>) FinderCacheUtil .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_ORDEMINDICADA, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Loja loja : list) { if ((companyId != loja.getCompanyId()) || (groupId != loja.getGroupId()) || (ordemIndicada != loja.getOrdemIndicada()) || !ArrayUtil.contains(statuses, loja.getStatus())) { list = null; break; } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_LOJA_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_ORDEMINDICADA_COMPANYID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_ORDEMINDICADA_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_ORDEMINDICADA_ORDEMINDICADA_5); conjunctionable = true; if ((statuses == null) || (statuses.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < statuses.length; i++) { query.append(_FINDER_COLUMN_CG_ORDEMINDICADA_STATUS_5); if ((i + 1) < statuses.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(LojaModelImpl.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(ordemIndicada); if (statuses != null) { qPos.add(statuses); } if (!pagination) { list = (List<Loja>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = new UnmodifiableList<Loja>(list); } else { list = (List<Loja>) QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_ORDEMINDICADA, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_ORDEMINDICADA, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; }
From source file:br.com.prodevelopment.lapidarios.loja.service.persistence.LojaPersistenceImpl.java
License:Open Source License
/** * Returns the number of lojas where companyId = ? and groupId = ? and ordemIndicada = ? and status = any ?. * * @param companyId the company ID/*from ww w. jav a 2 s . co m*/ * @param groupId the group ID * @param ordemIndicada the ordem indicada * @param statuses the statuses * @return the number of matching lojas * @throws SystemException if a system exception occurred */ @Override public int countByCG_OrdemIndicada(long companyId, long groupId, int ordemIndicada, int[] statuses) throws SystemException { Object[] finderArgs = new Object[] { companyId, groupId, ordemIndicada, StringUtil.merge(statuses) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_ORDEMINDICADA, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_LOJA_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_ORDEMINDICADA_COMPANYID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_ORDEMINDICADA_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_ORDEMINDICADA_ORDEMINDICADA_5); conjunctionable = true; if ((statuses == null) || (statuses.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < statuses.length; i++) { query.append(_FINDER_COLUMN_CG_ORDEMINDICADA_STATUS_5); if ((i + 1) < statuses.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } 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(ordemIndicada); if (statuses != null) { qPos.add(statuses); } count = (Long) q.uniqueResult(); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_ORDEMINDICADA, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_ORDEMINDICADA, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); }
From source file:br.com.prodevelopment.lapidarios.loja.service.persistence.LojaPersistenceImpl.java
License:Open Source License
/** * Returns the number of lojas where companyId = ? and groupId = ? and ordemIndicadaAtual = ? and status = any ?. * * @param companyId the company ID//from www .jav a 2 s. co m * @param groupId the group ID * @param ordemIndicadaAtual the ordem indicada atual * @param statuses the statuses * @return the number of matching lojas * @throws SystemException if a system exception occurred */ @Override public int countByCG_OrdemIndicadaAtual(long companyId, long groupId, boolean ordemIndicadaAtual, int[] statuses) throws SystemException { Object[] finderArgs = new Object[] { companyId, groupId, ordemIndicadaAtual, StringUtil.merge(statuses) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_ORDEMINDICADAATUAL, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_LOJA_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_ORDEMINDICADAATUAL_COMPANYID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_ORDEMINDICADAATUAL_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_ORDEMINDICADAATUAL_ORDEMINDICADAATUAL_5); conjunctionable = true; if ((statuses == null) || (statuses.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < statuses.length; i++) { query.append(_FINDER_COLUMN_CG_ORDEMINDICADAATUAL_STATUS_5); if ((i + 1) < statuses.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } 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(ordemIndicadaAtual); if (statuses != null) { qPos.add(statuses); } count = (Long) q.uniqueResult(); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_ORDEMINDICADAATUAL, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_ORDEMINDICADAATUAL, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); }
From source file:br.com.prodevelopment.lapidarios.loja.service.persistence.LojaPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the lojas where companyId = ? and groupId = ? and classNameId = ? and status = any ?. * * <p>//from w w w. j ava 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.loja.model.impl.LojaModelImpl}. 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 classNameId the class name ID * @param statuses the statuses * @param start the lower bound of the range of lojas * @param end the upper bound of the range of lojas (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching lojas * @throws SystemException if a system exception occurred */ @Override public List<Loja> findByCG_ClassName(long companyId, long groupId, long classNameId, int[] statuses, int start, int end, OrderByComparator orderByComparator) throws SystemException { if ((statuses != null) && (statuses.length == 1)) { return findByCG_ClassName(companyId, groupId, classNameId, statuses[0], start, end, orderByComparator); } boolean pagination = true; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderArgs = new Object[] { companyId, groupId, classNameId, StringUtil.merge(statuses) }; } else { finderArgs = new Object[] { companyId, groupId, classNameId, StringUtil.merge(statuses), start, end, orderByComparator }; } List<Loja> list = (List<Loja>) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_CLASSNAME, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Loja loja : list) { if ((companyId != loja.getCompanyId()) || (groupId != loja.getGroupId()) || (classNameId != loja.getClassNameId()) || !ArrayUtil.contains(statuses, loja.getStatus())) { list = null; break; } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_LOJA_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_CLASSNAME_COMPANYID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_CLASSNAME_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_CLASSNAME_CLASSNAMEID_5); conjunctionable = true; if ((statuses == null) || (statuses.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < statuses.length; i++) { query.append(_FINDER_COLUMN_CG_CLASSNAME_STATUS_5); if ((i + 1) < statuses.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(LojaModelImpl.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(classNameId); if (statuses != null) { qPos.add(statuses); } if (!pagination) { list = (List<Loja>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = new UnmodifiableList<Loja>(list); } else { list = (List<Loja>) QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_CLASSNAME, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_CLASSNAME, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; }
From source file:br.com.prodevelopment.lapidarios.loja.service.persistence.LojaPersistenceImpl.java
License:Open Source License
/** * Returns the number of lojas where companyId = ? and groupId = ? and classNameId = ? and status = any ?. * * @param companyId the company ID// w ww . j a v a 2s . c om * @param groupId the group ID * @param classNameId the class name ID * @param statuses the statuses * @return the number of matching lojas * @throws SystemException if a system exception occurred */ @Override public int countByCG_ClassName(long companyId, long groupId, long classNameId, int[] statuses) throws SystemException { Object[] finderArgs = new Object[] { companyId, groupId, classNameId, StringUtil.merge(statuses) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_CLASSNAME, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_LOJA_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_CLASSNAME_COMPANYID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_CLASSNAME_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_CLASSNAME_CLASSNAMEID_5); conjunctionable = true; if ((statuses == null) || (statuses.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < statuses.length; i++) { query.append(_FINDER_COLUMN_CG_CLASSNAME_STATUS_5); if ((i + 1) < statuses.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } 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(classNameId); if (statuses != null) { qPos.add(statuses); } count = (Long) q.uniqueResult(); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_CLASSNAME, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_CLASSNAME, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); }
From source file:br.com.prodevelopment.lapidarios.loja.service.persistence.LojaPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the lojas where companyId = ? and groupId = ? and classNameId = ? and nomeFantasia LIKE ? and status = any ?. * * <p>/*from ww w . j av a 2s .com*/ * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link br.com.prodevelopment.lapidarios.loja.model.impl.LojaModelImpl}. 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 classNameId the class name ID * @param nomeFantasia the nome fantasia * @param statuses the statuses * @param start the lower bound of the range of lojas * @param end the upper bound of the range of lojas (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching lojas * @throws SystemException if a system exception occurred */ @Override public List<Loja> findByCG_ClassNameNomeFantasia(long companyId, long groupId, long classNameId, String nomeFantasia, int[] statuses, int start, int end, OrderByComparator orderByComparator) throws SystemException { if ((statuses != null) && (statuses.length == 1)) { return findByCG_ClassNameNomeFantasia(companyId, groupId, classNameId, nomeFantasia, statuses[0], start, end, orderByComparator); } boolean pagination = true; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderArgs = new Object[] { companyId, groupId, classNameId, nomeFantasia, StringUtil.merge(statuses) }; } else { finderArgs = new Object[] { companyId, groupId, classNameId, nomeFantasia, StringUtil.merge(statuses), start, end, orderByComparator }; } List<Loja> list = (List<Loja>) FinderCacheUtil .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_CLASSNAMENOMEFANTASIA, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Loja loja : list) { if ((companyId != loja.getCompanyId()) || (groupId != loja.getGroupId()) || (classNameId != loja.getClassNameId()) || !StringUtil.wildcardMatches(loja.getNomeFantasia(), nomeFantasia, CharPool.UNDERLINE, CharPool.PERCENT, CharPool.BACK_SLASH, true) || !ArrayUtil.contains(statuses, loja.getStatus())) { list = null; break; } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_LOJA_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_CLASSNAMENOMEFANTASIA_COMPANYID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_CLASSNAMENOMEFANTASIA_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_CLASSNAMENOMEFANTASIA_CLASSNAMEID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } boolean bindNomeFantasia = false; if (nomeFantasia == null) { query.append(_FINDER_COLUMN_CG_CLASSNAMENOMEFANTASIA_NOMEFANTASIA_4); } else if (nomeFantasia.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_CG_CLASSNAMENOMEFANTASIA_NOMEFANTASIA_6); } else { bindNomeFantasia = true; query.append(_FINDER_COLUMN_CG_CLASSNAMENOMEFANTASIA_NOMEFANTASIA_5); } conjunctionable = true; if ((statuses == null) || (statuses.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < statuses.length; i++) { query.append(_FINDER_COLUMN_CG_CLASSNAMENOMEFANTASIA_STATUS_5); if ((i + 1) < statuses.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(LojaModelImpl.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(classNameId); if (bindNomeFantasia) { qPos.add(nomeFantasia); } if (statuses != null) { qPos.add(statuses); } if (!pagination) { list = (List<Loja>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = new UnmodifiableList<Loja>(list); } else { list = (List<Loja>) QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_CLASSNAMENOMEFANTASIA, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_CLASSNAMENOMEFANTASIA, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; }
From source file:br.com.prodevelopment.lapidarios.loja.service.persistence.LojaPersistenceImpl.java
License:Open Source License
/** * Returns the number of lojas where companyId = ? and groupId = ? and classNameId = ? and nomeFantasia LIKE ? and status = any ?. * * @param companyId the company ID/* w w w . j a v a2 s.c o m*/ * @param groupId the group ID * @param classNameId the class name ID * @param nomeFantasia the nome fantasia * @param statuses the statuses * @return the number of matching lojas * @throws SystemException if a system exception occurred */ @Override public int countByCG_ClassNameNomeFantasia(long companyId, long groupId, long classNameId, String nomeFantasia, int[] statuses) throws SystemException { Object[] finderArgs = new Object[] { companyId, groupId, classNameId, nomeFantasia, StringUtil.merge(statuses) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_CLASSNAMENOMEFANTASIA, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_LOJA_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_CLASSNAMENOMEFANTASIA_COMPANYID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_CLASSNAMENOMEFANTASIA_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_CLASSNAMENOMEFANTASIA_CLASSNAMEID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } boolean bindNomeFantasia = false; if (nomeFantasia == null) { query.append(_FINDER_COLUMN_CG_CLASSNAMENOMEFANTASIA_NOMEFANTASIA_4); } else if (nomeFantasia.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_CG_CLASSNAMENOMEFANTASIA_NOMEFANTASIA_6); } else { bindNomeFantasia = true; query.append(_FINDER_COLUMN_CG_CLASSNAMENOMEFANTASIA_NOMEFANTASIA_5); } conjunctionable = true; if ((statuses == null) || (statuses.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < statuses.length; i++) { query.append(_FINDER_COLUMN_CG_CLASSNAMENOMEFANTASIA_STATUS_5); if ((i + 1) < statuses.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } 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(classNameId); if (bindNomeFantasia) { qPos.add(nomeFantasia); } if (statuses != null) { qPos.add(statuses); } count = (Long) q.uniqueResult(); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_CLASSNAMENOMEFANTASIA, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_CLASSNAMENOMEFANTASIA, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); }
From source file:ca.efendi.datafeeds.service.persistence.impl.CJProductPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, CJProduct> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }//from w w w . j a v a2 s .co m Map<Serializable, CJProduct> map = new HashMap<Serializable, CJProduct>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); CJProduct cjProduct = fetchByPrimaryKey(primaryKey); if (cjProduct != null) { map.put(primaryKey, cjProduct); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(CJProductModelImpl.ENTITY_CACHE_ENABLED, CJProductImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (CJProduct) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_CJPRODUCT_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (CJProduct cjProduct : (List<CJProduct>) q.list()) { map.put(cjProduct.getPrimaryKeyObj(), cjProduct); cacheResult(cjProduct); uncachedPrimaryKeys.remove(cjProduct.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(CJProductModelImpl.ENTITY_CACHE_ENABLED, CJProductImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:ca.efendi.datafeeds.service.persistence.impl.FtpSubscriptionPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, FtpSubscription> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }//from w w w .ja v a 2s. c o m Map<Serializable, FtpSubscription> map = new HashMap<Serializable, FtpSubscription>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); FtpSubscription ftpSubscription = fetchByPrimaryKey(primaryKey); if (ftpSubscription != null) { map.put(primaryKey, ftpSubscription); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(FtpSubscriptionModelImpl.ENTITY_CACHE_ENABLED, FtpSubscriptionImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (FtpSubscription) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_FTPSUBSCRIPTION_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (FtpSubscription ftpSubscription : (List<FtpSubscription>) q.list()) { map.put(ftpSubscription.getPrimaryKeyObj(), ftpSubscription); cacheResult(ftpSubscription); uncachedPrimaryKeys.remove(ftpSubscription.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(FtpSubscriptionModelImpl.ENTITY_CACHE_ENABLED, FtpSubscriptionImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.bemis.portal.carriers.service.persistence.impl.CarrierPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, Carrier> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }// w ww . j ava 2 s .c om Map<Serializable, Carrier> map = new HashMap<Serializable, Carrier>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); Carrier carrier = fetchByPrimaryKey(primaryKey); if (carrier != null) { map.put(primaryKey, carrier); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(CarrierModelImpl.ENTITY_CACHE_ENABLED, CarrierImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (Carrier) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_CARRIER_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (Carrier carrier : (List<Carrier>) q.list()) { map.put(carrier.getPrimaryKeyObj(), carrier); cacheResult(carrier); uncachedPrimaryKeys.remove(carrier.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(CarrierModelImpl.ENTITY_CACHE_ENABLED, CarrierImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }