Example usage for com.liferay.portal.kernel.util StringPool CLOSE_PARENTHESIS

List of usage examples for com.liferay.portal.kernel.util StringPool CLOSE_PARENTHESIS

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util StringPool CLOSE_PARENTHESIS.

Prototype

String CLOSE_PARENTHESIS

To view the source code for com.liferay.portal.kernel.util StringPool CLOSE_PARENTHESIS.

Click Source Link

Usage

From source file:com.liferay.gs.hack.service.persistence.impl.TimesheetPersistenceImpl.java

License:Open Source License

@Override
public Map<Serializable, Timesheet> fetchByPrimaryKeys(Set<Serializable> primaryKeys) {
    if (primaryKeys.isEmpty()) {
        return Collections.emptyMap();
    }/* www . j a v  a  2  s  .c  o m*/

    Map<Serializable, Timesheet> map = new HashMap<Serializable, Timesheet>();

    if (primaryKeys.size() == 1) {
        Iterator<Serializable> iterator = primaryKeys.iterator();

        Serializable primaryKey = iterator.next();

        Timesheet timesheet = fetchByPrimaryKey(primaryKey);

        if (timesheet != null) {
            map.put(primaryKey, timesheet);
        }

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        Serializable serializable = entityCache.getResult(TimesheetModelImpl.ENTITY_CACHE_ENABLED,
                TimesheetImpl.class, primaryKey);

        if (serializable != nullModel) {
            if (serializable == null) {
                if (uncachedPrimaryKeys == null) {
                    uncachedPrimaryKeys = new HashSet<Serializable>();
                }

                uncachedPrimaryKeys.add(primaryKey);
            } else {
                map.put(primaryKey, (Timesheet) serializable);
            }
        }
    }

    if (uncachedPrimaryKeys == null) {
        return map;
    }

    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1);

    query.append(_SQL_SELECT_TIMESHEET_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 (Timesheet timesheet : (List<Timesheet>) q.list()) {
            map.put(timesheet.getPrimaryKeyObj(), timesheet);

            cacheResult(timesheet);

            uncachedPrimaryKeys.remove(timesheet.getPrimaryKeyObj());
        }

        for (Serializable primaryKey : uncachedPrimaryKeys) {
            entityCache.putResult(TimesheetModelImpl.ENTITY_CACHE_ENABLED, TimesheetImpl.class, primaryKey,
                    nullModel);
        }
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }

    return map;
}

From source file:com.liferay.ide.utils.library.listener.service.persistence.impl.LibraryPersistenceImpl.java

License:Open Source License

@Override
public Map<Serializable, Library> fetchByPrimaryKeys(Set<Serializable> primaryKeys) {
    if (primaryKeys.isEmpty()) {
        return Collections.emptyMap();
    }/*from  w ww  .j  a v a  2 s.c o m*/

    Map<Serializable, Library> map = new HashMap<Serializable, Library>();

    if (primaryKeys.size() == 1) {
        Iterator<Serializable> iterator = primaryKeys.iterator();

        Serializable primaryKey = iterator.next();

        Library library = fetchByPrimaryKey(primaryKey);

        if (library != null) {
            map.put(primaryKey, library);
        }

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        Serializable serializable = entityCache.getResult(LibraryModelImpl.ENTITY_CACHE_ENABLED,
                LibraryImpl.class, primaryKey);

        if (serializable != nullModel) {
            if (serializable == null) {
                if (uncachedPrimaryKeys == null) {
                    uncachedPrimaryKeys = new HashSet<Serializable>();
                }

                uncachedPrimaryKeys.add(primaryKey);
            } else {
                map.put(primaryKey, (Library) serializable);
            }
        }
    }

    if (uncachedPrimaryKeys == null) {
        return map;
    }

    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1);

    query.append(_SQL_SELECT_LIBRARY_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 (Library library : (List<Library>) q.list()) {
            map.put(library.getPrimaryKeyObj(), library);

            cacheResult(library);

            uncachedPrimaryKeys.remove(library.getPrimaryKeyObj());
        }

        for (Serializable primaryKey : uncachedPrimaryKeys) {
            entityCache.putResult(LibraryModelImpl.ENTITY_CACHE_ENABLED, LibraryImpl.class, primaryKey,
                    nullModel);
        }
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }

    return map;
}

From source file:com.liferay.ide.utils.library.listener.service.persistence.impl.RepositoryPersistenceImpl.java

License:Open Source License

@Override
public Map<Serializable, Repository> fetchByPrimaryKeys(Set<Serializable> primaryKeys) {
    if (primaryKeys.isEmpty()) {
        return Collections.emptyMap();
    }/*from  w  w w . jav a  2  s  . c  o m*/

    Map<Serializable, Repository> map = new HashMap<Serializable, Repository>();

    if (primaryKeys.size() == 1) {
        Iterator<Serializable> iterator = primaryKeys.iterator();

        Serializable primaryKey = iterator.next();

        Repository repository = fetchByPrimaryKey(primaryKey);

        if (repository != null) {
            map.put(primaryKey, repository);
        }

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        Serializable serializable = entityCache.getResult(RepositoryModelImpl.ENTITY_CACHE_ENABLED,
                RepositoryImpl.class, primaryKey);

        if (serializable != nullModel) {
            if (serializable == null) {
                if (uncachedPrimaryKeys == null) {
                    uncachedPrimaryKeys = new HashSet<Serializable>();
                }

                uncachedPrimaryKeys.add(primaryKey);
            } else {
                map.put(primaryKey, (Repository) serializable);
            }
        }
    }

    if (uncachedPrimaryKeys == null) {
        return map;
    }

    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1);

    query.append(_SQL_SELECT_REPOSITORY_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 (Repository repository : (List<Repository>) q.list()) {
            map.put(repository.getPrimaryKeyObj(), repository);

            cacheResult(repository);

            uncachedPrimaryKeys.remove(repository.getPrimaryKeyObj());
        }

        for (Serializable primaryKey : uncachedPrimaryKeys) {
            entityCache.putResult(RepositoryModelImpl.ENTITY_CACHE_ENABLED, RepositoryImpl.class, primaryKey,
                    nullModel);
        }
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }

    return map;
}

From source file:com.liferay.invitation.invite.members.service.persistence.impl.MemberRequestPersistenceImpl.java

License:Open Source License

@Override
public Map<Serializable, MemberRequest> fetchByPrimaryKeys(Set<Serializable> primaryKeys) {
    if (primaryKeys.isEmpty()) {
        return Collections.emptyMap();
    }/* ww  w  .  j a v  a 2s .c o m*/

    Map<Serializable, MemberRequest> map = new HashMap<Serializable, MemberRequest>();

    if (primaryKeys.size() == 1) {
        Iterator<Serializable> iterator = primaryKeys.iterator();

        Serializable primaryKey = iterator.next();

        MemberRequest memberRequest = fetchByPrimaryKey(primaryKey);

        if (memberRequest != null) {
            map.put(primaryKey, memberRequest);
        }

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        Serializable serializable = entityCache.getResult(MemberRequestModelImpl.ENTITY_CACHE_ENABLED,
                MemberRequestImpl.class, primaryKey);

        if (serializable != nullModel) {
            if (serializable == null) {
                if (uncachedPrimaryKeys == null) {
                    uncachedPrimaryKeys = new HashSet<Serializable>();
                }

                uncachedPrimaryKeys.add(primaryKey);
            } else {
                map.put(primaryKey, (MemberRequest) serializable);
            }
        }
    }

    if (uncachedPrimaryKeys == null) {
        return map;
    }

    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1);

    query.append(_SQL_SELECT_MEMBERREQUEST_WHERE_PKS_IN);

    for (Serializable primaryKey : uncachedPrimaryKeys) {
        query.append((long) 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 (MemberRequest memberRequest : (List<MemberRequest>) q.list()) {
            map.put(memberRequest.getPrimaryKeyObj(), memberRequest);

            cacheResult(memberRequest);

            uncachedPrimaryKeys.remove(memberRequest.getPrimaryKeyObj());
        }

        for (Serializable primaryKey : uncachedPrimaryKeys) {
            entityCache.putResult(MemberRequestModelImpl.ENTITY_CACHE_ENABLED, MemberRequestImpl.class,
                    primaryKey, nullModel);
        }
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }

    return map;
}

From source file:com.liferay.journal.service.persistence.impl.JournalArticleFinderImpl.java

License:Open Source License

protected String getDDMStructureKeys(String[] ddmStructureKeys, String tableName) {

    if (ArrayUtil.isEmpty(ddmStructureKeys)) {
        return StringPool.BLANK;
    }/* ww  w .  j ava  2s .  co m*/

    StringBundler sb = new StringBundler(ddmStructureKeys.length * 3 + 1);

    sb.append(StringPool.OPEN_PARENTHESIS);

    for (int i = 0; i < ddmStructureKeys.length; i++) {
        sb.append(tableName);
        sb.append(".DDMStructureKey = ? ");
        sb.append(WHERE_OR);
    }

    sb.setIndex(sb.index() - 1);

    sb.append(StringPool.CLOSE_PARENTHESIS);

    return sb.toString();
}

From source file:com.liferay.journal.service.persistence.impl.JournalArticleFinderImpl.java

License:Open Source License

protected String getFolderIds(List<Long> folderIds, String tableName) {
    if (folderIds.isEmpty()) {
        return StringPool.BLANK;
    }//from   w w w. j a  v a2 s  .c  o m

    StringBundler sb = new StringBundler(folderIds.size() * 3 + 1);

    sb.append(StringPool.OPEN_PARENTHESIS);

    for (int i = 0; i < folderIds.size(); i++) {
        sb.append(tableName);
        sb.append(".folderId = ? ");

        if ((i + 1) != folderIds.size()) {
            sb.append(WHERE_OR);
        }
    }

    sb.append(StringPool.CLOSE_PARENTHESIS);

    return sb.toString();
}

From source file:com.liferay.journal.service.persistence.impl.JournalArticleLocalizationPersistenceImpl.java

License:Open Source License

@Override
public Map<Serializable, JournalArticleLocalization> fetchByPrimaryKeys(Set<Serializable> primaryKeys) {
    if (primaryKeys.isEmpty()) {
        return Collections.emptyMap();
    }/*  www .  j  av  a2  s  . co m*/

    Map<Serializable, JournalArticleLocalization> map = new HashMap<Serializable, JournalArticleLocalization>();

    if (primaryKeys.size() == 1) {
        Iterator<Serializable> iterator = primaryKeys.iterator();

        Serializable primaryKey = iterator.next();

        JournalArticleLocalization journalArticleLocalization = fetchByPrimaryKey(primaryKey);

        if (journalArticleLocalization != null) {
            map.put(primaryKey, journalArticleLocalization);
        }

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        Serializable serializable = entityCache.getResult(
                JournalArticleLocalizationModelImpl.ENTITY_CACHE_ENABLED, JournalArticleLocalizationImpl.class,
                primaryKey);

        if (serializable != nullModel) {
            if (serializable == null) {
                if (uncachedPrimaryKeys == null) {
                    uncachedPrimaryKeys = new HashSet<Serializable>();
                }

                uncachedPrimaryKeys.add(primaryKey);
            } else {
                map.put(primaryKey, (JournalArticleLocalization) serializable);
            }
        }
    }

    if (uncachedPrimaryKeys == null) {
        return map;
    }

    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1);

    query.append(_SQL_SELECT_JOURNALARTICLELOCALIZATION_WHERE_PKS_IN);

    for (Serializable primaryKey : uncachedPrimaryKeys) {
        query.append((long) 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 (JournalArticleLocalization journalArticleLocalization : (List<JournalArticleLocalization>) q
                .list()) {
            map.put(journalArticleLocalization.getPrimaryKeyObj(), journalArticleLocalization);

            cacheResult(journalArticleLocalization);

            uncachedPrimaryKeys.remove(journalArticleLocalization.getPrimaryKeyObj());
        }

        for (Serializable primaryKey : uncachedPrimaryKeys) {
            entityCache.putResult(JournalArticleLocalizationModelImpl.ENTITY_CACHE_ENABLED,
                    JournalArticleLocalizationImpl.class, primaryKey, nullModel);
        }
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }

    return map;
}

From source file:com.liferay.journal.service.persistence.impl.JournalArticlePersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the journal articles where DDMStructureKey = &#63;, optionally using the finder cache.
 *
 * <p>//from w  ww . ja v 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. 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 DDMStructureKey the ddm structure key
 * @param start the lower bound of the range of journal articles
 * @param end the upper bound of the range of journal articles (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @param retrieveFromCache whether to retrieve from the finder cache
 * @return the ordered range of matching journal articles
 */
@Override
public List<JournalArticle> findByDDMStructureKey(String[] DDMStructureKeies, int start, int end,
        OrderByComparator<JournalArticle> orderByComparator, boolean retrieveFromCache) {
    if (DDMStructureKeies == null) {
        DDMStructureKeies = new String[0];
    } else if (DDMStructureKeies.length > 1) {
        DDMStructureKeies = ArrayUtil.distinct(DDMStructureKeies, NULL_SAFE_STRING_COMPARATOR);

        Arrays.sort(DDMStructureKeies, NULL_SAFE_STRING_COMPARATOR);
    }

    if (DDMStructureKeies.length == 1) {
        return findByDDMStructureKey(DDMStructureKeies[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[] { StringUtil.merge(DDMStructureKeies) };
    } else {
        finderArgs = new Object[] { StringUtil.merge(DDMStructureKeies),

                start, end, orderByComparator };
    }

    List<JournalArticle> list = null;

    if (retrieveFromCache) {
        list = (List<JournalArticle>) finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_DDMSTRUCTUREKEY,
                finderArgs, this);

        if ((list != null) && !list.isEmpty()) {
            for (JournalArticle journalArticle : list) {
                if (!ArrayUtil.contains(DDMStructureKeies, journalArticle.getDDMStructureKey())) {
                    list = null;

                    break;
                }
            }
        }
    }

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

        query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);

        if (DDMStructureKeies.length > 0) {
            query.append(StringPool.OPEN_PARENTHESIS);

            for (int i = 0; i < DDMStructureKeies.length; i++) {
                String DDMStructureKey = DDMStructureKeies[i];

                if (DDMStructureKey == null) {
                    query.append(_FINDER_COLUMN_DDMSTRUCTUREKEY_DDMSTRUCTUREKEY_1);
                } else if (DDMStructureKey.equals(StringPool.BLANK)) {
                    query.append(_FINDER_COLUMN_DDMSTRUCTUREKEY_DDMSTRUCTUREKEY_3);
                } else {
                    query.append(_FINDER_COLUMN_DDMSTRUCTUREKEY_DDMSTRUCTUREKEY_2);
                }

                if ((i + 1) < DDMStructureKeies.length) {
                    query.append(WHERE_OR);
                }
            }

            query.append(StringPool.CLOSE_PARENTHESIS);
        }

        query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1);

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

        String sql = query.toString();

        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(sql);

            QueryPos qPos = QueryPos.getInstance(q);

            for (String DDMStructureKey : DDMStructureKeies) {
                if ((DDMStructureKey != null) && !DDMStructureKey.isEmpty()) {
                    qPos.add(DDMStructureKey);
                }
            }

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

                Collections.sort(list);

                list = Collections.unmodifiableList(list);
            } else {
                list = (List<JournalArticle>) QueryUtil.list(q, getDialect(), start, end);
            }

            cacheResult(list);

            finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_DDMSTRUCTUREKEY, finderArgs, list);
        } catch (Exception e) {
            finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_DDMSTRUCTUREKEY, finderArgs);

            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    return list;
}

From source file:com.liferay.journal.service.persistence.impl.JournalArticlePersistenceImpl.java

License:Open Source License

/**
 * Returns the number of journal articles where DDMStructureKey = any &#63;.
 *
 * @param DDMStructureKeies the ddm structure keies
 * @return the number of matching journal articles
 */// ww w  .j av  a  2 s  . c om
@Override
public int countByDDMStructureKey(String[] DDMStructureKeies) {
    if (DDMStructureKeies == null) {
        DDMStructureKeies = new String[0];
    } else if (DDMStructureKeies.length > 1) {
        DDMStructureKeies = ArrayUtil.distinct(DDMStructureKeies, NULL_SAFE_STRING_COMPARATOR);

        Arrays.sort(DDMStructureKeies, NULL_SAFE_STRING_COMPARATOR);
    }

    Object[] finderArgs = new Object[] { StringUtil.merge(DDMStructureKeies) };

    Long count = (Long) finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_DDMSTRUCTUREKEY, finderArgs,
            this);

    if (count == null) {
        StringBundler query = new StringBundler();

        query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);

        if (DDMStructureKeies.length > 0) {
            query.append(StringPool.OPEN_PARENTHESIS);

            for (int i = 0; i < DDMStructureKeies.length; i++) {
                String DDMStructureKey = DDMStructureKeies[i];

                if (DDMStructureKey == null) {
                    query.append(_FINDER_COLUMN_DDMSTRUCTUREKEY_DDMSTRUCTUREKEY_1);
                } else if (DDMStructureKey.equals(StringPool.BLANK)) {
                    query.append(_FINDER_COLUMN_DDMSTRUCTUREKEY_DDMSTRUCTUREKEY_3);
                } else {
                    query.append(_FINDER_COLUMN_DDMSTRUCTUREKEY_DDMSTRUCTUREKEY_2);
                }

                if ((i + 1) < DDMStructureKeies.length) {
                    query.append(WHERE_OR);
                }
            }

            query.append(StringPool.CLOSE_PARENTHESIS);
        }

        query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1);

        String sql = query.toString();

        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(sql);

            QueryPos qPos = QueryPos.getInstance(q);

            for (String DDMStructureKey : DDMStructureKeies) {
                if ((DDMStructureKey != null) && !DDMStructureKey.isEmpty()) {
                    qPos.add(DDMStructureKey);
                }
            }

            count = (Long) q.uniqueResult();

            finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_DDMSTRUCTUREKEY, finderArgs, count);
        } catch (Exception e) {
            finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_DDMSTRUCTUREKEY, finderArgs);

            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    return count.intValue();
}

From source file:com.liferay.journal.service.persistence.impl.JournalArticlePersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and status = &#63;, optionally using the finder cache.
 *
 * <p>//from  w  w w.ja  va2 s.co m
 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. 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 resourcePrimKey the resource prim key
 * @param status the status
 * @param start the lower bound of the range of journal articles
 * @param end the upper bound of the range of journal articles (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @param retrieveFromCache whether to retrieve from the finder cache
 * @return the ordered range of matching journal articles
 */
@Override
public List<JournalArticle> findByR_ST(long resourcePrimKey, int[] statuses, int start, int end,
        OrderByComparator<JournalArticle> orderByComparator, boolean retrieveFromCache) {
    if (statuses == null) {
        statuses = new int[0];
    } else if (statuses.length > 1) {
        statuses = ArrayUtil.unique(statuses);

        Arrays.sort(statuses);
    }

    if (statuses.length == 1) {
        return findByR_ST(resourcePrimKey, 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[] { resourcePrimKey, StringUtil.merge(statuses) };
    } else {
        finderArgs = new Object[] { resourcePrimKey, StringUtil.merge(statuses),

                start, end, orderByComparator };
    }

    List<JournalArticle> list = null;

    if (retrieveFromCache) {
        list = (List<JournalArticle>) finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST,
                finderArgs, this);

        if ((list != null) && !list.isEmpty()) {
            for (JournalArticle journalArticle : list) {
                if ((resourcePrimKey != journalArticle.getResourcePrimKey())
                        || !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
                    list = null;

                    break;
                }
            }
        }
    }

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

        query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);

        query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);

        if (statuses.length > 0) {
            query.append(StringPool.OPEN_PARENTHESIS);

            query.append(_FINDER_COLUMN_R_ST_STATUS_7);

            query.append(StringUtil.merge(statuses));

            query.append(StringPool.CLOSE_PARENTHESIS);

            query.append(StringPool.CLOSE_PARENTHESIS);
        }

        query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1);

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

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

                Collections.sort(list);

                list = Collections.unmodifiableList(list);
            } else {
                list = (List<JournalArticle>) QueryUtil.list(q, getDialect(), start, end);
            }

            cacheResult(list);

            finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST, finderArgs, list);
        } catch (Exception e) {
            finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST, finderArgs);

            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    return list;
}