001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.journal.service.persistence.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.SQLQuery;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.util.ArrayUtil;
031    import com.liferay.portal.kernel.util.OrderByComparator;
032    import com.liferay.portal.kernel.util.SetUtil;
033    import com.liferay.portal.kernel.util.StringBundler;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.kernel.util.StringUtil;
036    import com.liferay.portal.kernel.util.Validator;
037    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
038    import com.liferay.portal.model.CacheModel;
039    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
040    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
041    
042    import com.liferay.portlet.journal.NoSuchArticleException;
043    import com.liferay.portlet.journal.model.JournalArticle;
044    import com.liferay.portlet.journal.model.impl.JournalArticleImpl;
045    import com.liferay.portlet.journal.model.impl.JournalArticleModelImpl;
046    import com.liferay.portlet.journal.service.persistence.JournalArticlePersistence;
047    
048    import java.io.Serializable;
049    
050    import java.sql.Timestamp;
051    
052    import java.util.Collections;
053    import java.util.Date;
054    import java.util.HashMap;
055    import java.util.HashSet;
056    import java.util.Iterator;
057    import java.util.List;
058    import java.util.Map;
059    import java.util.Set;
060    
061    /**
062     * The persistence implementation for the journal article service.
063     *
064     * <p>
065     * Caching information and settings can be found in <code>portal.properties</code>
066     * </p>
067     *
068     * @author Brian Wing Shun Chan
069     * @see JournalArticlePersistence
070     * @see JournalArticleUtil
071     * @generated
072     */
073    @ProviderType
074    public class JournalArticlePersistenceImpl extends BasePersistenceImpl<JournalArticle>
075            implements JournalArticlePersistence {
076            /*
077             * NOTE FOR DEVELOPERS:
078             *
079             * Never modify or reference this class directly. Always use {@link JournalArticleUtil} to access the journal article persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
080             */
081            public static final String FINDER_CLASS_NAME_ENTITY = JournalArticleImpl.class.getName();
082            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
083                    ".List1";
084            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
085                    ".List2";
086            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
087                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
088                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
089                            "findAll", new String[0]);
090            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
091                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
092                            JournalArticleImpl.class,
093                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
094            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
095                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
096                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
097            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
098                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
099                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
100                            "findByUuid",
101                            new String[] {
102                                    String.class.getName(),
103                                    
104                            Integer.class.getName(), Integer.class.getName(),
105                                    OrderByComparator.class.getName()
106                            });
107            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
108                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
109                            JournalArticleImpl.class,
110                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
111                            new String[] { String.class.getName() },
112                            JournalArticleModelImpl.UUID_COLUMN_BITMASK |
113                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
114                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
115            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
116                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
117                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
118                            new String[] { String.class.getName() });
119    
120            /**
121             * Returns all the journal articles where uuid = &#63;.
122             *
123             * @param uuid the uuid
124             * @return the matching journal articles
125             */
126            @Override
127            public List<JournalArticle> findByUuid(String uuid) {
128                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
129            }
130    
131            /**
132             * Returns a range of all the journal articles where uuid = &#63;.
133             *
134             * <p>
135             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
136             * </p>
137             *
138             * @param uuid the uuid
139             * @param start the lower bound of the range of journal articles
140             * @param end the upper bound of the range of journal articles (not inclusive)
141             * @return the range of matching journal articles
142             */
143            @Override
144            public List<JournalArticle> findByUuid(String uuid, int start, int end) {
145                    return findByUuid(uuid, start, end, null);
146            }
147    
148            /**
149             * Returns an ordered range of all the journal articles where uuid = &#63;.
150             *
151             * <p>
152             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
153             * </p>
154             *
155             * @param uuid the uuid
156             * @param start the lower bound of the range of journal articles
157             * @param end the upper bound of the range of journal articles (not inclusive)
158             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
159             * @return the ordered range of matching journal articles
160             */
161            @Override
162            public List<JournalArticle> findByUuid(String uuid, int start, int end,
163                    OrderByComparator<JournalArticle> orderByComparator) {
164                    boolean pagination = true;
165                    FinderPath finderPath = null;
166                    Object[] finderArgs = null;
167    
168                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
169                                    (orderByComparator == null)) {
170                            pagination = false;
171                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
172                            finderArgs = new Object[] { uuid };
173                    }
174                    else {
175                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
176                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
177                    }
178    
179                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
180                                    finderArgs, this);
181    
182                    if ((list != null) && !list.isEmpty()) {
183                            for (JournalArticle journalArticle : list) {
184                                    if (!Validator.equals(uuid, journalArticle.getUuid())) {
185                                            list = null;
186    
187                                            break;
188                                    }
189                            }
190                    }
191    
192                    if (list == null) {
193                            StringBundler query = null;
194    
195                            if (orderByComparator != null) {
196                                    query = new StringBundler(3 +
197                                                    (orderByComparator.getOrderByFields().length * 3));
198                            }
199                            else {
200                                    query = new StringBundler(3);
201                            }
202    
203                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
204    
205                            boolean bindUuid = false;
206    
207                            if (uuid == null) {
208                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
209                            }
210                            else if (uuid.equals(StringPool.BLANK)) {
211                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
212                            }
213                            else {
214                                    bindUuid = true;
215    
216                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
217                            }
218    
219                            if (orderByComparator != null) {
220                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
221                                            orderByComparator);
222                            }
223                            else
224                             if (pagination) {
225                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
226                            }
227    
228                            String sql = query.toString();
229    
230                            Session session = null;
231    
232                            try {
233                                    session = openSession();
234    
235                                    Query q = session.createQuery(sql);
236    
237                                    QueryPos qPos = QueryPos.getInstance(q);
238    
239                                    if (bindUuid) {
240                                            qPos.add(uuid);
241                                    }
242    
243                                    if (!pagination) {
244                                            list = (List<JournalArticle>)QueryUtil.list(q,
245                                                            getDialect(), start, end, false);
246    
247                                            Collections.sort(list);
248    
249                                            list = Collections.unmodifiableList(list);
250                                    }
251                                    else {
252                                            list = (List<JournalArticle>)QueryUtil.list(q,
253                                                            getDialect(), start, end);
254                                    }
255    
256                                    cacheResult(list);
257    
258                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
259                            }
260                            catch (Exception e) {
261                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
262    
263                                    throw processException(e);
264                            }
265                            finally {
266                                    closeSession(session);
267                            }
268                    }
269    
270                    return list;
271            }
272    
273            /**
274             * Returns the first journal article in the ordered set where uuid = &#63;.
275             *
276             * @param uuid the uuid
277             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
278             * @return the first matching journal article
279             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
280             */
281            @Override
282            public JournalArticle findByUuid_First(String uuid,
283                    OrderByComparator<JournalArticle> orderByComparator)
284                    throws NoSuchArticleException {
285                    JournalArticle journalArticle = fetchByUuid_First(uuid,
286                                    orderByComparator);
287    
288                    if (journalArticle != null) {
289                            return journalArticle;
290                    }
291    
292                    StringBundler msg = new StringBundler(4);
293    
294                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
295    
296                    msg.append("uuid=");
297                    msg.append(uuid);
298    
299                    msg.append(StringPool.CLOSE_CURLY_BRACE);
300    
301                    throw new NoSuchArticleException(msg.toString());
302            }
303    
304            /**
305             * Returns the first journal article in the ordered set where uuid = &#63;.
306             *
307             * @param uuid the uuid
308             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
309             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
310             */
311            @Override
312            public JournalArticle fetchByUuid_First(String uuid,
313                    OrderByComparator<JournalArticle> orderByComparator) {
314                    List<JournalArticle> list = findByUuid(uuid, 0, 1, orderByComparator);
315    
316                    if (!list.isEmpty()) {
317                            return list.get(0);
318                    }
319    
320                    return null;
321            }
322    
323            /**
324             * Returns the last journal article in the ordered set where uuid = &#63;.
325             *
326             * @param uuid the uuid
327             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
328             * @return the last matching journal article
329             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
330             */
331            @Override
332            public JournalArticle findByUuid_Last(String uuid,
333                    OrderByComparator<JournalArticle> orderByComparator)
334                    throws NoSuchArticleException {
335                    JournalArticle journalArticle = fetchByUuid_Last(uuid, orderByComparator);
336    
337                    if (journalArticle != null) {
338                            return journalArticle;
339                    }
340    
341                    StringBundler msg = new StringBundler(4);
342    
343                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
344    
345                    msg.append("uuid=");
346                    msg.append(uuid);
347    
348                    msg.append(StringPool.CLOSE_CURLY_BRACE);
349    
350                    throw new NoSuchArticleException(msg.toString());
351            }
352    
353            /**
354             * Returns the last journal article in the ordered set where uuid = &#63;.
355             *
356             * @param uuid the uuid
357             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
358             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
359             */
360            @Override
361            public JournalArticle fetchByUuid_Last(String uuid,
362                    OrderByComparator<JournalArticle> orderByComparator) {
363                    int count = countByUuid(uuid);
364    
365                    if (count == 0) {
366                            return null;
367                    }
368    
369                    List<JournalArticle> list = findByUuid(uuid, count - 1, count,
370                                    orderByComparator);
371    
372                    if (!list.isEmpty()) {
373                            return list.get(0);
374                    }
375    
376                    return null;
377            }
378    
379            /**
380             * Returns the journal articles before and after the current journal article in the ordered set where uuid = &#63;.
381             *
382             * @param id the primary key of the current journal article
383             * @param uuid the uuid
384             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
385             * @return the previous, current, and next journal article
386             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
387             */
388            @Override
389            public JournalArticle[] findByUuid_PrevAndNext(long id, String uuid,
390                    OrderByComparator<JournalArticle> orderByComparator)
391                    throws NoSuchArticleException {
392                    JournalArticle journalArticle = findByPrimaryKey(id);
393    
394                    Session session = null;
395    
396                    try {
397                            session = openSession();
398    
399                            JournalArticle[] array = new JournalArticleImpl[3];
400    
401                            array[0] = getByUuid_PrevAndNext(session, journalArticle, uuid,
402                                            orderByComparator, true);
403    
404                            array[1] = journalArticle;
405    
406                            array[2] = getByUuid_PrevAndNext(session, journalArticle, uuid,
407                                            orderByComparator, false);
408    
409                            return array;
410                    }
411                    catch (Exception e) {
412                            throw processException(e);
413                    }
414                    finally {
415                            closeSession(session);
416                    }
417            }
418    
419            protected JournalArticle getByUuid_PrevAndNext(Session session,
420                    JournalArticle journalArticle, String uuid,
421                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
422                    StringBundler query = null;
423    
424                    if (orderByComparator != null) {
425                            query = new StringBundler(6 +
426                                            (orderByComparator.getOrderByFields().length * 6));
427                    }
428                    else {
429                            query = new StringBundler(3);
430                    }
431    
432                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
433    
434                    boolean bindUuid = false;
435    
436                    if (uuid == null) {
437                            query.append(_FINDER_COLUMN_UUID_UUID_1);
438                    }
439                    else if (uuid.equals(StringPool.BLANK)) {
440                            query.append(_FINDER_COLUMN_UUID_UUID_3);
441                    }
442                    else {
443                            bindUuid = true;
444    
445                            query.append(_FINDER_COLUMN_UUID_UUID_2);
446                    }
447    
448                    if (orderByComparator != null) {
449                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
450    
451                            if (orderByConditionFields.length > 0) {
452                                    query.append(WHERE_AND);
453                            }
454    
455                            for (int i = 0; i < orderByConditionFields.length; i++) {
456                                    query.append(_ORDER_BY_ENTITY_ALIAS);
457                                    query.append(orderByConditionFields[i]);
458    
459                                    if ((i + 1) < orderByConditionFields.length) {
460                                            if (orderByComparator.isAscending() ^ previous) {
461                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
462                                            }
463                                            else {
464                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
465                                            }
466                                    }
467                                    else {
468                                            if (orderByComparator.isAscending() ^ previous) {
469                                                    query.append(WHERE_GREATER_THAN);
470                                            }
471                                            else {
472                                                    query.append(WHERE_LESSER_THAN);
473                                            }
474                                    }
475                            }
476    
477                            query.append(ORDER_BY_CLAUSE);
478    
479                            String[] orderByFields = orderByComparator.getOrderByFields();
480    
481                            for (int i = 0; i < orderByFields.length; i++) {
482                                    query.append(_ORDER_BY_ENTITY_ALIAS);
483                                    query.append(orderByFields[i]);
484    
485                                    if ((i + 1) < orderByFields.length) {
486                                            if (orderByComparator.isAscending() ^ previous) {
487                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
488                                            }
489                                            else {
490                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
491                                            }
492                                    }
493                                    else {
494                                            if (orderByComparator.isAscending() ^ previous) {
495                                                    query.append(ORDER_BY_ASC);
496                                            }
497                                            else {
498                                                    query.append(ORDER_BY_DESC);
499                                            }
500                                    }
501                            }
502                    }
503                    else {
504                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
505                    }
506    
507                    String sql = query.toString();
508    
509                    Query q = session.createQuery(sql);
510    
511                    q.setFirstResult(0);
512                    q.setMaxResults(2);
513    
514                    QueryPos qPos = QueryPos.getInstance(q);
515    
516                    if (bindUuid) {
517                            qPos.add(uuid);
518                    }
519    
520                    if (orderByComparator != null) {
521                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
522    
523                            for (Object value : values) {
524                                    qPos.add(value);
525                            }
526                    }
527    
528                    List<JournalArticle> list = q.list();
529    
530                    if (list.size() == 2) {
531                            return list.get(1);
532                    }
533                    else {
534                            return null;
535                    }
536            }
537    
538            /**
539             * Removes all the journal articles where uuid = &#63; from the database.
540             *
541             * @param uuid the uuid
542             */
543            @Override
544            public void removeByUuid(String uuid) {
545                    for (JournalArticle journalArticle : findByUuid(uuid,
546                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
547                            remove(journalArticle);
548                    }
549            }
550    
551            /**
552             * Returns the number of journal articles where uuid = &#63;.
553             *
554             * @param uuid the uuid
555             * @return the number of matching journal articles
556             */
557            @Override
558            public int countByUuid(String uuid) {
559                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
560    
561                    Object[] finderArgs = new Object[] { uuid };
562    
563                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
564                                    this);
565    
566                    if (count == null) {
567                            StringBundler query = new StringBundler(2);
568    
569                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
570    
571                            boolean bindUuid = false;
572    
573                            if (uuid == null) {
574                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
575                            }
576                            else if (uuid.equals(StringPool.BLANK)) {
577                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
578                            }
579                            else {
580                                    bindUuid = true;
581    
582                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
583                            }
584    
585                            String sql = query.toString();
586    
587                            Session session = null;
588    
589                            try {
590                                    session = openSession();
591    
592                                    Query q = session.createQuery(sql);
593    
594                                    QueryPos qPos = QueryPos.getInstance(q);
595    
596                                    if (bindUuid) {
597                                            qPos.add(uuid);
598                                    }
599    
600                                    count = (Long)q.uniqueResult();
601    
602                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
603                            }
604                            catch (Exception e) {
605                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
606    
607                                    throw processException(e);
608                            }
609                            finally {
610                                    closeSession(session);
611                            }
612                    }
613    
614                    return count.intValue();
615            }
616    
617            private static final String _FINDER_COLUMN_UUID_UUID_1 = "journalArticle.uuid IS NULL";
618            private static final String _FINDER_COLUMN_UUID_UUID_2 = "journalArticle.uuid = ?";
619            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = '')";
620            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
621                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
622                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY,
623                            "fetchByUUID_G",
624                            new String[] { String.class.getName(), Long.class.getName() },
625                            JournalArticleModelImpl.UUID_COLUMN_BITMASK |
626                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK);
627            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
628                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
629                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
630                            new String[] { String.class.getName(), Long.class.getName() });
631    
632            /**
633             * Returns the journal article where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.journal.NoSuchArticleException} if it could not be found.
634             *
635             * @param uuid the uuid
636             * @param groupId the group ID
637             * @return the matching journal article
638             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
639             */
640            @Override
641            public JournalArticle findByUUID_G(String uuid, long groupId)
642                    throws NoSuchArticleException {
643                    JournalArticle journalArticle = fetchByUUID_G(uuid, groupId);
644    
645                    if (journalArticle == null) {
646                            StringBundler msg = new StringBundler(6);
647    
648                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
649    
650                            msg.append("uuid=");
651                            msg.append(uuid);
652    
653                            msg.append(", groupId=");
654                            msg.append(groupId);
655    
656                            msg.append(StringPool.CLOSE_CURLY_BRACE);
657    
658                            if (_log.isWarnEnabled()) {
659                                    _log.warn(msg.toString());
660                            }
661    
662                            throw new NoSuchArticleException(msg.toString());
663                    }
664    
665                    return journalArticle;
666            }
667    
668            /**
669             * Returns the journal article where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
670             *
671             * @param uuid the uuid
672             * @param groupId the group ID
673             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
674             */
675            @Override
676            public JournalArticle fetchByUUID_G(String uuid, long groupId) {
677                    return fetchByUUID_G(uuid, groupId, true);
678            }
679    
680            /**
681             * Returns the journal article where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
682             *
683             * @param uuid the uuid
684             * @param groupId the group ID
685             * @param retrieveFromCache whether to use the finder cache
686             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
687             */
688            @Override
689            public JournalArticle fetchByUUID_G(String uuid, long groupId,
690                    boolean retrieveFromCache) {
691                    Object[] finderArgs = new Object[] { uuid, groupId };
692    
693                    Object result = null;
694    
695                    if (retrieveFromCache) {
696                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
697                                            finderArgs, this);
698                    }
699    
700                    if (result instanceof JournalArticle) {
701                            JournalArticle journalArticle = (JournalArticle)result;
702    
703                            if (!Validator.equals(uuid, journalArticle.getUuid()) ||
704                                            (groupId != journalArticle.getGroupId())) {
705                                    result = null;
706                            }
707                    }
708    
709                    if (result == null) {
710                            StringBundler query = new StringBundler(4);
711    
712                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
713    
714                            boolean bindUuid = false;
715    
716                            if (uuid == null) {
717                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
718                            }
719                            else if (uuid.equals(StringPool.BLANK)) {
720                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
721                            }
722                            else {
723                                    bindUuid = true;
724    
725                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
726                            }
727    
728                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
729    
730                            String sql = query.toString();
731    
732                            Session session = null;
733    
734                            try {
735                                    session = openSession();
736    
737                                    Query q = session.createQuery(sql);
738    
739                                    QueryPos qPos = QueryPos.getInstance(q);
740    
741                                    if (bindUuid) {
742                                            qPos.add(uuid);
743                                    }
744    
745                                    qPos.add(groupId);
746    
747                                    List<JournalArticle> list = q.list();
748    
749                                    if (list.isEmpty()) {
750                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
751                                                    finderArgs, list);
752                                    }
753                                    else {
754                                            JournalArticle journalArticle = list.get(0);
755    
756                                            result = journalArticle;
757    
758                                            cacheResult(journalArticle);
759    
760                                            if ((journalArticle.getUuid() == null) ||
761                                                            !journalArticle.getUuid().equals(uuid) ||
762                                                            (journalArticle.getGroupId() != groupId)) {
763                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
764                                                            finderArgs, journalArticle);
765                                            }
766                                    }
767                            }
768                            catch (Exception e) {
769                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
770                                            finderArgs);
771    
772                                    throw processException(e);
773                            }
774                            finally {
775                                    closeSession(session);
776                            }
777                    }
778    
779                    if (result instanceof List<?>) {
780                            return null;
781                    }
782                    else {
783                            return (JournalArticle)result;
784                    }
785            }
786    
787            /**
788             * Removes the journal article where uuid = &#63; and groupId = &#63; from the database.
789             *
790             * @param uuid the uuid
791             * @param groupId the group ID
792             * @return the journal article that was removed
793             */
794            @Override
795            public JournalArticle removeByUUID_G(String uuid, long groupId)
796                    throws NoSuchArticleException {
797                    JournalArticle journalArticle = findByUUID_G(uuid, groupId);
798    
799                    return remove(journalArticle);
800            }
801    
802            /**
803             * Returns the number of journal articles where uuid = &#63; and groupId = &#63;.
804             *
805             * @param uuid the uuid
806             * @param groupId the group ID
807             * @return the number of matching journal articles
808             */
809            @Override
810            public int countByUUID_G(String uuid, long groupId) {
811                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
812    
813                    Object[] finderArgs = new Object[] { uuid, groupId };
814    
815                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
816                                    this);
817    
818                    if (count == null) {
819                            StringBundler query = new StringBundler(3);
820    
821                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
822    
823                            boolean bindUuid = false;
824    
825                            if (uuid == null) {
826                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
827                            }
828                            else if (uuid.equals(StringPool.BLANK)) {
829                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
830                            }
831                            else {
832                                    bindUuid = true;
833    
834                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
835                            }
836    
837                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
838    
839                            String sql = query.toString();
840    
841                            Session session = null;
842    
843                            try {
844                                    session = openSession();
845    
846                                    Query q = session.createQuery(sql);
847    
848                                    QueryPos qPos = QueryPos.getInstance(q);
849    
850                                    if (bindUuid) {
851                                            qPos.add(uuid);
852                                    }
853    
854                                    qPos.add(groupId);
855    
856                                    count = (Long)q.uniqueResult();
857    
858                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
859                            }
860                            catch (Exception e) {
861                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
862    
863                                    throw processException(e);
864                            }
865                            finally {
866                                    closeSession(session);
867                            }
868                    }
869    
870                    return count.intValue();
871            }
872    
873            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "journalArticle.uuid IS NULL AND ";
874            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "journalArticle.uuid = ? AND ";
875            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = '') AND ";
876            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "journalArticle.groupId = ?";
877            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
878                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
879                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
880                            "findByUuid_C",
881                            new String[] {
882                                    String.class.getName(), Long.class.getName(),
883                                    
884                            Integer.class.getName(), Integer.class.getName(),
885                                    OrderByComparator.class.getName()
886                            });
887            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
888                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
889                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
890                            JournalArticleImpl.class,
891                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
892                            new String[] { String.class.getName(), Long.class.getName() },
893                            JournalArticleModelImpl.UUID_COLUMN_BITMASK |
894                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
895                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
896                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
897            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
898                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
899                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
900                            new String[] { String.class.getName(), Long.class.getName() });
901    
902            /**
903             * Returns all the journal articles where uuid = &#63; and companyId = &#63;.
904             *
905             * @param uuid the uuid
906             * @param companyId the company ID
907             * @return the matching journal articles
908             */
909            @Override
910            public List<JournalArticle> findByUuid_C(String uuid, long companyId) {
911                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
912                            QueryUtil.ALL_POS, null);
913            }
914    
915            /**
916             * Returns a range of all the journal articles where uuid = &#63; and companyId = &#63;.
917             *
918             * <p>
919             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
920             * </p>
921             *
922             * @param uuid the uuid
923             * @param companyId the company ID
924             * @param start the lower bound of the range of journal articles
925             * @param end the upper bound of the range of journal articles (not inclusive)
926             * @return the range of matching journal articles
927             */
928            @Override
929            public List<JournalArticle> findByUuid_C(String uuid, long companyId,
930                    int start, int end) {
931                    return findByUuid_C(uuid, companyId, start, end, null);
932            }
933    
934            /**
935             * Returns an ordered range of all the journal articles where uuid = &#63; and companyId = &#63;.
936             *
937             * <p>
938             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
939             * </p>
940             *
941             * @param uuid the uuid
942             * @param companyId the company ID
943             * @param start the lower bound of the range of journal articles
944             * @param end the upper bound of the range of journal articles (not inclusive)
945             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
946             * @return the ordered range of matching journal articles
947             */
948            @Override
949            public List<JournalArticle> findByUuid_C(String uuid, long companyId,
950                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
951                    boolean pagination = true;
952                    FinderPath finderPath = null;
953                    Object[] finderArgs = null;
954    
955                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
956                                    (orderByComparator == null)) {
957                            pagination = false;
958                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
959                            finderArgs = new Object[] { uuid, companyId };
960                    }
961                    else {
962                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
963                            finderArgs = new Object[] {
964                                            uuid, companyId,
965                                            
966                                            start, end, orderByComparator
967                                    };
968                    }
969    
970                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
971                                    finderArgs, this);
972    
973                    if ((list != null) && !list.isEmpty()) {
974                            for (JournalArticle journalArticle : list) {
975                                    if (!Validator.equals(uuid, journalArticle.getUuid()) ||
976                                                    (companyId != journalArticle.getCompanyId())) {
977                                            list = null;
978    
979                                            break;
980                                    }
981                            }
982                    }
983    
984                    if (list == null) {
985                            StringBundler query = null;
986    
987                            if (orderByComparator != null) {
988                                    query = new StringBundler(4 +
989                                                    (orderByComparator.getOrderByFields().length * 3));
990                            }
991                            else {
992                                    query = new StringBundler(4);
993                            }
994    
995                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
996    
997                            boolean bindUuid = false;
998    
999                            if (uuid == null) {
1000                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1001                            }
1002                            else if (uuid.equals(StringPool.BLANK)) {
1003                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1004                            }
1005                            else {
1006                                    bindUuid = true;
1007    
1008                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1009                            }
1010    
1011                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1012    
1013                            if (orderByComparator != null) {
1014                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1015                                            orderByComparator);
1016                            }
1017                            else
1018                             if (pagination) {
1019                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1020                            }
1021    
1022                            String sql = query.toString();
1023    
1024                            Session session = null;
1025    
1026                            try {
1027                                    session = openSession();
1028    
1029                                    Query q = session.createQuery(sql);
1030    
1031                                    QueryPos qPos = QueryPos.getInstance(q);
1032    
1033                                    if (bindUuid) {
1034                                            qPos.add(uuid);
1035                                    }
1036    
1037                                    qPos.add(companyId);
1038    
1039                                    if (!pagination) {
1040                                            list = (List<JournalArticle>)QueryUtil.list(q,
1041                                                            getDialect(), start, end, false);
1042    
1043                                            Collections.sort(list);
1044    
1045                                            list = Collections.unmodifiableList(list);
1046                                    }
1047                                    else {
1048                                            list = (List<JournalArticle>)QueryUtil.list(q,
1049                                                            getDialect(), start, end);
1050                                    }
1051    
1052                                    cacheResult(list);
1053    
1054                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1055                            }
1056                            catch (Exception e) {
1057                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1058    
1059                                    throw processException(e);
1060                            }
1061                            finally {
1062                                    closeSession(session);
1063                            }
1064                    }
1065    
1066                    return list;
1067            }
1068    
1069            /**
1070             * Returns the first journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1071             *
1072             * @param uuid the uuid
1073             * @param companyId the company ID
1074             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1075             * @return the first matching journal article
1076             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1077             */
1078            @Override
1079            public JournalArticle findByUuid_C_First(String uuid, long companyId,
1080                    OrderByComparator<JournalArticle> orderByComparator)
1081                    throws NoSuchArticleException {
1082                    JournalArticle journalArticle = fetchByUuid_C_First(uuid, companyId,
1083                                    orderByComparator);
1084    
1085                    if (journalArticle != null) {
1086                            return journalArticle;
1087                    }
1088    
1089                    StringBundler msg = new StringBundler(6);
1090    
1091                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1092    
1093                    msg.append("uuid=");
1094                    msg.append(uuid);
1095    
1096                    msg.append(", companyId=");
1097                    msg.append(companyId);
1098    
1099                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1100    
1101                    throw new NoSuchArticleException(msg.toString());
1102            }
1103    
1104            /**
1105             * Returns the first journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1106             *
1107             * @param uuid the uuid
1108             * @param companyId the company ID
1109             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1110             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
1111             */
1112            @Override
1113            public JournalArticle fetchByUuid_C_First(String uuid, long companyId,
1114                    OrderByComparator<JournalArticle> orderByComparator) {
1115                    List<JournalArticle> list = findByUuid_C(uuid, companyId, 0, 1,
1116                                    orderByComparator);
1117    
1118                    if (!list.isEmpty()) {
1119                            return list.get(0);
1120                    }
1121    
1122                    return null;
1123            }
1124    
1125            /**
1126             * Returns the last journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1127             *
1128             * @param uuid the uuid
1129             * @param companyId the company ID
1130             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1131             * @return the last matching journal article
1132             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1133             */
1134            @Override
1135            public JournalArticle findByUuid_C_Last(String uuid, long companyId,
1136                    OrderByComparator<JournalArticle> orderByComparator)
1137                    throws NoSuchArticleException {
1138                    JournalArticle journalArticle = fetchByUuid_C_Last(uuid, companyId,
1139                                    orderByComparator);
1140    
1141                    if (journalArticle != null) {
1142                            return journalArticle;
1143                    }
1144    
1145                    StringBundler msg = new StringBundler(6);
1146    
1147                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1148    
1149                    msg.append("uuid=");
1150                    msg.append(uuid);
1151    
1152                    msg.append(", companyId=");
1153                    msg.append(companyId);
1154    
1155                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1156    
1157                    throw new NoSuchArticleException(msg.toString());
1158            }
1159    
1160            /**
1161             * Returns the last journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1162             *
1163             * @param uuid the uuid
1164             * @param companyId the company ID
1165             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1166             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
1167             */
1168            @Override
1169            public JournalArticle fetchByUuid_C_Last(String uuid, long companyId,
1170                    OrderByComparator<JournalArticle> orderByComparator) {
1171                    int count = countByUuid_C(uuid, companyId);
1172    
1173                    if (count == 0) {
1174                            return null;
1175                    }
1176    
1177                    List<JournalArticle> list = findByUuid_C(uuid, companyId, count - 1,
1178                                    count, orderByComparator);
1179    
1180                    if (!list.isEmpty()) {
1181                            return list.get(0);
1182                    }
1183    
1184                    return null;
1185            }
1186    
1187            /**
1188             * Returns the journal articles before and after the current journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1189             *
1190             * @param id the primary key of the current journal article
1191             * @param uuid the uuid
1192             * @param companyId the company ID
1193             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1194             * @return the previous, current, and next journal article
1195             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
1196             */
1197            @Override
1198            public JournalArticle[] findByUuid_C_PrevAndNext(long id, String uuid,
1199                    long companyId, OrderByComparator<JournalArticle> orderByComparator)
1200                    throws NoSuchArticleException {
1201                    JournalArticle journalArticle = findByPrimaryKey(id);
1202    
1203                    Session session = null;
1204    
1205                    try {
1206                            session = openSession();
1207    
1208                            JournalArticle[] array = new JournalArticleImpl[3];
1209    
1210                            array[0] = getByUuid_C_PrevAndNext(session, journalArticle, uuid,
1211                                            companyId, orderByComparator, true);
1212    
1213                            array[1] = journalArticle;
1214    
1215                            array[2] = getByUuid_C_PrevAndNext(session, journalArticle, uuid,
1216                                            companyId, orderByComparator, false);
1217    
1218                            return array;
1219                    }
1220                    catch (Exception e) {
1221                            throw processException(e);
1222                    }
1223                    finally {
1224                            closeSession(session);
1225                    }
1226            }
1227    
1228            protected JournalArticle getByUuid_C_PrevAndNext(Session session,
1229                    JournalArticle journalArticle, String uuid, long companyId,
1230                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
1231                    StringBundler query = null;
1232    
1233                    if (orderByComparator != null) {
1234                            query = new StringBundler(6 +
1235                                            (orderByComparator.getOrderByFields().length * 6));
1236                    }
1237                    else {
1238                            query = new StringBundler(3);
1239                    }
1240    
1241                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1242    
1243                    boolean bindUuid = false;
1244    
1245                    if (uuid == null) {
1246                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1247                    }
1248                    else if (uuid.equals(StringPool.BLANK)) {
1249                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1250                    }
1251                    else {
1252                            bindUuid = true;
1253    
1254                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1255                    }
1256    
1257                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1258    
1259                    if (orderByComparator != null) {
1260                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1261    
1262                            if (orderByConditionFields.length > 0) {
1263                                    query.append(WHERE_AND);
1264                            }
1265    
1266                            for (int i = 0; i < orderByConditionFields.length; i++) {
1267                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1268                                    query.append(orderByConditionFields[i]);
1269    
1270                                    if ((i + 1) < orderByConditionFields.length) {
1271                                            if (orderByComparator.isAscending() ^ previous) {
1272                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1273                                            }
1274                                            else {
1275                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1276                                            }
1277                                    }
1278                                    else {
1279                                            if (orderByComparator.isAscending() ^ previous) {
1280                                                    query.append(WHERE_GREATER_THAN);
1281                                            }
1282                                            else {
1283                                                    query.append(WHERE_LESSER_THAN);
1284                                            }
1285                                    }
1286                            }
1287    
1288                            query.append(ORDER_BY_CLAUSE);
1289    
1290                            String[] orderByFields = orderByComparator.getOrderByFields();
1291    
1292                            for (int i = 0; i < orderByFields.length; i++) {
1293                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1294                                    query.append(orderByFields[i]);
1295    
1296                                    if ((i + 1) < orderByFields.length) {
1297                                            if (orderByComparator.isAscending() ^ previous) {
1298                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1299                                            }
1300                                            else {
1301                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1302                                            }
1303                                    }
1304                                    else {
1305                                            if (orderByComparator.isAscending() ^ previous) {
1306                                                    query.append(ORDER_BY_ASC);
1307                                            }
1308                                            else {
1309                                                    query.append(ORDER_BY_DESC);
1310                                            }
1311                                    }
1312                            }
1313                    }
1314                    else {
1315                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1316                    }
1317    
1318                    String sql = query.toString();
1319    
1320                    Query q = session.createQuery(sql);
1321    
1322                    q.setFirstResult(0);
1323                    q.setMaxResults(2);
1324    
1325                    QueryPos qPos = QueryPos.getInstance(q);
1326    
1327                    if (bindUuid) {
1328                            qPos.add(uuid);
1329                    }
1330    
1331                    qPos.add(companyId);
1332    
1333                    if (orderByComparator != null) {
1334                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
1335    
1336                            for (Object value : values) {
1337                                    qPos.add(value);
1338                            }
1339                    }
1340    
1341                    List<JournalArticle> list = q.list();
1342    
1343                    if (list.size() == 2) {
1344                            return list.get(1);
1345                    }
1346                    else {
1347                            return null;
1348                    }
1349            }
1350    
1351            /**
1352             * Removes all the journal articles where uuid = &#63; and companyId = &#63; from the database.
1353             *
1354             * @param uuid the uuid
1355             * @param companyId the company ID
1356             */
1357            @Override
1358            public void removeByUuid_C(String uuid, long companyId) {
1359                    for (JournalArticle journalArticle : findByUuid_C(uuid, companyId,
1360                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1361                            remove(journalArticle);
1362                    }
1363            }
1364    
1365            /**
1366             * Returns the number of journal articles where uuid = &#63; and companyId = &#63;.
1367             *
1368             * @param uuid the uuid
1369             * @param companyId the company ID
1370             * @return the number of matching journal articles
1371             */
1372            @Override
1373            public int countByUuid_C(String uuid, long companyId) {
1374                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1375    
1376                    Object[] finderArgs = new Object[] { uuid, companyId };
1377    
1378                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1379                                    this);
1380    
1381                    if (count == null) {
1382                            StringBundler query = new StringBundler(3);
1383    
1384                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
1385    
1386                            boolean bindUuid = false;
1387    
1388                            if (uuid == null) {
1389                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1390                            }
1391                            else if (uuid.equals(StringPool.BLANK)) {
1392                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1393                            }
1394                            else {
1395                                    bindUuid = true;
1396    
1397                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1398                            }
1399    
1400                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1401    
1402                            String sql = query.toString();
1403    
1404                            Session session = null;
1405    
1406                            try {
1407                                    session = openSession();
1408    
1409                                    Query q = session.createQuery(sql);
1410    
1411                                    QueryPos qPos = QueryPos.getInstance(q);
1412    
1413                                    if (bindUuid) {
1414                                            qPos.add(uuid);
1415                                    }
1416    
1417                                    qPos.add(companyId);
1418    
1419                                    count = (Long)q.uniqueResult();
1420    
1421                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1422                            }
1423                            catch (Exception e) {
1424                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1425    
1426                                    throw processException(e);
1427                            }
1428                            finally {
1429                                    closeSession(session);
1430                            }
1431                    }
1432    
1433                    return count.intValue();
1434            }
1435    
1436            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "journalArticle.uuid IS NULL AND ";
1437            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "journalArticle.uuid = ? AND ";
1438            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = '') AND ";
1439            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "journalArticle.companyId = ?";
1440            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEPRIMKEY =
1441                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1442                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1443                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1444                            "findByResourcePrimKey",
1445                            new String[] {
1446                                    Long.class.getName(),
1447                                    
1448                            Integer.class.getName(), Integer.class.getName(),
1449                                    OrderByComparator.class.getName()
1450                            });
1451            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY =
1452                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1453                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1454                            JournalArticleImpl.class,
1455                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByResourcePrimKey",
1456                            new String[] { Long.class.getName() },
1457                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
1458                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
1459                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
1460            public static final FinderPath FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1461                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
1462                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1463                            "countByResourcePrimKey", new String[] { Long.class.getName() });
1464    
1465            /**
1466             * Returns all the journal articles where resourcePrimKey = &#63;.
1467             *
1468             * @param resourcePrimKey the resource prim key
1469             * @return the matching journal articles
1470             */
1471            @Override
1472            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey) {
1473                    return findByResourcePrimKey(resourcePrimKey, QueryUtil.ALL_POS,
1474                            QueryUtil.ALL_POS, null);
1475            }
1476    
1477            /**
1478             * Returns a range of all the journal articles where resourcePrimKey = &#63;.
1479             *
1480             * <p>
1481             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
1482             * </p>
1483             *
1484             * @param resourcePrimKey the resource prim key
1485             * @param start the lower bound of the range of journal articles
1486             * @param end the upper bound of the range of journal articles (not inclusive)
1487             * @return the range of matching journal articles
1488             */
1489            @Override
1490            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey,
1491                    int start, int end) {
1492                    return findByResourcePrimKey(resourcePrimKey, start, end, null);
1493            }
1494    
1495            /**
1496             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63;.
1497             *
1498             * <p>
1499             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
1500             * </p>
1501             *
1502             * @param resourcePrimKey the resource prim key
1503             * @param start the lower bound of the range of journal articles
1504             * @param end the upper bound of the range of journal articles (not inclusive)
1505             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1506             * @return the ordered range of matching journal articles
1507             */
1508            @Override
1509            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey,
1510                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
1511                    boolean pagination = true;
1512                    FinderPath finderPath = null;
1513                    Object[] finderArgs = null;
1514    
1515                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1516                                    (orderByComparator == null)) {
1517                            pagination = false;
1518                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
1519                            finderArgs = new Object[] { resourcePrimKey };
1520                    }
1521                    else {
1522                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
1523                            finderArgs = new Object[] {
1524                                            resourcePrimKey,
1525                                            
1526                                            start, end, orderByComparator
1527                                    };
1528                    }
1529    
1530                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
1531                                    finderArgs, this);
1532    
1533                    if ((list != null) && !list.isEmpty()) {
1534                            for (JournalArticle journalArticle : list) {
1535                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey())) {
1536                                            list = null;
1537    
1538                                            break;
1539                                    }
1540                            }
1541                    }
1542    
1543                    if (list == null) {
1544                            StringBundler query = null;
1545    
1546                            if (orderByComparator != null) {
1547                                    query = new StringBundler(3 +
1548                                                    (orderByComparator.getOrderByFields().length * 3));
1549                            }
1550                            else {
1551                                    query = new StringBundler(3);
1552                            }
1553    
1554                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1555    
1556                            query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
1557    
1558                            if (orderByComparator != null) {
1559                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1560                                            orderByComparator);
1561                            }
1562                            else
1563                             if (pagination) {
1564                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1565                            }
1566    
1567                            String sql = query.toString();
1568    
1569                            Session session = null;
1570    
1571                            try {
1572                                    session = openSession();
1573    
1574                                    Query q = session.createQuery(sql);
1575    
1576                                    QueryPos qPos = QueryPos.getInstance(q);
1577    
1578                                    qPos.add(resourcePrimKey);
1579    
1580                                    if (!pagination) {
1581                                            list = (List<JournalArticle>)QueryUtil.list(q,
1582                                                            getDialect(), start, end, false);
1583    
1584                                            Collections.sort(list);
1585    
1586                                            list = Collections.unmodifiableList(list);
1587                                    }
1588                                    else {
1589                                            list = (List<JournalArticle>)QueryUtil.list(q,
1590                                                            getDialect(), start, end);
1591                                    }
1592    
1593                                    cacheResult(list);
1594    
1595                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1596                            }
1597                            catch (Exception e) {
1598                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1599    
1600                                    throw processException(e);
1601                            }
1602                            finally {
1603                                    closeSession(session);
1604                            }
1605                    }
1606    
1607                    return list;
1608            }
1609    
1610            /**
1611             * Returns the first journal article in the ordered set where resourcePrimKey = &#63;.
1612             *
1613             * @param resourcePrimKey the resource prim key
1614             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1615             * @return the first matching journal article
1616             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1617             */
1618            @Override
1619            public JournalArticle findByResourcePrimKey_First(long resourcePrimKey,
1620                    OrderByComparator<JournalArticle> orderByComparator)
1621                    throws NoSuchArticleException {
1622                    JournalArticle journalArticle = fetchByResourcePrimKey_First(resourcePrimKey,
1623                                    orderByComparator);
1624    
1625                    if (journalArticle != null) {
1626                            return journalArticle;
1627                    }
1628    
1629                    StringBundler msg = new StringBundler(4);
1630    
1631                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1632    
1633                    msg.append("resourcePrimKey=");
1634                    msg.append(resourcePrimKey);
1635    
1636                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1637    
1638                    throw new NoSuchArticleException(msg.toString());
1639            }
1640    
1641            /**
1642             * Returns the first journal article in the ordered set where resourcePrimKey = &#63;.
1643             *
1644             * @param resourcePrimKey the resource prim key
1645             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1646             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
1647             */
1648            @Override
1649            public JournalArticle fetchByResourcePrimKey_First(long resourcePrimKey,
1650                    OrderByComparator<JournalArticle> orderByComparator) {
1651                    List<JournalArticle> list = findByResourcePrimKey(resourcePrimKey, 0,
1652                                    1, orderByComparator);
1653    
1654                    if (!list.isEmpty()) {
1655                            return list.get(0);
1656                    }
1657    
1658                    return null;
1659            }
1660    
1661            /**
1662             * Returns the last journal article in the ordered set where resourcePrimKey = &#63;.
1663             *
1664             * @param resourcePrimKey the resource prim key
1665             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1666             * @return the last matching journal article
1667             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1668             */
1669            @Override
1670            public JournalArticle findByResourcePrimKey_Last(long resourcePrimKey,
1671                    OrderByComparator<JournalArticle> orderByComparator)
1672                    throws NoSuchArticleException {
1673                    JournalArticle journalArticle = fetchByResourcePrimKey_Last(resourcePrimKey,
1674                                    orderByComparator);
1675    
1676                    if (journalArticle != null) {
1677                            return journalArticle;
1678                    }
1679    
1680                    StringBundler msg = new StringBundler(4);
1681    
1682                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1683    
1684                    msg.append("resourcePrimKey=");
1685                    msg.append(resourcePrimKey);
1686    
1687                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1688    
1689                    throw new NoSuchArticleException(msg.toString());
1690            }
1691    
1692            /**
1693             * Returns the last journal article in the ordered set where resourcePrimKey = &#63;.
1694             *
1695             * @param resourcePrimKey the resource prim key
1696             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1697             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
1698             */
1699            @Override
1700            public JournalArticle fetchByResourcePrimKey_Last(long resourcePrimKey,
1701                    OrderByComparator<JournalArticle> orderByComparator) {
1702                    int count = countByResourcePrimKey(resourcePrimKey);
1703    
1704                    if (count == 0) {
1705                            return null;
1706                    }
1707    
1708                    List<JournalArticle> list = findByResourcePrimKey(resourcePrimKey,
1709                                    count - 1, count, orderByComparator);
1710    
1711                    if (!list.isEmpty()) {
1712                            return list.get(0);
1713                    }
1714    
1715                    return null;
1716            }
1717    
1718            /**
1719             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63;.
1720             *
1721             * @param id the primary key of the current journal article
1722             * @param resourcePrimKey the resource prim key
1723             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1724             * @return the previous, current, and next journal article
1725             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
1726             */
1727            @Override
1728            public JournalArticle[] findByResourcePrimKey_PrevAndNext(long id,
1729                    long resourcePrimKey,
1730                    OrderByComparator<JournalArticle> orderByComparator)
1731                    throws NoSuchArticleException {
1732                    JournalArticle journalArticle = findByPrimaryKey(id);
1733    
1734                    Session session = null;
1735    
1736                    try {
1737                            session = openSession();
1738    
1739                            JournalArticle[] array = new JournalArticleImpl[3];
1740    
1741                            array[0] = getByResourcePrimKey_PrevAndNext(session,
1742                                            journalArticle, resourcePrimKey, orderByComparator, true);
1743    
1744                            array[1] = journalArticle;
1745    
1746                            array[2] = getByResourcePrimKey_PrevAndNext(session,
1747                                            journalArticle, resourcePrimKey, orderByComparator, false);
1748    
1749                            return array;
1750                    }
1751                    catch (Exception e) {
1752                            throw processException(e);
1753                    }
1754                    finally {
1755                            closeSession(session);
1756                    }
1757            }
1758    
1759            protected JournalArticle getByResourcePrimKey_PrevAndNext(Session session,
1760                    JournalArticle journalArticle, long resourcePrimKey,
1761                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
1762                    StringBundler query = null;
1763    
1764                    if (orderByComparator != null) {
1765                            query = new StringBundler(6 +
1766                                            (orderByComparator.getOrderByFields().length * 6));
1767                    }
1768                    else {
1769                            query = new StringBundler(3);
1770                    }
1771    
1772                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1773    
1774                    query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
1775    
1776                    if (orderByComparator != null) {
1777                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1778    
1779                            if (orderByConditionFields.length > 0) {
1780                                    query.append(WHERE_AND);
1781                            }
1782    
1783                            for (int i = 0; i < orderByConditionFields.length; i++) {
1784                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1785                                    query.append(orderByConditionFields[i]);
1786    
1787                                    if ((i + 1) < orderByConditionFields.length) {
1788                                            if (orderByComparator.isAscending() ^ previous) {
1789                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1790                                            }
1791                                            else {
1792                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1793                                            }
1794                                    }
1795                                    else {
1796                                            if (orderByComparator.isAscending() ^ previous) {
1797                                                    query.append(WHERE_GREATER_THAN);
1798                                            }
1799                                            else {
1800                                                    query.append(WHERE_LESSER_THAN);
1801                                            }
1802                                    }
1803                            }
1804    
1805                            query.append(ORDER_BY_CLAUSE);
1806    
1807                            String[] orderByFields = orderByComparator.getOrderByFields();
1808    
1809                            for (int i = 0; i < orderByFields.length; i++) {
1810                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1811                                    query.append(orderByFields[i]);
1812    
1813                                    if ((i + 1) < orderByFields.length) {
1814                                            if (orderByComparator.isAscending() ^ previous) {
1815                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1816                                            }
1817                                            else {
1818                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1819                                            }
1820                                    }
1821                                    else {
1822                                            if (orderByComparator.isAscending() ^ previous) {
1823                                                    query.append(ORDER_BY_ASC);
1824                                            }
1825                                            else {
1826                                                    query.append(ORDER_BY_DESC);
1827                                            }
1828                                    }
1829                            }
1830                    }
1831                    else {
1832                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1833                    }
1834    
1835                    String sql = query.toString();
1836    
1837                    Query q = session.createQuery(sql);
1838    
1839                    q.setFirstResult(0);
1840                    q.setMaxResults(2);
1841    
1842                    QueryPos qPos = QueryPos.getInstance(q);
1843    
1844                    qPos.add(resourcePrimKey);
1845    
1846                    if (orderByComparator != null) {
1847                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
1848    
1849                            for (Object value : values) {
1850                                    qPos.add(value);
1851                            }
1852                    }
1853    
1854                    List<JournalArticle> list = q.list();
1855    
1856                    if (list.size() == 2) {
1857                            return list.get(1);
1858                    }
1859                    else {
1860                            return null;
1861                    }
1862            }
1863    
1864            /**
1865             * Removes all the journal articles where resourcePrimKey = &#63; from the database.
1866             *
1867             * @param resourcePrimKey the resource prim key
1868             */
1869            @Override
1870            public void removeByResourcePrimKey(long resourcePrimKey) {
1871                    for (JournalArticle journalArticle : findByResourcePrimKey(
1872                                    resourcePrimKey, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1873                            remove(journalArticle);
1874                    }
1875            }
1876    
1877            /**
1878             * Returns the number of journal articles where resourcePrimKey = &#63;.
1879             *
1880             * @param resourcePrimKey the resource prim key
1881             * @return the number of matching journal articles
1882             */
1883            @Override
1884            public int countByResourcePrimKey(long resourcePrimKey) {
1885                    FinderPath finderPath = FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY;
1886    
1887                    Object[] finderArgs = new Object[] { resourcePrimKey };
1888    
1889                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1890                                    this);
1891    
1892                    if (count == null) {
1893                            StringBundler query = new StringBundler(2);
1894    
1895                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
1896    
1897                            query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
1898    
1899                            String sql = query.toString();
1900    
1901                            Session session = null;
1902    
1903                            try {
1904                                    session = openSession();
1905    
1906                                    Query q = session.createQuery(sql);
1907    
1908                                    QueryPos qPos = QueryPos.getInstance(q);
1909    
1910                                    qPos.add(resourcePrimKey);
1911    
1912                                    count = (Long)q.uniqueResult();
1913    
1914                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1915                            }
1916                            catch (Exception e) {
1917                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1918    
1919                                    throw processException(e);
1920                            }
1921                            finally {
1922                                    closeSession(session);
1923                            }
1924                    }
1925    
1926                    return count.intValue();
1927            }
1928    
1929            private static final String _FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2 =
1930                    "journalArticle.resourcePrimKey = ?";
1931            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1932                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1933                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1934                            "findByGroupId",
1935                            new String[] {
1936                                    Long.class.getName(),
1937                                    
1938                            Integer.class.getName(), Integer.class.getName(),
1939                                    OrderByComparator.class.getName()
1940                            });
1941            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1942                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1943                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1944                            JournalArticleImpl.class,
1945                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1946                            new String[] { Long.class.getName() },
1947                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
1948                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
1949                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
1950            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1951                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
1952                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1953                            new String[] { Long.class.getName() });
1954    
1955            /**
1956             * Returns all the journal articles where groupId = &#63;.
1957             *
1958             * @param groupId the group ID
1959             * @return the matching journal articles
1960             */
1961            @Override
1962            public List<JournalArticle> findByGroupId(long groupId) {
1963                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1964            }
1965    
1966            /**
1967             * Returns a range of all the journal articles where groupId = &#63;.
1968             *
1969             * <p>
1970             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
1971             * </p>
1972             *
1973             * @param groupId the group ID
1974             * @param start the lower bound of the range of journal articles
1975             * @param end the upper bound of the range of journal articles (not inclusive)
1976             * @return the range of matching journal articles
1977             */
1978            @Override
1979            public List<JournalArticle> findByGroupId(long groupId, int start, int end) {
1980                    return findByGroupId(groupId, start, end, null);
1981            }
1982    
1983            /**
1984             * Returns an ordered range of all the journal articles where groupId = &#63;.
1985             *
1986             * <p>
1987             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
1988             * </p>
1989             *
1990             * @param groupId the group ID
1991             * @param start the lower bound of the range of journal articles
1992             * @param end the upper bound of the range of journal articles (not inclusive)
1993             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1994             * @return the ordered range of matching journal articles
1995             */
1996            @Override
1997            public List<JournalArticle> findByGroupId(long groupId, int start, int end,
1998                    OrderByComparator<JournalArticle> orderByComparator) {
1999                    boolean pagination = true;
2000                    FinderPath finderPath = null;
2001                    Object[] finderArgs = null;
2002    
2003                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2004                                    (orderByComparator == null)) {
2005                            pagination = false;
2006                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
2007                            finderArgs = new Object[] { groupId };
2008                    }
2009                    else {
2010                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
2011                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
2012                    }
2013    
2014                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
2015                                    finderArgs, this);
2016    
2017                    if ((list != null) && !list.isEmpty()) {
2018                            for (JournalArticle journalArticle : list) {
2019                                    if ((groupId != journalArticle.getGroupId())) {
2020                                            list = null;
2021    
2022                                            break;
2023                                    }
2024                            }
2025                    }
2026    
2027                    if (list == null) {
2028                            StringBundler query = null;
2029    
2030                            if (orderByComparator != null) {
2031                                    query = new StringBundler(3 +
2032                                                    (orderByComparator.getOrderByFields().length * 3));
2033                            }
2034                            else {
2035                                    query = new StringBundler(3);
2036                            }
2037    
2038                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2039    
2040                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2041    
2042                            if (orderByComparator != null) {
2043                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2044                                            orderByComparator);
2045                            }
2046                            else
2047                             if (pagination) {
2048                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2049                            }
2050    
2051                            String sql = query.toString();
2052    
2053                            Session session = null;
2054    
2055                            try {
2056                                    session = openSession();
2057    
2058                                    Query q = session.createQuery(sql);
2059    
2060                                    QueryPos qPos = QueryPos.getInstance(q);
2061    
2062                                    qPos.add(groupId);
2063    
2064                                    if (!pagination) {
2065                                            list = (List<JournalArticle>)QueryUtil.list(q,
2066                                                            getDialect(), start, end, false);
2067    
2068                                            Collections.sort(list);
2069    
2070                                            list = Collections.unmodifiableList(list);
2071                                    }
2072                                    else {
2073                                            list = (List<JournalArticle>)QueryUtil.list(q,
2074                                                            getDialect(), start, end);
2075                                    }
2076    
2077                                    cacheResult(list);
2078    
2079                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2080                            }
2081                            catch (Exception e) {
2082                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2083    
2084                                    throw processException(e);
2085                            }
2086                            finally {
2087                                    closeSession(session);
2088                            }
2089                    }
2090    
2091                    return list;
2092            }
2093    
2094            /**
2095             * Returns the first journal article in the ordered set where groupId = &#63;.
2096             *
2097             * @param groupId the group ID
2098             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2099             * @return the first matching journal article
2100             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2101             */
2102            @Override
2103            public JournalArticle findByGroupId_First(long groupId,
2104                    OrderByComparator<JournalArticle> orderByComparator)
2105                    throws NoSuchArticleException {
2106                    JournalArticle journalArticle = fetchByGroupId_First(groupId,
2107                                    orderByComparator);
2108    
2109                    if (journalArticle != null) {
2110                            return journalArticle;
2111                    }
2112    
2113                    StringBundler msg = new StringBundler(4);
2114    
2115                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2116    
2117                    msg.append("groupId=");
2118                    msg.append(groupId);
2119    
2120                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2121    
2122                    throw new NoSuchArticleException(msg.toString());
2123            }
2124    
2125            /**
2126             * Returns the first journal article in the ordered set where groupId = &#63;.
2127             *
2128             * @param groupId the group ID
2129             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2130             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
2131             */
2132            @Override
2133            public JournalArticle fetchByGroupId_First(long groupId,
2134                    OrderByComparator<JournalArticle> orderByComparator) {
2135                    List<JournalArticle> list = findByGroupId(groupId, 0, 1,
2136                                    orderByComparator);
2137    
2138                    if (!list.isEmpty()) {
2139                            return list.get(0);
2140                    }
2141    
2142                    return null;
2143            }
2144    
2145            /**
2146             * Returns the last journal article in the ordered set where groupId = &#63;.
2147             *
2148             * @param groupId the group ID
2149             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2150             * @return the last matching journal article
2151             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2152             */
2153            @Override
2154            public JournalArticle findByGroupId_Last(long groupId,
2155                    OrderByComparator<JournalArticle> orderByComparator)
2156                    throws NoSuchArticleException {
2157                    JournalArticle journalArticle = fetchByGroupId_Last(groupId,
2158                                    orderByComparator);
2159    
2160                    if (journalArticle != null) {
2161                            return journalArticle;
2162                    }
2163    
2164                    StringBundler msg = new StringBundler(4);
2165    
2166                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2167    
2168                    msg.append("groupId=");
2169                    msg.append(groupId);
2170    
2171                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2172    
2173                    throw new NoSuchArticleException(msg.toString());
2174            }
2175    
2176            /**
2177             * Returns the last journal article in the ordered set where groupId = &#63;.
2178             *
2179             * @param groupId the group ID
2180             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2181             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
2182             */
2183            @Override
2184            public JournalArticle fetchByGroupId_Last(long groupId,
2185                    OrderByComparator<JournalArticle> orderByComparator) {
2186                    int count = countByGroupId(groupId);
2187    
2188                    if (count == 0) {
2189                            return null;
2190                    }
2191    
2192                    List<JournalArticle> list = findByGroupId(groupId, count - 1, count,
2193                                    orderByComparator);
2194    
2195                    if (!list.isEmpty()) {
2196                            return list.get(0);
2197                    }
2198    
2199                    return null;
2200            }
2201    
2202            /**
2203             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63;.
2204             *
2205             * @param id the primary key of the current journal article
2206             * @param groupId the group ID
2207             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2208             * @return the previous, current, and next journal article
2209             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
2210             */
2211            @Override
2212            public JournalArticle[] findByGroupId_PrevAndNext(long id, long groupId,
2213                    OrderByComparator<JournalArticle> orderByComparator)
2214                    throws NoSuchArticleException {
2215                    JournalArticle journalArticle = findByPrimaryKey(id);
2216    
2217                    Session session = null;
2218    
2219                    try {
2220                            session = openSession();
2221    
2222                            JournalArticle[] array = new JournalArticleImpl[3];
2223    
2224                            array[0] = getByGroupId_PrevAndNext(session, journalArticle,
2225                                            groupId, orderByComparator, true);
2226    
2227                            array[1] = journalArticle;
2228    
2229                            array[2] = getByGroupId_PrevAndNext(session, journalArticle,
2230                                            groupId, orderByComparator, false);
2231    
2232                            return array;
2233                    }
2234                    catch (Exception e) {
2235                            throw processException(e);
2236                    }
2237                    finally {
2238                            closeSession(session);
2239                    }
2240            }
2241    
2242            protected JournalArticle getByGroupId_PrevAndNext(Session session,
2243                    JournalArticle journalArticle, long groupId,
2244                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
2245                    StringBundler query = null;
2246    
2247                    if (orderByComparator != null) {
2248                            query = new StringBundler(6 +
2249                                            (orderByComparator.getOrderByFields().length * 6));
2250                    }
2251                    else {
2252                            query = new StringBundler(3);
2253                    }
2254    
2255                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2256    
2257                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2258    
2259                    if (orderByComparator != null) {
2260                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2261    
2262                            if (orderByConditionFields.length > 0) {
2263                                    query.append(WHERE_AND);
2264                            }
2265    
2266                            for (int i = 0; i < orderByConditionFields.length; i++) {
2267                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2268                                    query.append(orderByConditionFields[i]);
2269    
2270                                    if ((i + 1) < orderByConditionFields.length) {
2271                                            if (orderByComparator.isAscending() ^ previous) {
2272                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2273                                            }
2274                                            else {
2275                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2276                                            }
2277                                    }
2278                                    else {
2279                                            if (orderByComparator.isAscending() ^ previous) {
2280                                                    query.append(WHERE_GREATER_THAN);
2281                                            }
2282                                            else {
2283                                                    query.append(WHERE_LESSER_THAN);
2284                                            }
2285                                    }
2286                            }
2287    
2288                            query.append(ORDER_BY_CLAUSE);
2289    
2290                            String[] orderByFields = orderByComparator.getOrderByFields();
2291    
2292                            for (int i = 0; i < orderByFields.length; i++) {
2293                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2294                                    query.append(orderByFields[i]);
2295    
2296                                    if ((i + 1) < orderByFields.length) {
2297                                            if (orderByComparator.isAscending() ^ previous) {
2298                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2299                                            }
2300                                            else {
2301                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2302                                            }
2303                                    }
2304                                    else {
2305                                            if (orderByComparator.isAscending() ^ previous) {
2306                                                    query.append(ORDER_BY_ASC);
2307                                            }
2308                                            else {
2309                                                    query.append(ORDER_BY_DESC);
2310                                            }
2311                                    }
2312                            }
2313                    }
2314                    else {
2315                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2316                    }
2317    
2318                    String sql = query.toString();
2319    
2320                    Query q = session.createQuery(sql);
2321    
2322                    q.setFirstResult(0);
2323                    q.setMaxResults(2);
2324    
2325                    QueryPos qPos = QueryPos.getInstance(q);
2326    
2327                    qPos.add(groupId);
2328    
2329                    if (orderByComparator != null) {
2330                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
2331    
2332                            for (Object value : values) {
2333                                    qPos.add(value);
2334                            }
2335                    }
2336    
2337                    List<JournalArticle> list = q.list();
2338    
2339                    if (list.size() == 2) {
2340                            return list.get(1);
2341                    }
2342                    else {
2343                            return null;
2344                    }
2345            }
2346    
2347            /**
2348             * Returns all the journal articles that the user has permission to view where groupId = &#63;.
2349             *
2350             * @param groupId the group ID
2351             * @return the matching journal articles that the user has permission to view
2352             */
2353            @Override
2354            public List<JournalArticle> filterFindByGroupId(long groupId) {
2355                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
2356                            QueryUtil.ALL_POS, null);
2357            }
2358    
2359            /**
2360             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63;.
2361             *
2362             * <p>
2363             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
2364             * </p>
2365             *
2366             * @param groupId the group ID
2367             * @param start the lower bound of the range of journal articles
2368             * @param end the upper bound of the range of journal articles (not inclusive)
2369             * @return the range of matching journal articles that the user has permission to view
2370             */
2371            @Override
2372            public List<JournalArticle> filterFindByGroupId(long groupId, int start,
2373                    int end) {
2374                    return filterFindByGroupId(groupId, start, end, null);
2375            }
2376    
2377            /**
2378             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63;.
2379             *
2380             * <p>
2381             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
2382             * </p>
2383             *
2384             * @param groupId the group ID
2385             * @param start the lower bound of the range of journal articles
2386             * @param end the upper bound of the range of journal articles (not inclusive)
2387             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2388             * @return the ordered range of matching journal articles that the user has permission to view
2389             */
2390            @Override
2391            public List<JournalArticle> filterFindByGroupId(long groupId, int start,
2392                    int end, OrderByComparator<JournalArticle> orderByComparator) {
2393                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2394                            return findByGroupId(groupId, start, end, orderByComparator);
2395                    }
2396    
2397                    StringBundler query = null;
2398    
2399                    if (orderByComparator != null) {
2400                            query = new StringBundler(3 +
2401                                            (orderByComparator.getOrderByFields().length * 3));
2402                    }
2403                    else {
2404                            query = new StringBundler(3);
2405                    }
2406    
2407                    if (getDB().isSupportsInlineDistinct()) {
2408                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
2409                    }
2410                    else {
2411                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
2412                    }
2413    
2414                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2415    
2416                    if (!getDB().isSupportsInlineDistinct()) {
2417                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
2418                    }
2419    
2420                    if (orderByComparator != null) {
2421                            if (getDB().isSupportsInlineDistinct()) {
2422                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2423                                            orderByComparator, true);
2424                            }
2425                            else {
2426                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2427                                            orderByComparator, true);
2428                            }
2429                    }
2430                    else {
2431                            if (getDB().isSupportsInlineDistinct()) {
2432                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2433                            }
2434                            else {
2435                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
2436                            }
2437                    }
2438    
2439                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2440                                    JournalArticle.class.getName(),
2441                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2442    
2443                    Session session = null;
2444    
2445                    try {
2446                            session = openSession();
2447    
2448                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2449    
2450                            if (getDB().isSupportsInlineDistinct()) {
2451                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
2452                            }
2453                            else {
2454                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
2455                            }
2456    
2457                            QueryPos qPos = QueryPos.getInstance(q);
2458    
2459                            qPos.add(groupId);
2460    
2461                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
2462                                    end);
2463                    }
2464                    catch (Exception e) {
2465                            throw processException(e);
2466                    }
2467                    finally {
2468                            closeSession(session);
2469                    }
2470            }
2471    
2472            /**
2473             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63;.
2474             *
2475             * @param id the primary key of the current journal article
2476             * @param groupId the group ID
2477             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2478             * @return the previous, current, and next journal article
2479             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
2480             */
2481            @Override
2482            public JournalArticle[] filterFindByGroupId_PrevAndNext(long id,
2483                    long groupId, OrderByComparator<JournalArticle> orderByComparator)
2484                    throws NoSuchArticleException {
2485                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2486                            return findByGroupId_PrevAndNext(id, groupId, orderByComparator);
2487                    }
2488    
2489                    JournalArticle journalArticle = findByPrimaryKey(id);
2490    
2491                    Session session = null;
2492    
2493                    try {
2494                            session = openSession();
2495    
2496                            JournalArticle[] array = new JournalArticleImpl[3];
2497    
2498                            array[0] = filterGetByGroupId_PrevAndNext(session, journalArticle,
2499                                            groupId, orderByComparator, true);
2500    
2501                            array[1] = journalArticle;
2502    
2503                            array[2] = filterGetByGroupId_PrevAndNext(session, journalArticle,
2504                                            groupId, orderByComparator, false);
2505    
2506                            return array;
2507                    }
2508                    catch (Exception e) {
2509                            throw processException(e);
2510                    }
2511                    finally {
2512                            closeSession(session);
2513                    }
2514            }
2515    
2516            protected JournalArticle filterGetByGroupId_PrevAndNext(Session session,
2517                    JournalArticle journalArticle, long groupId,
2518                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
2519                    StringBundler query = null;
2520    
2521                    if (orderByComparator != null) {
2522                            query = new StringBundler(6 +
2523                                            (orderByComparator.getOrderByFields().length * 6));
2524                    }
2525                    else {
2526                            query = new StringBundler(3);
2527                    }
2528    
2529                    if (getDB().isSupportsInlineDistinct()) {
2530                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
2531                    }
2532                    else {
2533                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
2534                    }
2535    
2536                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2537    
2538                    if (!getDB().isSupportsInlineDistinct()) {
2539                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
2540                    }
2541    
2542                    if (orderByComparator != null) {
2543                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2544    
2545                            if (orderByConditionFields.length > 0) {
2546                                    query.append(WHERE_AND);
2547                            }
2548    
2549                            for (int i = 0; i < orderByConditionFields.length; i++) {
2550                                    if (getDB().isSupportsInlineDistinct()) {
2551                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2552                                    }
2553                                    else {
2554                                            query.append(_ORDER_BY_ENTITY_TABLE);
2555                                    }
2556    
2557                                    query.append(orderByConditionFields[i]);
2558    
2559                                    if ((i + 1) < orderByConditionFields.length) {
2560                                            if (orderByComparator.isAscending() ^ previous) {
2561                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2562                                            }
2563                                            else {
2564                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2565                                            }
2566                                    }
2567                                    else {
2568                                            if (orderByComparator.isAscending() ^ previous) {
2569                                                    query.append(WHERE_GREATER_THAN);
2570                                            }
2571                                            else {
2572                                                    query.append(WHERE_LESSER_THAN);
2573                                            }
2574                                    }
2575                            }
2576    
2577                            query.append(ORDER_BY_CLAUSE);
2578    
2579                            String[] orderByFields = orderByComparator.getOrderByFields();
2580    
2581                            for (int i = 0; i < orderByFields.length; i++) {
2582                                    if (getDB().isSupportsInlineDistinct()) {
2583                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2584                                    }
2585                                    else {
2586                                            query.append(_ORDER_BY_ENTITY_TABLE);
2587                                    }
2588    
2589                                    query.append(orderByFields[i]);
2590    
2591                                    if ((i + 1) < orderByFields.length) {
2592                                            if (orderByComparator.isAscending() ^ previous) {
2593                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2594                                            }
2595                                            else {
2596                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2597                                            }
2598                                    }
2599                                    else {
2600                                            if (orderByComparator.isAscending() ^ previous) {
2601                                                    query.append(ORDER_BY_ASC);
2602                                            }
2603                                            else {
2604                                                    query.append(ORDER_BY_DESC);
2605                                            }
2606                                    }
2607                            }
2608                    }
2609                    else {
2610                            if (getDB().isSupportsInlineDistinct()) {
2611                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2612                            }
2613                            else {
2614                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
2615                            }
2616                    }
2617    
2618                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2619                                    JournalArticle.class.getName(),
2620                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2621    
2622                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
2623    
2624                    q.setFirstResult(0);
2625                    q.setMaxResults(2);
2626    
2627                    if (getDB().isSupportsInlineDistinct()) {
2628                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
2629                    }
2630                    else {
2631                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
2632                    }
2633    
2634                    QueryPos qPos = QueryPos.getInstance(q);
2635    
2636                    qPos.add(groupId);
2637    
2638                    if (orderByComparator != null) {
2639                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
2640    
2641                            for (Object value : values) {
2642                                    qPos.add(value);
2643                            }
2644                    }
2645    
2646                    List<JournalArticle> list = q.list();
2647    
2648                    if (list.size() == 2) {
2649                            return list.get(1);
2650                    }
2651                    else {
2652                            return null;
2653                    }
2654            }
2655    
2656            /**
2657             * Removes all the journal articles where groupId = &#63; from the database.
2658             *
2659             * @param groupId the group ID
2660             */
2661            @Override
2662            public void removeByGroupId(long groupId) {
2663                    for (JournalArticle journalArticle : findByGroupId(groupId,
2664                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2665                            remove(journalArticle);
2666                    }
2667            }
2668    
2669            /**
2670             * Returns the number of journal articles where groupId = &#63;.
2671             *
2672             * @param groupId the group ID
2673             * @return the number of matching journal articles
2674             */
2675            @Override
2676            public int countByGroupId(long groupId) {
2677                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2678    
2679                    Object[] finderArgs = new Object[] { groupId };
2680    
2681                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2682                                    this);
2683    
2684                    if (count == null) {
2685                            StringBundler query = new StringBundler(2);
2686    
2687                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
2688    
2689                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2690    
2691                            String sql = query.toString();
2692    
2693                            Session session = null;
2694    
2695                            try {
2696                                    session = openSession();
2697    
2698                                    Query q = session.createQuery(sql);
2699    
2700                                    QueryPos qPos = QueryPos.getInstance(q);
2701    
2702                                    qPos.add(groupId);
2703    
2704                                    count = (Long)q.uniqueResult();
2705    
2706                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2707                            }
2708                            catch (Exception e) {
2709                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2710    
2711                                    throw processException(e);
2712                            }
2713                            finally {
2714                                    closeSession(session);
2715                            }
2716                    }
2717    
2718                    return count.intValue();
2719            }
2720    
2721            /**
2722             * Returns the number of journal articles that the user has permission to view where groupId = &#63;.
2723             *
2724             * @param groupId the group ID
2725             * @return the number of matching journal articles that the user has permission to view
2726             */
2727            @Override
2728            public int filterCountByGroupId(long groupId) {
2729                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2730                            return countByGroupId(groupId);
2731                    }
2732    
2733                    StringBundler query = new StringBundler(2);
2734    
2735                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
2736    
2737                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2738    
2739                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2740                                    JournalArticle.class.getName(),
2741                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2742    
2743                    Session session = null;
2744    
2745                    try {
2746                            session = openSession();
2747    
2748                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2749    
2750                            q.addScalar(COUNT_COLUMN_NAME,
2751                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2752    
2753                            QueryPos qPos = QueryPos.getInstance(q);
2754    
2755                            qPos.add(groupId);
2756    
2757                            Long count = (Long)q.uniqueResult();
2758    
2759                            return count.intValue();
2760                    }
2761                    catch (Exception e) {
2762                            throw processException(e);
2763                    }
2764                    finally {
2765                            closeSession(session);
2766                    }
2767            }
2768    
2769            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "journalArticle.groupId = ?";
2770            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2771                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
2772                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
2773                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2774                            "findByCompanyId",
2775                            new String[] {
2776                                    Long.class.getName(),
2777                                    
2778                            Integer.class.getName(), Integer.class.getName(),
2779                                    OrderByComparator.class.getName()
2780                            });
2781            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2782                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
2783                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
2784                            JournalArticleImpl.class,
2785                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2786                            new String[] { Long.class.getName() },
2787                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
2788                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
2789                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
2790            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
2791                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
2792                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2793                            new String[] { Long.class.getName() });
2794    
2795            /**
2796             * Returns all the journal articles where companyId = &#63;.
2797             *
2798             * @param companyId the company ID
2799             * @return the matching journal articles
2800             */
2801            @Override
2802            public List<JournalArticle> findByCompanyId(long companyId) {
2803                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2804                            null);
2805            }
2806    
2807            /**
2808             * Returns a range of all the journal articles where companyId = &#63;.
2809             *
2810             * <p>
2811             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
2812             * </p>
2813             *
2814             * @param companyId the company ID
2815             * @param start the lower bound of the range of journal articles
2816             * @param end the upper bound of the range of journal articles (not inclusive)
2817             * @return the range of matching journal articles
2818             */
2819            @Override
2820            public List<JournalArticle> findByCompanyId(long companyId, int start,
2821                    int end) {
2822                    return findByCompanyId(companyId, start, end, null);
2823            }
2824    
2825            /**
2826             * Returns an ordered range of all the journal articles where companyId = &#63;.
2827             *
2828             * <p>
2829             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
2830             * </p>
2831             *
2832             * @param companyId the company ID
2833             * @param start the lower bound of the range of journal articles
2834             * @param end the upper bound of the range of journal articles (not inclusive)
2835             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2836             * @return the ordered range of matching journal articles
2837             */
2838            @Override
2839            public List<JournalArticle> findByCompanyId(long companyId, int start,
2840                    int end, OrderByComparator<JournalArticle> orderByComparator) {
2841                    boolean pagination = true;
2842                    FinderPath finderPath = null;
2843                    Object[] finderArgs = null;
2844    
2845                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2846                                    (orderByComparator == null)) {
2847                            pagination = false;
2848                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2849                            finderArgs = new Object[] { companyId };
2850                    }
2851                    else {
2852                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2853                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2854                    }
2855    
2856                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
2857                                    finderArgs, this);
2858    
2859                    if ((list != null) && !list.isEmpty()) {
2860                            for (JournalArticle journalArticle : list) {
2861                                    if ((companyId != journalArticle.getCompanyId())) {
2862                                            list = null;
2863    
2864                                            break;
2865                                    }
2866                            }
2867                    }
2868    
2869                    if (list == null) {
2870                            StringBundler query = null;
2871    
2872                            if (orderByComparator != null) {
2873                                    query = new StringBundler(3 +
2874                                                    (orderByComparator.getOrderByFields().length * 3));
2875                            }
2876                            else {
2877                                    query = new StringBundler(3);
2878                            }
2879    
2880                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2881    
2882                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2883    
2884                            if (orderByComparator != null) {
2885                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2886                                            orderByComparator);
2887                            }
2888                            else
2889                             if (pagination) {
2890                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2891                            }
2892    
2893                            String sql = query.toString();
2894    
2895                            Session session = null;
2896    
2897                            try {
2898                                    session = openSession();
2899    
2900                                    Query q = session.createQuery(sql);
2901    
2902                                    QueryPos qPos = QueryPos.getInstance(q);
2903    
2904                                    qPos.add(companyId);
2905    
2906                                    if (!pagination) {
2907                                            list = (List<JournalArticle>)QueryUtil.list(q,
2908                                                            getDialect(), start, end, false);
2909    
2910                                            Collections.sort(list);
2911    
2912                                            list = Collections.unmodifiableList(list);
2913                                    }
2914                                    else {
2915                                            list = (List<JournalArticle>)QueryUtil.list(q,
2916                                                            getDialect(), start, end);
2917                                    }
2918    
2919                                    cacheResult(list);
2920    
2921                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2922                            }
2923                            catch (Exception e) {
2924                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2925    
2926                                    throw processException(e);
2927                            }
2928                            finally {
2929                                    closeSession(session);
2930                            }
2931                    }
2932    
2933                    return list;
2934            }
2935    
2936            /**
2937             * Returns the first journal article in the ordered set where companyId = &#63;.
2938             *
2939             * @param companyId the company ID
2940             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2941             * @return the first matching journal article
2942             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2943             */
2944            @Override
2945            public JournalArticle findByCompanyId_First(long companyId,
2946                    OrderByComparator<JournalArticle> orderByComparator)
2947                    throws NoSuchArticleException {
2948                    JournalArticle journalArticle = fetchByCompanyId_First(companyId,
2949                                    orderByComparator);
2950    
2951                    if (journalArticle != null) {
2952                            return journalArticle;
2953                    }
2954    
2955                    StringBundler msg = new StringBundler(4);
2956    
2957                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2958    
2959                    msg.append("companyId=");
2960                    msg.append(companyId);
2961    
2962                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2963    
2964                    throw new NoSuchArticleException(msg.toString());
2965            }
2966    
2967            /**
2968             * Returns the first journal article in the ordered set where companyId = &#63;.
2969             *
2970             * @param companyId the company ID
2971             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2972             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
2973             */
2974            @Override
2975            public JournalArticle fetchByCompanyId_First(long companyId,
2976                    OrderByComparator<JournalArticle> orderByComparator) {
2977                    List<JournalArticle> list = findByCompanyId(companyId, 0, 1,
2978                                    orderByComparator);
2979    
2980                    if (!list.isEmpty()) {
2981                            return list.get(0);
2982                    }
2983    
2984                    return null;
2985            }
2986    
2987            /**
2988             * Returns the last journal article in the ordered set where companyId = &#63;.
2989             *
2990             * @param companyId the company ID
2991             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2992             * @return the last matching journal article
2993             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2994             */
2995            @Override
2996            public JournalArticle findByCompanyId_Last(long companyId,
2997                    OrderByComparator<JournalArticle> orderByComparator)
2998                    throws NoSuchArticleException {
2999                    JournalArticle journalArticle = fetchByCompanyId_Last(companyId,
3000                                    orderByComparator);
3001    
3002                    if (journalArticle != null) {
3003                            return journalArticle;
3004                    }
3005    
3006                    StringBundler msg = new StringBundler(4);
3007    
3008                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3009    
3010                    msg.append("companyId=");
3011                    msg.append(companyId);
3012    
3013                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3014    
3015                    throw new NoSuchArticleException(msg.toString());
3016            }
3017    
3018            /**
3019             * Returns the last journal article in the ordered set where companyId = &#63;.
3020             *
3021             * @param companyId the company ID
3022             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3023             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
3024             */
3025            @Override
3026            public JournalArticle fetchByCompanyId_Last(long companyId,
3027                    OrderByComparator<JournalArticle> orderByComparator) {
3028                    int count = countByCompanyId(companyId);
3029    
3030                    if (count == 0) {
3031                            return null;
3032                    }
3033    
3034                    List<JournalArticle> list = findByCompanyId(companyId, count - 1,
3035                                    count, orderByComparator);
3036    
3037                    if (!list.isEmpty()) {
3038                            return list.get(0);
3039                    }
3040    
3041                    return null;
3042            }
3043    
3044            /**
3045             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63;.
3046             *
3047             * @param id the primary key of the current journal article
3048             * @param companyId the company ID
3049             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3050             * @return the previous, current, and next journal article
3051             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
3052             */
3053            @Override
3054            public JournalArticle[] findByCompanyId_PrevAndNext(long id,
3055                    long companyId, OrderByComparator<JournalArticle> orderByComparator)
3056                    throws NoSuchArticleException {
3057                    JournalArticle journalArticle = findByPrimaryKey(id);
3058    
3059                    Session session = null;
3060    
3061                    try {
3062                            session = openSession();
3063    
3064                            JournalArticle[] array = new JournalArticleImpl[3];
3065    
3066                            array[0] = getByCompanyId_PrevAndNext(session, journalArticle,
3067                                            companyId, orderByComparator, true);
3068    
3069                            array[1] = journalArticle;
3070    
3071                            array[2] = getByCompanyId_PrevAndNext(session, journalArticle,
3072                                            companyId, orderByComparator, false);
3073    
3074                            return array;
3075                    }
3076                    catch (Exception e) {
3077                            throw processException(e);
3078                    }
3079                    finally {
3080                            closeSession(session);
3081                    }
3082            }
3083    
3084            protected JournalArticle getByCompanyId_PrevAndNext(Session session,
3085                    JournalArticle journalArticle, long companyId,
3086                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
3087                    StringBundler query = null;
3088    
3089                    if (orderByComparator != null) {
3090                            query = new StringBundler(6 +
3091                                            (orderByComparator.getOrderByFields().length * 6));
3092                    }
3093                    else {
3094                            query = new StringBundler(3);
3095                    }
3096    
3097                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3098    
3099                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3100    
3101                    if (orderByComparator != null) {
3102                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3103    
3104                            if (orderByConditionFields.length > 0) {
3105                                    query.append(WHERE_AND);
3106                            }
3107    
3108                            for (int i = 0; i < orderByConditionFields.length; i++) {
3109                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3110                                    query.append(orderByConditionFields[i]);
3111    
3112                                    if ((i + 1) < orderByConditionFields.length) {
3113                                            if (orderByComparator.isAscending() ^ previous) {
3114                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3115                                            }
3116                                            else {
3117                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3118                                            }
3119                                    }
3120                                    else {
3121                                            if (orderByComparator.isAscending() ^ previous) {
3122                                                    query.append(WHERE_GREATER_THAN);
3123                                            }
3124                                            else {
3125                                                    query.append(WHERE_LESSER_THAN);
3126                                            }
3127                                    }
3128                            }
3129    
3130                            query.append(ORDER_BY_CLAUSE);
3131    
3132                            String[] orderByFields = orderByComparator.getOrderByFields();
3133    
3134                            for (int i = 0; i < orderByFields.length; i++) {
3135                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3136                                    query.append(orderByFields[i]);
3137    
3138                                    if ((i + 1) < orderByFields.length) {
3139                                            if (orderByComparator.isAscending() ^ previous) {
3140                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3141                                            }
3142                                            else {
3143                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3144                                            }
3145                                    }
3146                                    else {
3147                                            if (orderByComparator.isAscending() ^ previous) {
3148                                                    query.append(ORDER_BY_ASC);
3149                                            }
3150                                            else {
3151                                                    query.append(ORDER_BY_DESC);
3152                                            }
3153                                    }
3154                            }
3155                    }
3156                    else {
3157                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3158                    }
3159    
3160                    String sql = query.toString();
3161    
3162                    Query q = session.createQuery(sql);
3163    
3164                    q.setFirstResult(0);
3165                    q.setMaxResults(2);
3166    
3167                    QueryPos qPos = QueryPos.getInstance(q);
3168    
3169                    qPos.add(companyId);
3170    
3171                    if (orderByComparator != null) {
3172                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3173    
3174                            for (Object value : values) {
3175                                    qPos.add(value);
3176                            }
3177                    }
3178    
3179                    List<JournalArticle> list = q.list();
3180    
3181                    if (list.size() == 2) {
3182                            return list.get(1);
3183                    }
3184                    else {
3185                            return null;
3186                    }
3187            }
3188    
3189            /**
3190             * Removes all the journal articles where companyId = &#63; from the database.
3191             *
3192             * @param companyId the company ID
3193             */
3194            @Override
3195            public void removeByCompanyId(long companyId) {
3196                    for (JournalArticle journalArticle : findByCompanyId(companyId,
3197                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3198                            remove(journalArticle);
3199                    }
3200            }
3201    
3202            /**
3203             * Returns the number of journal articles where companyId = &#63;.
3204             *
3205             * @param companyId the company ID
3206             * @return the number of matching journal articles
3207             */
3208            @Override
3209            public int countByCompanyId(long companyId) {
3210                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
3211    
3212                    Object[] finderArgs = new Object[] { companyId };
3213    
3214                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3215                                    this);
3216    
3217                    if (count == null) {
3218                            StringBundler query = new StringBundler(2);
3219    
3220                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
3221    
3222                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3223    
3224                            String sql = query.toString();
3225    
3226                            Session session = null;
3227    
3228                            try {
3229                                    session = openSession();
3230    
3231                                    Query q = session.createQuery(sql);
3232    
3233                                    QueryPos qPos = QueryPos.getInstance(q);
3234    
3235                                    qPos.add(companyId);
3236    
3237                                    count = (Long)q.uniqueResult();
3238    
3239                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3240                            }
3241                            catch (Exception e) {
3242                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3243    
3244                                    throw processException(e);
3245                            }
3246                            finally {
3247                                    closeSession(session);
3248                            }
3249                    }
3250    
3251                    return count.intValue();
3252            }
3253    
3254            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "journalArticle.companyId = ?";
3255            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID =
3256                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3257                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
3258                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
3259                            "findByStructureId",
3260                            new String[] {
3261                                    String.class.getName(),
3262                                    
3263                            Integer.class.getName(), Integer.class.getName(),
3264                                    OrderByComparator.class.getName()
3265                            });
3266            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID =
3267                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3268                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
3269                            JournalArticleImpl.class,
3270                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByStructureId",
3271                            new String[] { String.class.getName() },
3272                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK |
3273                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
3274                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
3275            public static final FinderPath FINDER_PATH_COUNT_BY_STRUCTUREID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3276                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
3277                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByStructureId",
3278                            new String[] { String.class.getName() });
3279            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_STRUCTUREID =
3280                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3281                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
3282                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByStructureId",
3283                            new String[] { String.class.getName() });
3284    
3285            /**
3286             * Returns all the journal articles where structureId = &#63;.
3287             *
3288             * @param structureId the structure ID
3289             * @return the matching journal articles
3290             */
3291            @Override
3292            public List<JournalArticle> findByStructureId(String structureId) {
3293                    return findByStructureId(structureId, QueryUtil.ALL_POS,
3294                            QueryUtil.ALL_POS, null);
3295            }
3296    
3297            /**
3298             * Returns a range of all the journal articles where structureId = &#63;.
3299             *
3300             * <p>
3301             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
3302             * </p>
3303             *
3304             * @param structureId the structure ID
3305             * @param start the lower bound of the range of journal articles
3306             * @param end the upper bound of the range of journal articles (not inclusive)
3307             * @return the range of matching journal articles
3308             */
3309            @Override
3310            public List<JournalArticle> findByStructureId(String structureId,
3311                    int start, int end) {
3312                    return findByStructureId(structureId, start, end, null);
3313            }
3314    
3315            /**
3316             * Returns an ordered range of all the journal articles where structureId = &#63;.
3317             *
3318             * <p>
3319             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
3320             * </p>
3321             *
3322             * @param structureId the structure ID
3323             * @param start the lower bound of the range of journal articles
3324             * @param end the upper bound of the range of journal articles (not inclusive)
3325             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3326             * @return the ordered range of matching journal articles
3327             */
3328            @Override
3329            public List<JournalArticle> findByStructureId(String structureId,
3330                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
3331                    boolean pagination = true;
3332                    FinderPath finderPath = null;
3333                    Object[] finderArgs = null;
3334    
3335                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3336                                    (orderByComparator == null)) {
3337                            pagination = false;
3338                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID;
3339                            finderArgs = new Object[] { structureId };
3340                    }
3341                    else {
3342                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID;
3343                            finderArgs = new Object[] { structureId, start, end, orderByComparator };
3344                    }
3345    
3346                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
3347                                    finderArgs, this);
3348    
3349                    if ((list != null) && !list.isEmpty()) {
3350                            for (JournalArticle journalArticle : list) {
3351                                    if (!Validator.equals(structureId,
3352                                                            journalArticle.getStructureId())) {
3353                                            list = null;
3354    
3355                                            break;
3356                                    }
3357                            }
3358                    }
3359    
3360                    if (list == null) {
3361                            StringBundler query = null;
3362    
3363                            if (orderByComparator != null) {
3364                                    query = new StringBundler(3 +
3365                                                    (orderByComparator.getOrderByFields().length * 3));
3366                            }
3367                            else {
3368                                    query = new StringBundler(3);
3369                            }
3370    
3371                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3372    
3373                            boolean bindStructureId = false;
3374    
3375                            if (structureId == null) {
3376                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
3377                            }
3378                            else if (structureId.equals(StringPool.BLANK)) {
3379                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
3380                            }
3381                            else {
3382                                    bindStructureId = true;
3383    
3384                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
3385                            }
3386    
3387                            if (orderByComparator != null) {
3388                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3389                                            orderByComparator);
3390                            }
3391                            else
3392                             if (pagination) {
3393                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3394                            }
3395    
3396                            String sql = query.toString();
3397    
3398                            Session session = null;
3399    
3400                            try {
3401                                    session = openSession();
3402    
3403                                    Query q = session.createQuery(sql);
3404    
3405                                    QueryPos qPos = QueryPos.getInstance(q);
3406    
3407                                    if (bindStructureId) {
3408                                            qPos.add(structureId);
3409                                    }
3410    
3411                                    if (!pagination) {
3412                                            list = (List<JournalArticle>)QueryUtil.list(q,
3413                                                            getDialect(), start, end, false);
3414    
3415                                            Collections.sort(list);
3416    
3417                                            list = Collections.unmodifiableList(list);
3418                                    }
3419                                    else {
3420                                            list = (List<JournalArticle>)QueryUtil.list(q,
3421                                                            getDialect(), start, end);
3422                                    }
3423    
3424                                    cacheResult(list);
3425    
3426                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3427                            }
3428                            catch (Exception e) {
3429                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3430    
3431                                    throw processException(e);
3432                            }
3433                            finally {
3434                                    closeSession(session);
3435                            }
3436                    }
3437    
3438                    return list;
3439            }
3440    
3441            /**
3442             * Returns the first journal article in the ordered set where structureId = &#63;.
3443             *
3444             * @param structureId the structure ID
3445             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3446             * @return the first matching journal article
3447             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3448             */
3449            @Override
3450            public JournalArticle findByStructureId_First(String structureId,
3451                    OrderByComparator<JournalArticle> orderByComparator)
3452                    throws NoSuchArticleException {
3453                    JournalArticle journalArticle = fetchByStructureId_First(structureId,
3454                                    orderByComparator);
3455    
3456                    if (journalArticle != null) {
3457                            return journalArticle;
3458                    }
3459    
3460                    StringBundler msg = new StringBundler(4);
3461    
3462                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3463    
3464                    msg.append("structureId=");
3465                    msg.append(structureId);
3466    
3467                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3468    
3469                    throw new NoSuchArticleException(msg.toString());
3470            }
3471    
3472            /**
3473             * Returns the first journal article in the ordered set where structureId = &#63;.
3474             *
3475             * @param structureId the structure ID
3476             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3477             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
3478             */
3479            @Override
3480            public JournalArticle fetchByStructureId_First(String structureId,
3481                    OrderByComparator<JournalArticle> orderByComparator) {
3482                    List<JournalArticle> list = findByStructureId(structureId, 0, 1,
3483                                    orderByComparator);
3484    
3485                    if (!list.isEmpty()) {
3486                            return list.get(0);
3487                    }
3488    
3489                    return null;
3490            }
3491    
3492            /**
3493             * Returns the last journal article in the ordered set where structureId = &#63;.
3494             *
3495             * @param structureId the structure ID
3496             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3497             * @return the last matching journal article
3498             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3499             */
3500            @Override
3501            public JournalArticle findByStructureId_Last(String structureId,
3502                    OrderByComparator<JournalArticle> orderByComparator)
3503                    throws NoSuchArticleException {
3504                    JournalArticle journalArticle = fetchByStructureId_Last(structureId,
3505                                    orderByComparator);
3506    
3507                    if (journalArticle != null) {
3508                            return journalArticle;
3509                    }
3510    
3511                    StringBundler msg = new StringBundler(4);
3512    
3513                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3514    
3515                    msg.append("structureId=");
3516                    msg.append(structureId);
3517    
3518                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3519    
3520                    throw new NoSuchArticleException(msg.toString());
3521            }
3522    
3523            /**
3524             * Returns the last journal article in the ordered set where structureId = &#63;.
3525             *
3526             * @param structureId the structure ID
3527             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3528             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
3529             */
3530            @Override
3531            public JournalArticle fetchByStructureId_Last(String structureId,
3532                    OrderByComparator<JournalArticle> orderByComparator) {
3533                    int count = countByStructureId(structureId);
3534    
3535                    if (count == 0) {
3536                            return null;
3537                    }
3538    
3539                    List<JournalArticle> list = findByStructureId(structureId, count - 1,
3540                                    count, orderByComparator);
3541    
3542                    if (!list.isEmpty()) {
3543                            return list.get(0);
3544                    }
3545    
3546                    return null;
3547            }
3548    
3549            /**
3550             * Returns the journal articles before and after the current journal article in the ordered set where structureId = &#63;.
3551             *
3552             * @param id the primary key of the current journal article
3553             * @param structureId the structure ID
3554             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3555             * @return the previous, current, and next journal article
3556             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
3557             */
3558            @Override
3559            public JournalArticle[] findByStructureId_PrevAndNext(long id,
3560                    String structureId, OrderByComparator<JournalArticle> orderByComparator)
3561                    throws NoSuchArticleException {
3562                    JournalArticle journalArticle = findByPrimaryKey(id);
3563    
3564                    Session session = null;
3565    
3566                    try {
3567                            session = openSession();
3568    
3569                            JournalArticle[] array = new JournalArticleImpl[3];
3570    
3571                            array[0] = getByStructureId_PrevAndNext(session, journalArticle,
3572                                            structureId, orderByComparator, true);
3573    
3574                            array[1] = journalArticle;
3575    
3576                            array[2] = getByStructureId_PrevAndNext(session, journalArticle,
3577                                            structureId, orderByComparator, false);
3578    
3579                            return array;
3580                    }
3581                    catch (Exception e) {
3582                            throw processException(e);
3583                    }
3584                    finally {
3585                            closeSession(session);
3586                    }
3587            }
3588    
3589            protected JournalArticle getByStructureId_PrevAndNext(Session session,
3590                    JournalArticle journalArticle, String structureId,
3591                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
3592                    StringBundler query = null;
3593    
3594                    if (orderByComparator != null) {
3595                            query = new StringBundler(6 +
3596                                            (orderByComparator.getOrderByFields().length * 6));
3597                    }
3598                    else {
3599                            query = new StringBundler(3);
3600                    }
3601    
3602                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3603    
3604                    boolean bindStructureId = false;
3605    
3606                    if (structureId == null) {
3607                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
3608                    }
3609                    else if (structureId.equals(StringPool.BLANK)) {
3610                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
3611                    }
3612                    else {
3613                            bindStructureId = true;
3614    
3615                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
3616                    }
3617    
3618                    if (orderByComparator != null) {
3619                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3620    
3621                            if (orderByConditionFields.length > 0) {
3622                                    query.append(WHERE_AND);
3623                            }
3624    
3625                            for (int i = 0; i < orderByConditionFields.length; i++) {
3626                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3627                                    query.append(orderByConditionFields[i]);
3628    
3629                                    if ((i + 1) < orderByConditionFields.length) {
3630                                            if (orderByComparator.isAscending() ^ previous) {
3631                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3632                                            }
3633                                            else {
3634                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3635                                            }
3636                                    }
3637                                    else {
3638                                            if (orderByComparator.isAscending() ^ previous) {
3639                                                    query.append(WHERE_GREATER_THAN);
3640                                            }
3641                                            else {
3642                                                    query.append(WHERE_LESSER_THAN);
3643                                            }
3644                                    }
3645                            }
3646    
3647                            query.append(ORDER_BY_CLAUSE);
3648    
3649                            String[] orderByFields = orderByComparator.getOrderByFields();
3650    
3651                            for (int i = 0; i < orderByFields.length; i++) {
3652                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3653                                    query.append(orderByFields[i]);
3654    
3655                                    if ((i + 1) < orderByFields.length) {
3656                                            if (orderByComparator.isAscending() ^ previous) {
3657                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3658                                            }
3659                                            else {
3660                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3661                                            }
3662                                    }
3663                                    else {
3664                                            if (orderByComparator.isAscending() ^ previous) {
3665                                                    query.append(ORDER_BY_ASC);
3666                                            }
3667                                            else {
3668                                                    query.append(ORDER_BY_DESC);
3669                                            }
3670                                    }
3671                            }
3672                    }
3673                    else {
3674                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3675                    }
3676    
3677                    String sql = query.toString();
3678    
3679                    Query q = session.createQuery(sql);
3680    
3681                    q.setFirstResult(0);
3682                    q.setMaxResults(2);
3683    
3684                    QueryPos qPos = QueryPos.getInstance(q);
3685    
3686                    if (bindStructureId) {
3687                            qPos.add(structureId);
3688                    }
3689    
3690                    if (orderByComparator != null) {
3691                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3692    
3693                            for (Object value : values) {
3694                                    qPos.add(value);
3695                            }
3696                    }
3697    
3698                    List<JournalArticle> list = q.list();
3699    
3700                    if (list.size() == 2) {
3701                            return list.get(1);
3702                    }
3703                    else {
3704                            return null;
3705                    }
3706            }
3707    
3708            /**
3709             * Returns all the journal articles where structureId = any &#63;.
3710             *
3711             * <p>
3712             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
3713             * </p>
3714             *
3715             * @param structureIds the structure IDs
3716             * @return the matching journal articles
3717             */
3718            @Override
3719            public List<JournalArticle> findByStructureId(String[] structureIds) {
3720                    return findByStructureId(structureIds, QueryUtil.ALL_POS,
3721                            QueryUtil.ALL_POS, null);
3722            }
3723    
3724            /**
3725             * Returns a range of all the journal articles where structureId = any &#63;.
3726             *
3727             * <p>
3728             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
3729             * </p>
3730             *
3731             * @param structureIds the structure IDs
3732             * @param start the lower bound of the range of journal articles
3733             * @param end the upper bound of the range of journal articles (not inclusive)
3734             * @return the range of matching journal articles
3735             */
3736            @Override
3737            public List<JournalArticle> findByStructureId(String[] structureIds,
3738                    int start, int end) {
3739                    return findByStructureId(structureIds, start, end, null);
3740            }
3741    
3742            /**
3743             * Returns an ordered range of all the journal articles where structureId = any &#63;.
3744             *
3745             * <p>
3746             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
3747             * </p>
3748             *
3749             * @param structureIds the structure IDs
3750             * @param start the lower bound of the range of journal articles
3751             * @param end the upper bound of the range of journal articles (not inclusive)
3752             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3753             * @return the ordered range of matching journal articles
3754             */
3755            @Override
3756            public List<JournalArticle> findByStructureId(String[] structureIds,
3757                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
3758                    if (structureIds == null) {
3759                            structureIds = new String[0];
3760                    }
3761                    else {
3762                            structureIds = ArrayUtil.distinct(structureIds,
3763                                            NULL_SAFE_STRING_COMPARATOR);
3764                    }
3765    
3766                    if (structureIds.length == 1) {
3767                            return findByStructureId(structureIds[0], start, end,
3768                                    orderByComparator);
3769                    }
3770    
3771                    boolean pagination = true;
3772                    Object[] finderArgs = null;
3773    
3774                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3775                                    (orderByComparator == null)) {
3776                            pagination = false;
3777                            finderArgs = new Object[] { StringUtil.merge(structureIds) };
3778                    }
3779                    else {
3780                            finderArgs = new Object[] {
3781                                            StringUtil.merge(structureIds),
3782                                            
3783                                            start, end, orderByComparator
3784                                    };
3785                    }
3786    
3787                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID,
3788                                    finderArgs, this);
3789    
3790                    if ((list != null) && !list.isEmpty()) {
3791                            for (JournalArticle journalArticle : list) {
3792                                    if (!ArrayUtil.contains(structureIds,
3793                                                            journalArticle.getStructureId())) {
3794                                            list = null;
3795    
3796                                            break;
3797                                    }
3798                            }
3799                    }
3800    
3801                    if (list == null) {
3802                            StringBundler query = new StringBundler();
3803    
3804                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3805    
3806                            if (structureIds.length > 0) {
3807                                    query.append(StringPool.OPEN_PARENTHESIS);
3808    
3809                                    for (int i = 0; i < structureIds.length; i++) {
3810                                            String structureId = structureIds[i];
3811    
3812                                            if (structureId == null) {
3813                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
3814                                            }
3815                                            else if (structureId.equals(StringPool.BLANK)) {
3816                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
3817                                            }
3818                                            else {
3819                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
3820                                            }
3821    
3822                                            if ((i + 1) < structureIds.length) {
3823                                                    query.append(WHERE_OR);
3824                                            }
3825                                    }
3826    
3827                                    query.append(StringPool.CLOSE_PARENTHESIS);
3828                            }
3829    
3830                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
3831                                                    1)), query.index() - 1);
3832    
3833                            if (orderByComparator != null) {
3834                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3835                                            orderByComparator);
3836                            }
3837                            else
3838                             if (pagination) {
3839                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3840                            }
3841    
3842                            String sql = query.toString();
3843    
3844                            Session session = null;
3845    
3846                            try {
3847                                    session = openSession();
3848    
3849                                    Query q = session.createQuery(sql);
3850    
3851                                    QueryPos qPos = QueryPos.getInstance(q);
3852    
3853                                    for (String structureId : structureIds) {
3854                                            if ((structureId != null) && !structureId.isEmpty()) {
3855                                                    qPos.add(structureId);
3856                                            }
3857                                    }
3858    
3859                                    if (!pagination) {
3860                                            list = (List<JournalArticle>)QueryUtil.list(q,
3861                                                            getDialect(), start, end, false);
3862    
3863                                            Collections.sort(list);
3864    
3865                                            list = Collections.unmodifiableList(list);
3866                                    }
3867                                    else {
3868                                            list = (List<JournalArticle>)QueryUtil.list(q,
3869                                                            getDialect(), start, end);
3870                                    }
3871    
3872                                    cacheResult(list);
3873    
3874                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID,
3875                                            finderArgs, list);
3876                            }
3877                            catch (Exception e) {
3878                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID,
3879                                            finderArgs);
3880    
3881                                    throw processException(e);
3882                            }
3883                            finally {
3884                                    closeSession(session);
3885                            }
3886                    }
3887    
3888                    return list;
3889            }
3890    
3891            /**
3892             * Removes all the journal articles where structureId = &#63; from the database.
3893             *
3894             * @param structureId the structure ID
3895             */
3896            @Override
3897            public void removeByStructureId(String structureId) {
3898                    for (JournalArticle journalArticle : findByStructureId(structureId,
3899                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3900                            remove(journalArticle);
3901                    }
3902            }
3903    
3904            /**
3905             * Returns the number of journal articles where structureId = &#63;.
3906             *
3907             * @param structureId the structure ID
3908             * @return the number of matching journal articles
3909             */
3910            @Override
3911            public int countByStructureId(String structureId) {
3912                    FinderPath finderPath = FINDER_PATH_COUNT_BY_STRUCTUREID;
3913    
3914                    Object[] finderArgs = new Object[] { structureId };
3915    
3916                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3917                                    this);
3918    
3919                    if (count == null) {
3920                            StringBundler query = new StringBundler(2);
3921    
3922                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
3923    
3924                            boolean bindStructureId = false;
3925    
3926                            if (structureId == null) {
3927                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
3928                            }
3929                            else if (structureId.equals(StringPool.BLANK)) {
3930                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
3931                            }
3932                            else {
3933                                    bindStructureId = true;
3934    
3935                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
3936                            }
3937    
3938                            String sql = query.toString();
3939    
3940                            Session session = null;
3941    
3942                            try {
3943                                    session = openSession();
3944    
3945                                    Query q = session.createQuery(sql);
3946    
3947                                    QueryPos qPos = QueryPos.getInstance(q);
3948    
3949                                    if (bindStructureId) {
3950                                            qPos.add(structureId);
3951                                    }
3952    
3953                                    count = (Long)q.uniqueResult();
3954    
3955                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3956                            }
3957                            catch (Exception e) {
3958                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3959    
3960                                    throw processException(e);
3961                            }
3962                            finally {
3963                                    closeSession(session);
3964                            }
3965                    }
3966    
3967                    return count.intValue();
3968            }
3969    
3970            /**
3971             * Returns the number of journal articles where structureId = any &#63;.
3972             *
3973             * @param structureIds the structure IDs
3974             * @return the number of matching journal articles
3975             */
3976            @Override
3977            public int countByStructureId(String[] structureIds) {
3978                    if (structureIds == null) {
3979                            structureIds = new String[0];
3980                    }
3981                    else {
3982                            structureIds = ArrayUtil.distinct(structureIds,
3983                                            NULL_SAFE_STRING_COMPARATOR);
3984                    }
3985    
3986                    Object[] finderArgs = new Object[] { StringUtil.merge(structureIds) };
3987    
3988                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_STRUCTUREID,
3989                                    finderArgs, this);
3990    
3991                    if (count == null) {
3992                            StringBundler query = new StringBundler();
3993    
3994                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
3995    
3996                            if (structureIds.length > 0) {
3997                                    query.append(StringPool.OPEN_PARENTHESIS);
3998    
3999                                    for (int i = 0; i < structureIds.length; i++) {
4000                                            String structureId = structureIds[i];
4001    
4002                                            if (structureId == null) {
4003                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
4004                                            }
4005                                            else if (structureId.equals(StringPool.BLANK)) {
4006                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
4007                                            }
4008                                            else {
4009                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
4010                                            }
4011    
4012                                            if ((i + 1) < structureIds.length) {
4013                                                    query.append(WHERE_OR);
4014                                            }
4015                                    }
4016    
4017                                    query.append(StringPool.CLOSE_PARENTHESIS);
4018                            }
4019    
4020                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
4021                                                    1)), query.index() - 1);
4022    
4023                            String sql = query.toString();
4024    
4025                            Session session = null;
4026    
4027                            try {
4028                                    session = openSession();
4029    
4030                                    Query q = session.createQuery(sql);
4031    
4032                                    QueryPos qPos = QueryPos.getInstance(q);
4033    
4034                                    for (String structureId : structureIds) {
4035                                            if ((structureId != null) && !structureId.isEmpty()) {
4036                                                    qPos.add(structureId);
4037                                            }
4038                                    }
4039    
4040                                    count = (Long)q.uniqueResult();
4041    
4042                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_STRUCTUREID,
4043                                            finderArgs, count);
4044                            }
4045                            catch (Exception e) {
4046                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_STRUCTUREID,
4047                                            finderArgs);
4048    
4049                                    throw processException(e);
4050                            }
4051                            finally {
4052                                    closeSession(session);
4053                            }
4054                    }
4055    
4056                    return count.intValue();
4057            }
4058    
4059            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
4060            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2 = "journalArticle.structureId = ?";
4061            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = '')";
4062            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_TEMPLATEID =
4063                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4064                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4065                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4066                            "findByTemplateId",
4067                            new String[] {
4068                                    String.class.getName(),
4069                                    
4070                            Integer.class.getName(), Integer.class.getName(),
4071                                    OrderByComparator.class.getName()
4072                            });
4073            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID =
4074                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4075                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4076                            JournalArticleImpl.class,
4077                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByTemplateId",
4078                            new String[] { String.class.getName() },
4079                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
4080                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
4081                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
4082            public static final FinderPath FINDER_PATH_COUNT_BY_TEMPLATEID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4083                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
4084                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByTemplateId",
4085                            new String[] { String.class.getName() });
4086    
4087            /**
4088             * Returns all the journal articles where templateId = &#63;.
4089             *
4090             * @param templateId the template ID
4091             * @return the matching journal articles
4092             */
4093            @Override
4094            public List<JournalArticle> findByTemplateId(String templateId) {
4095                    return findByTemplateId(templateId, QueryUtil.ALL_POS,
4096                            QueryUtil.ALL_POS, null);
4097            }
4098    
4099            /**
4100             * Returns a range of all the journal articles where templateId = &#63;.
4101             *
4102             * <p>
4103             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
4104             * </p>
4105             *
4106             * @param templateId the template ID
4107             * @param start the lower bound of the range of journal articles
4108             * @param end the upper bound of the range of journal articles (not inclusive)
4109             * @return the range of matching journal articles
4110             */
4111            @Override
4112            public List<JournalArticle> findByTemplateId(String templateId, int start,
4113                    int end) {
4114                    return findByTemplateId(templateId, start, end, null);
4115            }
4116    
4117            /**
4118             * Returns an ordered range of all the journal articles where templateId = &#63;.
4119             *
4120             * <p>
4121             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
4122             * </p>
4123             *
4124             * @param templateId the template ID
4125             * @param start the lower bound of the range of journal articles
4126             * @param end the upper bound of the range of journal articles (not inclusive)
4127             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4128             * @return the ordered range of matching journal articles
4129             */
4130            @Override
4131            public List<JournalArticle> findByTemplateId(String templateId, int start,
4132                    int end, OrderByComparator<JournalArticle> orderByComparator) {
4133                    boolean pagination = true;
4134                    FinderPath finderPath = null;
4135                    Object[] finderArgs = null;
4136    
4137                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4138                                    (orderByComparator == null)) {
4139                            pagination = false;
4140                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID;
4141                            finderArgs = new Object[] { templateId };
4142                    }
4143                    else {
4144                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_TEMPLATEID;
4145                            finderArgs = new Object[] { templateId, start, end, orderByComparator };
4146                    }
4147    
4148                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4149                                    finderArgs, this);
4150    
4151                    if ((list != null) && !list.isEmpty()) {
4152                            for (JournalArticle journalArticle : list) {
4153                                    if (!Validator.equals(templateId, journalArticle.getTemplateId())) {
4154                                            list = null;
4155    
4156                                            break;
4157                                    }
4158                            }
4159                    }
4160    
4161                    if (list == null) {
4162                            StringBundler query = null;
4163    
4164                            if (orderByComparator != null) {
4165                                    query = new StringBundler(3 +
4166                                                    (orderByComparator.getOrderByFields().length * 3));
4167                            }
4168                            else {
4169                                    query = new StringBundler(3);
4170                            }
4171    
4172                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4173    
4174                            boolean bindTemplateId = false;
4175    
4176                            if (templateId == null) {
4177                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
4178                            }
4179                            else if (templateId.equals(StringPool.BLANK)) {
4180                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
4181                            }
4182                            else {
4183                                    bindTemplateId = true;
4184    
4185                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
4186                            }
4187    
4188                            if (orderByComparator != null) {
4189                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4190                                            orderByComparator);
4191                            }
4192                            else
4193                             if (pagination) {
4194                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4195                            }
4196    
4197                            String sql = query.toString();
4198    
4199                            Session session = null;
4200    
4201                            try {
4202                                    session = openSession();
4203    
4204                                    Query q = session.createQuery(sql);
4205    
4206                                    QueryPos qPos = QueryPos.getInstance(q);
4207    
4208                                    if (bindTemplateId) {
4209                                            qPos.add(templateId);
4210                                    }
4211    
4212                                    if (!pagination) {
4213                                            list = (List<JournalArticle>)QueryUtil.list(q,
4214                                                            getDialect(), start, end, false);
4215    
4216                                            Collections.sort(list);
4217    
4218                                            list = Collections.unmodifiableList(list);
4219                                    }
4220                                    else {
4221                                            list = (List<JournalArticle>)QueryUtil.list(q,
4222                                                            getDialect(), start, end);
4223                                    }
4224    
4225                                    cacheResult(list);
4226    
4227                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4228                            }
4229                            catch (Exception e) {
4230                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4231    
4232                                    throw processException(e);
4233                            }
4234                            finally {
4235                                    closeSession(session);
4236                            }
4237                    }
4238    
4239                    return list;
4240            }
4241    
4242            /**
4243             * Returns the first journal article in the ordered set where templateId = &#63;.
4244             *
4245             * @param templateId the template ID
4246             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4247             * @return the first matching journal article
4248             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4249             */
4250            @Override
4251            public JournalArticle findByTemplateId_First(String templateId,
4252                    OrderByComparator<JournalArticle> orderByComparator)
4253                    throws NoSuchArticleException {
4254                    JournalArticle journalArticle = fetchByTemplateId_First(templateId,
4255                                    orderByComparator);
4256    
4257                    if (journalArticle != null) {
4258                            return journalArticle;
4259                    }
4260    
4261                    StringBundler msg = new StringBundler(4);
4262    
4263                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4264    
4265                    msg.append("templateId=");
4266                    msg.append(templateId);
4267    
4268                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4269    
4270                    throw new NoSuchArticleException(msg.toString());
4271            }
4272    
4273            /**
4274             * Returns the first journal article in the ordered set where templateId = &#63;.
4275             *
4276             * @param templateId the template ID
4277             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4278             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
4279             */
4280            @Override
4281            public JournalArticle fetchByTemplateId_First(String templateId,
4282                    OrderByComparator<JournalArticle> orderByComparator) {
4283                    List<JournalArticle> list = findByTemplateId(templateId, 0, 1,
4284                                    orderByComparator);
4285    
4286                    if (!list.isEmpty()) {
4287                            return list.get(0);
4288                    }
4289    
4290                    return null;
4291            }
4292    
4293            /**
4294             * Returns the last journal article in the ordered set where templateId = &#63;.
4295             *
4296             * @param templateId the template ID
4297             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4298             * @return the last matching journal article
4299             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4300             */
4301            @Override
4302            public JournalArticle findByTemplateId_Last(String templateId,
4303                    OrderByComparator<JournalArticle> orderByComparator)
4304                    throws NoSuchArticleException {
4305                    JournalArticle journalArticle = fetchByTemplateId_Last(templateId,
4306                                    orderByComparator);
4307    
4308                    if (journalArticle != null) {
4309                            return journalArticle;
4310                    }
4311    
4312                    StringBundler msg = new StringBundler(4);
4313    
4314                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4315    
4316                    msg.append("templateId=");
4317                    msg.append(templateId);
4318    
4319                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4320    
4321                    throw new NoSuchArticleException(msg.toString());
4322            }
4323    
4324            /**
4325             * Returns the last journal article in the ordered set where templateId = &#63;.
4326             *
4327             * @param templateId the template ID
4328             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4329             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
4330             */
4331            @Override
4332            public JournalArticle fetchByTemplateId_Last(String templateId,
4333                    OrderByComparator<JournalArticle> orderByComparator) {
4334                    int count = countByTemplateId(templateId);
4335    
4336                    if (count == 0) {
4337                            return null;
4338                    }
4339    
4340                    List<JournalArticle> list = findByTemplateId(templateId, count - 1,
4341                                    count, orderByComparator);
4342    
4343                    if (!list.isEmpty()) {
4344                            return list.get(0);
4345                    }
4346    
4347                    return null;
4348            }
4349    
4350            /**
4351             * Returns the journal articles before and after the current journal article in the ordered set where templateId = &#63;.
4352             *
4353             * @param id the primary key of the current journal article
4354             * @param templateId the template ID
4355             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4356             * @return the previous, current, and next journal article
4357             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4358             */
4359            @Override
4360            public JournalArticle[] findByTemplateId_PrevAndNext(long id,
4361                    String templateId, OrderByComparator<JournalArticle> orderByComparator)
4362                    throws NoSuchArticleException {
4363                    JournalArticle journalArticle = findByPrimaryKey(id);
4364    
4365                    Session session = null;
4366    
4367                    try {
4368                            session = openSession();
4369    
4370                            JournalArticle[] array = new JournalArticleImpl[3];
4371    
4372                            array[0] = getByTemplateId_PrevAndNext(session, journalArticle,
4373                                            templateId, orderByComparator, true);
4374    
4375                            array[1] = journalArticle;
4376    
4377                            array[2] = getByTemplateId_PrevAndNext(session, journalArticle,
4378                                            templateId, orderByComparator, false);
4379    
4380                            return array;
4381                    }
4382                    catch (Exception e) {
4383                            throw processException(e);
4384                    }
4385                    finally {
4386                            closeSession(session);
4387                    }
4388            }
4389    
4390            protected JournalArticle getByTemplateId_PrevAndNext(Session session,
4391                    JournalArticle journalArticle, String templateId,
4392                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
4393                    StringBundler query = null;
4394    
4395                    if (orderByComparator != null) {
4396                            query = new StringBundler(6 +
4397                                            (orderByComparator.getOrderByFields().length * 6));
4398                    }
4399                    else {
4400                            query = new StringBundler(3);
4401                    }
4402    
4403                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4404    
4405                    boolean bindTemplateId = false;
4406    
4407                    if (templateId == null) {
4408                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
4409                    }
4410                    else if (templateId.equals(StringPool.BLANK)) {
4411                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
4412                    }
4413                    else {
4414                            bindTemplateId = true;
4415    
4416                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
4417                    }
4418    
4419                    if (orderByComparator != null) {
4420                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4421    
4422                            if (orderByConditionFields.length > 0) {
4423                                    query.append(WHERE_AND);
4424                            }
4425    
4426                            for (int i = 0; i < orderByConditionFields.length; i++) {
4427                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4428                                    query.append(orderByConditionFields[i]);
4429    
4430                                    if ((i + 1) < orderByConditionFields.length) {
4431                                            if (orderByComparator.isAscending() ^ previous) {
4432                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4433                                            }
4434                                            else {
4435                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4436                                            }
4437                                    }
4438                                    else {
4439                                            if (orderByComparator.isAscending() ^ previous) {
4440                                                    query.append(WHERE_GREATER_THAN);
4441                                            }
4442                                            else {
4443                                                    query.append(WHERE_LESSER_THAN);
4444                                            }
4445                                    }
4446                            }
4447    
4448                            query.append(ORDER_BY_CLAUSE);
4449    
4450                            String[] orderByFields = orderByComparator.getOrderByFields();
4451    
4452                            for (int i = 0; i < orderByFields.length; i++) {
4453                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4454                                    query.append(orderByFields[i]);
4455    
4456                                    if ((i + 1) < orderByFields.length) {
4457                                            if (orderByComparator.isAscending() ^ previous) {
4458                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4459                                            }
4460                                            else {
4461                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4462                                            }
4463                                    }
4464                                    else {
4465                                            if (orderByComparator.isAscending() ^ previous) {
4466                                                    query.append(ORDER_BY_ASC);
4467                                            }
4468                                            else {
4469                                                    query.append(ORDER_BY_DESC);
4470                                            }
4471                                    }
4472                            }
4473                    }
4474                    else {
4475                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4476                    }
4477    
4478                    String sql = query.toString();
4479    
4480                    Query q = session.createQuery(sql);
4481    
4482                    q.setFirstResult(0);
4483                    q.setMaxResults(2);
4484    
4485                    QueryPos qPos = QueryPos.getInstance(q);
4486    
4487                    if (bindTemplateId) {
4488                            qPos.add(templateId);
4489                    }
4490    
4491                    if (orderByComparator != null) {
4492                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
4493    
4494                            for (Object value : values) {
4495                                    qPos.add(value);
4496                            }
4497                    }
4498    
4499                    List<JournalArticle> list = q.list();
4500    
4501                    if (list.size() == 2) {
4502                            return list.get(1);
4503                    }
4504                    else {
4505                            return null;
4506                    }
4507            }
4508    
4509            /**
4510             * Removes all the journal articles where templateId = &#63; from the database.
4511             *
4512             * @param templateId the template ID
4513             */
4514            @Override
4515            public void removeByTemplateId(String templateId) {
4516                    for (JournalArticle journalArticle : findByTemplateId(templateId,
4517                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4518                            remove(journalArticle);
4519                    }
4520            }
4521    
4522            /**
4523             * Returns the number of journal articles where templateId = &#63;.
4524             *
4525             * @param templateId the template ID
4526             * @return the number of matching journal articles
4527             */
4528            @Override
4529            public int countByTemplateId(String templateId) {
4530                    FinderPath finderPath = FINDER_PATH_COUNT_BY_TEMPLATEID;
4531    
4532                    Object[] finderArgs = new Object[] { templateId };
4533    
4534                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4535                                    this);
4536    
4537                    if (count == null) {
4538                            StringBundler query = new StringBundler(2);
4539    
4540                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
4541    
4542                            boolean bindTemplateId = false;
4543    
4544                            if (templateId == null) {
4545                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
4546                            }
4547                            else if (templateId.equals(StringPool.BLANK)) {
4548                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
4549                            }
4550                            else {
4551                                    bindTemplateId = true;
4552    
4553                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
4554                            }
4555    
4556                            String sql = query.toString();
4557    
4558                            Session session = null;
4559    
4560                            try {
4561                                    session = openSession();
4562    
4563                                    Query q = session.createQuery(sql);
4564    
4565                                    QueryPos qPos = QueryPos.getInstance(q);
4566    
4567                                    if (bindTemplateId) {
4568                                            qPos.add(templateId);
4569                                    }
4570    
4571                                    count = (Long)q.uniqueResult();
4572    
4573                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4574                            }
4575                            catch (Exception e) {
4576                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4577    
4578                                    throw processException(e);
4579                            }
4580                            finally {
4581                                    closeSession(session);
4582                            }
4583                    }
4584    
4585                    return count.intValue();
4586            }
4587    
4588            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
4589            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2 = "journalArticle.templateId = ?";
4590            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = '')";
4591            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTUUID =
4592                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4593                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4594                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4595                            "findByLayoutUuid",
4596                            new String[] {
4597                                    String.class.getName(),
4598                                    
4599                            Integer.class.getName(), Integer.class.getName(),
4600                                    OrderByComparator.class.getName()
4601                            });
4602            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID =
4603                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4604                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4605                            JournalArticleImpl.class,
4606                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByLayoutUuid",
4607                            new String[] { String.class.getName() },
4608                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
4609                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
4610                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
4611            public static final FinderPath FINDER_PATH_COUNT_BY_LAYOUTUUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4612                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
4613                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByLayoutUuid",
4614                            new String[] { String.class.getName() });
4615    
4616            /**
4617             * Returns all the journal articles where layoutUuid = &#63;.
4618             *
4619             * @param layoutUuid the layout uuid
4620             * @return the matching journal articles
4621             */
4622            @Override
4623            public List<JournalArticle> findByLayoutUuid(String layoutUuid) {
4624                    return findByLayoutUuid(layoutUuid, QueryUtil.ALL_POS,
4625                            QueryUtil.ALL_POS, null);
4626            }
4627    
4628            /**
4629             * Returns a range of all the journal articles where layoutUuid = &#63;.
4630             *
4631             * <p>
4632             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
4633             * </p>
4634             *
4635             * @param layoutUuid the layout uuid
4636             * @param start the lower bound of the range of journal articles
4637             * @param end the upper bound of the range of journal articles (not inclusive)
4638             * @return the range of matching journal articles
4639             */
4640            @Override
4641            public List<JournalArticle> findByLayoutUuid(String layoutUuid, int start,
4642                    int end) {
4643                    return findByLayoutUuid(layoutUuid, start, end, null);
4644            }
4645    
4646            /**
4647             * Returns an ordered range of all the journal articles where layoutUuid = &#63;.
4648             *
4649             * <p>
4650             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
4651             * </p>
4652             *
4653             * @param layoutUuid the layout uuid
4654             * @param start the lower bound of the range of journal articles
4655             * @param end the upper bound of the range of journal articles (not inclusive)
4656             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4657             * @return the ordered range of matching journal articles
4658             */
4659            @Override
4660            public List<JournalArticle> findByLayoutUuid(String layoutUuid, int start,
4661                    int end, OrderByComparator<JournalArticle> orderByComparator) {
4662                    boolean pagination = true;
4663                    FinderPath finderPath = null;
4664                    Object[] finderArgs = null;
4665    
4666                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4667                                    (orderByComparator == null)) {
4668                            pagination = false;
4669                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID;
4670                            finderArgs = new Object[] { layoutUuid };
4671                    }
4672                    else {
4673                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTUUID;
4674                            finderArgs = new Object[] { layoutUuid, start, end, orderByComparator };
4675                    }
4676    
4677                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4678                                    finderArgs, this);
4679    
4680                    if ((list != null) && !list.isEmpty()) {
4681                            for (JournalArticle journalArticle : list) {
4682                                    if (!Validator.equals(layoutUuid, journalArticle.getLayoutUuid())) {
4683                                            list = null;
4684    
4685                                            break;
4686                                    }
4687                            }
4688                    }
4689    
4690                    if (list == null) {
4691                            StringBundler query = null;
4692    
4693                            if (orderByComparator != null) {
4694                                    query = new StringBundler(3 +
4695                                                    (orderByComparator.getOrderByFields().length * 3));
4696                            }
4697                            else {
4698                                    query = new StringBundler(3);
4699                            }
4700    
4701                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4702    
4703                            boolean bindLayoutUuid = false;
4704    
4705                            if (layoutUuid == null) {
4706                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
4707                            }
4708                            else if (layoutUuid.equals(StringPool.BLANK)) {
4709                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
4710                            }
4711                            else {
4712                                    bindLayoutUuid = true;
4713    
4714                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
4715                            }
4716    
4717                            if (orderByComparator != null) {
4718                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4719                                            orderByComparator);
4720                            }
4721                            else
4722                             if (pagination) {
4723                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4724                            }
4725    
4726                            String sql = query.toString();
4727    
4728                            Session session = null;
4729    
4730                            try {
4731                                    session = openSession();
4732    
4733                                    Query q = session.createQuery(sql);
4734    
4735                                    QueryPos qPos = QueryPos.getInstance(q);
4736    
4737                                    if (bindLayoutUuid) {
4738                                            qPos.add(layoutUuid);
4739                                    }
4740    
4741                                    if (!pagination) {
4742                                            list = (List<JournalArticle>)QueryUtil.list(q,
4743                                                            getDialect(), start, end, false);
4744    
4745                                            Collections.sort(list);
4746    
4747                                            list = Collections.unmodifiableList(list);
4748                                    }
4749                                    else {
4750                                            list = (List<JournalArticle>)QueryUtil.list(q,
4751                                                            getDialect(), start, end);
4752                                    }
4753    
4754                                    cacheResult(list);
4755    
4756                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4757                            }
4758                            catch (Exception e) {
4759                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4760    
4761                                    throw processException(e);
4762                            }
4763                            finally {
4764                                    closeSession(session);
4765                            }
4766                    }
4767    
4768                    return list;
4769            }
4770    
4771            /**
4772             * Returns the first journal article in the ordered set where layoutUuid = &#63;.
4773             *
4774             * @param layoutUuid the layout uuid
4775             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4776             * @return the first matching journal article
4777             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4778             */
4779            @Override
4780            public JournalArticle findByLayoutUuid_First(String layoutUuid,
4781                    OrderByComparator<JournalArticle> orderByComparator)
4782                    throws NoSuchArticleException {
4783                    JournalArticle journalArticle = fetchByLayoutUuid_First(layoutUuid,
4784                                    orderByComparator);
4785    
4786                    if (journalArticle != null) {
4787                            return journalArticle;
4788                    }
4789    
4790                    StringBundler msg = new StringBundler(4);
4791    
4792                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4793    
4794                    msg.append("layoutUuid=");
4795                    msg.append(layoutUuid);
4796    
4797                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4798    
4799                    throw new NoSuchArticleException(msg.toString());
4800            }
4801    
4802            /**
4803             * Returns the first journal article in the ordered set where layoutUuid = &#63;.
4804             *
4805             * @param layoutUuid the layout uuid
4806             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4807             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
4808             */
4809            @Override
4810            public JournalArticle fetchByLayoutUuid_First(String layoutUuid,
4811                    OrderByComparator<JournalArticle> orderByComparator) {
4812                    List<JournalArticle> list = findByLayoutUuid(layoutUuid, 0, 1,
4813                                    orderByComparator);
4814    
4815                    if (!list.isEmpty()) {
4816                            return list.get(0);
4817                    }
4818    
4819                    return null;
4820            }
4821    
4822            /**
4823             * Returns the last journal article in the ordered set where layoutUuid = &#63;.
4824             *
4825             * @param layoutUuid the layout uuid
4826             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4827             * @return the last matching journal article
4828             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4829             */
4830            @Override
4831            public JournalArticle findByLayoutUuid_Last(String layoutUuid,
4832                    OrderByComparator<JournalArticle> orderByComparator)
4833                    throws NoSuchArticleException {
4834                    JournalArticle journalArticle = fetchByLayoutUuid_Last(layoutUuid,
4835                                    orderByComparator);
4836    
4837                    if (journalArticle != null) {
4838                            return journalArticle;
4839                    }
4840    
4841                    StringBundler msg = new StringBundler(4);
4842    
4843                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4844    
4845                    msg.append("layoutUuid=");
4846                    msg.append(layoutUuid);
4847    
4848                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4849    
4850                    throw new NoSuchArticleException(msg.toString());
4851            }
4852    
4853            /**
4854             * Returns the last journal article in the ordered set where layoutUuid = &#63;.
4855             *
4856             * @param layoutUuid the layout uuid
4857             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4858             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
4859             */
4860            @Override
4861            public JournalArticle fetchByLayoutUuid_Last(String layoutUuid,
4862                    OrderByComparator<JournalArticle> orderByComparator) {
4863                    int count = countByLayoutUuid(layoutUuid);
4864    
4865                    if (count == 0) {
4866                            return null;
4867                    }
4868    
4869                    List<JournalArticle> list = findByLayoutUuid(layoutUuid, count - 1,
4870                                    count, orderByComparator);
4871    
4872                    if (!list.isEmpty()) {
4873                            return list.get(0);
4874                    }
4875    
4876                    return null;
4877            }
4878    
4879            /**
4880             * Returns the journal articles before and after the current journal article in the ordered set where layoutUuid = &#63;.
4881             *
4882             * @param id the primary key of the current journal article
4883             * @param layoutUuid the layout uuid
4884             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4885             * @return the previous, current, and next journal article
4886             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4887             */
4888            @Override
4889            public JournalArticle[] findByLayoutUuid_PrevAndNext(long id,
4890                    String layoutUuid, OrderByComparator<JournalArticle> orderByComparator)
4891                    throws NoSuchArticleException {
4892                    JournalArticle journalArticle = findByPrimaryKey(id);
4893    
4894                    Session session = null;
4895    
4896                    try {
4897                            session = openSession();
4898    
4899                            JournalArticle[] array = new JournalArticleImpl[3];
4900    
4901                            array[0] = getByLayoutUuid_PrevAndNext(session, journalArticle,
4902                                            layoutUuid, orderByComparator, true);
4903    
4904                            array[1] = journalArticle;
4905    
4906                            array[2] = getByLayoutUuid_PrevAndNext(session, journalArticle,
4907                                            layoutUuid, orderByComparator, false);
4908    
4909                            return array;
4910                    }
4911                    catch (Exception e) {
4912                            throw processException(e);
4913                    }
4914                    finally {
4915                            closeSession(session);
4916                    }
4917            }
4918    
4919            protected JournalArticle getByLayoutUuid_PrevAndNext(Session session,
4920                    JournalArticle journalArticle, String layoutUuid,
4921                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
4922                    StringBundler query = null;
4923    
4924                    if (orderByComparator != null) {
4925                            query = new StringBundler(6 +
4926                                            (orderByComparator.getOrderByFields().length * 6));
4927                    }
4928                    else {
4929                            query = new StringBundler(3);
4930                    }
4931    
4932                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4933    
4934                    boolean bindLayoutUuid = false;
4935    
4936                    if (layoutUuid == null) {
4937                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
4938                    }
4939                    else if (layoutUuid.equals(StringPool.BLANK)) {
4940                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
4941                    }
4942                    else {
4943                            bindLayoutUuid = true;
4944    
4945                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
4946                    }
4947    
4948                    if (orderByComparator != null) {
4949                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4950    
4951                            if (orderByConditionFields.length > 0) {
4952                                    query.append(WHERE_AND);
4953                            }
4954    
4955                            for (int i = 0; i < orderByConditionFields.length; i++) {
4956                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4957                                    query.append(orderByConditionFields[i]);
4958    
4959                                    if ((i + 1) < orderByConditionFields.length) {
4960                                            if (orderByComparator.isAscending() ^ previous) {
4961                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4962                                            }
4963                                            else {
4964                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4965                                            }
4966                                    }
4967                                    else {
4968                                            if (orderByComparator.isAscending() ^ previous) {
4969                                                    query.append(WHERE_GREATER_THAN);
4970                                            }
4971                                            else {
4972                                                    query.append(WHERE_LESSER_THAN);
4973                                            }
4974                                    }
4975                            }
4976    
4977                            query.append(ORDER_BY_CLAUSE);
4978    
4979                            String[] orderByFields = orderByComparator.getOrderByFields();
4980    
4981                            for (int i = 0; i < orderByFields.length; i++) {
4982                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4983                                    query.append(orderByFields[i]);
4984    
4985                                    if ((i + 1) < orderByFields.length) {
4986                                            if (orderByComparator.isAscending() ^ previous) {
4987                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4988                                            }
4989                                            else {
4990                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4991                                            }
4992                                    }
4993                                    else {
4994                                            if (orderByComparator.isAscending() ^ previous) {
4995                                                    query.append(ORDER_BY_ASC);
4996                                            }
4997                                            else {
4998                                                    query.append(ORDER_BY_DESC);
4999                                            }
5000                                    }
5001                            }
5002                    }
5003                    else {
5004                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5005                    }
5006    
5007                    String sql = query.toString();
5008    
5009                    Query q = session.createQuery(sql);
5010    
5011                    q.setFirstResult(0);
5012                    q.setMaxResults(2);
5013    
5014                    QueryPos qPos = QueryPos.getInstance(q);
5015    
5016                    if (bindLayoutUuid) {
5017                            qPos.add(layoutUuid);
5018                    }
5019    
5020                    if (orderByComparator != null) {
5021                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5022    
5023                            for (Object value : values) {
5024                                    qPos.add(value);
5025                            }
5026                    }
5027    
5028                    List<JournalArticle> list = q.list();
5029    
5030                    if (list.size() == 2) {
5031                            return list.get(1);
5032                    }
5033                    else {
5034                            return null;
5035                    }
5036            }
5037    
5038            /**
5039             * Removes all the journal articles where layoutUuid = &#63; from the database.
5040             *
5041             * @param layoutUuid the layout uuid
5042             */
5043            @Override
5044            public void removeByLayoutUuid(String layoutUuid) {
5045                    for (JournalArticle journalArticle : findByLayoutUuid(layoutUuid,
5046                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5047                            remove(journalArticle);
5048                    }
5049            }
5050    
5051            /**
5052             * Returns the number of journal articles where layoutUuid = &#63;.
5053             *
5054             * @param layoutUuid the layout uuid
5055             * @return the number of matching journal articles
5056             */
5057            @Override
5058            public int countByLayoutUuid(String layoutUuid) {
5059                    FinderPath finderPath = FINDER_PATH_COUNT_BY_LAYOUTUUID;
5060    
5061                    Object[] finderArgs = new Object[] { layoutUuid };
5062    
5063                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5064                                    this);
5065    
5066                    if (count == null) {
5067                            StringBundler query = new StringBundler(2);
5068    
5069                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
5070    
5071                            boolean bindLayoutUuid = false;
5072    
5073                            if (layoutUuid == null) {
5074                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
5075                            }
5076                            else if (layoutUuid.equals(StringPool.BLANK)) {
5077                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
5078                            }
5079                            else {
5080                                    bindLayoutUuid = true;
5081    
5082                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
5083                            }
5084    
5085                            String sql = query.toString();
5086    
5087                            Session session = null;
5088    
5089                            try {
5090                                    session = openSession();
5091    
5092                                    Query q = session.createQuery(sql);
5093    
5094                                    QueryPos qPos = QueryPos.getInstance(q);
5095    
5096                                    if (bindLayoutUuid) {
5097                                            qPos.add(layoutUuid);
5098                                    }
5099    
5100                                    count = (Long)q.uniqueResult();
5101    
5102                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5103                            }
5104                            catch (Exception e) {
5105                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5106    
5107                                    throw processException(e);
5108                            }
5109                            finally {
5110                                    closeSession(session);
5111                            }
5112                    }
5113    
5114                    return count.intValue();
5115            }
5116    
5117            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
5118            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
5119            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = '')";
5120            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_SMALLIMAGEID =
5121                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5122                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5123                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5124                            "findBySmallImageId",
5125                            new String[] {
5126                                    Long.class.getName(),
5127                                    
5128                            Integer.class.getName(), Integer.class.getName(),
5129                                    OrderByComparator.class.getName()
5130                            });
5131            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID =
5132                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5133                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5134                            JournalArticleImpl.class,
5135                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findBySmallImageId",
5136                            new String[] { Long.class.getName() },
5137                            JournalArticleModelImpl.SMALLIMAGEID_COLUMN_BITMASK |
5138                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
5139                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
5140            public static final FinderPath FINDER_PATH_COUNT_BY_SMALLIMAGEID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5141                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
5142                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countBySmallImageId",
5143                            new String[] { Long.class.getName() });
5144    
5145            /**
5146             * Returns all the journal articles where smallImageId = &#63;.
5147             *
5148             * @param smallImageId the small image ID
5149             * @return the matching journal articles
5150             */
5151            @Override
5152            public List<JournalArticle> findBySmallImageId(long smallImageId) {
5153                    return findBySmallImageId(smallImageId, QueryUtil.ALL_POS,
5154                            QueryUtil.ALL_POS, null);
5155            }
5156    
5157            /**
5158             * Returns a range of all the journal articles where smallImageId = &#63;.
5159             *
5160             * <p>
5161             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
5162             * </p>
5163             *
5164             * @param smallImageId the small image ID
5165             * @param start the lower bound of the range of journal articles
5166             * @param end the upper bound of the range of journal articles (not inclusive)
5167             * @return the range of matching journal articles
5168             */
5169            @Override
5170            public List<JournalArticle> findBySmallImageId(long smallImageId,
5171                    int start, int end) {
5172                    return findBySmallImageId(smallImageId, start, end, null);
5173            }
5174    
5175            /**
5176             * Returns an ordered range of all the journal articles where smallImageId = &#63;.
5177             *
5178             * <p>
5179             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
5180             * </p>
5181             *
5182             * @param smallImageId the small image ID
5183             * @param start the lower bound of the range of journal articles
5184             * @param end the upper bound of the range of journal articles (not inclusive)
5185             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5186             * @return the ordered range of matching journal articles
5187             */
5188            @Override
5189            public List<JournalArticle> findBySmallImageId(long smallImageId,
5190                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
5191                    boolean pagination = true;
5192                    FinderPath finderPath = null;
5193                    Object[] finderArgs = null;
5194    
5195                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5196                                    (orderByComparator == null)) {
5197                            pagination = false;
5198                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID;
5199                            finderArgs = new Object[] { smallImageId };
5200                    }
5201                    else {
5202                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SMALLIMAGEID;
5203                            finderArgs = new Object[] {
5204                                            smallImageId,
5205                                            
5206                                            start, end, orderByComparator
5207                                    };
5208                    }
5209    
5210                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
5211                                    finderArgs, this);
5212    
5213                    if ((list != null) && !list.isEmpty()) {
5214                            for (JournalArticle journalArticle : list) {
5215                                    if ((smallImageId != journalArticle.getSmallImageId())) {
5216                                            list = null;
5217    
5218                                            break;
5219                                    }
5220                            }
5221                    }
5222    
5223                    if (list == null) {
5224                            StringBundler query = null;
5225    
5226                            if (orderByComparator != null) {
5227                                    query = new StringBundler(3 +
5228                                                    (orderByComparator.getOrderByFields().length * 3));
5229                            }
5230                            else {
5231                                    query = new StringBundler(3);
5232                            }
5233    
5234                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5235    
5236                            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
5237    
5238                            if (orderByComparator != null) {
5239                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5240                                            orderByComparator);
5241                            }
5242                            else
5243                             if (pagination) {
5244                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5245                            }
5246    
5247                            String sql = query.toString();
5248    
5249                            Session session = null;
5250    
5251                            try {
5252                                    session = openSession();
5253    
5254                                    Query q = session.createQuery(sql);
5255    
5256                                    QueryPos qPos = QueryPos.getInstance(q);
5257    
5258                                    qPos.add(smallImageId);
5259    
5260                                    if (!pagination) {
5261                                            list = (List<JournalArticle>)QueryUtil.list(q,
5262                                                            getDialect(), start, end, false);
5263    
5264                                            Collections.sort(list);
5265    
5266                                            list = Collections.unmodifiableList(list);
5267                                    }
5268                                    else {
5269                                            list = (List<JournalArticle>)QueryUtil.list(q,
5270                                                            getDialect(), start, end);
5271                                    }
5272    
5273                                    cacheResult(list);
5274    
5275                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5276                            }
5277                            catch (Exception e) {
5278                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5279    
5280                                    throw processException(e);
5281                            }
5282                            finally {
5283                                    closeSession(session);
5284                            }
5285                    }
5286    
5287                    return list;
5288            }
5289    
5290            /**
5291             * Returns the first journal article in the ordered set where smallImageId = &#63;.
5292             *
5293             * @param smallImageId the small image ID
5294             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5295             * @return the first matching journal article
5296             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5297             */
5298            @Override
5299            public JournalArticle findBySmallImageId_First(long smallImageId,
5300                    OrderByComparator<JournalArticle> orderByComparator)
5301                    throws NoSuchArticleException {
5302                    JournalArticle journalArticle = fetchBySmallImageId_First(smallImageId,
5303                                    orderByComparator);
5304    
5305                    if (journalArticle != null) {
5306                            return journalArticle;
5307                    }
5308    
5309                    StringBundler msg = new StringBundler(4);
5310    
5311                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5312    
5313                    msg.append("smallImageId=");
5314                    msg.append(smallImageId);
5315    
5316                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5317    
5318                    throw new NoSuchArticleException(msg.toString());
5319            }
5320    
5321            /**
5322             * Returns the first journal article in the ordered set where smallImageId = &#63;.
5323             *
5324             * @param smallImageId the small image ID
5325             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5326             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
5327             */
5328            @Override
5329            public JournalArticle fetchBySmallImageId_First(long smallImageId,
5330                    OrderByComparator<JournalArticle> orderByComparator) {
5331                    List<JournalArticle> list = findBySmallImageId(smallImageId, 0, 1,
5332                                    orderByComparator);
5333    
5334                    if (!list.isEmpty()) {
5335                            return list.get(0);
5336                    }
5337    
5338                    return null;
5339            }
5340    
5341            /**
5342             * Returns the last journal article in the ordered set where smallImageId = &#63;.
5343             *
5344             * @param smallImageId the small image ID
5345             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5346             * @return the last matching journal article
5347             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5348             */
5349            @Override
5350            public JournalArticle findBySmallImageId_Last(long smallImageId,
5351                    OrderByComparator<JournalArticle> orderByComparator)
5352                    throws NoSuchArticleException {
5353                    JournalArticle journalArticle = fetchBySmallImageId_Last(smallImageId,
5354                                    orderByComparator);
5355    
5356                    if (journalArticle != null) {
5357                            return journalArticle;
5358                    }
5359    
5360                    StringBundler msg = new StringBundler(4);
5361    
5362                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5363    
5364                    msg.append("smallImageId=");
5365                    msg.append(smallImageId);
5366    
5367                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5368    
5369                    throw new NoSuchArticleException(msg.toString());
5370            }
5371    
5372            /**
5373             * Returns the last journal article in the ordered set where smallImageId = &#63;.
5374             *
5375             * @param smallImageId the small image ID
5376             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5377             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
5378             */
5379            @Override
5380            public JournalArticle fetchBySmallImageId_Last(long smallImageId,
5381                    OrderByComparator<JournalArticle> orderByComparator) {
5382                    int count = countBySmallImageId(smallImageId);
5383    
5384                    if (count == 0) {
5385                            return null;
5386                    }
5387    
5388                    List<JournalArticle> list = findBySmallImageId(smallImageId, count - 1,
5389                                    count, orderByComparator);
5390    
5391                    if (!list.isEmpty()) {
5392                            return list.get(0);
5393                    }
5394    
5395                    return null;
5396            }
5397    
5398            /**
5399             * Returns the journal articles before and after the current journal article in the ordered set where smallImageId = &#63;.
5400             *
5401             * @param id the primary key of the current journal article
5402             * @param smallImageId the small image ID
5403             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5404             * @return the previous, current, and next journal article
5405             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
5406             */
5407            @Override
5408            public JournalArticle[] findBySmallImageId_PrevAndNext(long id,
5409                    long smallImageId, OrderByComparator<JournalArticle> orderByComparator)
5410                    throws NoSuchArticleException {
5411                    JournalArticle journalArticle = findByPrimaryKey(id);
5412    
5413                    Session session = null;
5414    
5415                    try {
5416                            session = openSession();
5417    
5418                            JournalArticle[] array = new JournalArticleImpl[3];
5419    
5420                            array[0] = getBySmallImageId_PrevAndNext(session, journalArticle,
5421                                            smallImageId, orderByComparator, true);
5422    
5423                            array[1] = journalArticle;
5424    
5425                            array[2] = getBySmallImageId_PrevAndNext(session, journalArticle,
5426                                            smallImageId, orderByComparator, false);
5427    
5428                            return array;
5429                    }
5430                    catch (Exception e) {
5431                            throw processException(e);
5432                    }
5433                    finally {
5434                            closeSession(session);
5435                    }
5436            }
5437    
5438            protected JournalArticle getBySmallImageId_PrevAndNext(Session session,
5439                    JournalArticle journalArticle, long smallImageId,
5440                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
5441                    StringBundler query = null;
5442    
5443                    if (orderByComparator != null) {
5444                            query = new StringBundler(6 +
5445                                            (orderByComparator.getOrderByFields().length * 6));
5446                    }
5447                    else {
5448                            query = new StringBundler(3);
5449                    }
5450    
5451                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5452    
5453                    query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
5454    
5455                    if (orderByComparator != null) {
5456                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5457    
5458                            if (orderByConditionFields.length > 0) {
5459                                    query.append(WHERE_AND);
5460                            }
5461    
5462                            for (int i = 0; i < orderByConditionFields.length; i++) {
5463                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5464                                    query.append(orderByConditionFields[i]);
5465    
5466                                    if ((i + 1) < orderByConditionFields.length) {
5467                                            if (orderByComparator.isAscending() ^ previous) {
5468                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5469                                            }
5470                                            else {
5471                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5472                                            }
5473                                    }
5474                                    else {
5475                                            if (orderByComparator.isAscending() ^ previous) {
5476                                                    query.append(WHERE_GREATER_THAN);
5477                                            }
5478                                            else {
5479                                                    query.append(WHERE_LESSER_THAN);
5480                                            }
5481                                    }
5482                            }
5483    
5484                            query.append(ORDER_BY_CLAUSE);
5485    
5486                            String[] orderByFields = orderByComparator.getOrderByFields();
5487    
5488                            for (int i = 0; i < orderByFields.length; i++) {
5489                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5490                                    query.append(orderByFields[i]);
5491    
5492                                    if ((i + 1) < orderByFields.length) {
5493                                            if (orderByComparator.isAscending() ^ previous) {
5494                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5495                                            }
5496                                            else {
5497                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5498                                            }
5499                                    }
5500                                    else {
5501                                            if (orderByComparator.isAscending() ^ previous) {
5502                                                    query.append(ORDER_BY_ASC);
5503                                            }
5504                                            else {
5505                                                    query.append(ORDER_BY_DESC);
5506                                            }
5507                                    }
5508                            }
5509                    }
5510                    else {
5511                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5512                    }
5513    
5514                    String sql = query.toString();
5515    
5516                    Query q = session.createQuery(sql);
5517    
5518                    q.setFirstResult(0);
5519                    q.setMaxResults(2);
5520    
5521                    QueryPos qPos = QueryPos.getInstance(q);
5522    
5523                    qPos.add(smallImageId);
5524    
5525                    if (orderByComparator != null) {
5526                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5527    
5528                            for (Object value : values) {
5529                                    qPos.add(value);
5530                            }
5531                    }
5532    
5533                    List<JournalArticle> list = q.list();
5534    
5535                    if (list.size() == 2) {
5536                            return list.get(1);
5537                    }
5538                    else {
5539                            return null;
5540                    }
5541            }
5542    
5543            /**
5544             * Removes all the journal articles where smallImageId = &#63; from the database.
5545             *
5546             * @param smallImageId the small image ID
5547             */
5548            @Override
5549            public void removeBySmallImageId(long smallImageId) {
5550                    for (JournalArticle journalArticle : findBySmallImageId(smallImageId,
5551                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5552                            remove(journalArticle);
5553                    }
5554            }
5555    
5556            /**
5557             * Returns the number of journal articles where smallImageId = &#63;.
5558             *
5559             * @param smallImageId the small image ID
5560             * @return the number of matching journal articles
5561             */
5562            @Override
5563            public int countBySmallImageId(long smallImageId) {
5564                    FinderPath finderPath = FINDER_PATH_COUNT_BY_SMALLIMAGEID;
5565    
5566                    Object[] finderArgs = new Object[] { smallImageId };
5567    
5568                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5569                                    this);
5570    
5571                    if (count == null) {
5572                            StringBundler query = new StringBundler(2);
5573    
5574                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
5575    
5576                            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
5577    
5578                            String sql = query.toString();
5579    
5580                            Session session = null;
5581    
5582                            try {
5583                                    session = openSession();
5584    
5585                                    Query q = session.createQuery(sql);
5586    
5587                                    QueryPos qPos = QueryPos.getInstance(q);
5588    
5589                                    qPos.add(smallImageId);
5590    
5591                                    count = (Long)q.uniqueResult();
5592    
5593                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5594                            }
5595                            catch (Exception e) {
5596                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5597    
5598                                    throw processException(e);
5599                            }
5600                            finally {
5601                                    closeSession(session);
5602                            }
5603                    }
5604    
5605                    return count.intValue();
5606            }
5607    
5608            private static final String _FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2 = "journalArticle.smallImageId = ?";
5609            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5610                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5611                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5612                            "findByR_I",
5613                            new String[] {
5614                                    Long.class.getName(), Boolean.class.getName(),
5615                                    
5616                            Integer.class.getName(), Integer.class.getName(),
5617                                    OrderByComparator.class.getName()
5618                            });
5619            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5620                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5621                            JournalArticleImpl.class,
5622                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_I",
5623                            new String[] { Long.class.getName(), Boolean.class.getName() },
5624                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
5625                            JournalArticleModelImpl.INDEXABLE_COLUMN_BITMASK |
5626                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
5627                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
5628            public static final FinderPath FINDER_PATH_COUNT_BY_R_I = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5629                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
5630                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_I",
5631                            new String[] { Long.class.getName(), Boolean.class.getName() });
5632    
5633            /**
5634             * Returns all the journal articles where resourcePrimKey = &#63; and indexable = &#63;.
5635             *
5636             * @param resourcePrimKey the resource prim key
5637             * @param indexable the indexable
5638             * @return the matching journal articles
5639             */
5640            @Override
5641            public List<JournalArticle> findByR_I(long resourcePrimKey,
5642                    boolean indexable) {
5643                    return findByR_I(resourcePrimKey, indexable, QueryUtil.ALL_POS,
5644                            QueryUtil.ALL_POS, null);
5645            }
5646    
5647            /**
5648             * Returns a range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63;.
5649             *
5650             * <p>
5651             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
5652             * </p>
5653             *
5654             * @param resourcePrimKey the resource prim key
5655             * @param indexable the indexable
5656             * @param start the lower bound of the range of journal articles
5657             * @param end the upper bound of the range of journal articles (not inclusive)
5658             * @return the range of matching journal articles
5659             */
5660            @Override
5661            public List<JournalArticle> findByR_I(long resourcePrimKey,
5662                    boolean indexable, int start, int end) {
5663                    return findByR_I(resourcePrimKey, indexable, start, end, null);
5664            }
5665    
5666            /**
5667             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63;.
5668             *
5669             * <p>
5670             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
5671             * </p>
5672             *
5673             * @param resourcePrimKey the resource prim key
5674             * @param indexable the indexable
5675             * @param start the lower bound of the range of journal articles
5676             * @param end the upper bound of the range of journal articles (not inclusive)
5677             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5678             * @return the ordered range of matching journal articles
5679             */
5680            @Override
5681            public List<JournalArticle> findByR_I(long resourcePrimKey,
5682                    boolean indexable, int start, int end,
5683                    OrderByComparator<JournalArticle> orderByComparator) {
5684                    boolean pagination = true;
5685                    FinderPath finderPath = null;
5686                    Object[] finderArgs = null;
5687    
5688                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5689                                    (orderByComparator == null)) {
5690                            pagination = false;
5691                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I;
5692                            finderArgs = new Object[] { resourcePrimKey, indexable };
5693                    }
5694                    else {
5695                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I;
5696                            finderArgs = new Object[] {
5697                                            resourcePrimKey, indexable,
5698                                            
5699                                            start, end, orderByComparator
5700                                    };
5701                    }
5702    
5703                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
5704                                    finderArgs, this);
5705    
5706                    if ((list != null) && !list.isEmpty()) {
5707                            for (JournalArticle journalArticle : list) {
5708                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
5709                                                    (indexable != journalArticle.getIndexable())) {
5710                                            list = null;
5711    
5712                                            break;
5713                                    }
5714                            }
5715                    }
5716    
5717                    if (list == null) {
5718                            StringBundler query = null;
5719    
5720                            if (orderByComparator != null) {
5721                                    query = new StringBundler(4 +
5722                                                    (orderByComparator.getOrderByFields().length * 3));
5723                            }
5724                            else {
5725                                    query = new StringBundler(4);
5726                            }
5727    
5728                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5729    
5730                            query.append(_FINDER_COLUMN_R_I_RESOURCEPRIMKEY_2);
5731    
5732                            query.append(_FINDER_COLUMN_R_I_INDEXABLE_2);
5733    
5734                            if (orderByComparator != null) {
5735                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5736                                            orderByComparator);
5737                            }
5738                            else
5739                             if (pagination) {
5740                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5741                            }
5742    
5743                            String sql = query.toString();
5744    
5745                            Session session = null;
5746    
5747                            try {
5748                                    session = openSession();
5749    
5750                                    Query q = session.createQuery(sql);
5751    
5752                                    QueryPos qPos = QueryPos.getInstance(q);
5753    
5754                                    qPos.add(resourcePrimKey);
5755    
5756                                    qPos.add(indexable);
5757    
5758                                    if (!pagination) {
5759                                            list = (List<JournalArticle>)QueryUtil.list(q,
5760                                                            getDialect(), start, end, false);
5761    
5762                                            Collections.sort(list);
5763    
5764                                            list = Collections.unmodifiableList(list);
5765                                    }
5766                                    else {
5767                                            list = (List<JournalArticle>)QueryUtil.list(q,
5768                                                            getDialect(), start, end);
5769                                    }
5770    
5771                                    cacheResult(list);
5772    
5773                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5774                            }
5775                            catch (Exception e) {
5776                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5777    
5778                                    throw processException(e);
5779                            }
5780                            finally {
5781                                    closeSession(session);
5782                            }
5783                    }
5784    
5785                    return list;
5786            }
5787    
5788            /**
5789             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
5790             *
5791             * @param resourcePrimKey the resource prim key
5792             * @param indexable the indexable
5793             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5794             * @return the first matching journal article
5795             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5796             */
5797            @Override
5798            public JournalArticle findByR_I_First(long resourcePrimKey,
5799                    boolean indexable, OrderByComparator<JournalArticle> orderByComparator)
5800                    throws NoSuchArticleException {
5801                    JournalArticle journalArticle = fetchByR_I_First(resourcePrimKey,
5802                                    indexable, orderByComparator);
5803    
5804                    if (journalArticle != null) {
5805                            return journalArticle;
5806                    }
5807    
5808                    StringBundler msg = new StringBundler(6);
5809    
5810                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5811    
5812                    msg.append("resourcePrimKey=");
5813                    msg.append(resourcePrimKey);
5814    
5815                    msg.append(", indexable=");
5816                    msg.append(indexable);
5817    
5818                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5819    
5820                    throw new NoSuchArticleException(msg.toString());
5821            }
5822    
5823            /**
5824             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
5825             *
5826             * @param resourcePrimKey the resource prim key
5827             * @param indexable the indexable
5828             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5829             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
5830             */
5831            @Override
5832            public JournalArticle fetchByR_I_First(long resourcePrimKey,
5833                    boolean indexable, OrderByComparator<JournalArticle> orderByComparator) {
5834                    List<JournalArticle> list = findByR_I(resourcePrimKey, indexable, 0, 1,
5835                                    orderByComparator);
5836    
5837                    if (!list.isEmpty()) {
5838                            return list.get(0);
5839                    }
5840    
5841                    return null;
5842            }
5843    
5844            /**
5845             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
5846             *
5847             * @param resourcePrimKey the resource prim key
5848             * @param indexable the indexable
5849             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5850             * @return the last matching journal article
5851             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5852             */
5853            @Override
5854            public JournalArticle findByR_I_Last(long resourcePrimKey,
5855                    boolean indexable, OrderByComparator<JournalArticle> orderByComparator)
5856                    throws NoSuchArticleException {
5857                    JournalArticle journalArticle = fetchByR_I_Last(resourcePrimKey,
5858                                    indexable, orderByComparator);
5859    
5860                    if (journalArticle != null) {
5861                            return journalArticle;
5862                    }
5863    
5864                    StringBundler msg = new StringBundler(6);
5865    
5866                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5867    
5868                    msg.append("resourcePrimKey=");
5869                    msg.append(resourcePrimKey);
5870    
5871                    msg.append(", indexable=");
5872                    msg.append(indexable);
5873    
5874                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5875    
5876                    throw new NoSuchArticleException(msg.toString());
5877            }
5878    
5879            /**
5880             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
5881             *
5882             * @param resourcePrimKey the resource prim key
5883             * @param indexable the indexable
5884             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5885             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
5886             */
5887            @Override
5888            public JournalArticle fetchByR_I_Last(long resourcePrimKey,
5889                    boolean indexable, OrderByComparator<JournalArticle> orderByComparator) {
5890                    int count = countByR_I(resourcePrimKey, indexable);
5891    
5892                    if (count == 0) {
5893                            return null;
5894                    }
5895    
5896                    List<JournalArticle> list = findByR_I(resourcePrimKey, indexable,
5897                                    count - 1, count, orderByComparator);
5898    
5899                    if (!list.isEmpty()) {
5900                            return list.get(0);
5901                    }
5902    
5903                    return null;
5904            }
5905    
5906            /**
5907             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
5908             *
5909             * @param id the primary key of the current journal article
5910             * @param resourcePrimKey the resource prim key
5911             * @param indexable the indexable
5912             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5913             * @return the previous, current, and next journal article
5914             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
5915             */
5916            @Override
5917            public JournalArticle[] findByR_I_PrevAndNext(long id,
5918                    long resourcePrimKey, boolean indexable,
5919                    OrderByComparator<JournalArticle> orderByComparator)
5920                    throws NoSuchArticleException {
5921                    JournalArticle journalArticle = findByPrimaryKey(id);
5922    
5923                    Session session = null;
5924    
5925                    try {
5926                            session = openSession();
5927    
5928                            JournalArticle[] array = new JournalArticleImpl[3];
5929    
5930                            array[0] = getByR_I_PrevAndNext(session, journalArticle,
5931                                            resourcePrimKey, indexable, orderByComparator, true);
5932    
5933                            array[1] = journalArticle;
5934    
5935                            array[2] = getByR_I_PrevAndNext(session, journalArticle,
5936                                            resourcePrimKey, indexable, orderByComparator, false);
5937    
5938                            return array;
5939                    }
5940                    catch (Exception e) {
5941                            throw processException(e);
5942                    }
5943                    finally {
5944                            closeSession(session);
5945                    }
5946            }
5947    
5948            protected JournalArticle getByR_I_PrevAndNext(Session session,
5949                    JournalArticle journalArticle, long resourcePrimKey, boolean indexable,
5950                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
5951                    StringBundler query = null;
5952    
5953                    if (orderByComparator != null) {
5954                            query = new StringBundler(6 +
5955                                            (orderByComparator.getOrderByFields().length * 6));
5956                    }
5957                    else {
5958                            query = new StringBundler(3);
5959                    }
5960    
5961                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5962    
5963                    query.append(_FINDER_COLUMN_R_I_RESOURCEPRIMKEY_2);
5964    
5965                    query.append(_FINDER_COLUMN_R_I_INDEXABLE_2);
5966    
5967                    if (orderByComparator != null) {
5968                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5969    
5970                            if (orderByConditionFields.length > 0) {
5971                                    query.append(WHERE_AND);
5972                            }
5973    
5974                            for (int i = 0; i < orderByConditionFields.length; i++) {
5975                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5976                                    query.append(orderByConditionFields[i]);
5977    
5978                                    if ((i + 1) < orderByConditionFields.length) {
5979                                            if (orderByComparator.isAscending() ^ previous) {
5980                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5981                                            }
5982                                            else {
5983                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5984                                            }
5985                                    }
5986                                    else {
5987                                            if (orderByComparator.isAscending() ^ previous) {
5988                                                    query.append(WHERE_GREATER_THAN);
5989                                            }
5990                                            else {
5991                                                    query.append(WHERE_LESSER_THAN);
5992                                            }
5993                                    }
5994                            }
5995    
5996                            query.append(ORDER_BY_CLAUSE);
5997    
5998                            String[] orderByFields = orderByComparator.getOrderByFields();
5999    
6000                            for (int i = 0; i < orderByFields.length; i++) {
6001                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6002                                    query.append(orderByFields[i]);
6003    
6004                                    if ((i + 1) < orderByFields.length) {
6005                                            if (orderByComparator.isAscending() ^ previous) {
6006                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6007                                            }
6008                                            else {
6009                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6010                                            }
6011                                    }
6012                                    else {
6013                                            if (orderByComparator.isAscending() ^ previous) {
6014                                                    query.append(ORDER_BY_ASC);
6015                                            }
6016                                            else {
6017                                                    query.append(ORDER_BY_DESC);
6018                                            }
6019                                    }
6020                            }
6021                    }
6022                    else {
6023                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6024                    }
6025    
6026                    String sql = query.toString();
6027    
6028                    Query q = session.createQuery(sql);
6029    
6030                    q.setFirstResult(0);
6031                    q.setMaxResults(2);
6032    
6033                    QueryPos qPos = QueryPos.getInstance(q);
6034    
6035                    qPos.add(resourcePrimKey);
6036    
6037                    qPos.add(indexable);
6038    
6039                    if (orderByComparator != null) {
6040                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6041    
6042                            for (Object value : values) {
6043                                    qPos.add(value);
6044                            }
6045                    }
6046    
6047                    List<JournalArticle> list = q.list();
6048    
6049                    if (list.size() == 2) {
6050                            return list.get(1);
6051                    }
6052                    else {
6053                            return null;
6054                    }
6055            }
6056    
6057            /**
6058             * Removes all the journal articles where resourcePrimKey = &#63; and indexable = &#63; from the database.
6059             *
6060             * @param resourcePrimKey the resource prim key
6061             * @param indexable the indexable
6062             */
6063            @Override
6064            public void removeByR_I(long resourcePrimKey, boolean indexable) {
6065                    for (JournalArticle journalArticle : findByR_I(resourcePrimKey,
6066                                    indexable, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6067                            remove(journalArticle);
6068                    }
6069            }
6070    
6071            /**
6072             * Returns the number of journal articles where resourcePrimKey = &#63; and indexable = &#63;.
6073             *
6074             * @param resourcePrimKey the resource prim key
6075             * @param indexable the indexable
6076             * @return the number of matching journal articles
6077             */
6078            @Override
6079            public int countByR_I(long resourcePrimKey, boolean indexable) {
6080                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_I;
6081    
6082                    Object[] finderArgs = new Object[] { resourcePrimKey, indexable };
6083    
6084                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6085                                    this);
6086    
6087                    if (count == null) {
6088                            StringBundler query = new StringBundler(3);
6089    
6090                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
6091    
6092                            query.append(_FINDER_COLUMN_R_I_RESOURCEPRIMKEY_2);
6093    
6094                            query.append(_FINDER_COLUMN_R_I_INDEXABLE_2);
6095    
6096                            String sql = query.toString();
6097    
6098                            Session session = null;
6099    
6100                            try {
6101                                    session = openSession();
6102    
6103                                    Query q = session.createQuery(sql);
6104    
6105                                    QueryPos qPos = QueryPos.getInstance(q);
6106    
6107                                    qPos.add(resourcePrimKey);
6108    
6109                                    qPos.add(indexable);
6110    
6111                                    count = (Long)q.uniqueResult();
6112    
6113                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6114                            }
6115                            catch (Exception e) {
6116                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6117    
6118                                    throw processException(e);
6119                            }
6120                            finally {
6121                                    closeSession(session);
6122                            }
6123                    }
6124    
6125                    return count.intValue();
6126            }
6127    
6128            private static final String _FINDER_COLUMN_R_I_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
6129            private static final String _FINDER_COLUMN_R_I_INDEXABLE_2 = "journalArticle.indexable = ?";
6130            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6131                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
6132                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
6133                            "findByR_ST",
6134                            new String[] {
6135                                    Long.class.getName(), Integer.class.getName(),
6136                                    
6137                            Integer.class.getName(), Integer.class.getName(),
6138                                    OrderByComparator.class.getName()
6139                            });
6140            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6141                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
6142                            JournalArticleImpl.class,
6143                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_ST",
6144                            new String[] { Long.class.getName(), Integer.class.getName() },
6145                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
6146                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
6147                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
6148                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
6149            public static final FinderPath FINDER_PATH_COUNT_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6150                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
6151                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_ST",
6152                            new String[] { Long.class.getName(), Integer.class.getName() });
6153            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6154                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
6155                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByR_ST",
6156                            new String[] { Long.class.getName(), Integer.class.getName() });
6157    
6158            /**
6159             * Returns all the journal articles where resourcePrimKey = &#63; and status = &#63;.
6160             *
6161             * @param resourcePrimKey the resource prim key
6162             * @param status the status
6163             * @return the matching journal articles
6164             */
6165            @Override
6166            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status) {
6167                    return findByR_ST(resourcePrimKey, status, QueryUtil.ALL_POS,
6168                            QueryUtil.ALL_POS, null);
6169            }
6170    
6171            /**
6172             * Returns a range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
6173             *
6174             * <p>
6175             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
6176             * </p>
6177             *
6178             * @param resourcePrimKey the resource prim key
6179             * @param status the status
6180             * @param start the lower bound of the range of journal articles
6181             * @param end the upper bound of the range of journal articles (not inclusive)
6182             * @return the range of matching journal articles
6183             */
6184            @Override
6185            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
6186                    int start, int end) {
6187                    return findByR_ST(resourcePrimKey, status, start, end, null);
6188            }
6189    
6190            /**
6191             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
6192             *
6193             * <p>
6194             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
6195             * </p>
6196             *
6197             * @param resourcePrimKey the resource prim key
6198             * @param status the status
6199             * @param start the lower bound of the range of journal articles
6200             * @param end the upper bound of the range of journal articles (not inclusive)
6201             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6202             * @return the ordered range of matching journal articles
6203             */
6204            @Override
6205            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
6206                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
6207                    boolean pagination = true;
6208                    FinderPath finderPath = null;
6209                    Object[] finderArgs = null;
6210    
6211                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6212                                    (orderByComparator == null)) {
6213                            pagination = false;
6214                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST;
6215                            finderArgs = new Object[] { resourcePrimKey, status };
6216                    }
6217                    else {
6218                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST;
6219                            finderArgs = new Object[] {
6220                                            resourcePrimKey, status,
6221                                            
6222                                            start, end, orderByComparator
6223                                    };
6224                    }
6225    
6226                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
6227                                    finderArgs, this);
6228    
6229                    if ((list != null) && !list.isEmpty()) {
6230                            for (JournalArticle journalArticle : list) {
6231                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
6232                                                    (status != journalArticle.getStatus())) {
6233                                            list = null;
6234    
6235                                            break;
6236                                    }
6237                            }
6238                    }
6239    
6240                    if (list == null) {
6241                            StringBundler query = null;
6242    
6243                            if (orderByComparator != null) {
6244                                    query = new StringBundler(4 +
6245                                                    (orderByComparator.getOrderByFields().length * 3));
6246                            }
6247                            else {
6248                                    query = new StringBundler(4);
6249                            }
6250    
6251                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6252    
6253                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
6254    
6255                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
6256    
6257                            if (orderByComparator != null) {
6258                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6259                                            orderByComparator);
6260                            }
6261                            else
6262                             if (pagination) {
6263                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6264                            }
6265    
6266                            String sql = query.toString();
6267    
6268                            Session session = null;
6269    
6270                            try {
6271                                    session = openSession();
6272    
6273                                    Query q = session.createQuery(sql);
6274    
6275                                    QueryPos qPos = QueryPos.getInstance(q);
6276    
6277                                    qPos.add(resourcePrimKey);
6278    
6279                                    qPos.add(status);
6280    
6281                                    if (!pagination) {
6282                                            list = (List<JournalArticle>)QueryUtil.list(q,
6283                                                            getDialect(), start, end, false);
6284    
6285                                            Collections.sort(list);
6286    
6287                                            list = Collections.unmodifiableList(list);
6288                                    }
6289                                    else {
6290                                            list = (List<JournalArticle>)QueryUtil.list(q,
6291                                                            getDialect(), start, end);
6292                                    }
6293    
6294                                    cacheResult(list);
6295    
6296                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6297                            }
6298                            catch (Exception e) {
6299                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6300    
6301                                    throw processException(e);
6302                            }
6303                            finally {
6304                                    closeSession(session);
6305                            }
6306                    }
6307    
6308                    return list;
6309            }
6310    
6311            /**
6312             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6313             *
6314             * @param resourcePrimKey the resource prim key
6315             * @param status the status
6316             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6317             * @return the first matching journal article
6318             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6319             */
6320            @Override
6321            public JournalArticle findByR_ST_First(long resourcePrimKey, int status,
6322                    OrderByComparator<JournalArticle> orderByComparator)
6323                    throws NoSuchArticleException {
6324                    JournalArticle journalArticle = fetchByR_ST_First(resourcePrimKey,
6325                                    status, orderByComparator);
6326    
6327                    if (journalArticle != null) {
6328                            return journalArticle;
6329                    }
6330    
6331                    StringBundler msg = new StringBundler(6);
6332    
6333                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6334    
6335                    msg.append("resourcePrimKey=");
6336                    msg.append(resourcePrimKey);
6337    
6338                    msg.append(", status=");
6339                    msg.append(status);
6340    
6341                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6342    
6343                    throw new NoSuchArticleException(msg.toString());
6344            }
6345    
6346            /**
6347             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6348             *
6349             * @param resourcePrimKey the resource prim key
6350             * @param status the status
6351             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6352             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
6353             */
6354            @Override
6355            public JournalArticle fetchByR_ST_First(long resourcePrimKey, int status,
6356                    OrderByComparator<JournalArticle> orderByComparator) {
6357                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status, 0, 1,
6358                                    orderByComparator);
6359    
6360                    if (!list.isEmpty()) {
6361                            return list.get(0);
6362                    }
6363    
6364                    return null;
6365            }
6366    
6367            /**
6368             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6369             *
6370             * @param resourcePrimKey the resource prim key
6371             * @param status the status
6372             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6373             * @return the last matching journal article
6374             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6375             */
6376            @Override
6377            public JournalArticle findByR_ST_Last(long resourcePrimKey, int status,
6378                    OrderByComparator<JournalArticle> orderByComparator)
6379                    throws NoSuchArticleException {
6380                    JournalArticle journalArticle = fetchByR_ST_Last(resourcePrimKey,
6381                                    status, orderByComparator);
6382    
6383                    if (journalArticle != null) {
6384                            return journalArticle;
6385                    }
6386    
6387                    StringBundler msg = new StringBundler(6);
6388    
6389                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6390    
6391                    msg.append("resourcePrimKey=");
6392                    msg.append(resourcePrimKey);
6393    
6394                    msg.append(", status=");
6395                    msg.append(status);
6396    
6397                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6398    
6399                    throw new NoSuchArticleException(msg.toString());
6400            }
6401    
6402            /**
6403             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6404             *
6405             * @param resourcePrimKey the resource prim key
6406             * @param status the status
6407             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6408             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
6409             */
6410            @Override
6411            public JournalArticle fetchByR_ST_Last(long resourcePrimKey, int status,
6412                    OrderByComparator<JournalArticle> orderByComparator) {
6413                    int count = countByR_ST(resourcePrimKey, status);
6414    
6415                    if (count == 0) {
6416                            return null;
6417                    }
6418    
6419                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status,
6420                                    count - 1, count, orderByComparator);
6421    
6422                    if (!list.isEmpty()) {
6423                            return list.get(0);
6424                    }
6425    
6426                    return null;
6427            }
6428    
6429            /**
6430             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6431             *
6432             * @param id the primary key of the current journal article
6433             * @param resourcePrimKey the resource prim key
6434             * @param status the status
6435             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6436             * @return the previous, current, and next journal article
6437             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6438             */
6439            @Override
6440            public JournalArticle[] findByR_ST_PrevAndNext(long id,
6441                    long resourcePrimKey, int status,
6442                    OrderByComparator<JournalArticle> orderByComparator)
6443                    throws NoSuchArticleException {
6444                    JournalArticle journalArticle = findByPrimaryKey(id);
6445    
6446                    Session session = null;
6447    
6448                    try {
6449                            session = openSession();
6450    
6451                            JournalArticle[] array = new JournalArticleImpl[3];
6452    
6453                            array[0] = getByR_ST_PrevAndNext(session, journalArticle,
6454                                            resourcePrimKey, status, orderByComparator, true);
6455    
6456                            array[1] = journalArticle;
6457    
6458                            array[2] = getByR_ST_PrevAndNext(session, journalArticle,
6459                                            resourcePrimKey, status, orderByComparator, false);
6460    
6461                            return array;
6462                    }
6463                    catch (Exception e) {
6464                            throw processException(e);
6465                    }
6466                    finally {
6467                            closeSession(session);
6468                    }
6469            }
6470    
6471            protected JournalArticle getByR_ST_PrevAndNext(Session session,
6472                    JournalArticle journalArticle, long resourcePrimKey, int status,
6473                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
6474                    StringBundler query = null;
6475    
6476                    if (orderByComparator != null) {
6477                            query = new StringBundler(6 +
6478                                            (orderByComparator.getOrderByFields().length * 6));
6479                    }
6480                    else {
6481                            query = new StringBundler(3);
6482                    }
6483    
6484                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6485    
6486                    query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
6487    
6488                    query.append(_FINDER_COLUMN_R_ST_STATUS_2);
6489    
6490                    if (orderByComparator != null) {
6491                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6492    
6493                            if (orderByConditionFields.length > 0) {
6494                                    query.append(WHERE_AND);
6495                            }
6496    
6497                            for (int i = 0; i < orderByConditionFields.length; i++) {
6498                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6499                                    query.append(orderByConditionFields[i]);
6500    
6501                                    if ((i + 1) < orderByConditionFields.length) {
6502                                            if (orderByComparator.isAscending() ^ previous) {
6503                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6504                                            }
6505                                            else {
6506                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6507                                            }
6508                                    }
6509                                    else {
6510                                            if (orderByComparator.isAscending() ^ previous) {
6511                                                    query.append(WHERE_GREATER_THAN);
6512                                            }
6513                                            else {
6514                                                    query.append(WHERE_LESSER_THAN);
6515                                            }
6516                                    }
6517                            }
6518    
6519                            query.append(ORDER_BY_CLAUSE);
6520    
6521                            String[] orderByFields = orderByComparator.getOrderByFields();
6522    
6523                            for (int i = 0; i < orderByFields.length; i++) {
6524                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6525                                    query.append(orderByFields[i]);
6526    
6527                                    if ((i + 1) < orderByFields.length) {
6528                                            if (orderByComparator.isAscending() ^ previous) {
6529                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6530                                            }
6531                                            else {
6532                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6533                                            }
6534                                    }
6535                                    else {
6536                                            if (orderByComparator.isAscending() ^ previous) {
6537                                                    query.append(ORDER_BY_ASC);
6538                                            }
6539                                            else {
6540                                                    query.append(ORDER_BY_DESC);
6541                                            }
6542                                    }
6543                            }
6544                    }
6545                    else {
6546                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6547                    }
6548    
6549                    String sql = query.toString();
6550    
6551                    Query q = session.createQuery(sql);
6552    
6553                    q.setFirstResult(0);
6554                    q.setMaxResults(2);
6555    
6556                    QueryPos qPos = QueryPos.getInstance(q);
6557    
6558                    qPos.add(resourcePrimKey);
6559    
6560                    qPos.add(status);
6561    
6562                    if (orderByComparator != null) {
6563                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6564    
6565                            for (Object value : values) {
6566                                    qPos.add(value);
6567                            }
6568                    }
6569    
6570                    List<JournalArticle> list = q.list();
6571    
6572                    if (list.size() == 2) {
6573                            return list.get(1);
6574                    }
6575                    else {
6576                            return null;
6577                    }
6578            }
6579    
6580            /**
6581             * Returns all the journal articles where resourcePrimKey = &#63; and status = any &#63;.
6582             *
6583             * <p>
6584             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
6585             * </p>
6586             *
6587             * @param resourcePrimKey the resource prim key
6588             * @param statuses the statuses
6589             * @return the matching journal articles
6590             */
6591            @Override
6592            public List<JournalArticle> findByR_ST(long resourcePrimKey, int[] statuses) {
6593                    return findByR_ST(resourcePrimKey, statuses, QueryUtil.ALL_POS,
6594                            QueryUtil.ALL_POS, null);
6595            }
6596    
6597            /**
6598             * Returns a range of all the journal articles where resourcePrimKey = &#63; and status = any &#63;.
6599             *
6600             * <p>
6601             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
6602             * </p>
6603             *
6604             * @param resourcePrimKey the resource prim key
6605             * @param statuses the statuses
6606             * @param start the lower bound of the range of journal articles
6607             * @param end the upper bound of the range of journal articles (not inclusive)
6608             * @return the range of matching journal articles
6609             */
6610            @Override
6611            public List<JournalArticle> findByR_ST(long resourcePrimKey,
6612                    int[] statuses, int start, int end) {
6613                    return findByR_ST(resourcePrimKey, statuses, start, end, null);
6614            }
6615    
6616            /**
6617             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and status = any &#63;.
6618             *
6619             * <p>
6620             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
6621             * </p>
6622             *
6623             * @param resourcePrimKey the resource prim key
6624             * @param statuses the statuses
6625             * @param start the lower bound of the range of journal articles
6626             * @param end the upper bound of the range of journal articles (not inclusive)
6627             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6628             * @return the ordered range of matching journal articles
6629             */
6630            @Override
6631            public List<JournalArticle> findByR_ST(long resourcePrimKey,
6632                    int[] statuses, int start, int end,
6633                    OrderByComparator<JournalArticle> orderByComparator) {
6634                    if (statuses == null) {
6635                            statuses = new int[0];
6636                    }
6637                    else {
6638                            statuses = ArrayUtil.unique(statuses);
6639                    }
6640    
6641                    if (statuses.length == 1) {
6642                            return findByR_ST(resourcePrimKey, statuses[0], start, end,
6643                                    orderByComparator);
6644                    }
6645    
6646                    boolean pagination = true;
6647                    Object[] finderArgs = null;
6648    
6649                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6650                                    (orderByComparator == null)) {
6651                            pagination = false;
6652                            finderArgs = new Object[] {
6653                                            resourcePrimKey, StringUtil.merge(statuses)
6654                                    };
6655                    }
6656                    else {
6657                            finderArgs = new Object[] {
6658                                            resourcePrimKey, StringUtil.merge(statuses),
6659                                            
6660                                            start, end, orderByComparator
6661                                    };
6662                    }
6663    
6664                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST,
6665                                    finderArgs, this);
6666    
6667                    if ((list != null) && !list.isEmpty()) {
6668                            for (JournalArticle journalArticle : list) {
6669                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
6670                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
6671                                            list = null;
6672    
6673                                            break;
6674                                    }
6675                            }
6676                    }
6677    
6678                    if (list == null) {
6679                            StringBundler query = new StringBundler();
6680    
6681                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6682    
6683                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
6684    
6685                            if (statuses.length > 0) {
6686                                    query.append(StringPool.OPEN_PARENTHESIS);
6687    
6688                                    query.append(_FINDER_COLUMN_R_ST_STATUS_7);
6689    
6690                                    query.append(StringUtil.merge(statuses));
6691    
6692                                    query.append(StringPool.CLOSE_PARENTHESIS);
6693    
6694                                    query.append(StringPool.CLOSE_PARENTHESIS);
6695                            }
6696    
6697                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
6698                                                    1)), query.index() - 1);
6699    
6700                            if (orderByComparator != null) {
6701                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6702                                            orderByComparator);
6703                            }
6704                            else
6705                             if (pagination) {
6706                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6707                            }
6708    
6709                            String sql = query.toString();
6710    
6711                            Session session = null;
6712    
6713                            try {
6714                                    session = openSession();
6715    
6716                                    Query q = session.createQuery(sql);
6717    
6718                                    QueryPos qPos = QueryPos.getInstance(q);
6719    
6720                                    qPos.add(resourcePrimKey);
6721    
6722                                    if (!pagination) {
6723                                            list = (List<JournalArticle>)QueryUtil.list(q,
6724                                                            getDialect(), start, end, false);
6725    
6726                                            Collections.sort(list);
6727    
6728                                            list = Collections.unmodifiableList(list);
6729                                    }
6730                                    else {
6731                                            list = (List<JournalArticle>)QueryUtil.list(q,
6732                                                            getDialect(), start, end);
6733                                    }
6734    
6735                                    cacheResult(list);
6736    
6737                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST,
6738                                            finderArgs, list);
6739                            }
6740                            catch (Exception e) {
6741                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST,
6742                                            finderArgs);
6743    
6744                                    throw processException(e);
6745                            }
6746                            finally {
6747                                    closeSession(session);
6748                            }
6749                    }
6750    
6751                    return list;
6752            }
6753    
6754            /**
6755             * Removes all the journal articles where resourcePrimKey = &#63; and status = &#63; from the database.
6756             *
6757             * @param resourcePrimKey the resource prim key
6758             * @param status the status
6759             */
6760            @Override
6761            public void removeByR_ST(long resourcePrimKey, int status) {
6762                    for (JournalArticle journalArticle : findByR_ST(resourcePrimKey,
6763                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6764                            remove(journalArticle);
6765                    }
6766            }
6767    
6768            /**
6769             * Returns the number of journal articles where resourcePrimKey = &#63; and status = &#63;.
6770             *
6771             * @param resourcePrimKey the resource prim key
6772             * @param status the status
6773             * @return the number of matching journal articles
6774             */
6775            @Override
6776            public int countByR_ST(long resourcePrimKey, int status) {
6777                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_ST;
6778    
6779                    Object[] finderArgs = new Object[] { resourcePrimKey, status };
6780    
6781                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6782                                    this);
6783    
6784                    if (count == null) {
6785                            StringBundler query = new StringBundler(3);
6786    
6787                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
6788    
6789                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
6790    
6791                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
6792    
6793                            String sql = query.toString();
6794    
6795                            Session session = null;
6796    
6797                            try {
6798                                    session = openSession();
6799    
6800                                    Query q = session.createQuery(sql);
6801    
6802                                    QueryPos qPos = QueryPos.getInstance(q);
6803    
6804                                    qPos.add(resourcePrimKey);
6805    
6806                                    qPos.add(status);
6807    
6808                                    count = (Long)q.uniqueResult();
6809    
6810                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6811                            }
6812                            catch (Exception e) {
6813                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6814    
6815                                    throw processException(e);
6816                            }
6817                            finally {
6818                                    closeSession(session);
6819                            }
6820                    }
6821    
6822                    return count.intValue();
6823            }
6824    
6825            /**
6826             * Returns the number of journal articles where resourcePrimKey = &#63; and status = any &#63;.
6827             *
6828             * @param resourcePrimKey the resource prim key
6829             * @param statuses the statuses
6830             * @return the number of matching journal articles
6831             */
6832            @Override
6833            public int countByR_ST(long resourcePrimKey, int[] statuses) {
6834                    if (statuses == null) {
6835                            statuses = new int[0];
6836                    }
6837                    else {
6838                            statuses = ArrayUtil.unique(statuses);
6839                    }
6840    
6841                    Object[] finderArgs = new Object[] {
6842                                    resourcePrimKey, StringUtil.merge(statuses)
6843                            };
6844    
6845                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_ST,
6846                                    finderArgs, this);
6847    
6848                    if (count == null) {
6849                            StringBundler query = new StringBundler();
6850    
6851                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
6852    
6853                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
6854    
6855                            if (statuses.length > 0) {
6856                                    query.append(StringPool.OPEN_PARENTHESIS);
6857    
6858                                    query.append(_FINDER_COLUMN_R_ST_STATUS_7);
6859    
6860                                    query.append(StringUtil.merge(statuses));
6861    
6862                                    query.append(StringPool.CLOSE_PARENTHESIS);
6863    
6864                                    query.append(StringPool.CLOSE_PARENTHESIS);
6865                            }
6866    
6867                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
6868                                                    1)), query.index() - 1);
6869    
6870                            String sql = query.toString();
6871    
6872                            Session session = null;
6873    
6874                            try {
6875                                    session = openSession();
6876    
6877                                    Query q = session.createQuery(sql);
6878    
6879                                    QueryPos qPos = QueryPos.getInstance(q);
6880    
6881                                    qPos.add(resourcePrimKey);
6882    
6883                                    count = (Long)q.uniqueResult();
6884    
6885                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_ST,
6886                                            finderArgs, count);
6887                            }
6888                            catch (Exception e) {
6889                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_ST,
6890                                            finderArgs);
6891    
6892                                    throw processException(e);
6893                            }
6894                            finally {
6895                                    closeSession(session);
6896                            }
6897                    }
6898    
6899                    return count.intValue();
6900            }
6901    
6902            private static final String _FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
6903            private static final String _FINDER_COLUMN_R_ST_STATUS_2 = "journalArticle.status = ?";
6904            private static final String _FINDER_COLUMN_R_ST_STATUS_7 = "journalArticle.status IN (";
6905            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6906                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
6907                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
6908                            "findByG_U",
6909                            new String[] {
6910                                    Long.class.getName(), Long.class.getName(),
6911                                    
6912                            Integer.class.getName(), Integer.class.getName(),
6913                                    OrderByComparator.class.getName()
6914                            });
6915            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6916                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
6917                            JournalArticleImpl.class,
6918                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U",
6919                            new String[] { Long.class.getName(), Long.class.getName() },
6920                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
6921                            JournalArticleModelImpl.USERID_COLUMN_BITMASK |
6922                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
6923                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
6924            public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6925                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
6926                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U",
6927                            new String[] { Long.class.getName(), Long.class.getName() });
6928    
6929            /**
6930             * Returns all the journal articles where groupId = &#63; and userId = &#63;.
6931             *
6932             * @param groupId the group ID
6933             * @param userId the user ID
6934             * @return the matching journal articles
6935             */
6936            @Override
6937            public List<JournalArticle> findByG_U(long groupId, long userId) {
6938                    return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
6939                            null);
6940            }
6941    
6942            /**
6943             * Returns a range of all the journal articles where groupId = &#63; and userId = &#63;.
6944             *
6945             * <p>
6946             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
6947             * </p>
6948             *
6949             * @param groupId the group ID
6950             * @param userId the user ID
6951             * @param start the lower bound of the range of journal articles
6952             * @param end the upper bound of the range of journal articles (not inclusive)
6953             * @return the range of matching journal articles
6954             */
6955            @Override
6956            public List<JournalArticle> findByG_U(long groupId, long userId, int start,
6957                    int end) {
6958                    return findByG_U(groupId, userId, start, end, null);
6959            }
6960    
6961            /**
6962             * Returns an ordered range of all the journal articles where groupId = &#63; and userId = &#63;.
6963             *
6964             * <p>
6965             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
6966             * </p>
6967             *
6968             * @param groupId the group ID
6969             * @param userId the user ID
6970             * @param start the lower bound of the range of journal articles
6971             * @param end the upper bound of the range of journal articles (not inclusive)
6972             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6973             * @return the ordered range of matching journal articles
6974             */
6975            @Override
6976            public List<JournalArticle> findByG_U(long groupId, long userId, int start,
6977                    int end, OrderByComparator<JournalArticle> orderByComparator) {
6978                    boolean pagination = true;
6979                    FinderPath finderPath = null;
6980                    Object[] finderArgs = null;
6981    
6982                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6983                                    (orderByComparator == null)) {
6984                            pagination = false;
6985                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U;
6986                            finderArgs = new Object[] { groupId, userId };
6987                    }
6988                    else {
6989                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U;
6990                            finderArgs = new Object[] {
6991                                            groupId, userId,
6992                                            
6993                                            start, end, orderByComparator
6994                                    };
6995                    }
6996    
6997                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
6998                                    finderArgs, this);
6999    
7000                    if ((list != null) && !list.isEmpty()) {
7001                            for (JournalArticle journalArticle : list) {
7002                                    if ((groupId != journalArticle.getGroupId()) ||
7003                                                    (userId != journalArticle.getUserId())) {
7004                                            list = null;
7005    
7006                                            break;
7007                                    }
7008                            }
7009                    }
7010    
7011                    if (list == null) {
7012                            StringBundler query = null;
7013    
7014                            if (orderByComparator != null) {
7015                                    query = new StringBundler(4 +
7016                                                    (orderByComparator.getOrderByFields().length * 3));
7017                            }
7018                            else {
7019                                    query = new StringBundler(4);
7020                            }
7021    
7022                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7023    
7024                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7025    
7026                            query.append(_FINDER_COLUMN_G_U_USERID_2);
7027    
7028                            if (orderByComparator != null) {
7029                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7030                                            orderByComparator);
7031                            }
7032                            else
7033                             if (pagination) {
7034                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7035                            }
7036    
7037                            String sql = query.toString();
7038    
7039                            Session session = null;
7040    
7041                            try {
7042                                    session = openSession();
7043    
7044                                    Query q = session.createQuery(sql);
7045    
7046                                    QueryPos qPos = QueryPos.getInstance(q);
7047    
7048                                    qPos.add(groupId);
7049    
7050                                    qPos.add(userId);
7051    
7052                                    if (!pagination) {
7053                                            list = (List<JournalArticle>)QueryUtil.list(q,
7054                                                            getDialect(), start, end, false);
7055    
7056                                            Collections.sort(list);
7057    
7058                                            list = Collections.unmodifiableList(list);
7059                                    }
7060                                    else {
7061                                            list = (List<JournalArticle>)QueryUtil.list(q,
7062                                                            getDialect(), start, end);
7063                                    }
7064    
7065                                    cacheResult(list);
7066    
7067                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
7068                            }
7069                            catch (Exception e) {
7070                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7071    
7072                                    throw processException(e);
7073                            }
7074                            finally {
7075                                    closeSession(session);
7076                            }
7077                    }
7078    
7079                    return list;
7080            }
7081    
7082            /**
7083             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63;.
7084             *
7085             * @param groupId the group ID
7086             * @param userId the user ID
7087             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7088             * @return the first matching journal article
7089             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
7090             */
7091            @Override
7092            public JournalArticle findByG_U_First(long groupId, long userId,
7093                    OrderByComparator<JournalArticle> orderByComparator)
7094                    throws NoSuchArticleException {
7095                    JournalArticle journalArticle = fetchByG_U_First(groupId, userId,
7096                                    orderByComparator);
7097    
7098                    if (journalArticle != null) {
7099                            return journalArticle;
7100                    }
7101    
7102                    StringBundler msg = new StringBundler(6);
7103    
7104                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7105    
7106                    msg.append("groupId=");
7107                    msg.append(groupId);
7108    
7109                    msg.append(", userId=");
7110                    msg.append(userId);
7111    
7112                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7113    
7114                    throw new NoSuchArticleException(msg.toString());
7115            }
7116    
7117            /**
7118             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63;.
7119             *
7120             * @param groupId the group ID
7121             * @param userId the user ID
7122             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7123             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
7124             */
7125            @Override
7126            public JournalArticle fetchByG_U_First(long groupId, long userId,
7127                    OrderByComparator<JournalArticle> orderByComparator) {
7128                    List<JournalArticle> list = findByG_U(groupId, userId, 0, 1,
7129                                    orderByComparator);
7130    
7131                    if (!list.isEmpty()) {
7132                            return list.get(0);
7133                    }
7134    
7135                    return null;
7136            }
7137    
7138            /**
7139             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63;.
7140             *
7141             * @param groupId the group ID
7142             * @param userId the user ID
7143             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7144             * @return the last matching journal article
7145             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
7146             */
7147            @Override
7148            public JournalArticle findByG_U_Last(long groupId, long userId,
7149                    OrderByComparator<JournalArticle> orderByComparator)
7150                    throws NoSuchArticleException {
7151                    JournalArticle journalArticle = fetchByG_U_Last(groupId, userId,
7152                                    orderByComparator);
7153    
7154                    if (journalArticle != null) {
7155                            return journalArticle;
7156                    }
7157    
7158                    StringBundler msg = new StringBundler(6);
7159    
7160                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7161    
7162                    msg.append("groupId=");
7163                    msg.append(groupId);
7164    
7165                    msg.append(", userId=");
7166                    msg.append(userId);
7167    
7168                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7169    
7170                    throw new NoSuchArticleException(msg.toString());
7171            }
7172    
7173            /**
7174             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63;.
7175             *
7176             * @param groupId the group ID
7177             * @param userId the user ID
7178             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7179             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
7180             */
7181            @Override
7182            public JournalArticle fetchByG_U_Last(long groupId, long userId,
7183                    OrderByComparator<JournalArticle> orderByComparator) {
7184                    int count = countByG_U(groupId, userId);
7185    
7186                    if (count == 0) {
7187                            return null;
7188                    }
7189    
7190                    List<JournalArticle> list = findByG_U(groupId, userId, count - 1,
7191                                    count, orderByComparator);
7192    
7193                    if (!list.isEmpty()) {
7194                            return list.get(0);
7195                    }
7196    
7197                    return null;
7198            }
7199    
7200            /**
7201             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and userId = &#63;.
7202             *
7203             * @param id the primary key of the current journal article
7204             * @param groupId the group ID
7205             * @param userId the user ID
7206             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7207             * @return the previous, current, and next journal article
7208             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
7209             */
7210            @Override
7211            public JournalArticle[] findByG_U_PrevAndNext(long id, long groupId,
7212                    long userId, OrderByComparator<JournalArticle> orderByComparator)
7213                    throws NoSuchArticleException {
7214                    JournalArticle journalArticle = findByPrimaryKey(id);
7215    
7216                    Session session = null;
7217    
7218                    try {
7219                            session = openSession();
7220    
7221                            JournalArticle[] array = new JournalArticleImpl[3];
7222    
7223                            array[0] = getByG_U_PrevAndNext(session, journalArticle, groupId,
7224                                            userId, orderByComparator, true);
7225    
7226                            array[1] = journalArticle;
7227    
7228                            array[2] = getByG_U_PrevAndNext(session, journalArticle, groupId,
7229                                            userId, orderByComparator, false);
7230    
7231                            return array;
7232                    }
7233                    catch (Exception e) {
7234                            throw processException(e);
7235                    }
7236                    finally {
7237                            closeSession(session);
7238                    }
7239            }
7240    
7241            protected JournalArticle getByG_U_PrevAndNext(Session session,
7242                    JournalArticle journalArticle, long groupId, long userId,
7243                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
7244                    StringBundler query = null;
7245    
7246                    if (orderByComparator != null) {
7247                            query = new StringBundler(6 +
7248                                            (orderByComparator.getOrderByFields().length * 6));
7249                    }
7250                    else {
7251                            query = new StringBundler(3);
7252                    }
7253    
7254                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7255    
7256                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7257    
7258                    query.append(_FINDER_COLUMN_G_U_USERID_2);
7259    
7260                    if (orderByComparator != null) {
7261                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7262    
7263                            if (orderByConditionFields.length > 0) {
7264                                    query.append(WHERE_AND);
7265                            }
7266    
7267                            for (int i = 0; i < orderByConditionFields.length; i++) {
7268                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7269                                    query.append(orderByConditionFields[i]);
7270    
7271                                    if ((i + 1) < orderByConditionFields.length) {
7272                                            if (orderByComparator.isAscending() ^ previous) {
7273                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7274                                            }
7275                                            else {
7276                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7277                                            }
7278                                    }
7279                                    else {
7280                                            if (orderByComparator.isAscending() ^ previous) {
7281                                                    query.append(WHERE_GREATER_THAN);
7282                                            }
7283                                            else {
7284                                                    query.append(WHERE_LESSER_THAN);
7285                                            }
7286                                    }
7287                            }
7288    
7289                            query.append(ORDER_BY_CLAUSE);
7290    
7291                            String[] orderByFields = orderByComparator.getOrderByFields();
7292    
7293                            for (int i = 0; i < orderByFields.length; i++) {
7294                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7295                                    query.append(orderByFields[i]);
7296    
7297                                    if ((i + 1) < orderByFields.length) {
7298                                            if (orderByComparator.isAscending() ^ previous) {
7299                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7300                                            }
7301                                            else {
7302                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7303                                            }
7304                                    }
7305                                    else {
7306                                            if (orderByComparator.isAscending() ^ previous) {
7307                                                    query.append(ORDER_BY_ASC);
7308                                            }
7309                                            else {
7310                                                    query.append(ORDER_BY_DESC);
7311                                            }
7312                                    }
7313                            }
7314                    }
7315                    else {
7316                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7317                    }
7318    
7319                    String sql = query.toString();
7320    
7321                    Query q = session.createQuery(sql);
7322    
7323                    q.setFirstResult(0);
7324                    q.setMaxResults(2);
7325    
7326                    QueryPos qPos = QueryPos.getInstance(q);
7327    
7328                    qPos.add(groupId);
7329    
7330                    qPos.add(userId);
7331    
7332                    if (orderByComparator != null) {
7333                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7334    
7335                            for (Object value : values) {
7336                                    qPos.add(value);
7337                            }
7338                    }
7339    
7340                    List<JournalArticle> list = q.list();
7341    
7342                    if (list.size() == 2) {
7343                            return list.get(1);
7344                    }
7345                    else {
7346                            return null;
7347                    }
7348            }
7349    
7350            /**
7351             * Returns all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
7352             *
7353             * @param groupId the group ID
7354             * @param userId the user ID
7355             * @return the matching journal articles that the user has permission to view
7356             */
7357            @Override
7358            public List<JournalArticle> filterFindByG_U(long groupId, long userId) {
7359                    return filterFindByG_U(groupId, userId, QueryUtil.ALL_POS,
7360                            QueryUtil.ALL_POS, null);
7361            }
7362    
7363            /**
7364             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
7365             *
7366             * <p>
7367             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
7368             * </p>
7369             *
7370             * @param groupId the group ID
7371             * @param userId the user ID
7372             * @param start the lower bound of the range of journal articles
7373             * @param end the upper bound of the range of journal articles (not inclusive)
7374             * @return the range of matching journal articles that the user has permission to view
7375             */
7376            @Override
7377            public List<JournalArticle> filterFindByG_U(long groupId, long userId,
7378                    int start, int end) {
7379                    return filterFindByG_U(groupId, userId, start, end, null);
7380            }
7381    
7382            /**
7383             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and userId = &#63;.
7384             *
7385             * <p>
7386             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
7387             * </p>
7388             *
7389             * @param groupId the group ID
7390             * @param userId the user ID
7391             * @param start the lower bound of the range of journal articles
7392             * @param end the upper bound of the range of journal articles (not inclusive)
7393             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7394             * @return the ordered range of matching journal articles that the user has permission to view
7395             */
7396            @Override
7397            public List<JournalArticle> filterFindByG_U(long groupId, long userId,
7398                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
7399                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7400                            return findByG_U(groupId, userId, start, end, orderByComparator);
7401                    }
7402    
7403                    StringBundler query = null;
7404    
7405                    if (orderByComparator != null) {
7406                            query = new StringBundler(4 +
7407                                            (orderByComparator.getOrderByFields().length * 3));
7408                    }
7409                    else {
7410                            query = new StringBundler(4);
7411                    }
7412    
7413                    if (getDB().isSupportsInlineDistinct()) {
7414                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7415                    }
7416                    else {
7417                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7418                    }
7419    
7420                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7421    
7422                    query.append(_FINDER_COLUMN_G_U_USERID_2);
7423    
7424                    if (!getDB().isSupportsInlineDistinct()) {
7425                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7426                    }
7427    
7428                    if (orderByComparator != null) {
7429                            if (getDB().isSupportsInlineDistinct()) {
7430                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7431                                            orderByComparator, true);
7432                            }
7433                            else {
7434                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7435                                            orderByComparator, true);
7436                            }
7437                    }
7438                    else {
7439                            if (getDB().isSupportsInlineDistinct()) {
7440                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7441                            }
7442                            else {
7443                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7444                            }
7445                    }
7446    
7447                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7448                                    JournalArticle.class.getName(),
7449                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7450    
7451                    Session session = null;
7452    
7453                    try {
7454                            session = openSession();
7455    
7456                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
7457    
7458                            if (getDB().isSupportsInlineDistinct()) {
7459                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7460                            }
7461                            else {
7462                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7463                            }
7464    
7465                            QueryPos qPos = QueryPos.getInstance(q);
7466    
7467                            qPos.add(groupId);
7468    
7469                            qPos.add(userId);
7470    
7471                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
7472                                    end);
7473                    }
7474                    catch (Exception e) {
7475                            throw processException(e);
7476                    }
7477                    finally {
7478                            closeSession(session);
7479                    }
7480            }
7481    
7482            /**
7483             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
7484             *
7485             * @param id the primary key of the current journal article
7486             * @param groupId the group ID
7487             * @param userId the user ID
7488             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7489             * @return the previous, current, and next journal article
7490             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
7491             */
7492            @Override
7493            public JournalArticle[] filterFindByG_U_PrevAndNext(long id, long groupId,
7494                    long userId, OrderByComparator<JournalArticle> orderByComparator)
7495                    throws NoSuchArticleException {
7496                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7497                            return findByG_U_PrevAndNext(id, groupId, userId, orderByComparator);
7498                    }
7499    
7500                    JournalArticle journalArticle = findByPrimaryKey(id);
7501    
7502                    Session session = null;
7503    
7504                    try {
7505                            session = openSession();
7506    
7507                            JournalArticle[] array = new JournalArticleImpl[3];
7508    
7509                            array[0] = filterGetByG_U_PrevAndNext(session, journalArticle,
7510                                            groupId, userId, orderByComparator, true);
7511    
7512                            array[1] = journalArticle;
7513    
7514                            array[2] = filterGetByG_U_PrevAndNext(session, journalArticle,
7515                                            groupId, userId, orderByComparator, false);
7516    
7517                            return array;
7518                    }
7519                    catch (Exception e) {
7520                            throw processException(e);
7521                    }
7522                    finally {
7523                            closeSession(session);
7524                    }
7525            }
7526    
7527            protected JournalArticle filterGetByG_U_PrevAndNext(Session session,
7528                    JournalArticle journalArticle, long groupId, long userId,
7529                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
7530                    StringBundler query = null;
7531    
7532                    if (orderByComparator != null) {
7533                            query = new StringBundler(6 +
7534                                            (orderByComparator.getOrderByFields().length * 6));
7535                    }
7536                    else {
7537                            query = new StringBundler(3);
7538                    }
7539    
7540                    if (getDB().isSupportsInlineDistinct()) {
7541                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7542                    }
7543                    else {
7544                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7545                    }
7546    
7547                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7548    
7549                    query.append(_FINDER_COLUMN_G_U_USERID_2);
7550    
7551                    if (!getDB().isSupportsInlineDistinct()) {
7552                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7553                    }
7554    
7555                    if (orderByComparator != null) {
7556                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7557    
7558                            if (orderByConditionFields.length > 0) {
7559                                    query.append(WHERE_AND);
7560                            }
7561    
7562                            for (int i = 0; i < orderByConditionFields.length; i++) {
7563                                    if (getDB().isSupportsInlineDistinct()) {
7564                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7565                                    }
7566                                    else {
7567                                            query.append(_ORDER_BY_ENTITY_TABLE);
7568                                    }
7569    
7570                                    query.append(orderByConditionFields[i]);
7571    
7572                                    if ((i + 1) < orderByConditionFields.length) {
7573                                            if (orderByComparator.isAscending() ^ previous) {
7574                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7575                                            }
7576                                            else {
7577                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7578                                            }
7579                                    }
7580                                    else {
7581                                            if (orderByComparator.isAscending() ^ previous) {
7582                                                    query.append(WHERE_GREATER_THAN);
7583                                            }
7584                                            else {
7585                                                    query.append(WHERE_LESSER_THAN);
7586                                            }
7587                                    }
7588                            }
7589    
7590                            query.append(ORDER_BY_CLAUSE);
7591    
7592                            String[] orderByFields = orderByComparator.getOrderByFields();
7593    
7594                            for (int i = 0; i < orderByFields.length; i++) {
7595                                    if (getDB().isSupportsInlineDistinct()) {
7596                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7597                                    }
7598                                    else {
7599                                            query.append(_ORDER_BY_ENTITY_TABLE);
7600                                    }
7601    
7602                                    query.append(orderByFields[i]);
7603    
7604                                    if ((i + 1) < orderByFields.length) {
7605                                            if (orderByComparator.isAscending() ^ previous) {
7606                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7607                                            }
7608                                            else {
7609                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7610                                            }
7611                                    }
7612                                    else {
7613                                            if (orderByComparator.isAscending() ^ previous) {
7614                                                    query.append(ORDER_BY_ASC);
7615                                            }
7616                                            else {
7617                                                    query.append(ORDER_BY_DESC);
7618                                            }
7619                                    }
7620                            }
7621                    }
7622                    else {
7623                            if (getDB().isSupportsInlineDistinct()) {
7624                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7625                            }
7626                            else {
7627                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7628                            }
7629                    }
7630    
7631                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7632                                    JournalArticle.class.getName(),
7633                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7634    
7635                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
7636    
7637                    q.setFirstResult(0);
7638                    q.setMaxResults(2);
7639    
7640                    if (getDB().isSupportsInlineDistinct()) {
7641                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7642                    }
7643                    else {
7644                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7645                    }
7646    
7647                    QueryPos qPos = QueryPos.getInstance(q);
7648    
7649                    qPos.add(groupId);
7650    
7651                    qPos.add(userId);
7652    
7653                    if (orderByComparator != null) {
7654                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7655    
7656                            for (Object value : values) {
7657                                    qPos.add(value);
7658                            }
7659                    }
7660    
7661                    List<JournalArticle> list = q.list();
7662    
7663                    if (list.size() == 2) {
7664                            return list.get(1);
7665                    }
7666                    else {
7667                            return null;
7668                    }
7669            }
7670    
7671            /**
7672             * Removes all the journal articles where groupId = &#63; and userId = &#63; from the database.
7673             *
7674             * @param groupId the group ID
7675             * @param userId the user ID
7676             */
7677            @Override
7678            public void removeByG_U(long groupId, long userId) {
7679                    for (JournalArticle journalArticle : findByG_U(groupId, userId,
7680                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7681                            remove(journalArticle);
7682                    }
7683            }
7684    
7685            /**
7686             * Returns the number of journal articles where groupId = &#63; and userId = &#63;.
7687             *
7688             * @param groupId the group ID
7689             * @param userId the user ID
7690             * @return the number of matching journal articles
7691             */
7692            @Override
7693            public int countByG_U(long groupId, long userId) {
7694                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U;
7695    
7696                    Object[] finderArgs = new Object[] { groupId, userId };
7697    
7698                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7699                                    this);
7700    
7701                    if (count == null) {
7702                            StringBundler query = new StringBundler(3);
7703    
7704                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
7705    
7706                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7707    
7708                            query.append(_FINDER_COLUMN_G_U_USERID_2);
7709    
7710                            String sql = query.toString();
7711    
7712                            Session session = null;
7713    
7714                            try {
7715                                    session = openSession();
7716    
7717                                    Query q = session.createQuery(sql);
7718    
7719                                    QueryPos qPos = QueryPos.getInstance(q);
7720    
7721                                    qPos.add(groupId);
7722    
7723                                    qPos.add(userId);
7724    
7725                                    count = (Long)q.uniqueResult();
7726    
7727                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
7728                            }
7729                            catch (Exception e) {
7730                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7731    
7732                                    throw processException(e);
7733                            }
7734                            finally {
7735                                    closeSession(session);
7736                            }
7737                    }
7738    
7739                    return count.intValue();
7740            }
7741    
7742            /**
7743             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
7744             *
7745             * @param groupId the group ID
7746             * @param userId the user ID
7747             * @return the number of matching journal articles that the user has permission to view
7748             */
7749            @Override
7750            public int filterCountByG_U(long groupId, long userId) {
7751                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7752                            return countByG_U(groupId, userId);
7753                    }
7754    
7755                    StringBundler query = new StringBundler(3);
7756    
7757                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
7758    
7759                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7760    
7761                    query.append(_FINDER_COLUMN_G_U_USERID_2);
7762    
7763                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7764                                    JournalArticle.class.getName(),
7765                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7766    
7767                    Session session = null;
7768    
7769                    try {
7770                            session = openSession();
7771    
7772                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
7773    
7774                            q.addScalar(COUNT_COLUMN_NAME,
7775                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
7776    
7777                            QueryPos qPos = QueryPos.getInstance(q);
7778    
7779                            qPos.add(groupId);
7780    
7781                            qPos.add(userId);
7782    
7783                            Long count = (Long)q.uniqueResult();
7784    
7785                            return count.intValue();
7786                    }
7787                    catch (Exception e) {
7788                            throw processException(e);
7789                    }
7790                    finally {
7791                            closeSession(session);
7792                    }
7793            }
7794    
7795            private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "journalArticle.groupId = ? AND ";
7796            private static final String _FINDER_COLUMN_G_U_USERID_2 = "journalArticle.userId = ?";
7797            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7798                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
7799                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
7800                            "findByG_F",
7801                            new String[] {
7802                                    Long.class.getName(), Long.class.getName(),
7803                                    
7804                            Integer.class.getName(), Integer.class.getName(),
7805                                    OrderByComparator.class.getName()
7806                            });
7807            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7808                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
7809                            JournalArticleImpl.class,
7810                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F",
7811                            new String[] { Long.class.getName(), Long.class.getName() },
7812                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
7813                            JournalArticleModelImpl.FOLDERID_COLUMN_BITMASK |
7814                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
7815                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
7816            public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7817                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
7818                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F",
7819                            new String[] { Long.class.getName(), Long.class.getName() });
7820            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7821                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
7822                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F",
7823                            new String[] { Long.class.getName(), Long.class.getName() });
7824    
7825            /**
7826             * Returns all the journal articles where groupId = &#63; and folderId = &#63;.
7827             *
7828             * @param groupId the group ID
7829             * @param folderId the folder ID
7830             * @return the matching journal articles
7831             */
7832            @Override
7833            public List<JournalArticle> findByG_F(long groupId, long folderId) {
7834                    return findByG_F(groupId, folderId, QueryUtil.ALL_POS,
7835                            QueryUtil.ALL_POS, null);
7836            }
7837    
7838            /**
7839             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63;.
7840             *
7841             * <p>
7842             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
7843             * </p>
7844             *
7845             * @param groupId the group ID
7846             * @param folderId the folder ID
7847             * @param start the lower bound of the range of journal articles
7848             * @param end the upper bound of the range of journal articles (not inclusive)
7849             * @return the range of matching journal articles
7850             */
7851            @Override
7852            public List<JournalArticle> findByG_F(long groupId, long folderId,
7853                    int start, int end) {
7854                    return findByG_F(groupId, folderId, start, end, null);
7855            }
7856    
7857            /**
7858             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63;.
7859             *
7860             * <p>
7861             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
7862             * </p>
7863             *
7864             * @param groupId the group ID
7865             * @param folderId the folder ID
7866             * @param start the lower bound of the range of journal articles
7867             * @param end the upper bound of the range of journal articles (not inclusive)
7868             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7869             * @return the ordered range of matching journal articles
7870             */
7871            @Override
7872            public List<JournalArticle> findByG_F(long groupId, long folderId,
7873                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
7874                    boolean pagination = true;
7875                    FinderPath finderPath = null;
7876                    Object[] finderArgs = null;
7877    
7878                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7879                                    (orderByComparator == null)) {
7880                            pagination = false;
7881                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F;
7882                            finderArgs = new Object[] { groupId, folderId };
7883                    }
7884                    else {
7885                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F;
7886                            finderArgs = new Object[] {
7887                                            groupId, folderId,
7888                                            
7889                                            start, end, orderByComparator
7890                                    };
7891                    }
7892    
7893                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
7894                                    finderArgs, this);
7895    
7896                    if ((list != null) && !list.isEmpty()) {
7897                            for (JournalArticle journalArticle : list) {
7898                                    if ((groupId != journalArticle.getGroupId()) ||
7899                                                    (folderId != journalArticle.getFolderId())) {
7900                                            list = null;
7901    
7902                                            break;
7903                                    }
7904                            }
7905                    }
7906    
7907                    if (list == null) {
7908                            StringBundler query = null;
7909    
7910                            if (orderByComparator != null) {
7911                                    query = new StringBundler(4 +
7912                                                    (orderByComparator.getOrderByFields().length * 3));
7913                            }
7914                            else {
7915                                    query = new StringBundler(4);
7916                            }
7917    
7918                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7919    
7920                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
7921    
7922                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
7923    
7924                            if (orderByComparator != null) {
7925                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7926                                            orderByComparator);
7927                            }
7928                            else
7929                             if (pagination) {
7930                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7931                            }
7932    
7933                            String sql = query.toString();
7934    
7935                            Session session = null;
7936    
7937                            try {
7938                                    session = openSession();
7939    
7940                                    Query q = session.createQuery(sql);
7941    
7942                                    QueryPos qPos = QueryPos.getInstance(q);
7943    
7944                                    qPos.add(groupId);
7945    
7946                                    qPos.add(folderId);
7947    
7948                                    if (!pagination) {
7949                                            list = (List<JournalArticle>)QueryUtil.list(q,
7950                                                            getDialect(), start, end, false);
7951    
7952                                            Collections.sort(list);
7953    
7954                                            list = Collections.unmodifiableList(list);
7955                                    }
7956                                    else {
7957                                            list = (List<JournalArticle>)QueryUtil.list(q,
7958                                                            getDialect(), start, end);
7959                                    }
7960    
7961                                    cacheResult(list);
7962    
7963                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
7964                            }
7965                            catch (Exception e) {
7966                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7967    
7968                                    throw processException(e);
7969                            }
7970                            finally {
7971                                    closeSession(session);
7972                            }
7973                    }
7974    
7975                    return list;
7976            }
7977    
7978            /**
7979             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63;.
7980             *
7981             * @param groupId the group ID
7982             * @param folderId the folder ID
7983             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7984             * @return the first matching journal article
7985             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
7986             */
7987            @Override
7988            public JournalArticle findByG_F_First(long groupId, long folderId,
7989                    OrderByComparator<JournalArticle> orderByComparator)
7990                    throws NoSuchArticleException {
7991                    JournalArticle journalArticle = fetchByG_F_First(groupId, folderId,
7992                                    orderByComparator);
7993    
7994                    if (journalArticle != null) {
7995                            return journalArticle;
7996                    }
7997    
7998                    StringBundler msg = new StringBundler(6);
7999    
8000                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8001    
8002                    msg.append("groupId=");
8003                    msg.append(groupId);
8004    
8005                    msg.append(", folderId=");
8006                    msg.append(folderId);
8007    
8008                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8009    
8010                    throw new NoSuchArticleException(msg.toString());
8011            }
8012    
8013            /**
8014             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63;.
8015             *
8016             * @param groupId the group ID
8017             * @param folderId the folder ID
8018             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8019             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
8020             */
8021            @Override
8022            public JournalArticle fetchByG_F_First(long groupId, long folderId,
8023                    OrderByComparator<JournalArticle> orderByComparator) {
8024                    List<JournalArticle> list = findByG_F(groupId, folderId, 0, 1,
8025                                    orderByComparator);
8026    
8027                    if (!list.isEmpty()) {
8028                            return list.get(0);
8029                    }
8030    
8031                    return null;
8032            }
8033    
8034            /**
8035             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63;.
8036             *
8037             * @param groupId the group ID
8038             * @param folderId the folder ID
8039             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8040             * @return the last matching journal article
8041             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
8042             */
8043            @Override
8044            public JournalArticle findByG_F_Last(long groupId, long folderId,
8045                    OrderByComparator<JournalArticle> orderByComparator)
8046                    throws NoSuchArticleException {
8047                    JournalArticle journalArticle = fetchByG_F_Last(groupId, folderId,
8048                                    orderByComparator);
8049    
8050                    if (journalArticle != null) {
8051                            return journalArticle;
8052                    }
8053    
8054                    StringBundler msg = new StringBundler(6);
8055    
8056                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8057    
8058                    msg.append("groupId=");
8059                    msg.append(groupId);
8060    
8061                    msg.append(", folderId=");
8062                    msg.append(folderId);
8063    
8064                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8065    
8066                    throw new NoSuchArticleException(msg.toString());
8067            }
8068    
8069            /**
8070             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63;.
8071             *
8072             * @param groupId the group ID
8073             * @param folderId the folder ID
8074             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8075             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
8076             */
8077            @Override
8078            public JournalArticle fetchByG_F_Last(long groupId, long folderId,
8079                    OrderByComparator<JournalArticle> orderByComparator) {
8080                    int count = countByG_F(groupId, folderId);
8081    
8082                    if (count == 0) {
8083                            return null;
8084                    }
8085    
8086                    List<JournalArticle> list = findByG_F(groupId, folderId, count - 1,
8087                                    count, orderByComparator);
8088    
8089                    if (!list.isEmpty()) {
8090                            return list.get(0);
8091                    }
8092    
8093                    return null;
8094            }
8095    
8096            /**
8097             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and folderId = &#63;.
8098             *
8099             * @param id the primary key of the current journal article
8100             * @param groupId the group ID
8101             * @param folderId the folder ID
8102             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8103             * @return the previous, current, and next journal article
8104             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
8105             */
8106            @Override
8107            public JournalArticle[] findByG_F_PrevAndNext(long id, long groupId,
8108                    long folderId, OrderByComparator<JournalArticle> orderByComparator)
8109                    throws NoSuchArticleException {
8110                    JournalArticle journalArticle = findByPrimaryKey(id);
8111    
8112                    Session session = null;
8113    
8114                    try {
8115                            session = openSession();
8116    
8117                            JournalArticle[] array = new JournalArticleImpl[3];
8118    
8119                            array[0] = getByG_F_PrevAndNext(session, journalArticle, groupId,
8120                                            folderId, orderByComparator, true);
8121    
8122                            array[1] = journalArticle;
8123    
8124                            array[2] = getByG_F_PrevAndNext(session, journalArticle, groupId,
8125                                            folderId, orderByComparator, false);
8126    
8127                            return array;
8128                    }
8129                    catch (Exception e) {
8130                            throw processException(e);
8131                    }
8132                    finally {
8133                            closeSession(session);
8134                    }
8135            }
8136    
8137            protected JournalArticle getByG_F_PrevAndNext(Session session,
8138                    JournalArticle journalArticle, long groupId, long folderId,
8139                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
8140                    StringBundler query = null;
8141    
8142                    if (orderByComparator != null) {
8143                            query = new StringBundler(6 +
8144                                            (orderByComparator.getOrderByFields().length * 6));
8145                    }
8146                    else {
8147                            query = new StringBundler(3);
8148                    }
8149    
8150                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8151    
8152                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8153    
8154                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
8155    
8156                    if (orderByComparator != null) {
8157                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8158    
8159                            if (orderByConditionFields.length > 0) {
8160                                    query.append(WHERE_AND);
8161                            }
8162    
8163                            for (int i = 0; i < orderByConditionFields.length; i++) {
8164                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8165                                    query.append(orderByConditionFields[i]);
8166    
8167                                    if ((i + 1) < orderByConditionFields.length) {
8168                                            if (orderByComparator.isAscending() ^ previous) {
8169                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8170                                            }
8171                                            else {
8172                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8173                                            }
8174                                    }
8175                                    else {
8176                                            if (orderByComparator.isAscending() ^ previous) {
8177                                                    query.append(WHERE_GREATER_THAN);
8178                                            }
8179                                            else {
8180                                                    query.append(WHERE_LESSER_THAN);
8181                                            }
8182                                    }
8183                            }
8184    
8185                            query.append(ORDER_BY_CLAUSE);
8186    
8187                            String[] orderByFields = orderByComparator.getOrderByFields();
8188    
8189                            for (int i = 0; i < orderByFields.length; i++) {
8190                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8191                                    query.append(orderByFields[i]);
8192    
8193                                    if ((i + 1) < orderByFields.length) {
8194                                            if (orderByComparator.isAscending() ^ previous) {
8195                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8196                                            }
8197                                            else {
8198                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8199                                            }
8200                                    }
8201                                    else {
8202                                            if (orderByComparator.isAscending() ^ previous) {
8203                                                    query.append(ORDER_BY_ASC);
8204                                            }
8205                                            else {
8206                                                    query.append(ORDER_BY_DESC);
8207                                            }
8208                                    }
8209                            }
8210                    }
8211                    else {
8212                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8213                    }
8214    
8215                    String sql = query.toString();
8216    
8217                    Query q = session.createQuery(sql);
8218    
8219                    q.setFirstResult(0);
8220                    q.setMaxResults(2);
8221    
8222                    QueryPos qPos = QueryPos.getInstance(q);
8223    
8224                    qPos.add(groupId);
8225    
8226                    qPos.add(folderId);
8227    
8228                    if (orderByComparator != null) {
8229                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8230    
8231                            for (Object value : values) {
8232                                    qPos.add(value);
8233                            }
8234                    }
8235    
8236                    List<JournalArticle> list = q.list();
8237    
8238                    if (list.size() == 2) {
8239                            return list.get(1);
8240                    }
8241                    else {
8242                            return null;
8243                    }
8244            }
8245    
8246            /**
8247             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
8248             *
8249             * @param groupId the group ID
8250             * @param folderId the folder ID
8251             * @return the matching journal articles that the user has permission to view
8252             */
8253            @Override
8254            public List<JournalArticle> filterFindByG_F(long groupId, long folderId) {
8255                    return filterFindByG_F(groupId, folderId, QueryUtil.ALL_POS,
8256                            QueryUtil.ALL_POS, null);
8257            }
8258    
8259            /**
8260             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
8261             *
8262             * <p>
8263             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
8264             * </p>
8265             *
8266             * @param groupId the group ID
8267             * @param folderId the folder ID
8268             * @param start the lower bound of the range of journal articles
8269             * @param end the upper bound of the range of journal articles (not inclusive)
8270             * @return the range of matching journal articles that the user has permission to view
8271             */
8272            @Override
8273            public List<JournalArticle> filterFindByG_F(long groupId, long folderId,
8274                    int start, int end) {
8275                    return filterFindByG_F(groupId, folderId, start, end, null);
8276            }
8277    
8278            /**
8279             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and folderId = &#63;.
8280             *
8281             * <p>
8282             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
8283             * </p>
8284             *
8285             * @param groupId the group ID
8286             * @param folderId the folder ID
8287             * @param start the lower bound of the range of journal articles
8288             * @param end the upper bound of the range of journal articles (not inclusive)
8289             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8290             * @return the ordered range of matching journal articles that the user has permission to view
8291             */
8292            @Override
8293            public List<JournalArticle> filterFindByG_F(long groupId, long folderId,
8294                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
8295                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8296                            return findByG_F(groupId, folderId, start, end, orderByComparator);
8297                    }
8298    
8299                    StringBundler query = null;
8300    
8301                    if (orderByComparator != null) {
8302                            query = new StringBundler(4 +
8303                                            (orderByComparator.getOrderByFields().length * 3));
8304                    }
8305                    else {
8306                            query = new StringBundler(4);
8307                    }
8308    
8309                    if (getDB().isSupportsInlineDistinct()) {
8310                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8311                    }
8312                    else {
8313                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8314                    }
8315    
8316                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8317    
8318                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
8319    
8320                    if (!getDB().isSupportsInlineDistinct()) {
8321                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8322                    }
8323    
8324                    if (orderByComparator != null) {
8325                            if (getDB().isSupportsInlineDistinct()) {
8326                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8327                                            orderByComparator, true);
8328                            }
8329                            else {
8330                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8331                                            orderByComparator, true);
8332                            }
8333                    }
8334                    else {
8335                            if (getDB().isSupportsInlineDistinct()) {
8336                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8337                            }
8338                            else {
8339                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8340                            }
8341                    }
8342    
8343                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8344                                    JournalArticle.class.getName(),
8345                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8346    
8347                    Session session = null;
8348    
8349                    try {
8350                            session = openSession();
8351    
8352                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
8353    
8354                            if (getDB().isSupportsInlineDistinct()) {
8355                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8356                            }
8357                            else {
8358                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8359                            }
8360    
8361                            QueryPos qPos = QueryPos.getInstance(q);
8362    
8363                            qPos.add(groupId);
8364    
8365                            qPos.add(folderId);
8366    
8367                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
8368                                    end);
8369                    }
8370                    catch (Exception e) {
8371                            throw processException(e);
8372                    }
8373                    finally {
8374                            closeSession(session);
8375                    }
8376            }
8377    
8378            /**
8379             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
8380             *
8381             * @param id the primary key of the current journal article
8382             * @param groupId the group ID
8383             * @param folderId the folder ID
8384             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8385             * @return the previous, current, and next journal article
8386             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
8387             */
8388            @Override
8389            public JournalArticle[] filterFindByG_F_PrevAndNext(long id, long groupId,
8390                    long folderId, OrderByComparator<JournalArticle> orderByComparator)
8391                    throws NoSuchArticleException {
8392                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8393                            return findByG_F_PrevAndNext(id, groupId, folderId,
8394                                    orderByComparator);
8395                    }
8396    
8397                    JournalArticle journalArticle = findByPrimaryKey(id);
8398    
8399                    Session session = null;
8400    
8401                    try {
8402                            session = openSession();
8403    
8404                            JournalArticle[] array = new JournalArticleImpl[3];
8405    
8406                            array[0] = filterGetByG_F_PrevAndNext(session, journalArticle,
8407                                            groupId, folderId, orderByComparator, true);
8408    
8409                            array[1] = journalArticle;
8410    
8411                            array[2] = filterGetByG_F_PrevAndNext(session, journalArticle,
8412                                            groupId, folderId, orderByComparator, false);
8413    
8414                            return array;
8415                    }
8416                    catch (Exception e) {
8417                            throw processException(e);
8418                    }
8419                    finally {
8420                            closeSession(session);
8421                    }
8422            }
8423    
8424            protected JournalArticle filterGetByG_F_PrevAndNext(Session session,
8425                    JournalArticle journalArticle, long groupId, long folderId,
8426                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
8427                    StringBundler query = null;
8428    
8429                    if (orderByComparator != null) {
8430                            query = new StringBundler(6 +
8431                                            (orderByComparator.getOrderByFields().length * 6));
8432                    }
8433                    else {
8434                            query = new StringBundler(3);
8435                    }
8436    
8437                    if (getDB().isSupportsInlineDistinct()) {
8438                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8439                    }
8440                    else {
8441                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8442                    }
8443    
8444                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8445    
8446                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
8447    
8448                    if (!getDB().isSupportsInlineDistinct()) {
8449                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8450                    }
8451    
8452                    if (orderByComparator != null) {
8453                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8454    
8455                            if (orderByConditionFields.length > 0) {
8456                                    query.append(WHERE_AND);
8457                            }
8458    
8459                            for (int i = 0; i < orderByConditionFields.length; i++) {
8460                                    if (getDB().isSupportsInlineDistinct()) {
8461                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8462                                    }
8463                                    else {
8464                                            query.append(_ORDER_BY_ENTITY_TABLE);
8465                                    }
8466    
8467                                    query.append(orderByConditionFields[i]);
8468    
8469                                    if ((i + 1) < orderByConditionFields.length) {
8470                                            if (orderByComparator.isAscending() ^ previous) {
8471                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8472                                            }
8473                                            else {
8474                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8475                                            }
8476                                    }
8477                                    else {
8478                                            if (orderByComparator.isAscending() ^ previous) {
8479                                                    query.append(WHERE_GREATER_THAN);
8480                                            }
8481                                            else {
8482                                                    query.append(WHERE_LESSER_THAN);
8483                                            }
8484                                    }
8485                            }
8486    
8487                            query.append(ORDER_BY_CLAUSE);
8488    
8489                            String[] orderByFields = orderByComparator.getOrderByFields();
8490    
8491                            for (int i = 0; i < orderByFields.length; i++) {
8492                                    if (getDB().isSupportsInlineDistinct()) {
8493                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8494                                    }
8495                                    else {
8496                                            query.append(_ORDER_BY_ENTITY_TABLE);
8497                                    }
8498    
8499                                    query.append(orderByFields[i]);
8500    
8501                                    if ((i + 1) < orderByFields.length) {
8502                                            if (orderByComparator.isAscending() ^ previous) {
8503                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8504                                            }
8505                                            else {
8506                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8507                                            }
8508                                    }
8509                                    else {
8510                                            if (orderByComparator.isAscending() ^ previous) {
8511                                                    query.append(ORDER_BY_ASC);
8512                                            }
8513                                            else {
8514                                                    query.append(ORDER_BY_DESC);
8515                                            }
8516                                    }
8517                            }
8518                    }
8519                    else {
8520                            if (getDB().isSupportsInlineDistinct()) {
8521                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8522                            }
8523                            else {
8524                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8525                            }
8526                    }
8527    
8528                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8529                                    JournalArticle.class.getName(),
8530                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8531    
8532                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
8533    
8534                    q.setFirstResult(0);
8535                    q.setMaxResults(2);
8536    
8537                    if (getDB().isSupportsInlineDistinct()) {
8538                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8539                    }
8540                    else {
8541                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8542                    }
8543    
8544                    QueryPos qPos = QueryPos.getInstance(q);
8545    
8546                    qPos.add(groupId);
8547    
8548                    qPos.add(folderId);
8549    
8550                    if (orderByComparator != null) {
8551                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8552    
8553                            for (Object value : values) {
8554                                    qPos.add(value);
8555                            }
8556                    }
8557    
8558                    List<JournalArticle> list = q.list();
8559    
8560                    if (list.size() == 2) {
8561                            return list.get(1);
8562                    }
8563                    else {
8564                            return null;
8565                    }
8566            }
8567    
8568            /**
8569             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
8570             *
8571             * @param groupId the group ID
8572             * @param folderIds the folder IDs
8573             * @return the matching journal articles that the user has permission to view
8574             */
8575            @Override
8576            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds) {
8577                    return filterFindByG_F(groupId, folderIds, QueryUtil.ALL_POS,
8578                            QueryUtil.ALL_POS, null);
8579            }
8580    
8581            /**
8582             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
8583             *
8584             * <p>
8585             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
8586             * </p>
8587             *
8588             * @param groupId the group ID
8589             * @param folderIds the folder IDs
8590             * @param start the lower bound of the range of journal articles
8591             * @param end the upper bound of the range of journal articles (not inclusive)
8592             * @return the range of matching journal articles that the user has permission to view
8593             */
8594            @Override
8595            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds,
8596                    int start, int end) {
8597                    return filterFindByG_F(groupId, folderIds, start, end, null);
8598            }
8599    
8600            /**
8601             * Returns an ordered range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
8602             *
8603             * <p>
8604             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
8605             * </p>
8606             *
8607             * @param groupId the group ID
8608             * @param folderIds the folder IDs
8609             * @param start the lower bound of the range of journal articles
8610             * @param end the upper bound of the range of journal articles (not inclusive)
8611             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8612             * @return the ordered range of matching journal articles that the user has permission to view
8613             */
8614            @Override
8615            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds,
8616                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
8617                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8618                            return findByG_F(groupId, folderIds, start, end, orderByComparator);
8619                    }
8620    
8621                    if (folderIds == null) {
8622                            folderIds = new long[0];
8623                    }
8624                    else {
8625                            folderIds = ArrayUtil.unique(folderIds);
8626                    }
8627    
8628                    StringBundler query = new StringBundler();
8629    
8630                    if (getDB().isSupportsInlineDistinct()) {
8631                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8632                    }
8633                    else {
8634                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8635                    }
8636    
8637                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8638    
8639                    if (folderIds.length > 0) {
8640                            query.append(StringPool.OPEN_PARENTHESIS);
8641    
8642                            query.append(_FINDER_COLUMN_G_F_FOLDERID_7);
8643    
8644                            query.append(StringUtil.merge(folderIds));
8645    
8646                            query.append(StringPool.CLOSE_PARENTHESIS);
8647    
8648                            query.append(StringPool.CLOSE_PARENTHESIS);
8649                    }
8650    
8651                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
8652                            query.index() - 1);
8653    
8654                    if (!getDB().isSupportsInlineDistinct()) {
8655                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8656                    }
8657    
8658                    if (orderByComparator != null) {
8659                            if (getDB().isSupportsInlineDistinct()) {
8660                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8661                                            orderByComparator, true);
8662                            }
8663                            else {
8664                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8665                                            orderByComparator, true);
8666                            }
8667                    }
8668                    else {
8669                            if (getDB().isSupportsInlineDistinct()) {
8670                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8671                            }
8672                            else {
8673                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8674                            }
8675                    }
8676    
8677                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8678                                    JournalArticle.class.getName(),
8679                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8680    
8681                    Session session = null;
8682    
8683                    try {
8684                            session = openSession();
8685    
8686                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
8687    
8688                            if (getDB().isSupportsInlineDistinct()) {
8689                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8690                            }
8691                            else {
8692                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8693                            }
8694    
8695                            QueryPos qPos = QueryPos.getInstance(q);
8696    
8697                            qPos.add(groupId);
8698    
8699                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
8700                                    end);
8701                    }
8702                    catch (Exception e) {
8703                            throw processException(e);
8704                    }
8705                    finally {
8706                            closeSession(session);
8707                    }
8708            }
8709    
8710            /**
8711             * Returns all the journal articles where groupId = &#63; and folderId = any &#63;.
8712             *
8713             * <p>
8714             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
8715             * </p>
8716             *
8717             * @param groupId the group ID
8718             * @param folderIds the folder IDs
8719             * @return the matching journal articles
8720             */
8721            @Override
8722            public List<JournalArticle> findByG_F(long groupId, long[] folderIds) {
8723                    return findByG_F(groupId, folderIds, QueryUtil.ALL_POS,
8724                            QueryUtil.ALL_POS, null);
8725            }
8726    
8727            /**
8728             * Returns a range of all the journal articles where groupId = &#63; and folderId = any &#63;.
8729             *
8730             * <p>
8731             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
8732             * </p>
8733             *
8734             * @param groupId the group ID
8735             * @param folderIds the folder IDs
8736             * @param start the lower bound of the range of journal articles
8737             * @param end the upper bound of the range of journal articles (not inclusive)
8738             * @return the range of matching journal articles
8739             */
8740            @Override
8741            public List<JournalArticle> findByG_F(long groupId, long[] folderIds,
8742                    int start, int end) {
8743                    return findByG_F(groupId, folderIds, start, end, null);
8744            }
8745    
8746            /**
8747             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = any &#63;.
8748             *
8749             * <p>
8750             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
8751             * </p>
8752             *
8753             * @param groupId the group ID
8754             * @param folderIds the folder IDs
8755             * @param start the lower bound of the range of journal articles
8756             * @param end the upper bound of the range of journal articles (not inclusive)
8757             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8758             * @return the ordered range of matching journal articles
8759             */
8760            @Override
8761            public List<JournalArticle> findByG_F(long groupId, long[] folderIds,
8762                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
8763                    if (folderIds == null) {
8764                            folderIds = new long[0];
8765                    }
8766                    else {
8767                            folderIds = ArrayUtil.unique(folderIds);
8768                    }
8769    
8770                    if (folderIds.length == 1) {
8771                            return findByG_F(groupId, folderIds[0], start, end,
8772                                    orderByComparator);
8773                    }
8774    
8775                    boolean pagination = true;
8776                    Object[] finderArgs = null;
8777    
8778                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8779                                    (orderByComparator == null)) {
8780                            pagination = false;
8781                            finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
8782                    }
8783                    else {
8784                            finderArgs = new Object[] {
8785                                            groupId, StringUtil.merge(folderIds),
8786                                            
8787                                            start, end, orderByComparator
8788                                    };
8789                    }
8790    
8791                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
8792                                    finderArgs, this);
8793    
8794                    if ((list != null) && !list.isEmpty()) {
8795                            for (JournalArticle journalArticle : list) {
8796                                    if ((groupId != journalArticle.getGroupId()) ||
8797                                                    !ArrayUtil.contains(folderIds,
8798                                                            journalArticle.getFolderId())) {
8799                                            list = null;
8800    
8801                                            break;
8802                                    }
8803                            }
8804                    }
8805    
8806                    if (list == null) {
8807                            StringBundler query = new StringBundler();
8808    
8809                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8810    
8811                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8812    
8813                            if (folderIds.length > 0) {
8814                                    query.append(StringPool.OPEN_PARENTHESIS);
8815    
8816                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_7);
8817    
8818                                    query.append(StringUtil.merge(folderIds));
8819    
8820                                    query.append(StringPool.CLOSE_PARENTHESIS);
8821    
8822                                    query.append(StringPool.CLOSE_PARENTHESIS);
8823                            }
8824    
8825                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
8826                                                    1)), query.index() - 1);
8827    
8828                            if (orderByComparator != null) {
8829                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8830                                            orderByComparator);
8831                            }
8832                            else
8833                             if (pagination) {
8834                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8835                            }
8836    
8837                            String sql = query.toString();
8838    
8839                            Session session = null;
8840    
8841                            try {
8842                                    session = openSession();
8843    
8844                                    Query q = session.createQuery(sql);
8845    
8846                                    QueryPos qPos = QueryPos.getInstance(q);
8847    
8848                                    qPos.add(groupId);
8849    
8850                                    if (!pagination) {
8851                                            list = (List<JournalArticle>)QueryUtil.list(q,
8852                                                            getDialect(), start, end, false);
8853    
8854                                            Collections.sort(list);
8855    
8856                                            list = Collections.unmodifiableList(list);
8857                                    }
8858                                    else {
8859                                            list = (List<JournalArticle>)QueryUtil.list(q,
8860                                                            getDialect(), start, end);
8861                                    }
8862    
8863                                    cacheResult(list);
8864    
8865                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
8866                                            finderArgs, list);
8867                            }
8868                            catch (Exception e) {
8869                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
8870                                            finderArgs);
8871    
8872                                    throw processException(e);
8873                            }
8874                            finally {
8875                                    closeSession(session);
8876                            }
8877                    }
8878    
8879                    return list;
8880            }
8881    
8882            /**
8883             * Removes all the journal articles where groupId = &#63; and folderId = &#63; from the database.
8884             *
8885             * @param groupId the group ID
8886             * @param folderId the folder ID
8887             */
8888            @Override
8889            public void removeByG_F(long groupId, long folderId) {
8890                    for (JournalArticle journalArticle : findByG_F(groupId, folderId,
8891                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8892                            remove(journalArticle);
8893                    }
8894            }
8895    
8896            /**
8897             * Returns the number of journal articles where groupId = &#63; and folderId = &#63;.
8898             *
8899             * @param groupId the group ID
8900             * @param folderId the folder ID
8901             * @return the number of matching journal articles
8902             */
8903            @Override
8904            public int countByG_F(long groupId, long folderId) {
8905                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F;
8906    
8907                    Object[] finderArgs = new Object[] { groupId, folderId };
8908    
8909                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8910                                    this);
8911    
8912                    if (count == null) {
8913                            StringBundler query = new StringBundler(3);
8914    
8915                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
8916    
8917                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8918    
8919                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
8920    
8921                            String sql = query.toString();
8922    
8923                            Session session = null;
8924    
8925                            try {
8926                                    session = openSession();
8927    
8928                                    Query q = session.createQuery(sql);
8929    
8930                                    QueryPos qPos = QueryPos.getInstance(q);
8931    
8932                                    qPos.add(groupId);
8933    
8934                                    qPos.add(folderId);
8935    
8936                                    count = (Long)q.uniqueResult();
8937    
8938                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
8939                            }
8940                            catch (Exception e) {
8941                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8942    
8943                                    throw processException(e);
8944                            }
8945                            finally {
8946                                    closeSession(session);
8947                            }
8948                    }
8949    
8950                    return count.intValue();
8951            }
8952    
8953            /**
8954             * Returns the number of journal articles where groupId = &#63; and folderId = any &#63;.
8955             *
8956             * @param groupId the group ID
8957             * @param folderIds the folder IDs
8958             * @return the number of matching journal articles
8959             */
8960            @Override
8961            public int countByG_F(long groupId, long[] folderIds) {
8962                    if (folderIds == null) {
8963                            folderIds = new long[0];
8964                    }
8965                    else {
8966                            folderIds = ArrayUtil.unique(folderIds);
8967                    }
8968    
8969                    Object[] finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
8970    
8971                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
8972                                    finderArgs, this);
8973    
8974                    if (count == null) {
8975                            StringBundler query = new StringBundler();
8976    
8977                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
8978    
8979                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8980    
8981                            if (folderIds.length > 0) {
8982                                    query.append(StringPool.OPEN_PARENTHESIS);
8983    
8984                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_7);
8985    
8986                                    query.append(StringUtil.merge(folderIds));
8987    
8988                                    query.append(StringPool.CLOSE_PARENTHESIS);
8989    
8990                                    query.append(StringPool.CLOSE_PARENTHESIS);
8991                            }
8992    
8993                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
8994                                                    1)), query.index() - 1);
8995    
8996                            String sql = query.toString();
8997    
8998                            Session session = null;
8999    
9000                            try {
9001                                    session = openSession();
9002    
9003                                    Query q = session.createQuery(sql);
9004    
9005                                    QueryPos qPos = QueryPos.getInstance(q);
9006    
9007                                    qPos.add(groupId);
9008    
9009                                    count = (Long)q.uniqueResult();
9010    
9011                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
9012                                            finderArgs, count);
9013                            }
9014                            catch (Exception e) {
9015                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
9016                                            finderArgs);
9017    
9018                                    throw processException(e);
9019                            }
9020                            finally {
9021                                    closeSession(session);
9022                            }
9023                    }
9024    
9025                    return count.intValue();
9026            }
9027    
9028            /**
9029             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
9030             *
9031             * @param groupId the group ID
9032             * @param folderId the folder ID
9033             * @return the number of matching journal articles that the user has permission to view
9034             */
9035            @Override
9036            public int filterCountByG_F(long groupId, long folderId) {
9037                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9038                            return countByG_F(groupId, folderId);
9039                    }
9040    
9041                    StringBundler query = new StringBundler(3);
9042    
9043                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
9044    
9045                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
9046    
9047                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
9048    
9049                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9050                                    JournalArticle.class.getName(),
9051                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9052    
9053                    Session session = null;
9054    
9055                    try {
9056                            session = openSession();
9057    
9058                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
9059    
9060                            q.addScalar(COUNT_COLUMN_NAME,
9061                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9062    
9063                            QueryPos qPos = QueryPos.getInstance(q);
9064    
9065                            qPos.add(groupId);
9066    
9067                            qPos.add(folderId);
9068    
9069                            Long count = (Long)q.uniqueResult();
9070    
9071                            return count.intValue();
9072                    }
9073                    catch (Exception e) {
9074                            throw processException(e);
9075                    }
9076                    finally {
9077                            closeSession(session);
9078                    }
9079            }
9080    
9081            /**
9082             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
9083             *
9084             * @param groupId the group ID
9085             * @param folderIds the folder IDs
9086             * @return the number of matching journal articles that the user has permission to view
9087             */
9088            @Override
9089            public int filterCountByG_F(long groupId, long[] folderIds) {
9090                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9091                            return countByG_F(groupId, folderIds);
9092                    }
9093    
9094                    if (folderIds == null) {
9095                            folderIds = new long[0];
9096                    }
9097                    else {
9098                            folderIds = ArrayUtil.unique(folderIds);
9099                    }
9100    
9101                    StringBundler query = new StringBundler();
9102    
9103                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
9104    
9105                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
9106    
9107                    if (folderIds.length > 0) {
9108                            query.append(StringPool.OPEN_PARENTHESIS);
9109    
9110                            query.append(_FINDER_COLUMN_G_F_FOLDERID_7);
9111    
9112                            query.append(StringUtil.merge(folderIds));
9113    
9114                            query.append(StringPool.CLOSE_PARENTHESIS);
9115    
9116                            query.append(StringPool.CLOSE_PARENTHESIS);
9117                    }
9118    
9119                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
9120                            query.index() - 1);
9121    
9122                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9123                                    JournalArticle.class.getName(),
9124                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9125    
9126                    Session session = null;
9127    
9128                    try {
9129                            session = openSession();
9130    
9131                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
9132    
9133                            q.addScalar(COUNT_COLUMN_NAME,
9134                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9135    
9136                            QueryPos qPos = QueryPos.getInstance(q);
9137    
9138                            qPos.add(groupId);
9139    
9140                            Long count = (Long)q.uniqueResult();
9141    
9142                            return count.intValue();
9143                    }
9144                    catch (Exception e) {
9145                            throw processException(e);
9146                    }
9147                    finally {
9148                            closeSession(session);
9149                    }
9150            }
9151    
9152            private static final String _FINDER_COLUMN_G_F_GROUPID_2 = "journalArticle.groupId = ? AND ";
9153            private static final String _FINDER_COLUMN_G_F_FOLDERID_2 = "journalArticle.folderId = ?";
9154            private static final String _FINDER_COLUMN_G_F_FOLDERID_7 = "journalArticle.folderId IN (";
9155            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9156                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
9157                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
9158                            "findByG_A",
9159                            new String[] {
9160                                    Long.class.getName(), String.class.getName(),
9161                                    
9162                            Integer.class.getName(), Integer.class.getName(),
9163                                    OrderByComparator.class.getName()
9164                            });
9165            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9166                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
9167                            JournalArticleImpl.class,
9168                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A",
9169                            new String[] { Long.class.getName(), String.class.getName() },
9170                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
9171                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
9172                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
9173            public static final FinderPath FINDER_PATH_COUNT_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9174                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
9175                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A",
9176                            new String[] { Long.class.getName(), String.class.getName() });
9177    
9178            /**
9179             * Returns all the journal articles where groupId = &#63; and articleId = &#63;.
9180             *
9181             * @param groupId the group ID
9182             * @param articleId the article ID
9183             * @return the matching journal articles
9184             */
9185            @Override
9186            public List<JournalArticle> findByG_A(long groupId, String articleId) {
9187                    return findByG_A(groupId, articleId, QueryUtil.ALL_POS,
9188                            QueryUtil.ALL_POS, null);
9189            }
9190    
9191            /**
9192             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63;.
9193             *
9194             * <p>
9195             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
9196             * </p>
9197             *
9198             * @param groupId the group ID
9199             * @param articleId the article ID
9200             * @param start the lower bound of the range of journal articles
9201             * @param end the upper bound of the range of journal articles (not inclusive)
9202             * @return the range of matching journal articles
9203             */
9204            @Override
9205            public List<JournalArticle> findByG_A(long groupId, String articleId,
9206                    int start, int end) {
9207                    return findByG_A(groupId, articleId, start, end, null);
9208            }
9209    
9210            /**
9211             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63;.
9212             *
9213             * <p>
9214             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
9215             * </p>
9216             *
9217             * @param groupId the group ID
9218             * @param articleId the article ID
9219             * @param start the lower bound of the range of journal articles
9220             * @param end the upper bound of the range of journal articles (not inclusive)
9221             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9222             * @return the ordered range of matching journal articles
9223             */
9224            @Override
9225            public List<JournalArticle> findByG_A(long groupId, String articleId,
9226                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
9227                    boolean pagination = true;
9228                    FinderPath finderPath = null;
9229                    Object[] finderArgs = null;
9230    
9231                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9232                                    (orderByComparator == null)) {
9233                            pagination = false;
9234                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A;
9235                            finderArgs = new Object[] { groupId, articleId };
9236                    }
9237                    else {
9238                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A;
9239                            finderArgs = new Object[] {
9240                                            groupId, articleId,
9241                                            
9242                                            start, end, orderByComparator
9243                                    };
9244                    }
9245    
9246                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
9247                                    finderArgs, this);
9248    
9249                    if ((list != null) && !list.isEmpty()) {
9250                            for (JournalArticle journalArticle : list) {
9251                                    if ((groupId != journalArticle.getGroupId()) ||
9252                                                    !Validator.equals(articleId,
9253                                                            journalArticle.getArticleId())) {
9254                                            list = null;
9255    
9256                                            break;
9257                                    }
9258                            }
9259                    }
9260    
9261                    if (list == null) {
9262                            StringBundler query = null;
9263    
9264                            if (orderByComparator != null) {
9265                                    query = new StringBundler(4 +
9266                                                    (orderByComparator.getOrderByFields().length * 3));
9267                            }
9268                            else {
9269                                    query = new StringBundler(4);
9270                            }
9271    
9272                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9273    
9274                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
9275    
9276                            boolean bindArticleId = false;
9277    
9278                            if (articleId == null) {
9279                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
9280                            }
9281                            else if (articleId.equals(StringPool.BLANK)) {
9282                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
9283                            }
9284                            else {
9285                                    bindArticleId = true;
9286    
9287                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
9288                            }
9289    
9290                            if (orderByComparator != null) {
9291                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9292                                            orderByComparator);
9293                            }
9294                            else
9295                             if (pagination) {
9296                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9297                            }
9298    
9299                            String sql = query.toString();
9300    
9301                            Session session = null;
9302    
9303                            try {
9304                                    session = openSession();
9305    
9306                                    Query q = session.createQuery(sql);
9307    
9308                                    QueryPos qPos = QueryPos.getInstance(q);
9309    
9310                                    qPos.add(groupId);
9311    
9312                                    if (bindArticleId) {
9313                                            qPos.add(articleId);
9314                                    }
9315    
9316                                    if (!pagination) {
9317                                            list = (List<JournalArticle>)QueryUtil.list(q,
9318                                                            getDialect(), start, end, false);
9319    
9320                                            Collections.sort(list);
9321    
9322                                            list = Collections.unmodifiableList(list);
9323                                    }
9324                                    else {
9325                                            list = (List<JournalArticle>)QueryUtil.list(q,
9326                                                            getDialect(), start, end);
9327                                    }
9328    
9329                                    cacheResult(list);
9330    
9331                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
9332                            }
9333                            catch (Exception e) {
9334                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9335    
9336                                    throw processException(e);
9337                            }
9338                            finally {
9339                                    closeSession(session);
9340                            }
9341                    }
9342    
9343                    return list;
9344            }
9345    
9346            /**
9347             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9348             *
9349             * @param groupId the group ID
9350             * @param articleId the article ID
9351             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9352             * @return the first matching journal article
9353             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9354             */
9355            @Override
9356            public JournalArticle findByG_A_First(long groupId, String articleId,
9357                    OrderByComparator<JournalArticle> orderByComparator)
9358                    throws NoSuchArticleException {
9359                    JournalArticle journalArticle = fetchByG_A_First(groupId, articleId,
9360                                    orderByComparator);
9361    
9362                    if (journalArticle != null) {
9363                            return journalArticle;
9364                    }
9365    
9366                    StringBundler msg = new StringBundler(6);
9367    
9368                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9369    
9370                    msg.append("groupId=");
9371                    msg.append(groupId);
9372    
9373                    msg.append(", articleId=");
9374                    msg.append(articleId);
9375    
9376                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9377    
9378                    throw new NoSuchArticleException(msg.toString());
9379            }
9380    
9381            /**
9382             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9383             *
9384             * @param groupId the group ID
9385             * @param articleId the article ID
9386             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9387             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
9388             */
9389            @Override
9390            public JournalArticle fetchByG_A_First(long groupId, String articleId,
9391                    OrderByComparator<JournalArticle> orderByComparator) {
9392                    List<JournalArticle> list = findByG_A(groupId, articleId, 0, 1,
9393                                    orderByComparator);
9394    
9395                    if (!list.isEmpty()) {
9396                            return list.get(0);
9397                    }
9398    
9399                    return null;
9400            }
9401    
9402            /**
9403             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9404             *
9405             * @param groupId the group ID
9406             * @param articleId the article ID
9407             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9408             * @return the last matching journal article
9409             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9410             */
9411            @Override
9412            public JournalArticle findByG_A_Last(long groupId, String articleId,
9413                    OrderByComparator<JournalArticle> orderByComparator)
9414                    throws NoSuchArticleException {
9415                    JournalArticle journalArticle = fetchByG_A_Last(groupId, articleId,
9416                                    orderByComparator);
9417    
9418                    if (journalArticle != null) {
9419                            return journalArticle;
9420                    }
9421    
9422                    StringBundler msg = new StringBundler(6);
9423    
9424                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9425    
9426                    msg.append("groupId=");
9427                    msg.append(groupId);
9428    
9429                    msg.append(", articleId=");
9430                    msg.append(articleId);
9431    
9432                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9433    
9434                    throw new NoSuchArticleException(msg.toString());
9435            }
9436    
9437            /**
9438             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9439             *
9440             * @param groupId the group ID
9441             * @param articleId the article ID
9442             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9443             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
9444             */
9445            @Override
9446            public JournalArticle fetchByG_A_Last(long groupId, String articleId,
9447                    OrderByComparator<JournalArticle> orderByComparator) {
9448                    int count = countByG_A(groupId, articleId);
9449    
9450                    if (count == 0) {
9451                            return null;
9452                    }
9453    
9454                    List<JournalArticle> list = findByG_A(groupId, articleId, count - 1,
9455                                    count, orderByComparator);
9456    
9457                    if (!list.isEmpty()) {
9458                            return list.get(0);
9459                    }
9460    
9461                    return null;
9462            }
9463    
9464            /**
9465             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9466             *
9467             * @param id the primary key of the current journal article
9468             * @param groupId the group ID
9469             * @param articleId the article ID
9470             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9471             * @return the previous, current, and next journal article
9472             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
9473             */
9474            @Override
9475            public JournalArticle[] findByG_A_PrevAndNext(long id, long groupId,
9476                    String articleId, OrderByComparator<JournalArticle> orderByComparator)
9477                    throws NoSuchArticleException {
9478                    JournalArticle journalArticle = findByPrimaryKey(id);
9479    
9480                    Session session = null;
9481    
9482                    try {
9483                            session = openSession();
9484    
9485                            JournalArticle[] array = new JournalArticleImpl[3];
9486    
9487                            array[0] = getByG_A_PrevAndNext(session, journalArticle, groupId,
9488                                            articleId, orderByComparator, true);
9489    
9490                            array[1] = journalArticle;
9491    
9492                            array[2] = getByG_A_PrevAndNext(session, journalArticle, groupId,
9493                                            articleId, orderByComparator, false);
9494    
9495                            return array;
9496                    }
9497                    catch (Exception e) {
9498                            throw processException(e);
9499                    }
9500                    finally {
9501                            closeSession(session);
9502                    }
9503            }
9504    
9505            protected JournalArticle getByG_A_PrevAndNext(Session session,
9506                    JournalArticle journalArticle, long groupId, String articleId,
9507                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
9508                    StringBundler query = null;
9509    
9510                    if (orderByComparator != null) {
9511                            query = new StringBundler(6 +
9512                                            (orderByComparator.getOrderByFields().length * 6));
9513                    }
9514                    else {
9515                            query = new StringBundler(3);
9516                    }
9517    
9518                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9519    
9520                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
9521    
9522                    boolean bindArticleId = false;
9523    
9524                    if (articleId == null) {
9525                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
9526                    }
9527                    else if (articleId.equals(StringPool.BLANK)) {
9528                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
9529                    }
9530                    else {
9531                            bindArticleId = true;
9532    
9533                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
9534                    }
9535    
9536                    if (orderByComparator != null) {
9537                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9538    
9539                            if (orderByConditionFields.length > 0) {
9540                                    query.append(WHERE_AND);
9541                            }
9542    
9543                            for (int i = 0; i < orderByConditionFields.length; i++) {
9544                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9545                                    query.append(orderByConditionFields[i]);
9546    
9547                                    if ((i + 1) < orderByConditionFields.length) {
9548                                            if (orderByComparator.isAscending() ^ previous) {
9549                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9550                                            }
9551                                            else {
9552                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9553                                            }
9554                                    }
9555                                    else {
9556                                            if (orderByComparator.isAscending() ^ previous) {
9557                                                    query.append(WHERE_GREATER_THAN);
9558                                            }
9559                                            else {
9560                                                    query.append(WHERE_LESSER_THAN);
9561                                            }
9562                                    }
9563                            }
9564    
9565                            query.append(ORDER_BY_CLAUSE);
9566    
9567                            String[] orderByFields = orderByComparator.getOrderByFields();
9568    
9569                            for (int i = 0; i < orderByFields.length; i++) {
9570                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9571                                    query.append(orderByFields[i]);
9572    
9573                                    if ((i + 1) < orderByFields.length) {
9574                                            if (orderByComparator.isAscending() ^ previous) {
9575                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9576                                            }
9577                                            else {
9578                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9579                                            }
9580                                    }
9581                                    else {
9582                                            if (orderByComparator.isAscending() ^ previous) {
9583                                                    query.append(ORDER_BY_ASC);
9584                                            }
9585                                            else {
9586                                                    query.append(ORDER_BY_DESC);
9587                                            }
9588                                    }
9589                            }
9590                    }
9591                    else {
9592                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9593                    }
9594    
9595                    String sql = query.toString();
9596    
9597                    Query q = session.createQuery(sql);
9598    
9599                    q.setFirstResult(0);
9600                    q.setMaxResults(2);
9601    
9602                    QueryPos qPos = QueryPos.getInstance(q);
9603    
9604                    qPos.add(groupId);
9605    
9606                    if (bindArticleId) {
9607                            qPos.add(articleId);
9608                    }
9609    
9610                    if (orderByComparator != null) {
9611                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
9612    
9613                            for (Object value : values) {
9614                                    qPos.add(value);
9615                            }
9616                    }
9617    
9618                    List<JournalArticle> list = q.list();
9619    
9620                    if (list.size() == 2) {
9621                            return list.get(1);
9622                    }
9623                    else {
9624                            return null;
9625                    }
9626            }
9627    
9628            /**
9629             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
9630             *
9631             * @param groupId the group ID
9632             * @param articleId the article ID
9633             * @return the matching journal articles that the user has permission to view
9634             */
9635            @Override
9636            public List<JournalArticle> filterFindByG_A(long groupId, String articleId) {
9637                    return filterFindByG_A(groupId, articleId, QueryUtil.ALL_POS,
9638                            QueryUtil.ALL_POS, null);
9639            }
9640    
9641            /**
9642             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
9643             *
9644             * <p>
9645             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
9646             * </p>
9647             *
9648             * @param groupId the group ID
9649             * @param articleId the article ID
9650             * @param start the lower bound of the range of journal articles
9651             * @param end the upper bound of the range of journal articles (not inclusive)
9652             * @return the range of matching journal articles that the user has permission to view
9653             */
9654            @Override
9655            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
9656                    int start, int end) {
9657                    return filterFindByG_A(groupId, articleId, start, end, null);
9658            }
9659    
9660            /**
9661             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and articleId = &#63;.
9662             *
9663             * <p>
9664             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
9665             * </p>
9666             *
9667             * @param groupId the group ID
9668             * @param articleId the article ID
9669             * @param start the lower bound of the range of journal articles
9670             * @param end the upper bound of the range of journal articles (not inclusive)
9671             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9672             * @return the ordered range of matching journal articles that the user has permission to view
9673             */
9674            @Override
9675            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
9676                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
9677                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9678                            return findByG_A(groupId, articleId, start, end, orderByComparator);
9679                    }
9680    
9681                    StringBundler query = null;
9682    
9683                    if (orderByComparator != null) {
9684                            query = new StringBundler(4 +
9685                                            (orderByComparator.getOrderByFields().length * 3));
9686                    }
9687                    else {
9688                            query = new StringBundler(4);
9689                    }
9690    
9691                    if (getDB().isSupportsInlineDistinct()) {
9692                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
9693                    }
9694                    else {
9695                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
9696                    }
9697    
9698                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
9699    
9700                    boolean bindArticleId = false;
9701    
9702                    if (articleId == null) {
9703                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
9704                    }
9705                    else if (articleId.equals(StringPool.BLANK)) {
9706                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
9707                    }
9708                    else {
9709                            bindArticleId = true;
9710    
9711                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
9712                    }
9713    
9714                    if (!getDB().isSupportsInlineDistinct()) {
9715                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
9716                    }
9717    
9718                    if (orderByComparator != null) {
9719                            if (getDB().isSupportsInlineDistinct()) {
9720                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9721                                            orderByComparator, true);
9722                            }
9723                            else {
9724                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9725                                            orderByComparator, true);
9726                            }
9727                    }
9728                    else {
9729                            if (getDB().isSupportsInlineDistinct()) {
9730                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9731                            }
9732                            else {
9733                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
9734                            }
9735                    }
9736    
9737                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9738                                    JournalArticle.class.getName(),
9739                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9740    
9741                    Session session = null;
9742    
9743                    try {
9744                            session = openSession();
9745    
9746                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
9747    
9748                            if (getDB().isSupportsInlineDistinct()) {
9749                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
9750                            }
9751                            else {
9752                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
9753                            }
9754    
9755                            QueryPos qPos = QueryPos.getInstance(q);
9756    
9757                            qPos.add(groupId);
9758    
9759                            if (bindArticleId) {
9760                                    qPos.add(articleId);
9761                            }
9762    
9763                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
9764                                    end);
9765                    }
9766                    catch (Exception e) {
9767                            throw processException(e);
9768                    }
9769                    finally {
9770                            closeSession(session);
9771                    }
9772            }
9773    
9774            /**
9775             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
9776             *
9777             * @param id the primary key of the current journal article
9778             * @param groupId the group ID
9779             * @param articleId the article ID
9780             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9781             * @return the previous, current, and next journal article
9782             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
9783             */
9784            @Override
9785            public JournalArticle[] filterFindByG_A_PrevAndNext(long id, long groupId,
9786                    String articleId, OrderByComparator<JournalArticle> orderByComparator)
9787                    throws NoSuchArticleException {
9788                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9789                            return findByG_A_PrevAndNext(id, groupId, articleId,
9790                                    orderByComparator);
9791                    }
9792    
9793                    JournalArticle journalArticle = findByPrimaryKey(id);
9794    
9795                    Session session = null;
9796    
9797                    try {
9798                            session = openSession();
9799    
9800                            JournalArticle[] array = new JournalArticleImpl[3];
9801    
9802                            array[0] = filterGetByG_A_PrevAndNext(session, journalArticle,
9803                                            groupId, articleId, orderByComparator, true);
9804    
9805                            array[1] = journalArticle;
9806    
9807                            array[2] = filterGetByG_A_PrevAndNext(session, journalArticle,
9808                                            groupId, articleId, orderByComparator, false);
9809    
9810                            return array;
9811                    }
9812                    catch (Exception e) {
9813                            throw processException(e);
9814                    }
9815                    finally {
9816                            closeSession(session);
9817                    }
9818            }
9819    
9820            protected JournalArticle filterGetByG_A_PrevAndNext(Session session,
9821                    JournalArticle journalArticle, long groupId, String articleId,
9822                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
9823                    StringBundler query = null;
9824    
9825                    if (orderByComparator != null) {
9826                            query = new StringBundler(6 +
9827                                            (orderByComparator.getOrderByFields().length * 6));
9828                    }
9829                    else {
9830                            query = new StringBundler(3);
9831                    }
9832    
9833                    if (getDB().isSupportsInlineDistinct()) {
9834                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
9835                    }
9836                    else {
9837                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
9838                    }
9839    
9840                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
9841    
9842                    boolean bindArticleId = false;
9843    
9844                    if (articleId == null) {
9845                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
9846                    }
9847                    else if (articleId.equals(StringPool.BLANK)) {
9848                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
9849                    }
9850                    else {
9851                            bindArticleId = true;
9852    
9853                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
9854                    }
9855    
9856                    if (!getDB().isSupportsInlineDistinct()) {
9857                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
9858                    }
9859    
9860                    if (orderByComparator != null) {
9861                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9862    
9863                            if (orderByConditionFields.length > 0) {
9864                                    query.append(WHERE_AND);
9865                            }
9866    
9867                            for (int i = 0; i < orderByConditionFields.length; i++) {
9868                                    if (getDB().isSupportsInlineDistinct()) {
9869                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9870                                    }
9871                                    else {
9872                                            query.append(_ORDER_BY_ENTITY_TABLE);
9873                                    }
9874    
9875                                    query.append(orderByConditionFields[i]);
9876    
9877                                    if ((i + 1) < orderByConditionFields.length) {
9878                                            if (orderByComparator.isAscending() ^ previous) {
9879                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9880                                            }
9881                                            else {
9882                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9883                                            }
9884                                    }
9885                                    else {
9886                                            if (orderByComparator.isAscending() ^ previous) {
9887                                                    query.append(WHERE_GREATER_THAN);
9888                                            }
9889                                            else {
9890                                                    query.append(WHERE_LESSER_THAN);
9891                                            }
9892                                    }
9893                            }
9894    
9895                            query.append(ORDER_BY_CLAUSE);
9896    
9897                            String[] orderByFields = orderByComparator.getOrderByFields();
9898    
9899                            for (int i = 0; i < orderByFields.length; i++) {
9900                                    if (getDB().isSupportsInlineDistinct()) {
9901                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9902                                    }
9903                                    else {
9904                                            query.append(_ORDER_BY_ENTITY_TABLE);
9905                                    }
9906    
9907                                    query.append(orderByFields[i]);
9908    
9909                                    if ((i + 1) < orderByFields.length) {
9910                                            if (orderByComparator.isAscending() ^ previous) {
9911                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9912                                            }
9913                                            else {
9914                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9915                                            }
9916                                    }
9917                                    else {
9918                                            if (orderByComparator.isAscending() ^ previous) {
9919                                                    query.append(ORDER_BY_ASC);
9920                                            }
9921                                            else {
9922                                                    query.append(ORDER_BY_DESC);
9923                                            }
9924                                    }
9925                            }
9926                    }
9927                    else {
9928                            if (getDB().isSupportsInlineDistinct()) {
9929                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9930                            }
9931                            else {
9932                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
9933                            }
9934                    }
9935    
9936                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9937                                    JournalArticle.class.getName(),
9938                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9939    
9940                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
9941    
9942                    q.setFirstResult(0);
9943                    q.setMaxResults(2);
9944    
9945                    if (getDB().isSupportsInlineDistinct()) {
9946                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
9947                    }
9948                    else {
9949                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
9950                    }
9951    
9952                    QueryPos qPos = QueryPos.getInstance(q);
9953    
9954                    qPos.add(groupId);
9955    
9956                    if (bindArticleId) {
9957                            qPos.add(articleId);
9958                    }
9959    
9960                    if (orderByComparator != null) {
9961                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
9962    
9963                            for (Object value : values) {
9964                                    qPos.add(value);
9965                            }
9966                    }
9967    
9968                    List<JournalArticle> list = q.list();
9969    
9970                    if (list.size() == 2) {
9971                            return list.get(1);
9972                    }
9973                    else {
9974                            return null;
9975                    }
9976            }
9977    
9978            /**
9979             * Removes all the journal articles where groupId = &#63; and articleId = &#63; from the database.
9980             *
9981             * @param groupId the group ID
9982             * @param articleId the article ID
9983             */
9984            @Override
9985            public void removeByG_A(long groupId, String articleId) {
9986                    for (JournalArticle journalArticle : findByG_A(groupId, articleId,
9987                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9988                            remove(journalArticle);
9989                    }
9990            }
9991    
9992            /**
9993             * Returns the number of journal articles where groupId = &#63; and articleId = &#63;.
9994             *
9995             * @param groupId the group ID
9996             * @param articleId the article ID
9997             * @return the number of matching journal articles
9998             */
9999            @Override
10000            public int countByG_A(long groupId, String articleId) {
10001                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A;
10002    
10003                    Object[] finderArgs = new Object[] { groupId, articleId };
10004    
10005                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10006                                    this);
10007    
10008                    if (count == null) {
10009                            StringBundler query = new StringBundler(3);
10010    
10011                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
10012    
10013                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
10014    
10015                            boolean bindArticleId = false;
10016    
10017                            if (articleId == null) {
10018                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
10019                            }
10020                            else if (articleId.equals(StringPool.BLANK)) {
10021                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
10022                            }
10023                            else {
10024                                    bindArticleId = true;
10025    
10026                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
10027                            }
10028    
10029                            String sql = query.toString();
10030    
10031                            Session session = null;
10032    
10033                            try {
10034                                    session = openSession();
10035    
10036                                    Query q = session.createQuery(sql);
10037    
10038                                    QueryPos qPos = QueryPos.getInstance(q);
10039    
10040                                    qPos.add(groupId);
10041    
10042                                    if (bindArticleId) {
10043                                            qPos.add(articleId);
10044                                    }
10045    
10046                                    count = (Long)q.uniqueResult();
10047    
10048                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
10049                            }
10050                            catch (Exception e) {
10051                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10052    
10053                                    throw processException(e);
10054                            }
10055                            finally {
10056                                    closeSession(session);
10057                            }
10058                    }
10059    
10060                    return count.intValue();
10061            }
10062    
10063            /**
10064             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
10065             *
10066             * @param groupId the group ID
10067             * @param articleId the article ID
10068             * @return the number of matching journal articles that the user has permission to view
10069             */
10070            @Override
10071            public int filterCountByG_A(long groupId, String articleId) {
10072                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10073                            return countByG_A(groupId, articleId);
10074                    }
10075    
10076                    StringBundler query = new StringBundler(3);
10077    
10078                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
10079    
10080                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
10081    
10082                    boolean bindArticleId = false;
10083    
10084                    if (articleId == null) {
10085                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
10086                    }
10087                    else if (articleId.equals(StringPool.BLANK)) {
10088                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
10089                    }
10090                    else {
10091                            bindArticleId = true;
10092    
10093                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
10094                    }
10095    
10096                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10097                                    JournalArticle.class.getName(),
10098                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10099    
10100                    Session session = null;
10101    
10102                    try {
10103                            session = openSession();
10104    
10105                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
10106    
10107                            q.addScalar(COUNT_COLUMN_NAME,
10108                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
10109    
10110                            QueryPos qPos = QueryPos.getInstance(q);
10111    
10112                            qPos.add(groupId);
10113    
10114                            if (bindArticleId) {
10115                                    qPos.add(articleId);
10116                            }
10117    
10118                            Long count = (Long)q.uniqueResult();
10119    
10120                            return count.intValue();
10121                    }
10122                    catch (Exception e) {
10123                            throw processException(e);
10124                    }
10125                    finally {
10126                            closeSession(session);
10127                    }
10128            }
10129    
10130            private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalArticle.groupId = ? AND ";
10131            private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalArticle.articleId IS NULL";
10132            private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalArticle.articleId = ?";
10133            private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '')";
10134            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10135                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
10136                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
10137                            "findByG_UT",
10138                            new String[] {
10139                                    Long.class.getName(), String.class.getName(),
10140                                    
10141                            Integer.class.getName(), Integer.class.getName(),
10142                                    OrderByComparator.class.getName()
10143                            });
10144            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10145                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
10146                            JournalArticleImpl.class,
10147                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_UT",
10148                            new String[] { Long.class.getName(), String.class.getName() },
10149                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
10150                            JournalArticleModelImpl.URLTITLE_COLUMN_BITMASK |
10151                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
10152                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
10153            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10154                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
10155                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT",
10156                            new String[] { Long.class.getName(), String.class.getName() });
10157    
10158            /**
10159             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63;.
10160             *
10161             * @param groupId the group ID
10162             * @param urlTitle the url title
10163             * @return the matching journal articles
10164             */
10165            @Override
10166            public List<JournalArticle> findByG_UT(long groupId, String urlTitle) {
10167                    return findByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
10168                            QueryUtil.ALL_POS, null);
10169            }
10170    
10171            /**
10172             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
10173             *
10174             * <p>
10175             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
10176             * </p>
10177             *
10178             * @param groupId the group ID
10179             * @param urlTitle the url title
10180             * @param start the lower bound of the range of journal articles
10181             * @param end the upper bound of the range of journal articles (not inclusive)
10182             * @return the range of matching journal articles
10183             */
10184            @Override
10185            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
10186                    int start, int end) {
10187                    return findByG_UT(groupId, urlTitle, start, end, null);
10188            }
10189    
10190            /**
10191             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
10192             *
10193             * <p>
10194             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
10195             * </p>
10196             *
10197             * @param groupId the group ID
10198             * @param urlTitle the url title
10199             * @param start the lower bound of the range of journal articles
10200             * @param end the upper bound of the range of journal articles (not inclusive)
10201             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10202             * @return the ordered range of matching journal articles
10203             */
10204            @Override
10205            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
10206                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
10207                    boolean pagination = true;
10208                    FinderPath finderPath = null;
10209                    Object[] finderArgs = null;
10210    
10211                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10212                                    (orderByComparator == null)) {
10213                            pagination = false;
10214                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT;
10215                            finderArgs = new Object[] { groupId, urlTitle };
10216                    }
10217                    else {
10218                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT;
10219                            finderArgs = new Object[] {
10220                                            groupId, urlTitle,
10221                                            
10222                                            start, end, orderByComparator
10223                                    };
10224                    }
10225    
10226                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
10227                                    finderArgs, this);
10228    
10229                    if ((list != null) && !list.isEmpty()) {
10230                            for (JournalArticle journalArticle : list) {
10231                                    if ((groupId != journalArticle.getGroupId()) ||
10232                                                    !Validator.equals(urlTitle, journalArticle.getUrlTitle())) {
10233                                            list = null;
10234    
10235                                            break;
10236                                    }
10237                            }
10238                    }
10239    
10240                    if (list == null) {
10241                            StringBundler query = null;
10242    
10243                            if (orderByComparator != null) {
10244                                    query = new StringBundler(4 +
10245                                                    (orderByComparator.getOrderByFields().length * 3));
10246                            }
10247                            else {
10248                                    query = new StringBundler(4);
10249                            }
10250    
10251                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10252    
10253                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10254    
10255                            boolean bindUrlTitle = false;
10256    
10257                            if (urlTitle == null) {
10258                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10259                            }
10260                            else if (urlTitle.equals(StringPool.BLANK)) {
10261                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
10262                            }
10263                            else {
10264                                    bindUrlTitle = true;
10265    
10266                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
10267                            }
10268    
10269                            if (orderByComparator != null) {
10270                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10271                                            orderByComparator);
10272                            }
10273                            else
10274                             if (pagination) {
10275                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10276                            }
10277    
10278                            String sql = query.toString();
10279    
10280                            Session session = null;
10281    
10282                            try {
10283                                    session = openSession();
10284    
10285                                    Query q = session.createQuery(sql);
10286    
10287                                    QueryPos qPos = QueryPos.getInstance(q);
10288    
10289                                    qPos.add(groupId);
10290    
10291                                    if (bindUrlTitle) {
10292                                            qPos.add(urlTitle);
10293                                    }
10294    
10295                                    if (!pagination) {
10296                                            list = (List<JournalArticle>)QueryUtil.list(q,
10297                                                            getDialect(), start, end, false);
10298    
10299                                            Collections.sort(list);
10300    
10301                                            list = Collections.unmodifiableList(list);
10302                                    }
10303                                    else {
10304                                            list = (List<JournalArticle>)QueryUtil.list(q,
10305                                                            getDialect(), start, end);
10306                                    }
10307    
10308                                    cacheResult(list);
10309    
10310                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
10311                            }
10312                            catch (Exception e) {
10313                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10314    
10315                                    throw processException(e);
10316                            }
10317                            finally {
10318                                    closeSession(session);
10319                            }
10320                    }
10321    
10322                    return list;
10323            }
10324    
10325            /**
10326             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10327             *
10328             * @param groupId the group ID
10329             * @param urlTitle the url title
10330             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10331             * @return the first matching journal article
10332             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10333             */
10334            @Override
10335            public JournalArticle findByG_UT_First(long groupId, String urlTitle,
10336                    OrderByComparator<JournalArticle> orderByComparator)
10337                    throws NoSuchArticleException {
10338                    JournalArticle journalArticle = fetchByG_UT_First(groupId, urlTitle,
10339                                    orderByComparator);
10340    
10341                    if (journalArticle != null) {
10342                            return journalArticle;
10343                    }
10344    
10345                    StringBundler msg = new StringBundler(6);
10346    
10347                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10348    
10349                    msg.append("groupId=");
10350                    msg.append(groupId);
10351    
10352                    msg.append(", urlTitle=");
10353                    msg.append(urlTitle);
10354    
10355                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10356    
10357                    throw new NoSuchArticleException(msg.toString());
10358            }
10359    
10360            /**
10361             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10362             *
10363             * @param groupId the group ID
10364             * @param urlTitle the url title
10365             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10366             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
10367             */
10368            @Override
10369            public JournalArticle fetchByG_UT_First(long groupId, String urlTitle,
10370                    OrderByComparator<JournalArticle> orderByComparator) {
10371                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, 0, 1,
10372                                    orderByComparator);
10373    
10374                    if (!list.isEmpty()) {
10375                            return list.get(0);
10376                    }
10377    
10378                    return null;
10379            }
10380    
10381            /**
10382             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10383             *
10384             * @param groupId the group ID
10385             * @param urlTitle the url title
10386             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10387             * @return the last matching journal article
10388             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10389             */
10390            @Override
10391            public JournalArticle findByG_UT_Last(long groupId, String urlTitle,
10392                    OrderByComparator<JournalArticle> orderByComparator)
10393                    throws NoSuchArticleException {
10394                    JournalArticle journalArticle = fetchByG_UT_Last(groupId, urlTitle,
10395                                    orderByComparator);
10396    
10397                    if (journalArticle != null) {
10398                            return journalArticle;
10399                    }
10400    
10401                    StringBundler msg = new StringBundler(6);
10402    
10403                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10404    
10405                    msg.append("groupId=");
10406                    msg.append(groupId);
10407    
10408                    msg.append(", urlTitle=");
10409                    msg.append(urlTitle);
10410    
10411                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10412    
10413                    throw new NoSuchArticleException(msg.toString());
10414            }
10415    
10416            /**
10417             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10418             *
10419             * @param groupId the group ID
10420             * @param urlTitle the url title
10421             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10422             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
10423             */
10424            @Override
10425            public JournalArticle fetchByG_UT_Last(long groupId, String urlTitle,
10426                    OrderByComparator<JournalArticle> orderByComparator) {
10427                    int count = countByG_UT(groupId, urlTitle);
10428    
10429                    if (count == 0) {
10430                            return null;
10431                    }
10432    
10433                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, count - 1,
10434                                    count, orderByComparator);
10435    
10436                    if (!list.isEmpty()) {
10437                            return list.get(0);
10438                    }
10439    
10440                    return null;
10441            }
10442    
10443            /**
10444             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10445             *
10446             * @param id the primary key of the current journal article
10447             * @param groupId the group ID
10448             * @param urlTitle the url title
10449             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10450             * @return the previous, current, and next journal article
10451             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10452             */
10453            @Override
10454            public JournalArticle[] findByG_UT_PrevAndNext(long id, long groupId,
10455                    String urlTitle, OrderByComparator<JournalArticle> orderByComparator)
10456                    throws NoSuchArticleException {
10457                    JournalArticle journalArticle = findByPrimaryKey(id);
10458    
10459                    Session session = null;
10460    
10461                    try {
10462                            session = openSession();
10463    
10464                            JournalArticle[] array = new JournalArticleImpl[3];
10465    
10466                            array[0] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
10467                                            urlTitle, orderByComparator, true);
10468    
10469                            array[1] = journalArticle;
10470    
10471                            array[2] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
10472                                            urlTitle, orderByComparator, false);
10473    
10474                            return array;
10475                    }
10476                    catch (Exception e) {
10477                            throw processException(e);
10478                    }
10479                    finally {
10480                            closeSession(session);
10481                    }
10482            }
10483    
10484            protected JournalArticle getByG_UT_PrevAndNext(Session session,
10485                    JournalArticle journalArticle, long groupId, String urlTitle,
10486                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
10487                    StringBundler query = null;
10488    
10489                    if (orderByComparator != null) {
10490                            query = new StringBundler(6 +
10491                                            (orderByComparator.getOrderByFields().length * 6));
10492                    }
10493                    else {
10494                            query = new StringBundler(3);
10495                    }
10496    
10497                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10498    
10499                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10500    
10501                    boolean bindUrlTitle = false;
10502    
10503                    if (urlTitle == null) {
10504                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10505                    }
10506                    else if (urlTitle.equals(StringPool.BLANK)) {
10507                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
10508                    }
10509                    else {
10510                            bindUrlTitle = true;
10511    
10512                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
10513                    }
10514    
10515                    if (orderByComparator != null) {
10516                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10517    
10518                            if (orderByConditionFields.length > 0) {
10519                                    query.append(WHERE_AND);
10520                            }
10521    
10522                            for (int i = 0; i < orderByConditionFields.length; i++) {
10523                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10524                                    query.append(orderByConditionFields[i]);
10525    
10526                                    if ((i + 1) < orderByConditionFields.length) {
10527                                            if (orderByComparator.isAscending() ^ previous) {
10528                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10529                                            }
10530                                            else {
10531                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10532                                            }
10533                                    }
10534                                    else {
10535                                            if (orderByComparator.isAscending() ^ previous) {
10536                                                    query.append(WHERE_GREATER_THAN);
10537                                            }
10538                                            else {
10539                                                    query.append(WHERE_LESSER_THAN);
10540                                            }
10541                                    }
10542                            }
10543    
10544                            query.append(ORDER_BY_CLAUSE);
10545    
10546                            String[] orderByFields = orderByComparator.getOrderByFields();
10547    
10548                            for (int i = 0; i < orderByFields.length; i++) {
10549                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10550                                    query.append(orderByFields[i]);
10551    
10552                                    if ((i + 1) < orderByFields.length) {
10553                                            if (orderByComparator.isAscending() ^ previous) {
10554                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10555                                            }
10556                                            else {
10557                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10558                                            }
10559                                    }
10560                                    else {
10561                                            if (orderByComparator.isAscending() ^ previous) {
10562                                                    query.append(ORDER_BY_ASC);
10563                                            }
10564                                            else {
10565                                                    query.append(ORDER_BY_DESC);
10566                                            }
10567                                    }
10568                            }
10569                    }
10570                    else {
10571                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10572                    }
10573    
10574                    String sql = query.toString();
10575    
10576                    Query q = session.createQuery(sql);
10577    
10578                    q.setFirstResult(0);
10579                    q.setMaxResults(2);
10580    
10581                    QueryPos qPos = QueryPos.getInstance(q);
10582    
10583                    qPos.add(groupId);
10584    
10585                    if (bindUrlTitle) {
10586                            qPos.add(urlTitle);
10587                    }
10588    
10589                    if (orderByComparator != null) {
10590                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10591    
10592                            for (Object value : values) {
10593                                    qPos.add(value);
10594                            }
10595                    }
10596    
10597                    List<JournalArticle> list = q.list();
10598    
10599                    if (list.size() == 2) {
10600                            return list.get(1);
10601                    }
10602                    else {
10603                            return null;
10604                    }
10605            }
10606    
10607            /**
10608             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
10609             *
10610             * @param groupId the group ID
10611             * @param urlTitle the url title
10612             * @return the matching journal articles that the user has permission to view
10613             */
10614            @Override
10615            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle) {
10616                    return filterFindByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
10617                            QueryUtil.ALL_POS, null);
10618            }
10619    
10620            /**
10621             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
10622             *
10623             * <p>
10624             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
10625             * </p>
10626             *
10627             * @param groupId the group ID
10628             * @param urlTitle the url title
10629             * @param start the lower bound of the range of journal articles
10630             * @param end the upper bound of the range of journal articles (not inclusive)
10631             * @return the range of matching journal articles that the user has permission to view
10632             */
10633            @Override
10634            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
10635                    int start, int end) {
10636                    return filterFindByG_UT(groupId, urlTitle, start, end, null);
10637            }
10638    
10639            /**
10640             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and urlTitle = &#63;.
10641             *
10642             * <p>
10643             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
10644             * </p>
10645             *
10646             * @param groupId the group ID
10647             * @param urlTitle the url title
10648             * @param start the lower bound of the range of journal articles
10649             * @param end the upper bound of the range of journal articles (not inclusive)
10650             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10651             * @return the ordered range of matching journal articles that the user has permission to view
10652             */
10653            @Override
10654            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
10655                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
10656                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10657                            return findByG_UT(groupId, urlTitle, start, end, orderByComparator);
10658                    }
10659    
10660                    StringBundler query = null;
10661    
10662                    if (orderByComparator != null) {
10663                            query = new StringBundler(4 +
10664                                            (orderByComparator.getOrderByFields().length * 3));
10665                    }
10666                    else {
10667                            query = new StringBundler(4);
10668                    }
10669    
10670                    if (getDB().isSupportsInlineDistinct()) {
10671                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
10672                    }
10673                    else {
10674                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
10675                    }
10676    
10677                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10678    
10679                    boolean bindUrlTitle = false;
10680    
10681                    if (urlTitle == null) {
10682                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10683                    }
10684                    else if (urlTitle.equals(StringPool.BLANK)) {
10685                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
10686                    }
10687                    else {
10688                            bindUrlTitle = true;
10689    
10690                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
10691                    }
10692    
10693                    if (!getDB().isSupportsInlineDistinct()) {
10694                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
10695                    }
10696    
10697                    if (orderByComparator != null) {
10698                            if (getDB().isSupportsInlineDistinct()) {
10699                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10700                                            orderByComparator, true);
10701                            }
10702                            else {
10703                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10704                                            orderByComparator, true);
10705                            }
10706                    }
10707                    else {
10708                            if (getDB().isSupportsInlineDistinct()) {
10709                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10710                            }
10711                            else {
10712                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
10713                            }
10714                    }
10715    
10716                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10717                                    JournalArticle.class.getName(),
10718                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10719    
10720                    Session session = null;
10721    
10722                    try {
10723                            session = openSession();
10724    
10725                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
10726    
10727                            if (getDB().isSupportsInlineDistinct()) {
10728                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
10729                            }
10730                            else {
10731                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
10732                            }
10733    
10734                            QueryPos qPos = QueryPos.getInstance(q);
10735    
10736                            qPos.add(groupId);
10737    
10738                            if (bindUrlTitle) {
10739                                    qPos.add(urlTitle);
10740                            }
10741    
10742                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
10743                                    end);
10744                    }
10745                    catch (Exception e) {
10746                            throw processException(e);
10747                    }
10748                    finally {
10749                            closeSession(session);
10750                    }
10751            }
10752    
10753            /**
10754             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
10755             *
10756             * @param id the primary key of the current journal article
10757             * @param groupId the group ID
10758             * @param urlTitle the url title
10759             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10760             * @return the previous, current, and next journal article
10761             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10762             */
10763            @Override
10764            public JournalArticle[] filterFindByG_UT_PrevAndNext(long id, long groupId,
10765                    String urlTitle, OrderByComparator<JournalArticle> orderByComparator)
10766                    throws NoSuchArticleException {
10767                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10768                            return findByG_UT_PrevAndNext(id, groupId, urlTitle,
10769                                    orderByComparator);
10770                    }
10771    
10772                    JournalArticle journalArticle = findByPrimaryKey(id);
10773    
10774                    Session session = null;
10775    
10776                    try {
10777                            session = openSession();
10778    
10779                            JournalArticle[] array = new JournalArticleImpl[3];
10780    
10781                            array[0] = filterGetByG_UT_PrevAndNext(session, journalArticle,
10782                                            groupId, urlTitle, orderByComparator, true);
10783    
10784                            array[1] = journalArticle;
10785    
10786                            array[2] = filterGetByG_UT_PrevAndNext(session, journalArticle,
10787                                            groupId, urlTitle, orderByComparator, false);
10788    
10789                            return array;
10790                    }
10791                    catch (Exception e) {
10792                            throw processException(e);
10793                    }
10794                    finally {
10795                            closeSession(session);
10796                    }
10797            }
10798    
10799            protected JournalArticle filterGetByG_UT_PrevAndNext(Session session,
10800                    JournalArticle journalArticle, long groupId, String urlTitle,
10801                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
10802                    StringBundler query = null;
10803    
10804                    if (orderByComparator != null) {
10805                            query = new StringBundler(6 +
10806                                            (orderByComparator.getOrderByFields().length * 6));
10807                    }
10808                    else {
10809                            query = new StringBundler(3);
10810                    }
10811    
10812                    if (getDB().isSupportsInlineDistinct()) {
10813                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
10814                    }
10815                    else {
10816                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
10817                    }
10818    
10819                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10820    
10821                    boolean bindUrlTitle = false;
10822    
10823                    if (urlTitle == null) {
10824                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10825                    }
10826                    else if (urlTitle.equals(StringPool.BLANK)) {
10827                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
10828                    }
10829                    else {
10830                            bindUrlTitle = true;
10831    
10832                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
10833                    }
10834    
10835                    if (!getDB().isSupportsInlineDistinct()) {
10836                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
10837                    }
10838    
10839                    if (orderByComparator != null) {
10840                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10841    
10842                            if (orderByConditionFields.length > 0) {
10843                                    query.append(WHERE_AND);
10844                            }
10845    
10846                            for (int i = 0; i < orderByConditionFields.length; i++) {
10847                                    if (getDB().isSupportsInlineDistinct()) {
10848                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10849                                    }
10850                                    else {
10851                                            query.append(_ORDER_BY_ENTITY_TABLE);
10852                                    }
10853    
10854                                    query.append(orderByConditionFields[i]);
10855    
10856                                    if ((i + 1) < orderByConditionFields.length) {
10857                                            if (orderByComparator.isAscending() ^ previous) {
10858                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10859                                            }
10860                                            else {
10861                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10862                                            }
10863                                    }
10864                                    else {
10865                                            if (orderByComparator.isAscending() ^ previous) {
10866                                                    query.append(WHERE_GREATER_THAN);
10867                                            }
10868                                            else {
10869                                                    query.append(WHERE_LESSER_THAN);
10870                                            }
10871                                    }
10872                            }
10873    
10874                            query.append(ORDER_BY_CLAUSE);
10875    
10876                            String[] orderByFields = orderByComparator.getOrderByFields();
10877    
10878                            for (int i = 0; i < orderByFields.length; i++) {
10879                                    if (getDB().isSupportsInlineDistinct()) {
10880                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10881                                    }
10882                                    else {
10883                                            query.append(_ORDER_BY_ENTITY_TABLE);
10884                                    }
10885    
10886                                    query.append(orderByFields[i]);
10887    
10888                                    if ((i + 1) < orderByFields.length) {
10889                                            if (orderByComparator.isAscending() ^ previous) {
10890                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10891                                            }
10892                                            else {
10893                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10894                                            }
10895                                    }
10896                                    else {
10897                                            if (orderByComparator.isAscending() ^ previous) {
10898                                                    query.append(ORDER_BY_ASC);
10899                                            }
10900                                            else {
10901                                                    query.append(ORDER_BY_DESC);
10902                                            }
10903                                    }
10904                            }
10905                    }
10906                    else {
10907                            if (getDB().isSupportsInlineDistinct()) {
10908                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10909                            }
10910                            else {
10911                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
10912                            }
10913                    }
10914    
10915                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10916                                    JournalArticle.class.getName(),
10917                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10918    
10919                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
10920    
10921                    q.setFirstResult(0);
10922                    q.setMaxResults(2);
10923    
10924                    if (getDB().isSupportsInlineDistinct()) {
10925                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
10926                    }
10927                    else {
10928                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
10929                    }
10930    
10931                    QueryPos qPos = QueryPos.getInstance(q);
10932    
10933                    qPos.add(groupId);
10934    
10935                    if (bindUrlTitle) {
10936                            qPos.add(urlTitle);
10937                    }
10938    
10939                    if (orderByComparator != null) {
10940                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10941    
10942                            for (Object value : values) {
10943                                    qPos.add(value);
10944                            }
10945                    }
10946    
10947                    List<JournalArticle> list = q.list();
10948    
10949                    if (list.size() == 2) {
10950                            return list.get(1);
10951                    }
10952                    else {
10953                            return null;
10954                    }
10955            }
10956    
10957            /**
10958             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; from the database.
10959             *
10960             * @param groupId the group ID
10961             * @param urlTitle the url title
10962             */
10963            @Override
10964            public void removeByG_UT(long groupId, String urlTitle) {
10965                    for (JournalArticle journalArticle : findByG_UT(groupId, urlTitle,
10966                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10967                            remove(journalArticle);
10968                    }
10969            }
10970    
10971            /**
10972             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63;.
10973             *
10974             * @param groupId the group ID
10975             * @param urlTitle the url title
10976             * @return the number of matching journal articles
10977             */
10978            @Override
10979            public int countByG_UT(long groupId, String urlTitle) {
10980                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT;
10981    
10982                    Object[] finderArgs = new Object[] { groupId, urlTitle };
10983    
10984                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10985                                    this);
10986    
10987                    if (count == null) {
10988                            StringBundler query = new StringBundler(3);
10989    
10990                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
10991    
10992                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10993    
10994                            boolean bindUrlTitle = false;
10995    
10996                            if (urlTitle == null) {
10997                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10998                            }
10999                            else if (urlTitle.equals(StringPool.BLANK)) {
11000                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
11001                            }
11002                            else {
11003                                    bindUrlTitle = true;
11004    
11005                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
11006                            }
11007    
11008                            String sql = query.toString();
11009    
11010                            Session session = null;
11011    
11012                            try {
11013                                    session = openSession();
11014    
11015                                    Query q = session.createQuery(sql);
11016    
11017                                    QueryPos qPos = QueryPos.getInstance(q);
11018    
11019                                    qPos.add(groupId);
11020    
11021                                    if (bindUrlTitle) {
11022                                            qPos.add(urlTitle);
11023                                    }
11024    
11025                                    count = (Long)q.uniqueResult();
11026    
11027                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
11028                            }
11029                            catch (Exception e) {
11030                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11031    
11032                                    throw processException(e);
11033                            }
11034                            finally {
11035                                    closeSession(session);
11036                            }
11037                    }
11038    
11039                    return count.intValue();
11040            }
11041    
11042            /**
11043             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
11044             *
11045             * @param groupId the group ID
11046             * @param urlTitle the url title
11047             * @return the number of matching journal articles that the user has permission to view
11048             */
11049            @Override
11050            public int filterCountByG_UT(long groupId, String urlTitle) {
11051                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11052                            return countByG_UT(groupId, urlTitle);
11053                    }
11054    
11055                    StringBundler query = new StringBundler(3);
11056    
11057                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
11058    
11059                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
11060    
11061                    boolean bindUrlTitle = false;
11062    
11063                    if (urlTitle == null) {
11064                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
11065                    }
11066                    else if (urlTitle.equals(StringPool.BLANK)) {
11067                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
11068                    }
11069                    else {
11070                            bindUrlTitle = true;
11071    
11072                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
11073                    }
11074    
11075                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11076                                    JournalArticle.class.getName(),
11077                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11078    
11079                    Session session = null;
11080    
11081                    try {
11082                            session = openSession();
11083    
11084                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11085    
11086                            q.addScalar(COUNT_COLUMN_NAME,
11087                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11088    
11089                            QueryPos qPos = QueryPos.getInstance(q);
11090    
11091                            qPos.add(groupId);
11092    
11093                            if (bindUrlTitle) {
11094                                    qPos.add(urlTitle);
11095                            }
11096    
11097                            Long count = (Long)q.uniqueResult();
11098    
11099                            return count.intValue();
11100                    }
11101                    catch (Exception e) {
11102                            throw processException(e);
11103                    }
11104                    finally {
11105                            closeSession(session);
11106                    }
11107            }
11108    
11109            private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "journalArticle.groupId = ? AND ";
11110            private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "journalArticle.urlTitle IS NULL";
11111            private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "journalArticle.urlTitle = ?";
11112            private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = '')";
11113            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11114                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
11115                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
11116                            "findByG_S",
11117                            new String[] {
11118                                    Long.class.getName(), String.class.getName(),
11119                                    
11120                            Integer.class.getName(), Integer.class.getName(),
11121                                    OrderByComparator.class.getName()
11122                            });
11123            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11124                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
11125                            JournalArticleImpl.class,
11126                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
11127                            new String[] { Long.class.getName(), String.class.getName() },
11128                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
11129                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK |
11130                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
11131                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
11132            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11133                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
11134                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
11135                            new String[] { Long.class.getName(), String.class.getName() });
11136    
11137            /**
11138             * Returns all the journal articles where groupId = &#63; and structureId = &#63;.
11139             *
11140             * @param groupId the group ID
11141             * @param structureId the structure ID
11142             * @return the matching journal articles
11143             */
11144            @Override
11145            public List<JournalArticle> findByG_S(long groupId, String structureId) {
11146                    return findByG_S(groupId, structureId, QueryUtil.ALL_POS,
11147                            QueryUtil.ALL_POS, null);
11148            }
11149    
11150            /**
11151             * Returns a range of all the journal articles where groupId = &#63; and structureId = &#63;.
11152             *
11153             * <p>
11154             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
11155             * </p>
11156             *
11157             * @param groupId the group ID
11158             * @param structureId the structure ID
11159             * @param start the lower bound of the range of journal articles
11160             * @param end the upper bound of the range of journal articles (not inclusive)
11161             * @return the range of matching journal articles
11162             */
11163            @Override
11164            public List<JournalArticle> findByG_S(long groupId, String structureId,
11165                    int start, int end) {
11166                    return findByG_S(groupId, structureId, start, end, null);
11167            }
11168    
11169            /**
11170             * Returns an ordered range of all the journal articles where groupId = &#63; and structureId = &#63;.
11171             *
11172             * <p>
11173             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
11174             * </p>
11175             *
11176             * @param groupId the group ID
11177             * @param structureId the structure ID
11178             * @param start the lower bound of the range of journal articles
11179             * @param end the upper bound of the range of journal articles (not inclusive)
11180             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11181             * @return the ordered range of matching journal articles
11182             */
11183            @Override
11184            public List<JournalArticle> findByG_S(long groupId, String structureId,
11185                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
11186                    boolean pagination = true;
11187                    FinderPath finderPath = null;
11188                    Object[] finderArgs = null;
11189    
11190                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11191                                    (orderByComparator == null)) {
11192                            pagination = false;
11193                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
11194                            finderArgs = new Object[] { groupId, structureId };
11195                    }
11196                    else {
11197                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
11198                            finderArgs = new Object[] {
11199                                            groupId, structureId,
11200                                            
11201                                            start, end, orderByComparator
11202                                    };
11203                    }
11204    
11205                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
11206                                    finderArgs, this);
11207    
11208                    if ((list != null) && !list.isEmpty()) {
11209                            for (JournalArticle journalArticle : list) {
11210                                    if ((groupId != journalArticle.getGroupId()) ||
11211                                                    !Validator.equals(structureId,
11212                                                            journalArticle.getStructureId())) {
11213                                            list = null;
11214    
11215                                            break;
11216                                    }
11217                            }
11218                    }
11219    
11220                    if (list == null) {
11221                            StringBundler query = null;
11222    
11223                            if (orderByComparator != null) {
11224                                    query = new StringBundler(4 +
11225                                                    (orderByComparator.getOrderByFields().length * 3));
11226                            }
11227                            else {
11228                                    query = new StringBundler(4);
11229                            }
11230    
11231                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11232    
11233                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
11234    
11235                            boolean bindStructureId = false;
11236    
11237                            if (structureId == null) {
11238                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
11239                            }
11240                            else if (structureId.equals(StringPool.BLANK)) {
11241                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
11242                            }
11243                            else {
11244                                    bindStructureId = true;
11245    
11246                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
11247                            }
11248    
11249                            if (orderByComparator != null) {
11250                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11251                                            orderByComparator);
11252                            }
11253                            else
11254                             if (pagination) {
11255                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11256                            }
11257    
11258                            String sql = query.toString();
11259    
11260                            Session session = null;
11261    
11262                            try {
11263                                    session = openSession();
11264    
11265                                    Query q = session.createQuery(sql);
11266    
11267                                    QueryPos qPos = QueryPos.getInstance(q);
11268    
11269                                    qPos.add(groupId);
11270    
11271                                    if (bindStructureId) {
11272                                            qPos.add(structureId);
11273                                    }
11274    
11275                                    if (!pagination) {
11276                                            list = (List<JournalArticle>)QueryUtil.list(q,
11277                                                            getDialect(), start, end, false);
11278    
11279                                            Collections.sort(list);
11280    
11281                                            list = Collections.unmodifiableList(list);
11282                                    }
11283                                    else {
11284                                            list = (List<JournalArticle>)QueryUtil.list(q,
11285                                                            getDialect(), start, end);
11286                                    }
11287    
11288                                    cacheResult(list);
11289    
11290                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
11291                            }
11292                            catch (Exception e) {
11293                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11294    
11295                                    throw processException(e);
11296                            }
11297                            finally {
11298                                    closeSession(session);
11299                            }
11300                    }
11301    
11302                    return list;
11303            }
11304    
11305            /**
11306             * Returns the first journal article in the ordered set where groupId = &#63; and structureId = &#63;.
11307             *
11308             * @param groupId the group ID
11309             * @param structureId the structure ID
11310             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11311             * @return the first matching journal article
11312             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11313             */
11314            @Override
11315            public JournalArticle findByG_S_First(long groupId, String structureId,
11316                    OrderByComparator<JournalArticle> orderByComparator)
11317                    throws NoSuchArticleException {
11318                    JournalArticle journalArticle = fetchByG_S_First(groupId, structureId,
11319                                    orderByComparator);
11320    
11321                    if (journalArticle != null) {
11322                            return journalArticle;
11323                    }
11324    
11325                    StringBundler msg = new StringBundler(6);
11326    
11327                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11328    
11329                    msg.append("groupId=");
11330                    msg.append(groupId);
11331    
11332                    msg.append(", structureId=");
11333                    msg.append(structureId);
11334    
11335                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11336    
11337                    throw new NoSuchArticleException(msg.toString());
11338            }
11339    
11340            /**
11341             * Returns the first journal article in the ordered set where groupId = &#63; and structureId = &#63;.
11342             *
11343             * @param groupId the group ID
11344             * @param structureId the structure ID
11345             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11346             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
11347             */
11348            @Override
11349            public JournalArticle fetchByG_S_First(long groupId, String structureId,
11350                    OrderByComparator<JournalArticle> orderByComparator) {
11351                    List<JournalArticle> list = findByG_S(groupId, structureId, 0, 1,
11352                                    orderByComparator);
11353    
11354                    if (!list.isEmpty()) {
11355                            return list.get(0);
11356                    }
11357    
11358                    return null;
11359            }
11360    
11361            /**
11362             * Returns the last journal article in the ordered set where groupId = &#63; and structureId = &#63;.
11363             *
11364             * @param groupId the group ID
11365             * @param structureId the structure ID
11366             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11367             * @return the last matching journal article
11368             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11369             */
11370            @Override
11371            public JournalArticle findByG_S_Last(long groupId, String structureId,
11372                    OrderByComparator<JournalArticle> orderByComparator)
11373                    throws NoSuchArticleException {
11374                    JournalArticle journalArticle = fetchByG_S_Last(groupId, structureId,
11375                                    orderByComparator);
11376    
11377                    if (journalArticle != null) {
11378                            return journalArticle;
11379                    }
11380    
11381                    StringBundler msg = new StringBundler(6);
11382    
11383                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11384    
11385                    msg.append("groupId=");
11386                    msg.append(groupId);
11387    
11388                    msg.append(", structureId=");
11389                    msg.append(structureId);
11390    
11391                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11392    
11393                    throw new NoSuchArticleException(msg.toString());
11394            }
11395    
11396            /**
11397             * Returns the last journal article in the ordered set where groupId = &#63; and structureId = &#63;.
11398             *
11399             * @param groupId the group ID
11400             * @param structureId the structure ID
11401             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11402             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
11403             */
11404            @Override
11405            public JournalArticle fetchByG_S_Last(long groupId, String structureId,
11406                    OrderByComparator<JournalArticle> orderByComparator) {
11407                    int count = countByG_S(groupId, structureId);
11408    
11409                    if (count == 0) {
11410                            return null;
11411                    }
11412    
11413                    List<JournalArticle> list = findByG_S(groupId, structureId, count - 1,
11414                                    count, orderByComparator);
11415    
11416                    if (!list.isEmpty()) {
11417                            return list.get(0);
11418                    }
11419    
11420                    return null;
11421            }
11422    
11423            /**
11424             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and structureId = &#63;.
11425             *
11426             * @param id the primary key of the current journal article
11427             * @param groupId the group ID
11428             * @param structureId the structure ID
11429             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11430             * @return the previous, current, and next journal article
11431             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11432             */
11433            @Override
11434            public JournalArticle[] findByG_S_PrevAndNext(long id, long groupId,
11435                    String structureId, OrderByComparator<JournalArticle> orderByComparator)
11436                    throws NoSuchArticleException {
11437                    JournalArticle journalArticle = findByPrimaryKey(id);
11438    
11439                    Session session = null;
11440    
11441                    try {
11442                            session = openSession();
11443    
11444                            JournalArticle[] array = new JournalArticleImpl[3];
11445    
11446                            array[0] = getByG_S_PrevAndNext(session, journalArticle, groupId,
11447                                            structureId, orderByComparator, true);
11448    
11449                            array[1] = journalArticle;
11450    
11451                            array[2] = getByG_S_PrevAndNext(session, journalArticle, groupId,
11452                                            structureId, orderByComparator, false);
11453    
11454                            return array;
11455                    }
11456                    catch (Exception e) {
11457                            throw processException(e);
11458                    }
11459                    finally {
11460                            closeSession(session);
11461                    }
11462            }
11463    
11464            protected JournalArticle getByG_S_PrevAndNext(Session session,
11465                    JournalArticle journalArticle, long groupId, String structureId,
11466                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
11467                    StringBundler query = null;
11468    
11469                    if (orderByComparator != null) {
11470                            query = new StringBundler(6 +
11471                                            (orderByComparator.getOrderByFields().length * 6));
11472                    }
11473                    else {
11474                            query = new StringBundler(3);
11475                    }
11476    
11477                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11478    
11479                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
11480    
11481                    boolean bindStructureId = false;
11482    
11483                    if (structureId == null) {
11484                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
11485                    }
11486                    else if (structureId.equals(StringPool.BLANK)) {
11487                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
11488                    }
11489                    else {
11490                            bindStructureId = true;
11491    
11492                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
11493                    }
11494    
11495                    if (orderByComparator != null) {
11496                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11497    
11498                            if (orderByConditionFields.length > 0) {
11499                                    query.append(WHERE_AND);
11500                            }
11501    
11502                            for (int i = 0; i < orderByConditionFields.length; i++) {
11503                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11504                                    query.append(orderByConditionFields[i]);
11505    
11506                                    if ((i + 1) < orderByConditionFields.length) {
11507                                            if (orderByComparator.isAscending() ^ previous) {
11508                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11509                                            }
11510                                            else {
11511                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11512                                            }
11513                                    }
11514                                    else {
11515                                            if (orderByComparator.isAscending() ^ previous) {
11516                                                    query.append(WHERE_GREATER_THAN);
11517                                            }
11518                                            else {
11519                                                    query.append(WHERE_LESSER_THAN);
11520                                            }
11521                                    }
11522                            }
11523    
11524                            query.append(ORDER_BY_CLAUSE);
11525    
11526                            String[] orderByFields = orderByComparator.getOrderByFields();
11527    
11528                            for (int i = 0; i < orderByFields.length; i++) {
11529                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11530                                    query.append(orderByFields[i]);
11531    
11532                                    if ((i + 1) < orderByFields.length) {
11533                                            if (orderByComparator.isAscending() ^ previous) {
11534                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11535                                            }
11536                                            else {
11537                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11538                                            }
11539                                    }
11540                                    else {
11541                                            if (orderByComparator.isAscending() ^ previous) {
11542                                                    query.append(ORDER_BY_ASC);
11543                                            }
11544                                            else {
11545                                                    query.append(ORDER_BY_DESC);
11546                                            }
11547                                    }
11548                            }
11549                    }
11550                    else {
11551                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11552                    }
11553    
11554                    String sql = query.toString();
11555    
11556                    Query q = session.createQuery(sql);
11557    
11558                    q.setFirstResult(0);
11559                    q.setMaxResults(2);
11560    
11561                    QueryPos qPos = QueryPos.getInstance(q);
11562    
11563                    qPos.add(groupId);
11564    
11565                    if (bindStructureId) {
11566                            qPos.add(structureId);
11567                    }
11568    
11569                    if (orderByComparator != null) {
11570                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11571    
11572                            for (Object value : values) {
11573                                    qPos.add(value);
11574                            }
11575                    }
11576    
11577                    List<JournalArticle> list = q.list();
11578    
11579                    if (list.size() == 2) {
11580                            return list.get(1);
11581                    }
11582                    else {
11583                            return null;
11584                    }
11585            }
11586    
11587            /**
11588             * Returns all the journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
11589             *
11590             * @param groupId the group ID
11591             * @param structureId the structure ID
11592             * @return the matching journal articles that the user has permission to view
11593             */
11594            @Override
11595            public List<JournalArticle> filterFindByG_S(long groupId, String structureId) {
11596                    return filterFindByG_S(groupId, structureId, QueryUtil.ALL_POS,
11597                            QueryUtil.ALL_POS, null);
11598            }
11599    
11600            /**
11601             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
11602             *
11603             * <p>
11604             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
11605             * </p>
11606             *
11607             * @param groupId the group ID
11608             * @param structureId the structure ID
11609             * @param start the lower bound of the range of journal articles
11610             * @param end the upper bound of the range of journal articles (not inclusive)
11611             * @return the range of matching journal articles that the user has permission to view
11612             */
11613            @Override
11614            public List<JournalArticle> filterFindByG_S(long groupId,
11615                    String structureId, int start, int end) {
11616                    return filterFindByG_S(groupId, structureId, start, end, null);
11617            }
11618    
11619            /**
11620             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and structureId = &#63;.
11621             *
11622             * <p>
11623             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
11624             * </p>
11625             *
11626             * @param groupId the group ID
11627             * @param structureId the structure ID
11628             * @param start the lower bound of the range of journal articles
11629             * @param end the upper bound of the range of journal articles (not inclusive)
11630             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11631             * @return the ordered range of matching journal articles that the user has permission to view
11632             */
11633            @Override
11634            public List<JournalArticle> filterFindByG_S(long groupId,
11635                    String structureId, int start, int end,
11636                    OrderByComparator<JournalArticle> orderByComparator) {
11637                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11638                            return findByG_S(groupId, structureId, start, end, orderByComparator);
11639                    }
11640    
11641                    StringBundler query = null;
11642    
11643                    if (orderByComparator != null) {
11644                            query = new StringBundler(4 +
11645                                            (orderByComparator.getOrderByFields().length * 3));
11646                    }
11647                    else {
11648                            query = new StringBundler(4);
11649                    }
11650    
11651                    if (getDB().isSupportsInlineDistinct()) {
11652                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11653                    }
11654                    else {
11655                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11656                    }
11657    
11658                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
11659    
11660                    boolean bindStructureId = false;
11661    
11662                    if (structureId == null) {
11663                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
11664                    }
11665                    else if (structureId.equals(StringPool.BLANK)) {
11666                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
11667                    }
11668                    else {
11669                            bindStructureId = true;
11670    
11671                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
11672                    }
11673    
11674                    if (!getDB().isSupportsInlineDistinct()) {
11675                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11676                    }
11677    
11678                    if (orderByComparator != null) {
11679                            if (getDB().isSupportsInlineDistinct()) {
11680                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11681                                            orderByComparator, true);
11682                            }
11683                            else {
11684                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11685                                            orderByComparator, true);
11686                            }
11687                    }
11688                    else {
11689                            if (getDB().isSupportsInlineDistinct()) {
11690                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11691                            }
11692                            else {
11693                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11694                            }
11695                    }
11696    
11697                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11698                                    JournalArticle.class.getName(),
11699                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11700    
11701                    Session session = null;
11702    
11703                    try {
11704                            session = openSession();
11705    
11706                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11707    
11708                            if (getDB().isSupportsInlineDistinct()) {
11709                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11710                            }
11711                            else {
11712                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11713                            }
11714    
11715                            QueryPos qPos = QueryPos.getInstance(q);
11716    
11717                            qPos.add(groupId);
11718    
11719                            if (bindStructureId) {
11720                                    qPos.add(structureId);
11721                            }
11722    
11723                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
11724                                    end);
11725                    }
11726                    catch (Exception e) {
11727                            throw processException(e);
11728                    }
11729                    finally {
11730                            closeSession(session);
11731                    }
11732            }
11733    
11734            /**
11735             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
11736             *
11737             * @param id the primary key of the current journal article
11738             * @param groupId the group ID
11739             * @param structureId the structure ID
11740             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11741             * @return the previous, current, and next journal article
11742             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11743             */
11744            @Override
11745            public JournalArticle[] filterFindByG_S_PrevAndNext(long id, long groupId,
11746                    String structureId, OrderByComparator<JournalArticle> orderByComparator)
11747                    throws NoSuchArticleException {
11748                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11749                            return findByG_S_PrevAndNext(id, groupId, structureId,
11750                                    orderByComparator);
11751                    }
11752    
11753                    JournalArticle journalArticle = findByPrimaryKey(id);
11754    
11755                    Session session = null;
11756    
11757                    try {
11758                            session = openSession();
11759    
11760                            JournalArticle[] array = new JournalArticleImpl[3];
11761    
11762                            array[0] = filterGetByG_S_PrevAndNext(session, journalArticle,
11763                                            groupId, structureId, orderByComparator, true);
11764    
11765                            array[1] = journalArticle;
11766    
11767                            array[2] = filterGetByG_S_PrevAndNext(session, journalArticle,
11768                                            groupId, structureId, orderByComparator, false);
11769    
11770                            return array;
11771                    }
11772                    catch (Exception e) {
11773                            throw processException(e);
11774                    }
11775                    finally {
11776                            closeSession(session);
11777                    }
11778            }
11779    
11780            protected JournalArticle filterGetByG_S_PrevAndNext(Session session,
11781                    JournalArticle journalArticle, long groupId, String structureId,
11782                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
11783                    StringBundler query = null;
11784    
11785                    if (orderByComparator != null) {
11786                            query = new StringBundler(6 +
11787                                            (orderByComparator.getOrderByFields().length * 6));
11788                    }
11789                    else {
11790                            query = new StringBundler(3);
11791                    }
11792    
11793                    if (getDB().isSupportsInlineDistinct()) {
11794                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11795                    }
11796                    else {
11797                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11798                    }
11799    
11800                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
11801    
11802                    boolean bindStructureId = false;
11803    
11804                    if (structureId == null) {
11805                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
11806                    }
11807                    else if (structureId.equals(StringPool.BLANK)) {
11808                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
11809                    }
11810                    else {
11811                            bindStructureId = true;
11812    
11813                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
11814                    }
11815    
11816                    if (!getDB().isSupportsInlineDistinct()) {
11817                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11818                    }
11819    
11820                    if (orderByComparator != null) {
11821                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11822    
11823                            if (orderByConditionFields.length > 0) {
11824                                    query.append(WHERE_AND);
11825                            }
11826    
11827                            for (int i = 0; i < orderByConditionFields.length; i++) {
11828                                    if (getDB().isSupportsInlineDistinct()) {
11829                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11830                                    }
11831                                    else {
11832                                            query.append(_ORDER_BY_ENTITY_TABLE);
11833                                    }
11834    
11835                                    query.append(orderByConditionFields[i]);
11836    
11837                                    if ((i + 1) < orderByConditionFields.length) {
11838                                            if (orderByComparator.isAscending() ^ previous) {
11839                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11840                                            }
11841                                            else {
11842                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11843                                            }
11844                                    }
11845                                    else {
11846                                            if (orderByComparator.isAscending() ^ previous) {
11847                                                    query.append(WHERE_GREATER_THAN);
11848                                            }
11849                                            else {
11850                                                    query.append(WHERE_LESSER_THAN);
11851                                            }
11852                                    }
11853                            }
11854    
11855                            query.append(ORDER_BY_CLAUSE);
11856    
11857                            String[] orderByFields = orderByComparator.getOrderByFields();
11858    
11859                            for (int i = 0; i < orderByFields.length; i++) {
11860                                    if (getDB().isSupportsInlineDistinct()) {
11861                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11862                                    }
11863                                    else {
11864                                            query.append(_ORDER_BY_ENTITY_TABLE);
11865                                    }
11866    
11867                                    query.append(orderByFields[i]);
11868    
11869                                    if ((i + 1) < orderByFields.length) {
11870                                            if (orderByComparator.isAscending() ^ previous) {
11871                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11872                                            }
11873                                            else {
11874                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11875                                            }
11876                                    }
11877                                    else {
11878                                            if (orderByComparator.isAscending() ^ previous) {
11879                                                    query.append(ORDER_BY_ASC);
11880                                            }
11881                                            else {
11882                                                    query.append(ORDER_BY_DESC);
11883                                            }
11884                                    }
11885                            }
11886                    }
11887                    else {
11888                            if (getDB().isSupportsInlineDistinct()) {
11889                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11890                            }
11891                            else {
11892                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11893                            }
11894                    }
11895    
11896                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11897                                    JournalArticle.class.getName(),
11898                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11899    
11900                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
11901    
11902                    q.setFirstResult(0);
11903                    q.setMaxResults(2);
11904    
11905                    if (getDB().isSupportsInlineDistinct()) {
11906                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11907                    }
11908                    else {
11909                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11910                    }
11911    
11912                    QueryPos qPos = QueryPos.getInstance(q);
11913    
11914                    qPos.add(groupId);
11915    
11916                    if (bindStructureId) {
11917                            qPos.add(structureId);
11918                    }
11919    
11920                    if (orderByComparator != null) {
11921                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11922    
11923                            for (Object value : values) {
11924                                    qPos.add(value);
11925                            }
11926                    }
11927    
11928                    List<JournalArticle> list = q.list();
11929    
11930                    if (list.size() == 2) {
11931                            return list.get(1);
11932                    }
11933                    else {
11934                            return null;
11935                    }
11936            }
11937    
11938            /**
11939             * Removes all the journal articles where groupId = &#63; and structureId = &#63; from the database.
11940             *
11941             * @param groupId the group ID
11942             * @param structureId the structure ID
11943             */
11944            @Override
11945            public void removeByG_S(long groupId, String structureId) {
11946                    for (JournalArticle journalArticle : findByG_S(groupId, structureId,
11947                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
11948                            remove(journalArticle);
11949                    }
11950            }
11951    
11952            /**
11953             * Returns the number of journal articles where groupId = &#63; and structureId = &#63;.
11954             *
11955             * @param groupId the group ID
11956             * @param structureId the structure ID
11957             * @return the number of matching journal articles
11958             */
11959            @Override
11960            public int countByG_S(long groupId, String structureId) {
11961                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
11962    
11963                    Object[] finderArgs = new Object[] { groupId, structureId };
11964    
11965                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
11966                                    this);
11967    
11968                    if (count == null) {
11969                            StringBundler query = new StringBundler(3);
11970    
11971                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
11972    
11973                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
11974    
11975                            boolean bindStructureId = false;
11976    
11977                            if (structureId == null) {
11978                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
11979                            }
11980                            else if (structureId.equals(StringPool.BLANK)) {
11981                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
11982                            }
11983                            else {
11984                                    bindStructureId = true;
11985    
11986                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
11987                            }
11988    
11989                            String sql = query.toString();
11990    
11991                            Session session = null;
11992    
11993                            try {
11994                                    session = openSession();
11995    
11996                                    Query q = session.createQuery(sql);
11997    
11998                                    QueryPos qPos = QueryPos.getInstance(q);
11999    
12000                                    qPos.add(groupId);
12001    
12002                                    if (bindStructureId) {
12003                                            qPos.add(structureId);
12004                                    }
12005    
12006                                    count = (Long)q.uniqueResult();
12007    
12008                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
12009                            }
12010                            catch (Exception e) {
12011                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12012    
12013                                    throw processException(e);
12014                            }
12015                            finally {
12016                                    closeSession(session);
12017                            }
12018                    }
12019    
12020                    return count.intValue();
12021            }
12022    
12023            /**
12024             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
12025             *
12026             * @param groupId the group ID
12027             * @param structureId the structure ID
12028             * @return the number of matching journal articles that the user has permission to view
12029             */
12030            @Override
12031            public int filterCountByG_S(long groupId, String structureId) {
12032                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12033                            return countByG_S(groupId, structureId);
12034                    }
12035    
12036                    StringBundler query = new StringBundler(3);
12037    
12038                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
12039    
12040                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
12041    
12042                    boolean bindStructureId = false;
12043    
12044                    if (structureId == null) {
12045                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
12046                    }
12047                    else if (structureId.equals(StringPool.BLANK)) {
12048                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
12049                    }
12050                    else {
12051                            bindStructureId = true;
12052    
12053                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
12054                    }
12055    
12056                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12057                                    JournalArticle.class.getName(),
12058                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12059    
12060                    Session session = null;
12061    
12062                    try {
12063                            session = openSession();
12064    
12065                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
12066    
12067                            q.addScalar(COUNT_COLUMN_NAME,
12068                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
12069    
12070                            QueryPos qPos = QueryPos.getInstance(q);
12071    
12072                            qPos.add(groupId);
12073    
12074                            if (bindStructureId) {
12075                                    qPos.add(structureId);
12076                            }
12077    
12078                            Long count = (Long)q.uniqueResult();
12079    
12080                            return count.intValue();
12081                    }
12082                    catch (Exception e) {
12083                            throw processException(e);
12084                    }
12085                    finally {
12086                            closeSession(session);
12087                    }
12088            }
12089    
12090            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
12091            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
12092            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
12093            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = '')";
12094            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12095                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
12096                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
12097                            "findByG_T",
12098                            new String[] {
12099                                    Long.class.getName(), String.class.getName(),
12100                                    
12101                            Integer.class.getName(), Integer.class.getName(),
12102                                    OrderByComparator.class.getName()
12103                            });
12104            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12105                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
12106                            JournalArticleImpl.class,
12107                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_T",
12108                            new String[] { Long.class.getName(), String.class.getName() },
12109                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
12110                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
12111                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
12112                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
12113            public static final FinderPath FINDER_PATH_COUNT_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12114                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
12115                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_T",
12116                            new String[] { Long.class.getName(), String.class.getName() });
12117    
12118            /**
12119             * Returns all the journal articles where groupId = &#63; and templateId = &#63;.
12120             *
12121             * @param groupId the group ID
12122             * @param templateId the template ID
12123             * @return the matching journal articles
12124             */
12125            @Override
12126            public List<JournalArticle> findByG_T(long groupId, String templateId) {
12127                    return findByG_T(groupId, templateId, QueryUtil.ALL_POS,
12128                            QueryUtil.ALL_POS, null);
12129            }
12130    
12131            /**
12132             * Returns a range of all the journal articles where groupId = &#63; and templateId = &#63;.
12133             *
12134             * <p>
12135             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
12136             * </p>
12137             *
12138             * @param groupId the group ID
12139             * @param templateId the template ID
12140             * @param start the lower bound of the range of journal articles
12141             * @param end the upper bound of the range of journal articles (not inclusive)
12142             * @return the range of matching journal articles
12143             */
12144            @Override
12145            public List<JournalArticle> findByG_T(long groupId, String templateId,
12146                    int start, int end) {
12147                    return findByG_T(groupId, templateId, start, end, null);
12148            }
12149    
12150            /**
12151             * Returns an ordered range of all the journal articles where groupId = &#63; and templateId = &#63;.
12152             *
12153             * <p>
12154             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
12155             * </p>
12156             *
12157             * @param groupId the group ID
12158             * @param templateId the template ID
12159             * @param start the lower bound of the range of journal articles
12160             * @param end the upper bound of the range of journal articles (not inclusive)
12161             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12162             * @return the ordered range of matching journal articles
12163             */
12164            @Override
12165            public List<JournalArticle> findByG_T(long groupId, String templateId,
12166                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
12167                    boolean pagination = true;
12168                    FinderPath finderPath = null;
12169                    Object[] finderArgs = null;
12170    
12171                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12172                                    (orderByComparator == null)) {
12173                            pagination = false;
12174                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T;
12175                            finderArgs = new Object[] { groupId, templateId };
12176                    }
12177                    else {
12178                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T;
12179                            finderArgs = new Object[] {
12180                                            groupId, templateId,
12181                                            
12182                                            start, end, orderByComparator
12183                                    };
12184                    }
12185    
12186                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
12187                                    finderArgs, this);
12188    
12189                    if ((list != null) && !list.isEmpty()) {
12190                            for (JournalArticle journalArticle : list) {
12191                                    if ((groupId != journalArticle.getGroupId()) ||
12192                                                    !Validator.equals(templateId,
12193                                                            journalArticle.getTemplateId())) {
12194                                            list = null;
12195    
12196                                            break;
12197                                    }
12198                            }
12199                    }
12200    
12201                    if (list == null) {
12202                            StringBundler query = null;
12203    
12204                            if (orderByComparator != null) {
12205                                    query = new StringBundler(4 +
12206                                                    (orderByComparator.getOrderByFields().length * 3));
12207                            }
12208                            else {
12209                                    query = new StringBundler(4);
12210                            }
12211    
12212                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12213    
12214                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
12215    
12216                            boolean bindTemplateId = false;
12217    
12218                            if (templateId == null) {
12219                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
12220                            }
12221                            else if (templateId.equals(StringPool.BLANK)) {
12222                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
12223                            }
12224                            else {
12225                                    bindTemplateId = true;
12226    
12227                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
12228                            }
12229    
12230                            if (orderByComparator != null) {
12231                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12232                                            orderByComparator);
12233                            }
12234                            else
12235                             if (pagination) {
12236                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12237                            }
12238    
12239                            String sql = query.toString();
12240    
12241                            Session session = null;
12242    
12243                            try {
12244                                    session = openSession();
12245    
12246                                    Query q = session.createQuery(sql);
12247    
12248                                    QueryPos qPos = QueryPos.getInstance(q);
12249    
12250                                    qPos.add(groupId);
12251    
12252                                    if (bindTemplateId) {
12253                                            qPos.add(templateId);
12254                                    }
12255    
12256                                    if (!pagination) {
12257                                            list = (List<JournalArticle>)QueryUtil.list(q,
12258                                                            getDialect(), start, end, false);
12259    
12260                                            Collections.sort(list);
12261    
12262                                            list = Collections.unmodifiableList(list);
12263                                    }
12264                                    else {
12265                                            list = (List<JournalArticle>)QueryUtil.list(q,
12266                                                            getDialect(), start, end);
12267                                    }
12268    
12269                                    cacheResult(list);
12270    
12271                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
12272                            }
12273                            catch (Exception e) {
12274                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12275    
12276                                    throw processException(e);
12277                            }
12278                            finally {
12279                                    closeSession(session);
12280                            }
12281                    }
12282    
12283                    return list;
12284            }
12285    
12286            /**
12287             * Returns the first journal article in the ordered set where groupId = &#63; and templateId = &#63;.
12288             *
12289             * @param groupId the group ID
12290             * @param templateId the template ID
12291             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12292             * @return the first matching journal article
12293             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12294             */
12295            @Override
12296            public JournalArticle findByG_T_First(long groupId, String templateId,
12297                    OrderByComparator<JournalArticle> orderByComparator)
12298                    throws NoSuchArticleException {
12299                    JournalArticle journalArticle = fetchByG_T_First(groupId, templateId,
12300                                    orderByComparator);
12301    
12302                    if (journalArticle != null) {
12303                            return journalArticle;
12304                    }
12305    
12306                    StringBundler msg = new StringBundler(6);
12307    
12308                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12309    
12310                    msg.append("groupId=");
12311                    msg.append(groupId);
12312    
12313                    msg.append(", templateId=");
12314                    msg.append(templateId);
12315    
12316                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12317    
12318                    throw new NoSuchArticleException(msg.toString());
12319            }
12320    
12321            /**
12322             * Returns the first journal article in the ordered set where groupId = &#63; and templateId = &#63;.
12323             *
12324             * @param groupId the group ID
12325             * @param templateId the template ID
12326             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12327             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
12328             */
12329            @Override
12330            public JournalArticle fetchByG_T_First(long groupId, String templateId,
12331                    OrderByComparator<JournalArticle> orderByComparator) {
12332                    List<JournalArticle> list = findByG_T(groupId, templateId, 0, 1,
12333                                    orderByComparator);
12334    
12335                    if (!list.isEmpty()) {
12336                            return list.get(0);
12337                    }
12338    
12339                    return null;
12340            }
12341    
12342            /**
12343             * Returns the last journal article in the ordered set where groupId = &#63; and templateId = &#63;.
12344             *
12345             * @param groupId the group ID
12346             * @param templateId the template ID
12347             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12348             * @return the last matching journal article
12349             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12350             */
12351            @Override
12352            public JournalArticle findByG_T_Last(long groupId, String templateId,
12353                    OrderByComparator<JournalArticle> orderByComparator)
12354                    throws NoSuchArticleException {
12355                    JournalArticle journalArticle = fetchByG_T_Last(groupId, templateId,
12356                                    orderByComparator);
12357    
12358                    if (journalArticle != null) {
12359                            return journalArticle;
12360                    }
12361    
12362                    StringBundler msg = new StringBundler(6);
12363    
12364                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12365    
12366                    msg.append("groupId=");
12367                    msg.append(groupId);
12368    
12369                    msg.append(", templateId=");
12370                    msg.append(templateId);
12371    
12372                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12373    
12374                    throw new NoSuchArticleException(msg.toString());
12375            }
12376    
12377            /**
12378             * Returns the last journal article in the ordered set where groupId = &#63; and templateId = &#63;.
12379             *
12380             * @param groupId the group ID
12381             * @param templateId the template ID
12382             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12383             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
12384             */
12385            @Override
12386            public JournalArticle fetchByG_T_Last(long groupId, String templateId,
12387                    OrderByComparator<JournalArticle> orderByComparator) {
12388                    int count = countByG_T(groupId, templateId);
12389    
12390                    if (count == 0) {
12391                            return null;
12392                    }
12393    
12394                    List<JournalArticle> list = findByG_T(groupId, templateId, count - 1,
12395                                    count, orderByComparator);
12396    
12397                    if (!list.isEmpty()) {
12398                            return list.get(0);
12399                    }
12400    
12401                    return null;
12402            }
12403    
12404            /**
12405             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and templateId = &#63;.
12406             *
12407             * @param id the primary key of the current journal article
12408             * @param groupId the group ID
12409             * @param templateId the template ID
12410             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12411             * @return the previous, current, and next journal article
12412             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12413             */
12414            @Override
12415            public JournalArticle[] findByG_T_PrevAndNext(long id, long groupId,
12416                    String templateId, OrderByComparator<JournalArticle> orderByComparator)
12417                    throws NoSuchArticleException {
12418                    JournalArticle journalArticle = findByPrimaryKey(id);
12419    
12420                    Session session = null;
12421    
12422                    try {
12423                            session = openSession();
12424    
12425                            JournalArticle[] array = new JournalArticleImpl[3];
12426    
12427                            array[0] = getByG_T_PrevAndNext(session, journalArticle, groupId,
12428                                            templateId, orderByComparator, true);
12429    
12430                            array[1] = journalArticle;
12431    
12432                            array[2] = getByG_T_PrevAndNext(session, journalArticle, groupId,
12433                                            templateId, orderByComparator, false);
12434    
12435                            return array;
12436                    }
12437                    catch (Exception e) {
12438                            throw processException(e);
12439                    }
12440                    finally {
12441                            closeSession(session);
12442                    }
12443            }
12444    
12445            protected JournalArticle getByG_T_PrevAndNext(Session session,
12446                    JournalArticle journalArticle, long groupId, String templateId,
12447                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
12448                    StringBundler query = null;
12449    
12450                    if (orderByComparator != null) {
12451                            query = new StringBundler(6 +
12452                                            (orderByComparator.getOrderByFields().length * 6));
12453                    }
12454                    else {
12455                            query = new StringBundler(3);
12456                    }
12457    
12458                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12459    
12460                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
12461    
12462                    boolean bindTemplateId = false;
12463    
12464                    if (templateId == null) {
12465                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
12466                    }
12467                    else if (templateId.equals(StringPool.BLANK)) {
12468                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
12469                    }
12470                    else {
12471                            bindTemplateId = true;
12472    
12473                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
12474                    }
12475    
12476                    if (orderByComparator != null) {
12477                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12478    
12479                            if (orderByConditionFields.length > 0) {
12480                                    query.append(WHERE_AND);
12481                            }
12482    
12483                            for (int i = 0; i < orderByConditionFields.length; i++) {
12484                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12485                                    query.append(orderByConditionFields[i]);
12486    
12487                                    if ((i + 1) < orderByConditionFields.length) {
12488                                            if (orderByComparator.isAscending() ^ previous) {
12489                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12490                                            }
12491                                            else {
12492                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12493                                            }
12494                                    }
12495                                    else {
12496                                            if (orderByComparator.isAscending() ^ previous) {
12497                                                    query.append(WHERE_GREATER_THAN);
12498                                            }
12499                                            else {
12500                                                    query.append(WHERE_LESSER_THAN);
12501                                            }
12502                                    }
12503                            }
12504    
12505                            query.append(ORDER_BY_CLAUSE);
12506    
12507                            String[] orderByFields = orderByComparator.getOrderByFields();
12508    
12509                            for (int i = 0; i < orderByFields.length; i++) {
12510                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12511                                    query.append(orderByFields[i]);
12512    
12513                                    if ((i + 1) < orderByFields.length) {
12514                                            if (orderByComparator.isAscending() ^ previous) {
12515                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12516                                            }
12517                                            else {
12518                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12519                                            }
12520                                    }
12521                                    else {
12522                                            if (orderByComparator.isAscending() ^ previous) {
12523                                                    query.append(ORDER_BY_ASC);
12524                                            }
12525                                            else {
12526                                                    query.append(ORDER_BY_DESC);
12527                                            }
12528                                    }
12529                            }
12530                    }
12531                    else {
12532                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12533                    }
12534    
12535                    String sql = query.toString();
12536    
12537                    Query q = session.createQuery(sql);
12538    
12539                    q.setFirstResult(0);
12540                    q.setMaxResults(2);
12541    
12542                    QueryPos qPos = QueryPos.getInstance(q);
12543    
12544                    qPos.add(groupId);
12545    
12546                    if (bindTemplateId) {
12547                            qPos.add(templateId);
12548                    }
12549    
12550                    if (orderByComparator != null) {
12551                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12552    
12553                            for (Object value : values) {
12554                                    qPos.add(value);
12555                            }
12556                    }
12557    
12558                    List<JournalArticle> list = q.list();
12559    
12560                    if (list.size() == 2) {
12561                            return list.get(1);
12562                    }
12563                    else {
12564                            return null;
12565                    }
12566            }
12567    
12568            /**
12569             * Returns all the journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
12570             *
12571             * @param groupId the group ID
12572             * @param templateId the template ID
12573             * @return the matching journal articles that the user has permission to view
12574             */
12575            @Override
12576            public List<JournalArticle> filterFindByG_T(long groupId, String templateId) {
12577                    return filterFindByG_T(groupId, templateId, QueryUtil.ALL_POS,
12578                            QueryUtil.ALL_POS, null);
12579            }
12580    
12581            /**
12582             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
12583             *
12584             * <p>
12585             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
12586             * </p>
12587             *
12588             * @param groupId the group ID
12589             * @param templateId the template ID
12590             * @param start the lower bound of the range of journal articles
12591             * @param end the upper bound of the range of journal articles (not inclusive)
12592             * @return the range of matching journal articles that the user has permission to view
12593             */
12594            @Override
12595            public List<JournalArticle> filterFindByG_T(long groupId,
12596                    String templateId, int start, int end) {
12597                    return filterFindByG_T(groupId, templateId, start, end, null);
12598            }
12599    
12600            /**
12601             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and templateId = &#63;.
12602             *
12603             * <p>
12604             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
12605             * </p>
12606             *
12607             * @param groupId the group ID
12608             * @param templateId the template ID
12609             * @param start the lower bound of the range of journal articles
12610             * @param end the upper bound of the range of journal articles (not inclusive)
12611             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12612             * @return the ordered range of matching journal articles that the user has permission to view
12613             */
12614            @Override
12615            public List<JournalArticle> filterFindByG_T(long groupId,
12616                    String templateId, int start, int end,
12617                    OrderByComparator<JournalArticle> orderByComparator) {
12618                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12619                            return findByG_T(groupId, templateId, start, end, orderByComparator);
12620                    }
12621    
12622                    StringBundler query = null;
12623    
12624                    if (orderByComparator != null) {
12625                            query = new StringBundler(4 +
12626                                            (orderByComparator.getOrderByFields().length * 3));
12627                    }
12628                    else {
12629                            query = new StringBundler(4);
12630                    }
12631    
12632                    if (getDB().isSupportsInlineDistinct()) {
12633                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12634                    }
12635                    else {
12636                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12637                    }
12638    
12639                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
12640    
12641                    boolean bindTemplateId = false;
12642    
12643                    if (templateId == null) {
12644                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
12645                    }
12646                    else if (templateId.equals(StringPool.BLANK)) {
12647                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
12648                    }
12649                    else {
12650                            bindTemplateId = true;
12651    
12652                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
12653                    }
12654    
12655                    if (!getDB().isSupportsInlineDistinct()) {
12656                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12657                    }
12658    
12659                    if (orderByComparator != null) {
12660                            if (getDB().isSupportsInlineDistinct()) {
12661                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12662                                            orderByComparator, true);
12663                            }
12664                            else {
12665                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12666                                            orderByComparator, true);
12667                            }
12668                    }
12669                    else {
12670                            if (getDB().isSupportsInlineDistinct()) {
12671                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12672                            }
12673                            else {
12674                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12675                            }
12676                    }
12677    
12678                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12679                                    JournalArticle.class.getName(),
12680                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12681    
12682                    Session session = null;
12683    
12684                    try {
12685                            session = openSession();
12686    
12687                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
12688    
12689                            if (getDB().isSupportsInlineDistinct()) {
12690                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12691                            }
12692                            else {
12693                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12694                            }
12695    
12696                            QueryPos qPos = QueryPos.getInstance(q);
12697    
12698                            qPos.add(groupId);
12699    
12700                            if (bindTemplateId) {
12701                                    qPos.add(templateId);
12702                            }
12703    
12704                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
12705                                    end);
12706                    }
12707                    catch (Exception e) {
12708                            throw processException(e);
12709                    }
12710                    finally {
12711                            closeSession(session);
12712                    }
12713            }
12714    
12715            /**
12716             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
12717             *
12718             * @param id the primary key of the current journal article
12719             * @param groupId the group ID
12720             * @param templateId the template ID
12721             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12722             * @return the previous, current, and next journal article
12723             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12724             */
12725            @Override
12726            public JournalArticle[] filterFindByG_T_PrevAndNext(long id, long groupId,
12727                    String templateId, OrderByComparator<JournalArticle> orderByComparator)
12728                    throws NoSuchArticleException {
12729                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12730                            return findByG_T_PrevAndNext(id, groupId, templateId,
12731                                    orderByComparator);
12732                    }
12733    
12734                    JournalArticle journalArticle = findByPrimaryKey(id);
12735    
12736                    Session session = null;
12737    
12738                    try {
12739                            session = openSession();
12740    
12741                            JournalArticle[] array = new JournalArticleImpl[3];
12742    
12743                            array[0] = filterGetByG_T_PrevAndNext(session, journalArticle,
12744                                            groupId, templateId, orderByComparator, true);
12745    
12746                            array[1] = journalArticle;
12747    
12748                            array[2] = filterGetByG_T_PrevAndNext(session, journalArticle,
12749                                            groupId, templateId, orderByComparator, false);
12750    
12751                            return array;
12752                    }
12753                    catch (Exception e) {
12754                            throw processException(e);
12755                    }
12756                    finally {
12757                            closeSession(session);
12758                    }
12759            }
12760    
12761            protected JournalArticle filterGetByG_T_PrevAndNext(Session session,
12762                    JournalArticle journalArticle, long groupId, String templateId,
12763                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
12764                    StringBundler query = null;
12765    
12766                    if (orderByComparator != null) {
12767                            query = new StringBundler(6 +
12768                                            (orderByComparator.getOrderByFields().length * 6));
12769                    }
12770                    else {
12771                            query = new StringBundler(3);
12772                    }
12773    
12774                    if (getDB().isSupportsInlineDistinct()) {
12775                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12776                    }
12777                    else {
12778                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12779                    }
12780    
12781                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
12782    
12783                    boolean bindTemplateId = false;
12784    
12785                    if (templateId == null) {
12786                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
12787                    }
12788                    else if (templateId.equals(StringPool.BLANK)) {
12789                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
12790                    }
12791                    else {
12792                            bindTemplateId = true;
12793    
12794                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
12795                    }
12796    
12797                    if (!getDB().isSupportsInlineDistinct()) {
12798                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12799                    }
12800    
12801                    if (orderByComparator != null) {
12802                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12803    
12804                            if (orderByConditionFields.length > 0) {
12805                                    query.append(WHERE_AND);
12806                            }
12807    
12808                            for (int i = 0; i < orderByConditionFields.length; i++) {
12809                                    if (getDB().isSupportsInlineDistinct()) {
12810                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12811                                    }
12812                                    else {
12813                                            query.append(_ORDER_BY_ENTITY_TABLE);
12814                                    }
12815    
12816                                    query.append(orderByConditionFields[i]);
12817    
12818                                    if ((i + 1) < orderByConditionFields.length) {
12819                                            if (orderByComparator.isAscending() ^ previous) {
12820                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12821                                            }
12822                                            else {
12823                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12824                                            }
12825                                    }
12826                                    else {
12827                                            if (orderByComparator.isAscending() ^ previous) {
12828                                                    query.append(WHERE_GREATER_THAN);
12829                                            }
12830                                            else {
12831                                                    query.append(WHERE_LESSER_THAN);
12832                                            }
12833                                    }
12834                            }
12835    
12836                            query.append(ORDER_BY_CLAUSE);
12837    
12838                            String[] orderByFields = orderByComparator.getOrderByFields();
12839    
12840                            for (int i = 0; i < orderByFields.length; i++) {
12841                                    if (getDB().isSupportsInlineDistinct()) {
12842                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12843                                    }
12844                                    else {
12845                                            query.append(_ORDER_BY_ENTITY_TABLE);
12846                                    }
12847    
12848                                    query.append(orderByFields[i]);
12849    
12850                                    if ((i + 1) < orderByFields.length) {
12851                                            if (orderByComparator.isAscending() ^ previous) {
12852                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12853                                            }
12854                                            else {
12855                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12856                                            }
12857                                    }
12858                                    else {
12859                                            if (orderByComparator.isAscending() ^ previous) {
12860                                                    query.append(ORDER_BY_ASC);
12861                                            }
12862                                            else {
12863                                                    query.append(ORDER_BY_DESC);
12864                                            }
12865                                    }
12866                            }
12867                    }
12868                    else {
12869                            if (getDB().isSupportsInlineDistinct()) {
12870                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12871                            }
12872                            else {
12873                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12874                            }
12875                    }
12876    
12877                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12878                                    JournalArticle.class.getName(),
12879                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12880    
12881                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
12882    
12883                    q.setFirstResult(0);
12884                    q.setMaxResults(2);
12885    
12886                    if (getDB().isSupportsInlineDistinct()) {
12887                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12888                    }
12889                    else {
12890                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12891                    }
12892    
12893                    QueryPos qPos = QueryPos.getInstance(q);
12894    
12895                    qPos.add(groupId);
12896    
12897                    if (bindTemplateId) {
12898                            qPos.add(templateId);
12899                    }
12900    
12901                    if (orderByComparator != null) {
12902                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12903    
12904                            for (Object value : values) {
12905                                    qPos.add(value);
12906                            }
12907                    }
12908    
12909                    List<JournalArticle> list = q.list();
12910    
12911                    if (list.size() == 2) {
12912                            return list.get(1);
12913                    }
12914                    else {
12915                            return null;
12916                    }
12917            }
12918    
12919            /**
12920             * Removes all the journal articles where groupId = &#63; and templateId = &#63; from the database.
12921             *
12922             * @param groupId the group ID
12923             * @param templateId the template ID
12924             */
12925            @Override
12926            public void removeByG_T(long groupId, String templateId) {
12927                    for (JournalArticle journalArticle : findByG_T(groupId, templateId,
12928                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
12929                            remove(journalArticle);
12930                    }
12931            }
12932    
12933            /**
12934             * Returns the number of journal articles where groupId = &#63; and templateId = &#63;.
12935             *
12936             * @param groupId the group ID
12937             * @param templateId the template ID
12938             * @return the number of matching journal articles
12939             */
12940            @Override
12941            public int countByG_T(long groupId, String templateId) {
12942                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_T;
12943    
12944                    Object[] finderArgs = new Object[] { groupId, templateId };
12945    
12946                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
12947                                    this);
12948    
12949                    if (count == null) {
12950                            StringBundler query = new StringBundler(3);
12951    
12952                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
12953    
12954                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
12955    
12956                            boolean bindTemplateId = false;
12957    
12958                            if (templateId == null) {
12959                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
12960                            }
12961                            else if (templateId.equals(StringPool.BLANK)) {
12962                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
12963                            }
12964                            else {
12965                                    bindTemplateId = true;
12966    
12967                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
12968                            }
12969    
12970                            String sql = query.toString();
12971    
12972                            Session session = null;
12973    
12974                            try {
12975                                    session = openSession();
12976    
12977                                    Query q = session.createQuery(sql);
12978    
12979                                    QueryPos qPos = QueryPos.getInstance(q);
12980    
12981                                    qPos.add(groupId);
12982    
12983                                    if (bindTemplateId) {
12984                                            qPos.add(templateId);
12985                                    }
12986    
12987                                    count = (Long)q.uniqueResult();
12988    
12989                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
12990                            }
12991                            catch (Exception e) {
12992                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12993    
12994                                    throw processException(e);
12995                            }
12996                            finally {
12997                                    closeSession(session);
12998                            }
12999                    }
13000    
13001                    return count.intValue();
13002            }
13003    
13004            /**
13005             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
13006             *
13007             * @param groupId the group ID
13008             * @param templateId the template ID
13009             * @return the number of matching journal articles that the user has permission to view
13010             */
13011            @Override
13012            public int filterCountByG_T(long groupId, String templateId) {
13013                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13014                            return countByG_T(groupId, templateId);
13015                    }
13016    
13017                    StringBundler query = new StringBundler(3);
13018    
13019                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
13020    
13021                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
13022    
13023                    boolean bindTemplateId = false;
13024    
13025                    if (templateId == null) {
13026                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
13027                    }
13028                    else if (templateId.equals(StringPool.BLANK)) {
13029                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
13030                    }
13031                    else {
13032                            bindTemplateId = true;
13033    
13034                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
13035                    }
13036    
13037                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13038                                    JournalArticle.class.getName(),
13039                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13040    
13041                    Session session = null;
13042    
13043                    try {
13044                            session = openSession();
13045    
13046                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
13047    
13048                            q.addScalar(COUNT_COLUMN_NAME,
13049                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
13050    
13051                            QueryPos qPos = QueryPos.getInstance(q);
13052    
13053                            qPos.add(groupId);
13054    
13055                            if (bindTemplateId) {
13056                                    qPos.add(templateId);
13057                            }
13058    
13059                            Long count = (Long)q.uniqueResult();
13060    
13061                            return count.intValue();
13062                    }
13063                    catch (Exception e) {
13064                            throw processException(e);
13065                    }
13066                    finally {
13067                            closeSession(session);
13068                    }
13069            }
13070    
13071            private static final String _FINDER_COLUMN_G_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
13072            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
13073            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
13074            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = '')";
13075            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13076                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
13077                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
13078                            "findByG_L",
13079                            new String[] {
13080                                    Long.class.getName(), String.class.getName(),
13081                                    
13082                            Integer.class.getName(), Integer.class.getName(),
13083                                    OrderByComparator.class.getName()
13084                            });
13085            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13086                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
13087                            JournalArticleImpl.class,
13088                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_L",
13089                            new String[] { Long.class.getName(), String.class.getName() },
13090                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
13091                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
13092                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
13093                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
13094            public static final FinderPath FINDER_PATH_COUNT_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13095                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
13096                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_L",
13097                            new String[] { Long.class.getName(), String.class.getName() });
13098    
13099            /**
13100             * Returns all the journal articles where groupId = &#63; and layoutUuid = &#63;.
13101             *
13102             * @param groupId the group ID
13103             * @param layoutUuid the layout uuid
13104             * @return the matching journal articles
13105             */
13106            @Override
13107            public List<JournalArticle> findByG_L(long groupId, String layoutUuid) {
13108                    return findByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
13109                            QueryUtil.ALL_POS, null);
13110            }
13111    
13112            /**
13113             * Returns a range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
13114             *
13115             * <p>
13116             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
13117             * </p>
13118             *
13119             * @param groupId the group ID
13120             * @param layoutUuid the layout uuid
13121             * @param start the lower bound of the range of journal articles
13122             * @param end the upper bound of the range of journal articles (not inclusive)
13123             * @return the range of matching journal articles
13124             */
13125            @Override
13126            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
13127                    int start, int end) {
13128                    return findByG_L(groupId, layoutUuid, start, end, null);
13129            }
13130    
13131            /**
13132             * Returns an ordered range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
13133             *
13134             * <p>
13135             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
13136             * </p>
13137             *
13138             * @param groupId the group ID
13139             * @param layoutUuid the layout uuid
13140             * @param start the lower bound of the range of journal articles
13141             * @param end the upper bound of the range of journal articles (not inclusive)
13142             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13143             * @return the ordered range of matching journal articles
13144             */
13145            @Override
13146            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
13147                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
13148                    boolean pagination = true;
13149                    FinderPath finderPath = null;
13150                    Object[] finderArgs = null;
13151    
13152                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13153                                    (orderByComparator == null)) {
13154                            pagination = false;
13155                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L;
13156                            finderArgs = new Object[] { groupId, layoutUuid };
13157                    }
13158                    else {
13159                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L;
13160                            finderArgs = new Object[] {
13161                                            groupId, layoutUuid,
13162                                            
13163                                            start, end, orderByComparator
13164                                    };
13165                    }
13166    
13167                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
13168                                    finderArgs, this);
13169    
13170                    if ((list != null) && !list.isEmpty()) {
13171                            for (JournalArticle journalArticle : list) {
13172                                    if ((groupId != journalArticle.getGroupId()) ||
13173                                                    !Validator.equals(layoutUuid,
13174                                                            journalArticle.getLayoutUuid())) {
13175                                            list = null;
13176    
13177                                            break;
13178                                    }
13179                            }
13180                    }
13181    
13182                    if (list == null) {
13183                            StringBundler query = null;
13184    
13185                            if (orderByComparator != null) {
13186                                    query = new StringBundler(4 +
13187                                                    (orderByComparator.getOrderByFields().length * 3));
13188                            }
13189                            else {
13190                                    query = new StringBundler(4);
13191                            }
13192    
13193                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13194    
13195                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
13196    
13197                            boolean bindLayoutUuid = false;
13198    
13199                            if (layoutUuid == null) {
13200                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
13201                            }
13202                            else if (layoutUuid.equals(StringPool.BLANK)) {
13203                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
13204                            }
13205                            else {
13206                                    bindLayoutUuid = true;
13207    
13208                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
13209                            }
13210    
13211                            if (orderByComparator != null) {
13212                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13213                                            orderByComparator);
13214                            }
13215                            else
13216                             if (pagination) {
13217                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13218                            }
13219    
13220                            String sql = query.toString();
13221    
13222                            Session session = null;
13223    
13224                            try {
13225                                    session = openSession();
13226    
13227                                    Query q = session.createQuery(sql);
13228    
13229                                    QueryPos qPos = QueryPos.getInstance(q);
13230    
13231                                    qPos.add(groupId);
13232    
13233                                    if (bindLayoutUuid) {
13234                                            qPos.add(layoutUuid);
13235                                    }
13236    
13237                                    if (!pagination) {
13238                                            list = (List<JournalArticle>)QueryUtil.list(q,
13239                                                            getDialect(), start, end, false);
13240    
13241                                            Collections.sort(list);
13242    
13243                                            list = Collections.unmodifiableList(list);
13244                                    }
13245                                    else {
13246                                            list = (List<JournalArticle>)QueryUtil.list(q,
13247                                                            getDialect(), start, end);
13248                                    }
13249    
13250                                    cacheResult(list);
13251    
13252                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
13253                            }
13254                            catch (Exception e) {
13255                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13256    
13257                                    throw processException(e);
13258                            }
13259                            finally {
13260                                    closeSession(session);
13261                            }
13262                    }
13263    
13264                    return list;
13265            }
13266    
13267            /**
13268             * Returns the first journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13269             *
13270             * @param groupId the group ID
13271             * @param layoutUuid the layout uuid
13272             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13273             * @return the first matching journal article
13274             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13275             */
13276            @Override
13277            public JournalArticle findByG_L_First(long groupId, String layoutUuid,
13278                    OrderByComparator<JournalArticle> orderByComparator)
13279                    throws NoSuchArticleException {
13280                    JournalArticle journalArticle = fetchByG_L_First(groupId, layoutUuid,
13281                                    orderByComparator);
13282    
13283                    if (journalArticle != null) {
13284                            return journalArticle;
13285                    }
13286    
13287                    StringBundler msg = new StringBundler(6);
13288    
13289                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13290    
13291                    msg.append("groupId=");
13292                    msg.append(groupId);
13293    
13294                    msg.append(", layoutUuid=");
13295                    msg.append(layoutUuid);
13296    
13297                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13298    
13299                    throw new NoSuchArticleException(msg.toString());
13300            }
13301    
13302            /**
13303             * Returns the first journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13304             *
13305             * @param groupId the group ID
13306             * @param layoutUuid the layout uuid
13307             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13308             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
13309             */
13310            @Override
13311            public JournalArticle fetchByG_L_First(long groupId, String layoutUuid,
13312                    OrderByComparator<JournalArticle> orderByComparator) {
13313                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, 0, 1,
13314                                    orderByComparator);
13315    
13316                    if (!list.isEmpty()) {
13317                            return list.get(0);
13318                    }
13319    
13320                    return null;
13321            }
13322    
13323            /**
13324             * Returns the last journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13325             *
13326             * @param groupId the group ID
13327             * @param layoutUuid the layout uuid
13328             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13329             * @return the last matching journal article
13330             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13331             */
13332            @Override
13333            public JournalArticle findByG_L_Last(long groupId, String layoutUuid,
13334                    OrderByComparator<JournalArticle> orderByComparator)
13335                    throws NoSuchArticleException {
13336                    JournalArticle journalArticle = fetchByG_L_Last(groupId, layoutUuid,
13337                                    orderByComparator);
13338    
13339                    if (journalArticle != null) {
13340                            return journalArticle;
13341                    }
13342    
13343                    StringBundler msg = new StringBundler(6);
13344    
13345                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13346    
13347                    msg.append("groupId=");
13348                    msg.append(groupId);
13349    
13350                    msg.append(", layoutUuid=");
13351                    msg.append(layoutUuid);
13352    
13353                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13354    
13355                    throw new NoSuchArticleException(msg.toString());
13356            }
13357    
13358            /**
13359             * Returns the last journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13360             *
13361             * @param groupId the group ID
13362             * @param layoutUuid the layout uuid
13363             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13364             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
13365             */
13366            @Override
13367            public JournalArticle fetchByG_L_Last(long groupId, String layoutUuid,
13368                    OrderByComparator<JournalArticle> orderByComparator) {
13369                    int count = countByG_L(groupId, layoutUuid);
13370    
13371                    if (count == 0) {
13372                            return null;
13373                    }
13374    
13375                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, count - 1,
13376                                    count, orderByComparator);
13377    
13378                    if (!list.isEmpty()) {
13379                            return list.get(0);
13380                    }
13381    
13382                    return null;
13383            }
13384    
13385            /**
13386             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13387             *
13388             * @param id the primary key of the current journal article
13389             * @param groupId the group ID
13390             * @param layoutUuid the layout uuid
13391             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13392             * @return the previous, current, and next journal article
13393             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13394             */
13395            @Override
13396            public JournalArticle[] findByG_L_PrevAndNext(long id, long groupId,
13397                    String layoutUuid, OrderByComparator<JournalArticle> orderByComparator)
13398                    throws NoSuchArticleException {
13399                    JournalArticle journalArticle = findByPrimaryKey(id);
13400    
13401                    Session session = null;
13402    
13403                    try {
13404                            session = openSession();
13405    
13406                            JournalArticle[] array = new JournalArticleImpl[3];
13407    
13408                            array[0] = getByG_L_PrevAndNext(session, journalArticle, groupId,
13409                                            layoutUuid, orderByComparator, true);
13410    
13411                            array[1] = journalArticle;
13412    
13413                            array[2] = getByG_L_PrevAndNext(session, journalArticle, groupId,
13414                                            layoutUuid, orderByComparator, false);
13415    
13416                            return array;
13417                    }
13418                    catch (Exception e) {
13419                            throw processException(e);
13420                    }
13421                    finally {
13422                            closeSession(session);
13423                    }
13424            }
13425    
13426            protected JournalArticle getByG_L_PrevAndNext(Session session,
13427                    JournalArticle journalArticle, long groupId, String layoutUuid,
13428                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
13429                    StringBundler query = null;
13430    
13431                    if (orderByComparator != null) {
13432                            query = new StringBundler(6 +
13433                                            (orderByComparator.getOrderByFields().length * 6));
13434                    }
13435                    else {
13436                            query = new StringBundler(3);
13437                    }
13438    
13439                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13440    
13441                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
13442    
13443                    boolean bindLayoutUuid = false;
13444    
13445                    if (layoutUuid == null) {
13446                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
13447                    }
13448                    else if (layoutUuid.equals(StringPool.BLANK)) {
13449                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
13450                    }
13451                    else {
13452                            bindLayoutUuid = true;
13453    
13454                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
13455                    }
13456    
13457                    if (orderByComparator != null) {
13458                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13459    
13460                            if (orderByConditionFields.length > 0) {
13461                                    query.append(WHERE_AND);
13462                            }
13463    
13464                            for (int i = 0; i < orderByConditionFields.length; i++) {
13465                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13466                                    query.append(orderByConditionFields[i]);
13467    
13468                                    if ((i + 1) < orderByConditionFields.length) {
13469                                            if (orderByComparator.isAscending() ^ previous) {
13470                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13471                                            }
13472                                            else {
13473                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13474                                            }
13475                                    }
13476                                    else {
13477                                            if (orderByComparator.isAscending() ^ previous) {
13478                                                    query.append(WHERE_GREATER_THAN);
13479                                            }
13480                                            else {
13481                                                    query.append(WHERE_LESSER_THAN);
13482                                            }
13483                                    }
13484                            }
13485    
13486                            query.append(ORDER_BY_CLAUSE);
13487    
13488                            String[] orderByFields = orderByComparator.getOrderByFields();
13489    
13490                            for (int i = 0; i < orderByFields.length; i++) {
13491                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13492                                    query.append(orderByFields[i]);
13493    
13494                                    if ((i + 1) < orderByFields.length) {
13495                                            if (orderByComparator.isAscending() ^ previous) {
13496                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13497                                            }
13498                                            else {
13499                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13500                                            }
13501                                    }
13502                                    else {
13503                                            if (orderByComparator.isAscending() ^ previous) {
13504                                                    query.append(ORDER_BY_ASC);
13505                                            }
13506                                            else {
13507                                                    query.append(ORDER_BY_DESC);
13508                                            }
13509                                    }
13510                            }
13511                    }
13512                    else {
13513                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13514                    }
13515    
13516                    String sql = query.toString();
13517    
13518                    Query q = session.createQuery(sql);
13519    
13520                    q.setFirstResult(0);
13521                    q.setMaxResults(2);
13522    
13523                    QueryPos qPos = QueryPos.getInstance(q);
13524    
13525                    qPos.add(groupId);
13526    
13527                    if (bindLayoutUuid) {
13528                            qPos.add(layoutUuid);
13529                    }
13530    
13531                    if (orderByComparator != null) {
13532                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13533    
13534                            for (Object value : values) {
13535                                    qPos.add(value);
13536                            }
13537                    }
13538    
13539                    List<JournalArticle> list = q.list();
13540    
13541                    if (list.size() == 2) {
13542                            return list.get(1);
13543                    }
13544                    else {
13545                            return null;
13546                    }
13547            }
13548    
13549            /**
13550             * Returns all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
13551             *
13552             * @param groupId the group ID
13553             * @param layoutUuid the layout uuid
13554             * @return the matching journal articles that the user has permission to view
13555             */
13556            @Override
13557            public List<JournalArticle> filterFindByG_L(long groupId, String layoutUuid) {
13558                    return filterFindByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
13559                            QueryUtil.ALL_POS, null);
13560            }
13561    
13562            /**
13563             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
13564             *
13565             * <p>
13566             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
13567             * </p>
13568             *
13569             * @param groupId the group ID
13570             * @param layoutUuid the layout uuid
13571             * @param start the lower bound of the range of journal articles
13572             * @param end the upper bound of the range of journal articles (not inclusive)
13573             * @return the range of matching journal articles that the user has permission to view
13574             */
13575            @Override
13576            public List<JournalArticle> filterFindByG_L(long groupId,
13577                    String layoutUuid, int start, int end) {
13578                    return filterFindByG_L(groupId, layoutUuid, start, end, null);
13579            }
13580    
13581            /**
13582             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and layoutUuid = &#63;.
13583             *
13584             * <p>
13585             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
13586             * </p>
13587             *
13588             * @param groupId the group ID
13589             * @param layoutUuid the layout uuid
13590             * @param start the lower bound of the range of journal articles
13591             * @param end the upper bound of the range of journal articles (not inclusive)
13592             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13593             * @return the ordered range of matching journal articles that the user has permission to view
13594             */
13595            @Override
13596            public List<JournalArticle> filterFindByG_L(long groupId,
13597                    String layoutUuid, int start, int end,
13598                    OrderByComparator<JournalArticle> orderByComparator) {
13599                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13600                            return findByG_L(groupId, layoutUuid, start, end, orderByComparator);
13601                    }
13602    
13603                    StringBundler query = null;
13604    
13605                    if (orderByComparator != null) {
13606                            query = new StringBundler(4 +
13607                                            (orderByComparator.getOrderByFields().length * 3));
13608                    }
13609                    else {
13610                            query = new StringBundler(4);
13611                    }
13612    
13613                    if (getDB().isSupportsInlineDistinct()) {
13614                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13615                    }
13616                    else {
13617                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13618                    }
13619    
13620                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
13621    
13622                    boolean bindLayoutUuid = false;
13623    
13624                    if (layoutUuid == null) {
13625                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
13626                    }
13627                    else if (layoutUuid.equals(StringPool.BLANK)) {
13628                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
13629                    }
13630                    else {
13631                            bindLayoutUuid = true;
13632    
13633                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
13634                    }
13635    
13636                    if (!getDB().isSupportsInlineDistinct()) {
13637                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13638                    }
13639    
13640                    if (orderByComparator != null) {
13641                            if (getDB().isSupportsInlineDistinct()) {
13642                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13643                                            orderByComparator, true);
13644                            }
13645                            else {
13646                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13647                                            orderByComparator, true);
13648                            }
13649                    }
13650                    else {
13651                            if (getDB().isSupportsInlineDistinct()) {
13652                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13653                            }
13654                            else {
13655                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13656                            }
13657                    }
13658    
13659                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13660                                    JournalArticle.class.getName(),
13661                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13662    
13663                    Session session = null;
13664    
13665                    try {
13666                            session = openSession();
13667    
13668                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
13669    
13670                            if (getDB().isSupportsInlineDistinct()) {
13671                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13672                            }
13673                            else {
13674                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13675                            }
13676    
13677                            QueryPos qPos = QueryPos.getInstance(q);
13678    
13679                            qPos.add(groupId);
13680    
13681                            if (bindLayoutUuid) {
13682                                    qPos.add(layoutUuid);
13683                            }
13684    
13685                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
13686                                    end);
13687                    }
13688                    catch (Exception e) {
13689                            throw processException(e);
13690                    }
13691                    finally {
13692                            closeSession(session);
13693                    }
13694            }
13695    
13696            /**
13697             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
13698             *
13699             * @param id the primary key of the current journal article
13700             * @param groupId the group ID
13701             * @param layoutUuid the layout uuid
13702             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13703             * @return the previous, current, and next journal article
13704             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13705             */
13706            @Override
13707            public JournalArticle[] filterFindByG_L_PrevAndNext(long id, long groupId,
13708                    String layoutUuid, OrderByComparator<JournalArticle> orderByComparator)
13709                    throws NoSuchArticleException {
13710                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13711                            return findByG_L_PrevAndNext(id, groupId, layoutUuid,
13712                                    orderByComparator);
13713                    }
13714    
13715                    JournalArticle journalArticle = findByPrimaryKey(id);
13716    
13717                    Session session = null;
13718    
13719                    try {
13720                            session = openSession();
13721    
13722                            JournalArticle[] array = new JournalArticleImpl[3];
13723    
13724                            array[0] = filterGetByG_L_PrevAndNext(session, journalArticle,
13725                                            groupId, layoutUuid, orderByComparator, true);
13726    
13727                            array[1] = journalArticle;
13728    
13729                            array[2] = filterGetByG_L_PrevAndNext(session, journalArticle,
13730                                            groupId, layoutUuid, orderByComparator, false);
13731    
13732                            return array;
13733                    }
13734                    catch (Exception e) {
13735                            throw processException(e);
13736                    }
13737                    finally {
13738                            closeSession(session);
13739                    }
13740            }
13741    
13742            protected JournalArticle filterGetByG_L_PrevAndNext(Session session,
13743                    JournalArticle journalArticle, long groupId, String layoutUuid,
13744                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
13745                    StringBundler query = null;
13746    
13747                    if (orderByComparator != null) {
13748                            query = new StringBundler(6 +
13749                                            (orderByComparator.getOrderByFields().length * 6));
13750                    }
13751                    else {
13752                            query = new StringBundler(3);
13753                    }
13754    
13755                    if (getDB().isSupportsInlineDistinct()) {
13756                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13757                    }
13758                    else {
13759                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13760                    }
13761    
13762                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
13763    
13764                    boolean bindLayoutUuid = false;
13765    
13766                    if (layoutUuid == null) {
13767                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
13768                    }
13769                    else if (layoutUuid.equals(StringPool.BLANK)) {
13770                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
13771                    }
13772                    else {
13773                            bindLayoutUuid = true;
13774    
13775                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
13776                    }
13777    
13778                    if (!getDB().isSupportsInlineDistinct()) {
13779                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13780                    }
13781    
13782                    if (orderByComparator != null) {
13783                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13784    
13785                            if (orderByConditionFields.length > 0) {
13786                                    query.append(WHERE_AND);
13787                            }
13788    
13789                            for (int i = 0; i < orderByConditionFields.length; i++) {
13790                                    if (getDB().isSupportsInlineDistinct()) {
13791                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13792                                    }
13793                                    else {
13794                                            query.append(_ORDER_BY_ENTITY_TABLE);
13795                                    }
13796    
13797                                    query.append(orderByConditionFields[i]);
13798    
13799                                    if ((i + 1) < orderByConditionFields.length) {
13800                                            if (orderByComparator.isAscending() ^ previous) {
13801                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13802                                            }
13803                                            else {
13804                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13805                                            }
13806                                    }
13807                                    else {
13808                                            if (orderByComparator.isAscending() ^ previous) {
13809                                                    query.append(WHERE_GREATER_THAN);
13810                                            }
13811                                            else {
13812                                                    query.append(WHERE_LESSER_THAN);
13813                                            }
13814                                    }
13815                            }
13816    
13817                            query.append(ORDER_BY_CLAUSE);
13818    
13819                            String[] orderByFields = orderByComparator.getOrderByFields();
13820    
13821                            for (int i = 0; i < orderByFields.length; i++) {
13822                                    if (getDB().isSupportsInlineDistinct()) {
13823                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13824                                    }
13825                                    else {
13826                                            query.append(_ORDER_BY_ENTITY_TABLE);
13827                                    }
13828    
13829                                    query.append(orderByFields[i]);
13830    
13831                                    if ((i + 1) < orderByFields.length) {
13832                                            if (orderByComparator.isAscending() ^ previous) {
13833                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13834                                            }
13835                                            else {
13836                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13837                                            }
13838                                    }
13839                                    else {
13840                                            if (orderByComparator.isAscending() ^ previous) {
13841                                                    query.append(ORDER_BY_ASC);
13842                                            }
13843                                            else {
13844                                                    query.append(ORDER_BY_DESC);
13845                                            }
13846                                    }
13847                            }
13848                    }
13849                    else {
13850                            if (getDB().isSupportsInlineDistinct()) {
13851                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13852                            }
13853                            else {
13854                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13855                            }
13856                    }
13857    
13858                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13859                                    JournalArticle.class.getName(),
13860                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13861    
13862                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
13863    
13864                    q.setFirstResult(0);
13865                    q.setMaxResults(2);
13866    
13867                    if (getDB().isSupportsInlineDistinct()) {
13868                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13869                    }
13870                    else {
13871                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13872                    }
13873    
13874                    QueryPos qPos = QueryPos.getInstance(q);
13875    
13876                    qPos.add(groupId);
13877    
13878                    if (bindLayoutUuid) {
13879                            qPos.add(layoutUuid);
13880                    }
13881    
13882                    if (orderByComparator != null) {
13883                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13884    
13885                            for (Object value : values) {
13886                                    qPos.add(value);
13887                            }
13888                    }
13889    
13890                    List<JournalArticle> list = q.list();
13891    
13892                    if (list.size() == 2) {
13893                            return list.get(1);
13894                    }
13895                    else {
13896                            return null;
13897                    }
13898            }
13899    
13900            /**
13901             * Removes all the journal articles where groupId = &#63; and layoutUuid = &#63; from the database.
13902             *
13903             * @param groupId the group ID
13904             * @param layoutUuid the layout uuid
13905             */
13906            @Override
13907            public void removeByG_L(long groupId, String layoutUuid) {
13908                    for (JournalArticle journalArticle : findByG_L(groupId, layoutUuid,
13909                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
13910                            remove(journalArticle);
13911                    }
13912            }
13913    
13914            /**
13915             * Returns the number of journal articles where groupId = &#63; and layoutUuid = &#63;.
13916             *
13917             * @param groupId the group ID
13918             * @param layoutUuid the layout uuid
13919             * @return the number of matching journal articles
13920             */
13921            @Override
13922            public int countByG_L(long groupId, String layoutUuid) {
13923                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_L;
13924    
13925                    Object[] finderArgs = new Object[] { groupId, layoutUuid };
13926    
13927                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
13928                                    this);
13929    
13930                    if (count == null) {
13931                            StringBundler query = new StringBundler(3);
13932    
13933                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
13934    
13935                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
13936    
13937                            boolean bindLayoutUuid = false;
13938    
13939                            if (layoutUuid == null) {
13940                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
13941                            }
13942                            else if (layoutUuid.equals(StringPool.BLANK)) {
13943                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
13944                            }
13945                            else {
13946                                    bindLayoutUuid = true;
13947    
13948                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
13949                            }
13950    
13951                            String sql = query.toString();
13952    
13953                            Session session = null;
13954    
13955                            try {
13956                                    session = openSession();
13957    
13958                                    Query q = session.createQuery(sql);
13959    
13960                                    QueryPos qPos = QueryPos.getInstance(q);
13961    
13962                                    qPos.add(groupId);
13963    
13964                                    if (bindLayoutUuid) {
13965                                            qPos.add(layoutUuid);
13966                                    }
13967    
13968                                    count = (Long)q.uniqueResult();
13969    
13970                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
13971                            }
13972                            catch (Exception e) {
13973                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13974    
13975                                    throw processException(e);
13976                            }
13977                            finally {
13978                                    closeSession(session);
13979                            }
13980                    }
13981    
13982                    return count.intValue();
13983            }
13984    
13985            /**
13986             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
13987             *
13988             * @param groupId the group ID
13989             * @param layoutUuid the layout uuid
13990             * @return the number of matching journal articles that the user has permission to view
13991             */
13992            @Override
13993            public int filterCountByG_L(long groupId, String layoutUuid) {
13994                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13995                            return countByG_L(groupId, layoutUuid);
13996                    }
13997    
13998                    StringBundler query = new StringBundler(3);
13999    
14000                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
14001    
14002                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
14003    
14004                    boolean bindLayoutUuid = false;
14005    
14006                    if (layoutUuid == null) {
14007                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
14008                    }
14009                    else if (layoutUuid.equals(StringPool.BLANK)) {
14010                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
14011                    }
14012                    else {
14013                            bindLayoutUuid = true;
14014    
14015                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
14016                    }
14017    
14018                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14019                                    JournalArticle.class.getName(),
14020                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14021    
14022                    Session session = null;
14023    
14024                    try {
14025                            session = openSession();
14026    
14027                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
14028    
14029                            q.addScalar(COUNT_COLUMN_NAME,
14030                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
14031    
14032                            QueryPos qPos = QueryPos.getInstance(q);
14033    
14034                            qPos.add(groupId);
14035    
14036                            if (bindLayoutUuid) {
14037                                    qPos.add(layoutUuid);
14038                            }
14039    
14040                            Long count = (Long)q.uniqueResult();
14041    
14042                            return count.intValue();
14043                    }
14044                    catch (Exception e) {
14045                            throw processException(e);
14046                    }
14047                    finally {
14048                            closeSession(session);
14049                    }
14050            }
14051    
14052            private static final String _FINDER_COLUMN_G_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
14053            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
14054            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
14055            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = '')";
14056            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14057                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
14058                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
14059                            "findByG_ST",
14060                            new String[] {
14061                                    Long.class.getName(), Integer.class.getName(),
14062                                    
14063                            Integer.class.getName(), Integer.class.getName(),
14064                                    OrderByComparator.class.getName()
14065                            });
14066            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14067                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
14068                            JournalArticleImpl.class,
14069                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_ST",
14070                            new String[] { Long.class.getName(), Integer.class.getName() },
14071                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
14072                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
14073                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
14074                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
14075            public static final FinderPath FINDER_PATH_COUNT_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14076                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
14077                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_ST",
14078                            new String[] { Long.class.getName(), Integer.class.getName() });
14079    
14080            /**
14081             * Returns all the journal articles where groupId = &#63; and status = &#63;.
14082             *
14083             * @param groupId the group ID
14084             * @param status the status
14085             * @return the matching journal articles
14086             */
14087            @Override
14088            public List<JournalArticle> findByG_ST(long groupId, int status) {
14089                    return findByG_ST(groupId, status, QueryUtil.ALL_POS,
14090                            QueryUtil.ALL_POS, null);
14091            }
14092    
14093            /**
14094             * Returns a range of all the journal articles where groupId = &#63; and status = &#63;.
14095             *
14096             * <p>
14097             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
14098             * </p>
14099             *
14100             * @param groupId the group ID
14101             * @param status the status
14102             * @param start the lower bound of the range of journal articles
14103             * @param end the upper bound of the range of journal articles (not inclusive)
14104             * @return the range of matching journal articles
14105             */
14106            @Override
14107            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
14108                    int end) {
14109                    return findByG_ST(groupId, status, start, end, null);
14110            }
14111    
14112            /**
14113             * Returns an ordered range of all the journal articles where groupId = &#63; and status = &#63;.
14114             *
14115             * <p>
14116             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
14117             * </p>
14118             *
14119             * @param groupId the group ID
14120             * @param status the status
14121             * @param start the lower bound of the range of journal articles
14122             * @param end the upper bound of the range of journal articles (not inclusive)
14123             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14124             * @return the ordered range of matching journal articles
14125             */
14126            @Override
14127            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
14128                    int end, OrderByComparator<JournalArticle> orderByComparator) {
14129                    boolean pagination = true;
14130                    FinderPath finderPath = null;
14131                    Object[] finderArgs = null;
14132    
14133                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
14134                                    (orderByComparator == null)) {
14135                            pagination = false;
14136                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST;
14137                            finderArgs = new Object[] { groupId, status };
14138                    }
14139                    else {
14140                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_ST;
14141                            finderArgs = new Object[] {
14142                                            groupId, status,
14143                                            
14144                                            start, end, orderByComparator
14145                                    };
14146                    }
14147    
14148                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
14149                                    finderArgs, this);
14150    
14151                    if ((list != null) && !list.isEmpty()) {
14152                            for (JournalArticle journalArticle : list) {
14153                                    if ((groupId != journalArticle.getGroupId()) ||
14154                                                    (status != journalArticle.getStatus())) {
14155                                            list = null;
14156    
14157                                            break;
14158                                    }
14159                            }
14160                    }
14161    
14162                    if (list == null) {
14163                            StringBundler query = null;
14164    
14165                            if (orderByComparator != null) {
14166                                    query = new StringBundler(4 +
14167                                                    (orderByComparator.getOrderByFields().length * 3));
14168                            }
14169                            else {
14170                                    query = new StringBundler(4);
14171                            }
14172    
14173                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14174    
14175                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
14176    
14177                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
14178    
14179                            if (orderByComparator != null) {
14180                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14181                                            orderByComparator);
14182                            }
14183                            else
14184                             if (pagination) {
14185                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14186                            }
14187    
14188                            String sql = query.toString();
14189    
14190                            Session session = null;
14191    
14192                            try {
14193                                    session = openSession();
14194    
14195                                    Query q = session.createQuery(sql);
14196    
14197                                    QueryPos qPos = QueryPos.getInstance(q);
14198    
14199                                    qPos.add(groupId);
14200    
14201                                    qPos.add(status);
14202    
14203                                    if (!pagination) {
14204                                            list = (List<JournalArticle>)QueryUtil.list(q,
14205                                                            getDialect(), start, end, false);
14206    
14207                                            Collections.sort(list);
14208    
14209                                            list = Collections.unmodifiableList(list);
14210                                    }
14211                                    else {
14212                                            list = (List<JournalArticle>)QueryUtil.list(q,
14213                                                            getDialect(), start, end);
14214                                    }
14215    
14216                                    cacheResult(list);
14217    
14218                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
14219                            }
14220                            catch (Exception e) {
14221                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14222    
14223                                    throw processException(e);
14224                            }
14225                            finally {
14226                                    closeSession(session);
14227                            }
14228                    }
14229    
14230                    return list;
14231            }
14232    
14233            /**
14234             * Returns the first journal article in the ordered set where groupId = &#63; and status = &#63;.
14235             *
14236             * @param groupId the group ID
14237             * @param status the status
14238             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14239             * @return the first matching journal article
14240             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14241             */
14242            @Override
14243            public JournalArticle findByG_ST_First(long groupId, int status,
14244                    OrderByComparator<JournalArticle> orderByComparator)
14245                    throws NoSuchArticleException {
14246                    JournalArticle journalArticle = fetchByG_ST_First(groupId, status,
14247                                    orderByComparator);
14248    
14249                    if (journalArticle != null) {
14250                            return journalArticle;
14251                    }
14252    
14253                    StringBundler msg = new StringBundler(6);
14254    
14255                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14256    
14257                    msg.append("groupId=");
14258                    msg.append(groupId);
14259    
14260                    msg.append(", status=");
14261                    msg.append(status);
14262    
14263                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14264    
14265                    throw new NoSuchArticleException(msg.toString());
14266            }
14267    
14268            /**
14269             * Returns the first journal article in the ordered set where groupId = &#63; and status = &#63;.
14270             *
14271             * @param groupId the group ID
14272             * @param status the status
14273             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14274             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
14275             */
14276            @Override
14277            public JournalArticle fetchByG_ST_First(long groupId, int status,
14278                    OrderByComparator<JournalArticle> orderByComparator) {
14279                    List<JournalArticle> list = findByG_ST(groupId, status, 0, 1,
14280                                    orderByComparator);
14281    
14282                    if (!list.isEmpty()) {
14283                            return list.get(0);
14284                    }
14285    
14286                    return null;
14287            }
14288    
14289            /**
14290             * Returns the last journal article in the ordered set where groupId = &#63; and status = &#63;.
14291             *
14292             * @param groupId the group ID
14293             * @param status the status
14294             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14295             * @return the last matching journal article
14296             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14297             */
14298            @Override
14299            public JournalArticle findByG_ST_Last(long groupId, int status,
14300                    OrderByComparator<JournalArticle> orderByComparator)
14301                    throws NoSuchArticleException {
14302                    JournalArticle journalArticle = fetchByG_ST_Last(groupId, status,
14303                                    orderByComparator);
14304    
14305                    if (journalArticle != null) {
14306                            return journalArticle;
14307                    }
14308    
14309                    StringBundler msg = new StringBundler(6);
14310    
14311                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14312    
14313                    msg.append("groupId=");
14314                    msg.append(groupId);
14315    
14316                    msg.append(", status=");
14317                    msg.append(status);
14318    
14319                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14320    
14321                    throw new NoSuchArticleException(msg.toString());
14322            }
14323    
14324            /**
14325             * Returns the last journal article in the ordered set where groupId = &#63; and status = &#63;.
14326             *
14327             * @param groupId the group ID
14328             * @param status the status
14329             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14330             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
14331             */
14332            @Override
14333            public JournalArticle fetchByG_ST_Last(long groupId, int status,
14334                    OrderByComparator<JournalArticle> orderByComparator) {
14335                    int count = countByG_ST(groupId, status);
14336    
14337                    if (count == 0) {
14338                            return null;
14339                    }
14340    
14341                    List<JournalArticle> list = findByG_ST(groupId, status, count - 1,
14342                                    count, orderByComparator);
14343    
14344                    if (!list.isEmpty()) {
14345                            return list.get(0);
14346                    }
14347    
14348                    return null;
14349            }
14350    
14351            /**
14352             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and status = &#63;.
14353             *
14354             * @param id the primary key of the current journal article
14355             * @param groupId the group ID
14356             * @param status the status
14357             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14358             * @return the previous, current, and next journal article
14359             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
14360             */
14361            @Override
14362            public JournalArticle[] findByG_ST_PrevAndNext(long id, long groupId,
14363                    int status, OrderByComparator<JournalArticle> orderByComparator)
14364                    throws NoSuchArticleException {
14365                    JournalArticle journalArticle = findByPrimaryKey(id);
14366    
14367                    Session session = null;
14368    
14369                    try {
14370                            session = openSession();
14371    
14372                            JournalArticle[] array = new JournalArticleImpl[3];
14373    
14374                            array[0] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
14375                                            status, orderByComparator, true);
14376    
14377                            array[1] = journalArticle;
14378    
14379                            array[2] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
14380                                            status, orderByComparator, false);
14381    
14382                            return array;
14383                    }
14384                    catch (Exception e) {
14385                            throw processException(e);
14386                    }
14387                    finally {
14388                            closeSession(session);
14389                    }
14390            }
14391    
14392            protected JournalArticle getByG_ST_PrevAndNext(Session session,
14393                    JournalArticle journalArticle, long groupId, int status,
14394                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
14395                    StringBundler query = null;
14396    
14397                    if (orderByComparator != null) {
14398                            query = new StringBundler(6 +
14399                                            (orderByComparator.getOrderByFields().length * 6));
14400                    }
14401                    else {
14402                            query = new StringBundler(3);
14403                    }
14404    
14405                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14406    
14407                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
14408    
14409                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
14410    
14411                    if (orderByComparator != null) {
14412                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14413    
14414                            if (orderByConditionFields.length > 0) {
14415                                    query.append(WHERE_AND);
14416                            }
14417    
14418                            for (int i = 0; i < orderByConditionFields.length; i++) {
14419                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14420                                    query.append(orderByConditionFields[i]);
14421    
14422                                    if ((i + 1) < orderByConditionFields.length) {
14423                                            if (orderByComparator.isAscending() ^ previous) {
14424                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14425                                            }
14426                                            else {
14427                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14428                                            }
14429                                    }
14430                                    else {
14431                                            if (orderByComparator.isAscending() ^ previous) {
14432                                                    query.append(WHERE_GREATER_THAN);
14433                                            }
14434                                            else {
14435                                                    query.append(WHERE_LESSER_THAN);
14436                                            }
14437                                    }
14438                            }
14439    
14440                            query.append(ORDER_BY_CLAUSE);
14441    
14442                            String[] orderByFields = orderByComparator.getOrderByFields();
14443    
14444                            for (int i = 0; i < orderByFields.length; i++) {
14445                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14446                                    query.append(orderByFields[i]);
14447    
14448                                    if ((i + 1) < orderByFields.length) {
14449                                            if (orderByComparator.isAscending() ^ previous) {
14450                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14451                                            }
14452                                            else {
14453                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14454                                            }
14455                                    }
14456                                    else {
14457                                            if (orderByComparator.isAscending() ^ previous) {
14458                                                    query.append(ORDER_BY_ASC);
14459                                            }
14460                                            else {
14461                                                    query.append(ORDER_BY_DESC);
14462                                            }
14463                                    }
14464                            }
14465                    }
14466                    else {
14467                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14468                    }
14469    
14470                    String sql = query.toString();
14471    
14472                    Query q = session.createQuery(sql);
14473    
14474                    q.setFirstResult(0);
14475                    q.setMaxResults(2);
14476    
14477                    QueryPos qPos = QueryPos.getInstance(q);
14478    
14479                    qPos.add(groupId);
14480    
14481                    qPos.add(status);
14482    
14483                    if (orderByComparator != null) {
14484                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
14485    
14486                            for (Object value : values) {
14487                                    qPos.add(value);
14488                            }
14489                    }
14490    
14491                    List<JournalArticle> list = q.list();
14492    
14493                    if (list.size() == 2) {
14494                            return list.get(1);
14495                    }
14496                    else {
14497                            return null;
14498                    }
14499            }
14500    
14501            /**
14502             * Returns all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
14503             *
14504             * @param groupId the group ID
14505             * @param status the status
14506             * @return the matching journal articles that the user has permission to view
14507             */
14508            @Override
14509            public List<JournalArticle> filterFindByG_ST(long groupId, int status) {
14510                    return filterFindByG_ST(groupId, status, QueryUtil.ALL_POS,
14511                            QueryUtil.ALL_POS, null);
14512            }
14513    
14514            /**
14515             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
14516             *
14517             * <p>
14518             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
14519             * </p>
14520             *
14521             * @param groupId the group ID
14522             * @param status the status
14523             * @param start the lower bound of the range of journal articles
14524             * @param end the upper bound of the range of journal articles (not inclusive)
14525             * @return the range of matching journal articles that the user has permission to view
14526             */
14527            @Override
14528            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
14529                    int start, int end) {
14530                    return filterFindByG_ST(groupId, status, start, end, null);
14531            }
14532    
14533            /**
14534             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and status = &#63;.
14535             *
14536             * <p>
14537             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
14538             * </p>
14539             *
14540             * @param groupId the group ID
14541             * @param status the status
14542             * @param start the lower bound of the range of journal articles
14543             * @param end the upper bound of the range of journal articles (not inclusive)
14544             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14545             * @return the ordered range of matching journal articles that the user has permission to view
14546             */
14547            @Override
14548            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
14549                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
14550                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14551                            return findByG_ST(groupId, status, start, end, orderByComparator);
14552                    }
14553    
14554                    StringBundler query = null;
14555    
14556                    if (orderByComparator != null) {
14557                            query = new StringBundler(4 +
14558                                            (orderByComparator.getOrderByFields().length * 3));
14559                    }
14560                    else {
14561                            query = new StringBundler(4);
14562                    }
14563    
14564                    if (getDB().isSupportsInlineDistinct()) {
14565                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
14566                    }
14567                    else {
14568                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
14569                    }
14570    
14571                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
14572    
14573                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
14574    
14575                    if (!getDB().isSupportsInlineDistinct()) {
14576                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
14577                    }
14578    
14579                    if (orderByComparator != null) {
14580                            if (getDB().isSupportsInlineDistinct()) {
14581                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14582                                            orderByComparator, true);
14583                            }
14584                            else {
14585                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
14586                                            orderByComparator, true);
14587                            }
14588                    }
14589                    else {
14590                            if (getDB().isSupportsInlineDistinct()) {
14591                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14592                            }
14593                            else {
14594                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
14595                            }
14596                    }
14597    
14598                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14599                                    JournalArticle.class.getName(),
14600                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14601    
14602                    Session session = null;
14603    
14604                    try {
14605                            session = openSession();
14606    
14607                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
14608    
14609                            if (getDB().isSupportsInlineDistinct()) {
14610                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
14611                            }
14612                            else {
14613                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
14614                            }
14615    
14616                            QueryPos qPos = QueryPos.getInstance(q);
14617    
14618                            qPos.add(groupId);
14619    
14620                            qPos.add(status);
14621    
14622                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
14623                                    end);
14624                    }
14625                    catch (Exception e) {
14626                            throw processException(e);
14627                    }
14628                    finally {
14629                            closeSession(session);
14630                    }
14631            }
14632    
14633            /**
14634             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
14635             *
14636             * @param id the primary key of the current journal article
14637             * @param groupId the group ID
14638             * @param status the status
14639             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14640             * @return the previous, current, and next journal article
14641             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
14642             */
14643            @Override
14644            public JournalArticle[] filterFindByG_ST_PrevAndNext(long id, long groupId,
14645                    int status, OrderByComparator<JournalArticle> orderByComparator)
14646                    throws NoSuchArticleException {
14647                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14648                            return findByG_ST_PrevAndNext(id, groupId, status, orderByComparator);
14649                    }
14650    
14651                    JournalArticle journalArticle = findByPrimaryKey(id);
14652    
14653                    Session session = null;
14654    
14655                    try {
14656                            session = openSession();
14657    
14658                            JournalArticle[] array = new JournalArticleImpl[3];
14659    
14660                            array[0] = filterGetByG_ST_PrevAndNext(session, journalArticle,
14661                                            groupId, status, orderByComparator, true);
14662    
14663                            array[1] = journalArticle;
14664    
14665                            array[2] = filterGetByG_ST_PrevAndNext(session, journalArticle,
14666                                            groupId, status, orderByComparator, false);
14667    
14668                            return array;
14669                    }
14670                    catch (Exception e) {
14671                            throw processException(e);
14672                    }
14673                    finally {
14674                            closeSession(session);
14675                    }
14676            }
14677    
14678            protected JournalArticle filterGetByG_ST_PrevAndNext(Session session,
14679                    JournalArticle journalArticle, long groupId, int status,
14680                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
14681                    StringBundler query = null;
14682    
14683                    if (orderByComparator != null) {
14684                            query = new StringBundler(6 +
14685                                            (orderByComparator.getOrderByFields().length * 6));
14686                    }
14687                    else {
14688                            query = new StringBundler(3);
14689                    }
14690    
14691                    if (getDB().isSupportsInlineDistinct()) {
14692                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
14693                    }
14694                    else {
14695                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
14696                    }
14697    
14698                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
14699    
14700                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
14701    
14702                    if (!getDB().isSupportsInlineDistinct()) {
14703                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
14704                    }
14705    
14706                    if (orderByComparator != null) {
14707                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14708    
14709                            if (orderByConditionFields.length > 0) {
14710                                    query.append(WHERE_AND);
14711                            }
14712    
14713                            for (int i = 0; i < orderByConditionFields.length; i++) {
14714                                    if (getDB().isSupportsInlineDistinct()) {
14715                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14716                                    }
14717                                    else {
14718                                            query.append(_ORDER_BY_ENTITY_TABLE);
14719                                    }
14720    
14721                                    query.append(orderByConditionFields[i]);
14722    
14723                                    if ((i + 1) < orderByConditionFields.length) {
14724                                            if (orderByComparator.isAscending() ^ previous) {
14725                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14726                                            }
14727                                            else {
14728                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14729                                            }
14730                                    }
14731                                    else {
14732                                            if (orderByComparator.isAscending() ^ previous) {
14733                                                    query.append(WHERE_GREATER_THAN);
14734                                            }
14735                                            else {
14736                                                    query.append(WHERE_LESSER_THAN);
14737                                            }
14738                                    }
14739                            }
14740    
14741                            query.append(ORDER_BY_CLAUSE);
14742    
14743                            String[] orderByFields = orderByComparator.getOrderByFields();
14744    
14745                            for (int i = 0; i < orderByFields.length; i++) {
14746                                    if (getDB().isSupportsInlineDistinct()) {
14747                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14748                                    }
14749                                    else {
14750                                            query.append(_ORDER_BY_ENTITY_TABLE);
14751                                    }
14752    
14753                                    query.append(orderByFields[i]);
14754    
14755                                    if ((i + 1) < orderByFields.length) {
14756                                            if (orderByComparator.isAscending() ^ previous) {
14757                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14758                                            }
14759                                            else {
14760                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14761                                            }
14762                                    }
14763                                    else {
14764                                            if (orderByComparator.isAscending() ^ previous) {
14765                                                    query.append(ORDER_BY_ASC);
14766                                            }
14767                                            else {
14768                                                    query.append(ORDER_BY_DESC);
14769                                            }
14770                                    }
14771                            }
14772                    }
14773                    else {
14774                            if (getDB().isSupportsInlineDistinct()) {
14775                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14776                            }
14777                            else {
14778                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
14779                            }
14780                    }
14781    
14782                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14783                                    JournalArticle.class.getName(),
14784                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14785    
14786                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
14787    
14788                    q.setFirstResult(0);
14789                    q.setMaxResults(2);
14790    
14791                    if (getDB().isSupportsInlineDistinct()) {
14792                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
14793                    }
14794                    else {
14795                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
14796                    }
14797    
14798                    QueryPos qPos = QueryPos.getInstance(q);
14799    
14800                    qPos.add(groupId);
14801    
14802                    qPos.add(status);
14803    
14804                    if (orderByComparator != null) {
14805                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
14806    
14807                            for (Object value : values) {
14808                                    qPos.add(value);
14809                            }
14810                    }
14811    
14812                    List<JournalArticle> list = q.list();
14813    
14814                    if (list.size() == 2) {
14815                            return list.get(1);
14816                    }
14817                    else {
14818                            return null;
14819                    }
14820            }
14821    
14822            /**
14823             * Removes all the journal articles where groupId = &#63; and status = &#63; from the database.
14824             *
14825             * @param groupId the group ID
14826             * @param status the status
14827             */
14828            @Override
14829            public void removeByG_ST(long groupId, int status) {
14830                    for (JournalArticle journalArticle : findByG_ST(groupId, status,
14831                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14832                            remove(journalArticle);
14833                    }
14834            }
14835    
14836            /**
14837             * Returns the number of journal articles where groupId = &#63; and status = &#63;.
14838             *
14839             * @param groupId the group ID
14840             * @param status the status
14841             * @return the number of matching journal articles
14842             */
14843            @Override
14844            public int countByG_ST(long groupId, int status) {
14845                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_ST;
14846    
14847                    Object[] finderArgs = new Object[] { groupId, status };
14848    
14849                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
14850                                    this);
14851    
14852                    if (count == null) {
14853                            StringBundler query = new StringBundler(3);
14854    
14855                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14856    
14857                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
14858    
14859                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
14860    
14861                            String sql = query.toString();
14862    
14863                            Session session = null;
14864    
14865                            try {
14866                                    session = openSession();
14867    
14868                                    Query q = session.createQuery(sql);
14869    
14870                                    QueryPos qPos = QueryPos.getInstance(q);
14871    
14872                                    qPos.add(groupId);
14873    
14874                                    qPos.add(status);
14875    
14876                                    count = (Long)q.uniqueResult();
14877    
14878                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
14879                            }
14880                            catch (Exception e) {
14881                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14882    
14883                                    throw processException(e);
14884                            }
14885                            finally {
14886                                    closeSession(session);
14887                            }
14888                    }
14889    
14890                    return count.intValue();
14891            }
14892    
14893            /**
14894             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
14895             *
14896             * @param groupId the group ID
14897             * @param status the status
14898             * @return the number of matching journal articles that the user has permission to view
14899             */
14900            @Override
14901            public int filterCountByG_ST(long groupId, int status) {
14902                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14903                            return countByG_ST(groupId, status);
14904                    }
14905    
14906                    StringBundler query = new StringBundler(3);
14907    
14908                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
14909    
14910                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
14911    
14912                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
14913    
14914                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14915                                    JournalArticle.class.getName(),
14916                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14917    
14918                    Session session = null;
14919    
14920                    try {
14921                            session = openSession();
14922    
14923                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
14924    
14925                            q.addScalar(COUNT_COLUMN_NAME,
14926                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
14927    
14928                            QueryPos qPos = QueryPos.getInstance(q);
14929    
14930                            qPos.add(groupId);
14931    
14932                            qPos.add(status);
14933    
14934                            Long count = (Long)q.uniqueResult();
14935    
14936                            return count.intValue();
14937                    }
14938                    catch (Exception e) {
14939                            throw processException(e);
14940                    }
14941                    finally {
14942                            closeSession(session);
14943                    }
14944            }
14945    
14946            private static final String _FINDER_COLUMN_G_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
14947            private static final String _FINDER_COLUMN_G_ST_STATUS_2 = "journalArticle.status = ?";
14948            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14949                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
14950                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
14951                            "findByC_V",
14952                            new String[] {
14953                                    Long.class.getName(), Double.class.getName(),
14954                                    
14955                            Integer.class.getName(), Integer.class.getName(),
14956                                    OrderByComparator.class.getName()
14957                            });
14958            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14959                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
14960                            JournalArticleImpl.class,
14961                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_V",
14962                            new String[] { Long.class.getName(), Double.class.getName() },
14963                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
14964                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK |
14965                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK);
14966            public static final FinderPath FINDER_PATH_COUNT_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14967                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
14968                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_V",
14969                            new String[] { Long.class.getName(), Double.class.getName() });
14970    
14971            /**
14972             * Returns all the journal articles where companyId = &#63; and version = &#63;.
14973             *
14974             * @param companyId the company ID
14975             * @param version the version
14976             * @return the matching journal articles
14977             */
14978            @Override
14979            public List<JournalArticle> findByC_V(long companyId, double version) {
14980                    return findByC_V(companyId, version, QueryUtil.ALL_POS,
14981                            QueryUtil.ALL_POS, null);
14982            }
14983    
14984            /**
14985             * Returns a range of all the journal articles where companyId = &#63; and version = &#63;.
14986             *
14987             * <p>
14988             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
14989             * </p>
14990             *
14991             * @param companyId the company ID
14992             * @param version the version
14993             * @param start the lower bound of the range of journal articles
14994             * @param end the upper bound of the range of journal articles (not inclusive)
14995             * @return the range of matching journal articles
14996             */
14997            @Override
14998            public List<JournalArticle> findByC_V(long companyId, double version,
14999                    int start, int end) {
15000                    return findByC_V(companyId, version, start, end, null);
15001            }
15002    
15003            /**
15004             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63;.
15005             *
15006             * <p>
15007             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
15008             * </p>
15009             *
15010             * @param companyId the company ID
15011             * @param version the version
15012             * @param start the lower bound of the range of journal articles
15013             * @param end the upper bound of the range of journal articles (not inclusive)
15014             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15015             * @return the ordered range of matching journal articles
15016             */
15017            @Override
15018            public List<JournalArticle> findByC_V(long companyId, double version,
15019                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
15020                    boolean pagination = true;
15021                    FinderPath finderPath = null;
15022                    Object[] finderArgs = null;
15023    
15024                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
15025                                    (orderByComparator == null)) {
15026                            pagination = false;
15027                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V;
15028                            finderArgs = new Object[] { companyId, version };
15029                    }
15030                    else {
15031                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V;
15032                            finderArgs = new Object[] {
15033                                            companyId, version,
15034                                            
15035                                            start, end, orderByComparator
15036                                    };
15037                    }
15038    
15039                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
15040                                    finderArgs, this);
15041    
15042                    if ((list != null) && !list.isEmpty()) {
15043                            for (JournalArticle journalArticle : list) {
15044                                    if ((companyId != journalArticle.getCompanyId()) ||
15045                                                    (version != journalArticle.getVersion())) {
15046                                            list = null;
15047    
15048                                            break;
15049                                    }
15050                            }
15051                    }
15052    
15053                    if (list == null) {
15054                            StringBundler query = null;
15055    
15056                            if (orderByComparator != null) {
15057                                    query = new StringBundler(4 +
15058                                                    (orderByComparator.getOrderByFields().length * 3));
15059                            }
15060                            else {
15061                                    query = new StringBundler(4);
15062                            }
15063    
15064                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15065    
15066                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
15067    
15068                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
15069    
15070                            if (orderByComparator != null) {
15071                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15072                                            orderByComparator);
15073                            }
15074                            else
15075                             if (pagination) {
15076                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15077                            }
15078    
15079                            String sql = query.toString();
15080    
15081                            Session session = null;
15082    
15083                            try {
15084                                    session = openSession();
15085    
15086                                    Query q = session.createQuery(sql);
15087    
15088                                    QueryPos qPos = QueryPos.getInstance(q);
15089    
15090                                    qPos.add(companyId);
15091    
15092                                    qPos.add(version);
15093    
15094                                    if (!pagination) {
15095                                            list = (List<JournalArticle>)QueryUtil.list(q,
15096                                                            getDialect(), start, end, false);
15097    
15098                                            Collections.sort(list);
15099    
15100                                            list = Collections.unmodifiableList(list);
15101                                    }
15102                                    else {
15103                                            list = (List<JournalArticle>)QueryUtil.list(q,
15104                                                            getDialect(), start, end);
15105                                    }
15106    
15107                                    cacheResult(list);
15108    
15109                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
15110                            }
15111                            catch (Exception e) {
15112                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15113    
15114                                    throw processException(e);
15115                            }
15116                            finally {
15117                                    closeSession(session);
15118                            }
15119                    }
15120    
15121                    return list;
15122            }
15123    
15124            /**
15125             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63;.
15126             *
15127             * @param companyId the company ID
15128             * @param version the version
15129             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15130             * @return the first matching journal article
15131             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15132             */
15133            @Override
15134            public JournalArticle findByC_V_First(long companyId, double version,
15135                    OrderByComparator<JournalArticle> orderByComparator)
15136                    throws NoSuchArticleException {
15137                    JournalArticle journalArticle = fetchByC_V_First(companyId, version,
15138                                    orderByComparator);
15139    
15140                    if (journalArticle != null) {
15141                            return journalArticle;
15142                    }
15143    
15144                    StringBundler msg = new StringBundler(6);
15145    
15146                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15147    
15148                    msg.append("companyId=");
15149                    msg.append(companyId);
15150    
15151                    msg.append(", version=");
15152                    msg.append(version);
15153    
15154                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15155    
15156                    throw new NoSuchArticleException(msg.toString());
15157            }
15158    
15159            /**
15160             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63;.
15161             *
15162             * @param companyId the company ID
15163             * @param version the version
15164             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15165             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
15166             */
15167            @Override
15168            public JournalArticle fetchByC_V_First(long companyId, double version,
15169                    OrderByComparator<JournalArticle> orderByComparator) {
15170                    List<JournalArticle> list = findByC_V(companyId, version, 0, 1,
15171                                    orderByComparator);
15172    
15173                    if (!list.isEmpty()) {
15174                            return list.get(0);
15175                    }
15176    
15177                    return null;
15178            }
15179    
15180            /**
15181             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63;.
15182             *
15183             * @param companyId the company ID
15184             * @param version the version
15185             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15186             * @return the last matching journal article
15187             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15188             */
15189            @Override
15190            public JournalArticle findByC_V_Last(long companyId, double version,
15191                    OrderByComparator<JournalArticle> orderByComparator)
15192                    throws NoSuchArticleException {
15193                    JournalArticle journalArticle = fetchByC_V_Last(companyId, version,
15194                                    orderByComparator);
15195    
15196                    if (journalArticle != null) {
15197                            return journalArticle;
15198                    }
15199    
15200                    StringBundler msg = new StringBundler(6);
15201    
15202                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15203    
15204                    msg.append("companyId=");
15205                    msg.append(companyId);
15206    
15207                    msg.append(", version=");
15208                    msg.append(version);
15209    
15210                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15211    
15212                    throw new NoSuchArticleException(msg.toString());
15213            }
15214    
15215            /**
15216             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63;.
15217             *
15218             * @param companyId the company ID
15219             * @param version the version
15220             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15221             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
15222             */
15223            @Override
15224            public JournalArticle fetchByC_V_Last(long companyId, double version,
15225                    OrderByComparator<JournalArticle> orderByComparator) {
15226                    int count = countByC_V(companyId, version);
15227    
15228                    if (count == 0) {
15229                            return null;
15230                    }
15231    
15232                    List<JournalArticle> list = findByC_V(companyId, version, count - 1,
15233                                    count, orderByComparator);
15234    
15235                    if (!list.isEmpty()) {
15236                            return list.get(0);
15237                    }
15238    
15239                    return null;
15240            }
15241    
15242            /**
15243             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63;.
15244             *
15245             * @param id the primary key of the current journal article
15246             * @param companyId the company ID
15247             * @param version the version
15248             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15249             * @return the previous, current, and next journal article
15250             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
15251             */
15252            @Override
15253            public JournalArticle[] findByC_V_PrevAndNext(long id, long companyId,
15254                    double version, OrderByComparator<JournalArticle> orderByComparator)
15255                    throws NoSuchArticleException {
15256                    JournalArticle journalArticle = findByPrimaryKey(id);
15257    
15258                    Session session = null;
15259    
15260                    try {
15261                            session = openSession();
15262    
15263                            JournalArticle[] array = new JournalArticleImpl[3];
15264    
15265                            array[0] = getByC_V_PrevAndNext(session, journalArticle, companyId,
15266                                            version, orderByComparator, true);
15267    
15268                            array[1] = journalArticle;
15269    
15270                            array[2] = getByC_V_PrevAndNext(session, journalArticle, companyId,
15271                                            version, orderByComparator, false);
15272    
15273                            return array;
15274                    }
15275                    catch (Exception e) {
15276                            throw processException(e);
15277                    }
15278                    finally {
15279                            closeSession(session);
15280                    }
15281            }
15282    
15283            protected JournalArticle getByC_V_PrevAndNext(Session session,
15284                    JournalArticle journalArticle, long companyId, double version,
15285                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
15286                    StringBundler query = null;
15287    
15288                    if (orderByComparator != null) {
15289                            query = new StringBundler(6 +
15290                                            (orderByComparator.getOrderByFields().length * 6));
15291                    }
15292                    else {
15293                            query = new StringBundler(3);
15294                    }
15295    
15296                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15297    
15298                    query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
15299    
15300                    query.append(_FINDER_COLUMN_C_V_VERSION_2);
15301    
15302                    if (orderByComparator != null) {
15303                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15304    
15305                            if (orderByConditionFields.length > 0) {
15306                                    query.append(WHERE_AND);
15307                            }
15308    
15309                            for (int i = 0; i < orderByConditionFields.length; i++) {
15310                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15311                                    query.append(orderByConditionFields[i]);
15312    
15313                                    if ((i + 1) < orderByConditionFields.length) {
15314                                            if (orderByComparator.isAscending() ^ previous) {
15315                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15316                                            }
15317                                            else {
15318                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15319                                            }
15320                                    }
15321                                    else {
15322                                            if (orderByComparator.isAscending() ^ previous) {
15323                                                    query.append(WHERE_GREATER_THAN);
15324                                            }
15325                                            else {
15326                                                    query.append(WHERE_LESSER_THAN);
15327                                            }
15328                                    }
15329                            }
15330    
15331                            query.append(ORDER_BY_CLAUSE);
15332    
15333                            String[] orderByFields = orderByComparator.getOrderByFields();
15334    
15335                            for (int i = 0; i < orderByFields.length; i++) {
15336                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15337                                    query.append(orderByFields[i]);
15338    
15339                                    if ((i + 1) < orderByFields.length) {
15340                                            if (orderByComparator.isAscending() ^ previous) {
15341                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15342                                            }
15343                                            else {
15344                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15345                                            }
15346                                    }
15347                                    else {
15348                                            if (orderByComparator.isAscending() ^ previous) {
15349                                                    query.append(ORDER_BY_ASC);
15350                                            }
15351                                            else {
15352                                                    query.append(ORDER_BY_DESC);
15353                                            }
15354                                    }
15355                            }
15356                    }
15357                    else {
15358                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15359                    }
15360    
15361                    String sql = query.toString();
15362    
15363                    Query q = session.createQuery(sql);
15364    
15365                    q.setFirstResult(0);
15366                    q.setMaxResults(2);
15367    
15368                    QueryPos qPos = QueryPos.getInstance(q);
15369    
15370                    qPos.add(companyId);
15371    
15372                    qPos.add(version);
15373    
15374                    if (orderByComparator != null) {
15375                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
15376    
15377                            for (Object value : values) {
15378                                    qPos.add(value);
15379                            }
15380                    }
15381    
15382                    List<JournalArticle> list = q.list();
15383    
15384                    if (list.size() == 2) {
15385                            return list.get(1);
15386                    }
15387                    else {
15388                            return null;
15389                    }
15390            }
15391    
15392            /**
15393             * Removes all the journal articles where companyId = &#63; and version = &#63; from the database.
15394             *
15395             * @param companyId the company ID
15396             * @param version the version
15397             */
15398            @Override
15399            public void removeByC_V(long companyId, double version) {
15400                    for (JournalArticle journalArticle : findByC_V(companyId, version,
15401                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15402                            remove(journalArticle);
15403                    }
15404            }
15405    
15406            /**
15407             * Returns the number of journal articles where companyId = &#63; and version = &#63;.
15408             *
15409             * @param companyId the company ID
15410             * @param version the version
15411             * @return the number of matching journal articles
15412             */
15413            @Override
15414            public int countByC_V(long companyId, double version) {
15415                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_V;
15416    
15417                    Object[] finderArgs = new Object[] { companyId, version };
15418    
15419                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
15420                                    this);
15421    
15422                    if (count == null) {
15423                            StringBundler query = new StringBundler(3);
15424    
15425                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15426    
15427                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
15428    
15429                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
15430    
15431                            String sql = query.toString();
15432    
15433                            Session session = null;
15434    
15435                            try {
15436                                    session = openSession();
15437    
15438                                    Query q = session.createQuery(sql);
15439    
15440                                    QueryPos qPos = QueryPos.getInstance(q);
15441    
15442                                    qPos.add(companyId);
15443    
15444                                    qPos.add(version);
15445    
15446                                    count = (Long)q.uniqueResult();
15447    
15448                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
15449                            }
15450                            catch (Exception e) {
15451                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15452    
15453                                    throw processException(e);
15454                            }
15455                            finally {
15456                                    closeSession(session);
15457                            }
15458                    }
15459    
15460                    return count.intValue();
15461            }
15462    
15463            private static final String _FINDER_COLUMN_C_V_COMPANYID_2 = "journalArticle.companyId = ? AND ";
15464            private static final String _FINDER_COLUMN_C_V_VERSION_2 = "journalArticle.version = ?";
15465            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15466                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
15467                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
15468                            "findByC_ST",
15469                            new String[] {
15470                                    Long.class.getName(), Integer.class.getName(),
15471                                    
15472                            Integer.class.getName(), Integer.class.getName(),
15473                                    OrderByComparator.class.getName()
15474                            });
15475            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15476                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
15477                            JournalArticleImpl.class,
15478                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_ST",
15479                            new String[] { Long.class.getName(), Integer.class.getName() },
15480                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
15481                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
15482                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
15483                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
15484            public static final FinderPath FINDER_PATH_COUNT_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15485                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
15486                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_ST",
15487                            new String[] { Long.class.getName(), Integer.class.getName() });
15488    
15489            /**
15490             * Returns all the journal articles where companyId = &#63; and status = &#63;.
15491             *
15492             * @param companyId the company ID
15493             * @param status the status
15494             * @return the matching journal articles
15495             */
15496            @Override
15497            public List<JournalArticle> findByC_ST(long companyId, int status) {
15498                    return findByC_ST(companyId, status, QueryUtil.ALL_POS,
15499                            QueryUtil.ALL_POS, null);
15500            }
15501    
15502            /**
15503             * Returns a range of all the journal articles where companyId = &#63; and status = &#63;.
15504             *
15505             * <p>
15506             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
15507             * </p>
15508             *
15509             * @param companyId the company ID
15510             * @param status the status
15511             * @param start the lower bound of the range of journal articles
15512             * @param end the upper bound of the range of journal articles (not inclusive)
15513             * @return the range of matching journal articles
15514             */
15515            @Override
15516            public List<JournalArticle> findByC_ST(long companyId, int status,
15517                    int start, int end) {
15518                    return findByC_ST(companyId, status, start, end, null);
15519            }
15520    
15521            /**
15522             * Returns an ordered range of all the journal articles where companyId = &#63; and status = &#63;.
15523             *
15524             * <p>
15525             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
15526             * </p>
15527             *
15528             * @param companyId the company ID
15529             * @param status the status
15530             * @param start the lower bound of the range of journal articles
15531             * @param end the upper bound of the range of journal articles (not inclusive)
15532             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15533             * @return the ordered range of matching journal articles
15534             */
15535            @Override
15536            public List<JournalArticle> findByC_ST(long companyId, int status,
15537                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
15538                    boolean pagination = true;
15539                    FinderPath finderPath = null;
15540                    Object[] finderArgs = null;
15541    
15542                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
15543                                    (orderByComparator == null)) {
15544                            pagination = false;
15545                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST;
15546                            finderArgs = new Object[] { companyId, status };
15547                    }
15548                    else {
15549                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_ST;
15550                            finderArgs = new Object[] {
15551                                            companyId, status,
15552                                            
15553                                            start, end, orderByComparator
15554                                    };
15555                    }
15556    
15557                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
15558                                    finderArgs, this);
15559    
15560                    if ((list != null) && !list.isEmpty()) {
15561                            for (JournalArticle journalArticle : list) {
15562                                    if ((companyId != journalArticle.getCompanyId()) ||
15563                                                    (status != journalArticle.getStatus())) {
15564                                            list = null;
15565    
15566                                            break;
15567                                    }
15568                            }
15569                    }
15570    
15571                    if (list == null) {
15572                            StringBundler query = null;
15573    
15574                            if (orderByComparator != null) {
15575                                    query = new StringBundler(4 +
15576                                                    (orderByComparator.getOrderByFields().length * 3));
15577                            }
15578                            else {
15579                                    query = new StringBundler(4);
15580                            }
15581    
15582                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15583    
15584                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
15585    
15586                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
15587    
15588                            if (orderByComparator != null) {
15589                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15590                                            orderByComparator);
15591                            }
15592                            else
15593                             if (pagination) {
15594                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15595                            }
15596    
15597                            String sql = query.toString();
15598    
15599                            Session session = null;
15600    
15601                            try {
15602                                    session = openSession();
15603    
15604                                    Query q = session.createQuery(sql);
15605    
15606                                    QueryPos qPos = QueryPos.getInstance(q);
15607    
15608                                    qPos.add(companyId);
15609    
15610                                    qPos.add(status);
15611    
15612                                    if (!pagination) {
15613                                            list = (List<JournalArticle>)QueryUtil.list(q,
15614                                                            getDialect(), start, end, false);
15615    
15616                                            Collections.sort(list);
15617    
15618                                            list = Collections.unmodifiableList(list);
15619                                    }
15620                                    else {
15621                                            list = (List<JournalArticle>)QueryUtil.list(q,
15622                                                            getDialect(), start, end);
15623                                    }
15624    
15625                                    cacheResult(list);
15626    
15627                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
15628                            }
15629                            catch (Exception e) {
15630                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15631    
15632                                    throw processException(e);
15633                            }
15634                            finally {
15635                                    closeSession(session);
15636                            }
15637                    }
15638    
15639                    return list;
15640            }
15641    
15642            /**
15643             * Returns the first journal article in the ordered set where companyId = &#63; and status = &#63;.
15644             *
15645             * @param companyId the company ID
15646             * @param status the status
15647             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15648             * @return the first matching journal article
15649             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15650             */
15651            @Override
15652            public JournalArticle findByC_ST_First(long companyId, int status,
15653                    OrderByComparator<JournalArticle> orderByComparator)
15654                    throws NoSuchArticleException {
15655                    JournalArticle journalArticle = fetchByC_ST_First(companyId, status,
15656                                    orderByComparator);
15657    
15658                    if (journalArticle != null) {
15659                            return journalArticle;
15660                    }
15661    
15662                    StringBundler msg = new StringBundler(6);
15663    
15664                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15665    
15666                    msg.append("companyId=");
15667                    msg.append(companyId);
15668    
15669                    msg.append(", status=");
15670                    msg.append(status);
15671    
15672                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15673    
15674                    throw new NoSuchArticleException(msg.toString());
15675            }
15676    
15677            /**
15678             * Returns the first journal article in the ordered set where companyId = &#63; and status = &#63;.
15679             *
15680             * @param companyId the company ID
15681             * @param status the status
15682             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15683             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
15684             */
15685            @Override
15686            public JournalArticle fetchByC_ST_First(long companyId, int status,
15687                    OrderByComparator<JournalArticle> orderByComparator) {
15688                    List<JournalArticle> list = findByC_ST(companyId, status, 0, 1,
15689                                    orderByComparator);
15690    
15691                    if (!list.isEmpty()) {
15692                            return list.get(0);
15693                    }
15694    
15695                    return null;
15696            }
15697    
15698            /**
15699             * Returns the last journal article in the ordered set where companyId = &#63; and status = &#63;.
15700             *
15701             * @param companyId the company ID
15702             * @param status the status
15703             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15704             * @return the last matching journal article
15705             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15706             */
15707            @Override
15708            public JournalArticle findByC_ST_Last(long companyId, int status,
15709                    OrderByComparator<JournalArticle> orderByComparator)
15710                    throws NoSuchArticleException {
15711                    JournalArticle journalArticle = fetchByC_ST_Last(companyId, status,
15712                                    orderByComparator);
15713    
15714                    if (journalArticle != null) {
15715                            return journalArticle;
15716                    }
15717    
15718                    StringBundler msg = new StringBundler(6);
15719    
15720                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15721    
15722                    msg.append("companyId=");
15723                    msg.append(companyId);
15724    
15725                    msg.append(", status=");
15726                    msg.append(status);
15727    
15728                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15729    
15730                    throw new NoSuchArticleException(msg.toString());
15731            }
15732    
15733            /**
15734             * Returns the last journal article in the ordered set where companyId = &#63; and status = &#63;.
15735             *
15736             * @param companyId the company ID
15737             * @param status the status
15738             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15739             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
15740             */
15741            @Override
15742            public JournalArticle fetchByC_ST_Last(long companyId, int status,
15743                    OrderByComparator<JournalArticle> orderByComparator) {
15744                    int count = countByC_ST(companyId, status);
15745    
15746                    if (count == 0) {
15747                            return null;
15748                    }
15749    
15750                    List<JournalArticle> list = findByC_ST(companyId, status, count - 1,
15751                                    count, orderByComparator);
15752    
15753                    if (!list.isEmpty()) {
15754                            return list.get(0);
15755                    }
15756    
15757                    return null;
15758            }
15759    
15760            /**
15761             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and status = &#63;.
15762             *
15763             * @param id the primary key of the current journal article
15764             * @param companyId the company ID
15765             * @param status the status
15766             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15767             * @return the previous, current, and next journal article
15768             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
15769             */
15770            @Override
15771            public JournalArticle[] findByC_ST_PrevAndNext(long id, long companyId,
15772                    int status, OrderByComparator<JournalArticle> orderByComparator)
15773                    throws NoSuchArticleException {
15774                    JournalArticle journalArticle = findByPrimaryKey(id);
15775    
15776                    Session session = null;
15777    
15778                    try {
15779                            session = openSession();
15780    
15781                            JournalArticle[] array = new JournalArticleImpl[3];
15782    
15783                            array[0] = getByC_ST_PrevAndNext(session, journalArticle,
15784                                            companyId, status, orderByComparator, true);
15785    
15786                            array[1] = journalArticle;
15787    
15788                            array[2] = getByC_ST_PrevAndNext(session, journalArticle,
15789                                            companyId, status, orderByComparator, false);
15790    
15791                            return array;
15792                    }
15793                    catch (Exception e) {
15794                            throw processException(e);
15795                    }
15796                    finally {
15797                            closeSession(session);
15798                    }
15799            }
15800    
15801            protected JournalArticle getByC_ST_PrevAndNext(Session session,
15802                    JournalArticle journalArticle, long companyId, int status,
15803                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
15804                    StringBundler query = null;
15805    
15806                    if (orderByComparator != null) {
15807                            query = new StringBundler(6 +
15808                                            (orderByComparator.getOrderByFields().length * 6));
15809                    }
15810                    else {
15811                            query = new StringBundler(3);
15812                    }
15813    
15814                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15815    
15816                    query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
15817    
15818                    query.append(_FINDER_COLUMN_C_ST_STATUS_2);
15819    
15820                    if (orderByComparator != null) {
15821                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15822    
15823                            if (orderByConditionFields.length > 0) {
15824                                    query.append(WHERE_AND);
15825                            }
15826    
15827                            for (int i = 0; i < orderByConditionFields.length; i++) {
15828                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15829                                    query.append(orderByConditionFields[i]);
15830    
15831                                    if ((i + 1) < orderByConditionFields.length) {
15832                                            if (orderByComparator.isAscending() ^ previous) {
15833                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15834                                            }
15835                                            else {
15836                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15837                                            }
15838                                    }
15839                                    else {
15840                                            if (orderByComparator.isAscending() ^ previous) {
15841                                                    query.append(WHERE_GREATER_THAN);
15842                                            }
15843                                            else {
15844                                                    query.append(WHERE_LESSER_THAN);
15845                                            }
15846                                    }
15847                            }
15848    
15849                            query.append(ORDER_BY_CLAUSE);
15850    
15851                            String[] orderByFields = orderByComparator.getOrderByFields();
15852    
15853                            for (int i = 0; i < orderByFields.length; i++) {
15854                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15855                                    query.append(orderByFields[i]);
15856    
15857                                    if ((i + 1) < orderByFields.length) {
15858                                            if (orderByComparator.isAscending() ^ previous) {
15859                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15860                                            }
15861                                            else {
15862                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15863                                            }
15864                                    }
15865                                    else {
15866                                            if (orderByComparator.isAscending() ^ previous) {
15867                                                    query.append(ORDER_BY_ASC);
15868                                            }
15869                                            else {
15870                                                    query.append(ORDER_BY_DESC);
15871                                            }
15872                                    }
15873                            }
15874                    }
15875                    else {
15876                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15877                    }
15878    
15879                    String sql = query.toString();
15880    
15881                    Query q = session.createQuery(sql);
15882    
15883                    q.setFirstResult(0);
15884                    q.setMaxResults(2);
15885    
15886                    QueryPos qPos = QueryPos.getInstance(q);
15887    
15888                    qPos.add(companyId);
15889    
15890                    qPos.add(status);
15891    
15892                    if (orderByComparator != null) {
15893                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
15894    
15895                            for (Object value : values) {
15896                                    qPos.add(value);
15897                            }
15898                    }
15899    
15900                    List<JournalArticle> list = q.list();
15901    
15902                    if (list.size() == 2) {
15903                            return list.get(1);
15904                    }
15905                    else {
15906                            return null;
15907                    }
15908            }
15909    
15910            /**
15911             * Removes all the journal articles where companyId = &#63; and status = &#63; from the database.
15912             *
15913             * @param companyId the company ID
15914             * @param status the status
15915             */
15916            @Override
15917            public void removeByC_ST(long companyId, int status) {
15918                    for (JournalArticle journalArticle : findByC_ST(companyId, status,
15919                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15920                            remove(journalArticle);
15921                    }
15922            }
15923    
15924            /**
15925             * Returns the number of journal articles where companyId = &#63; and status = &#63;.
15926             *
15927             * @param companyId the company ID
15928             * @param status the status
15929             * @return the number of matching journal articles
15930             */
15931            @Override
15932            public int countByC_ST(long companyId, int status) {
15933                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_ST;
15934    
15935                    Object[] finderArgs = new Object[] { companyId, status };
15936    
15937                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
15938                                    this);
15939    
15940                    if (count == null) {
15941                            StringBundler query = new StringBundler(3);
15942    
15943                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15944    
15945                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
15946    
15947                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
15948    
15949                            String sql = query.toString();
15950    
15951                            Session session = null;
15952    
15953                            try {
15954                                    session = openSession();
15955    
15956                                    Query q = session.createQuery(sql);
15957    
15958                                    QueryPos qPos = QueryPos.getInstance(q);
15959    
15960                                    qPos.add(companyId);
15961    
15962                                    qPos.add(status);
15963    
15964                                    count = (Long)q.uniqueResult();
15965    
15966                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
15967                            }
15968                            catch (Exception e) {
15969                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15970    
15971                                    throw processException(e);
15972                            }
15973                            finally {
15974                                    closeSession(session);
15975                            }
15976                    }
15977    
15978                    return count.intValue();
15979            }
15980    
15981            private static final String _FINDER_COLUMN_C_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
15982            private static final String _FINDER_COLUMN_C_ST_STATUS_2 = "journalArticle.status = ?";
15983            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15984                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
15985                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
15986                            "findByC_NotST",
15987                            new String[] {
15988                                    Long.class.getName(), Integer.class.getName(),
15989                                    
15990                            Integer.class.getName(), Integer.class.getName(),
15991                                    OrderByComparator.class.getName()
15992                            });
15993            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15994                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
15995                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_NotST",
15996                            new String[] { Long.class.getName(), Integer.class.getName() });
15997    
15998            /**
15999             * Returns all the journal articles where companyId = &#63; and status &ne; &#63;.
16000             *
16001             * @param companyId the company ID
16002             * @param status the status
16003             * @return the matching journal articles
16004             */
16005            @Override
16006            public List<JournalArticle> findByC_NotST(long companyId, int status) {
16007                    return findByC_NotST(companyId, status, QueryUtil.ALL_POS,
16008                            QueryUtil.ALL_POS, null);
16009            }
16010    
16011            /**
16012             * Returns a range of all the journal articles where companyId = &#63; and status &ne; &#63;.
16013             *
16014             * <p>
16015             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
16016             * </p>
16017             *
16018             * @param companyId the company ID
16019             * @param status the status
16020             * @param start the lower bound of the range of journal articles
16021             * @param end the upper bound of the range of journal articles (not inclusive)
16022             * @return the range of matching journal articles
16023             */
16024            @Override
16025            public List<JournalArticle> findByC_NotST(long companyId, int status,
16026                    int start, int end) {
16027                    return findByC_NotST(companyId, status, start, end, null);
16028            }
16029    
16030            /**
16031             * Returns an ordered range of all the journal articles where companyId = &#63; and status &ne; &#63;.
16032             *
16033             * <p>
16034             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
16035             * </p>
16036             *
16037             * @param companyId the company ID
16038             * @param status the status
16039             * @param start the lower bound of the range of journal articles
16040             * @param end the upper bound of the range of journal articles (not inclusive)
16041             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16042             * @return the ordered range of matching journal articles
16043             */
16044            @Override
16045            public List<JournalArticle> findByC_NotST(long companyId, int status,
16046                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
16047                    boolean pagination = true;
16048                    FinderPath finderPath = null;
16049                    Object[] finderArgs = null;
16050    
16051                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTST;
16052                    finderArgs = new Object[] {
16053                                    companyId, status,
16054                                    
16055                                    start, end, orderByComparator
16056                            };
16057    
16058                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
16059                                    finderArgs, this);
16060    
16061                    if ((list != null) && !list.isEmpty()) {
16062                            for (JournalArticle journalArticle : list) {
16063                                    if ((companyId != journalArticle.getCompanyId()) ||
16064                                                    (status == journalArticle.getStatus())) {
16065                                            list = null;
16066    
16067                                            break;
16068                                    }
16069                            }
16070                    }
16071    
16072                    if (list == null) {
16073                            StringBundler query = null;
16074    
16075                            if (orderByComparator != null) {
16076                                    query = new StringBundler(4 +
16077                                                    (orderByComparator.getOrderByFields().length * 3));
16078                            }
16079                            else {
16080                                    query = new StringBundler(4);
16081                            }
16082    
16083                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16084    
16085                            query.append(_FINDER_COLUMN_C_NOTST_COMPANYID_2);
16086    
16087                            query.append(_FINDER_COLUMN_C_NOTST_STATUS_2);
16088    
16089                            if (orderByComparator != null) {
16090                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16091                                            orderByComparator);
16092                            }
16093                            else
16094                             if (pagination) {
16095                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16096                            }
16097    
16098                            String sql = query.toString();
16099    
16100                            Session session = null;
16101    
16102                            try {
16103                                    session = openSession();
16104    
16105                                    Query q = session.createQuery(sql);
16106    
16107                                    QueryPos qPos = QueryPos.getInstance(q);
16108    
16109                                    qPos.add(companyId);
16110    
16111                                    qPos.add(status);
16112    
16113                                    if (!pagination) {
16114                                            list = (List<JournalArticle>)QueryUtil.list(q,
16115                                                            getDialect(), start, end, false);
16116    
16117                                            Collections.sort(list);
16118    
16119                                            list = Collections.unmodifiableList(list);
16120                                    }
16121                                    else {
16122                                            list = (List<JournalArticle>)QueryUtil.list(q,
16123                                                            getDialect(), start, end);
16124                                    }
16125    
16126                                    cacheResult(list);
16127    
16128                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
16129                            }
16130                            catch (Exception e) {
16131                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16132    
16133                                    throw processException(e);
16134                            }
16135                            finally {
16136                                    closeSession(session);
16137                            }
16138                    }
16139    
16140                    return list;
16141            }
16142    
16143            /**
16144             * Returns the first journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
16145             *
16146             * @param companyId the company ID
16147             * @param status the status
16148             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16149             * @return the first matching journal article
16150             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16151             */
16152            @Override
16153            public JournalArticle findByC_NotST_First(long companyId, int status,
16154                    OrderByComparator<JournalArticle> orderByComparator)
16155                    throws NoSuchArticleException {
16156                    JournalArticle journalArticle = fetchByC_NotST_First(companyId, status,
16157                                    orderByComparator);
16158    
16159                    if (journalArticle != null) {
16160                            return journalArticle;
16161                    }
16162    
16163                    StringBundler msg = new StringBundler(6);
16164    
16165                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16166    
16167                    msg.append("companyId=");
16168                    msg.append(companyId);
16169    
16170                    msg.append(", status=");
16171                    msg.append(status);
16172    
16173                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16174    
16175                    throw new NoSuchArticleException(msg.toString());
16176            }
16177    
16178            /**
16179             * Returns the first journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
16180             *
16181             * @param companyId the company ID
16182             * @param status the status
16183             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16184             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
16185             */
16186            @Override
16187            public JournalArticle fetchByC_NotST_First(long companyId, int status,
16188                    OrderByComparator<JournalArticle> orderByComparator) {
16189                    List<JournalArticle> list = findByC_NotST(companyId, status, 0, 1,
16190                                    orderByComparator);
16191    
16192                    if (!list.isEmpty()) {
16193                            return list.get(0);
16194                    }
16195    
16196                    return null;
16197            }
16198    
16199            /**
16200             * Returns the last journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
16201             *
16202             * @param companyId the company ID
16203             * @param status the status
16204             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16205             * @return the last matching journal article
16206             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16207             */
16208            @Override
16209            public JournalArticle findByC_NotST_Last(long companyId, int status,
16210                    OrderByComparator<JournalArticle> orderByComparator)
16211                    throws NoSuchArticleException {
16212                    JournalArticle journalArticle = fetchByC_NotST_Last(companyId, status,
16213                                    orderByComparator);
16214    
16215                    if (journalArticle != null) {
16216                            return journalArticle;
16217                    }
16218    
16219                    StringBundler msg = new StringBundler(6);
16220    
16221                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16222    
16223                    msg.append("companyId=");
16224                    msg.append(companyId);
16225    
16226                    msg.append(", status=");
16227                    msg.append(status);
16228    
16229                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16230    
16231                    throw new NoSuchArticleException(msg.toString());
16232            }
16233    
16234            /**
16235             * Returns the last journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
16236             *
16237             * @param companyId the company ID
16238             * @param status the status
16239             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16240             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
16241             */
16242            @Override
16243            public JournalArticle fetchByC_NotST_Last(long companyId, int status,
16244                    OrderByComparator<JournalArticle> orderByComparator) {
16245                    int count = countByC_NotST(companyId, status);
16246    
16247                    if (count == 0) {
16248                            return null;
16249                    }
16250    
16251                    List<JournalArticle> list = findByC_NotST(companyId, status, count - 1,
16252                                    count, orderByComparator);
16253    
16254                    if (!list.isEmpty()) {
16255                            return list.get(0);
16256                    }
16257    
16258                    return null;
16259            }
16260    
16261            /**
16262             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
16263             *
16264             * @param id the primary key of the current journal article
16265             * @param companyId the company ID
16266             * @param status the status
16267             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16268             * @return the previous, current, and next journal article
16269             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
16270             */
16271            @Override
16272            public JournalArticle[] findByC_NotST_PrevAndNext(long id, long companyId,
16273                    int status, OrderByComparator<JournalArticle> orderByComparator)
16274                    throws NoSuchArticleException {
16275                    JournalArticle journalArticle = findByPrimaryKey(id);
16276    
16277                    Session session = null;
16278    
16279                    try {
16280                            session = openSession();
16281    
16282                            JournalArticle[] array = new JournalArticleImpl[3];
16283    
16284                            array[0] = getByC_NotST_PrevAndNext(session, journalArticle,
16285                                            companyId, status, orderByComparator, true);
16286    
16287                            array[1] = journalArticle;
16288    
16289                            array[2] = getByC_NotST_PrevAndNext(session, journalArticle,
16290                                            companyId, status, orderByComparator, false);
16291    
16292                            return array;
16293                    }
16294                    catch (Exception e) {
16295                            throw processException(e);
16296                    }
16297                    finally {
16298                            closeSession(session);
16299                    }
16300            }
16301    
16302            protected JournalArticle getByC_NotST_PrevAndNext(Session session,
16303                    JournalArticle journalArticle, long companyId, int status,
16304                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
16305                    StringBundler query = null;
16306    
16307                    if (orderByComparator != null) {
16308                            query = new StringBundler(6 +
16309                                            (orderByComparator.getOrderByFields().length * 6));
16310                    }
16311                    else {
16312                            query = new StringBundler(3);
16313                    }
16314    
16315                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16316    
16317                    query.append(_FINDER_COLUMN_C_NOTST_COMPANYID_2);
16318    
16319                    query.append(_FINDER_COLUMN_C_NOTST_STATUS_2);
16320    
16321                    if (orderByComparator != null) {
16322                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16323    
16324                            if (orderByConditionFields.length > 0) {
16325                                    query.append(WHERE_AND);
16326                            }
16327    
16328                            for (int i = 0; i < orderByConditionFields.length; i++) {
16329                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16330                                    query.append(orderByConditionFields[i]);
16331    
16332                                    if ((i + 1) < orderByConditionFields.length) {
16333                                            if (orderByComparator.isAscending() ^ previous) {
16334                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16335                                            }
16336                                            else {
16337                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16338                                            }
16339                                    }
16340                                    else {
16341                                            if (orderByComparator.isAscending() ^ previous) {
16342                                                    query.append(WHERE_GREATER_THAN);
16343                                            }
16344                                            else {
16345                                                    query.append(WHERE_LESSER_THAN);
16346                                            }
16347                                    }
16348                            }
16349    
16350                            query.append(ORDER_BY_CLAUSE);
16351    
16352                            String[] orderByFields = orderByComparator.getOrderByFields();
16353    
16354                            for (int i = 0; i < orderByFields.length; i++) {
16355                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16356                                    query.append(orderByFields[i]);
16357    
16358                                    if ((i + 1) < orderByFields.length) {
16359                                            if (orderByComparator.isAscending() ^ previous) {
16360                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16361                                            }
16362                                            else {
16363                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16364                                            }
16365                                    }
16366                                    else {
16367                                            if (orderByComparator.isAscending() ^ previous) {
16368                                                    query.append(ORDER_BY_ASC);
16369                                            }
16370                                            else {
16371                                                    query.append(ORDER_BY_DESC);
16372                                            }
16373                                    }
16374                            }
16375                    }
16376                    else {
16377                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16378                    }
16379    
16380                    String sql = query.toString();
16381    
16382                    Query q = session.createQuery(sql);
16383    
16384                    q.setFirstResult(0);
16385                    q.setMaxResults(2);
16386    
16387                    QueryPos qPos = QueryPos.getInstance(q);
16388    
16389                    qPos.add(companyId);
16390    
16391                    qPos.add(status);
16392    
16393                    if (orderByComparator != null) {
16394                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
16395    
16396                            for (Object value : values) {
16397                                    qPos.add(value);
16398                            }
16399                    }
16400    
16401                    List<JournalArticle> list = q.list();
16402    
16403                    if (list.size() == 2) {
16404                            return list.get(1);
16405                    }
16406                    else {
16407                            return null;
16408                    }
16409            }
16410    
16411            /**
16412             * Removes all the journal articles where companyId = &#63; and status &ne; &#63; from the database.
16413             *
16414             * @param companyId the company ID
16415             * @param status the status
16416             */
16417            @Override
16418            public void removeByC_NotST(long companyId, int status) {
16419                    for (JournalArticle journalArticle : findByC_NotST(companyId, status,
16420                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16421                            remove(journalArticle);
16422                    }
16423            }
16424    
16425            /**
16426             * Returns the number of journal articles where companyId = &#63; and status &ne; &#63;.
16427             *
16428             * @param companyId the company ID
16429             * @param status the status
16430             * @return the number of matching journal articles
16431             */
16432            @Override
16433            public int countByC_NotST(long companyId, int status) {
16434                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTST;
16435    
16436                    Object[] finderArgs = new Object[] { companyId, status };
16437    
16438                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
16439                                    this);
16440    
16441                    if (count == null) {
16442                            StringBundler query = new StringBundler(3);
16443    
16444                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16445    
16446                            query.append(_FINDER_COLUMN_C_NOTST_COMPANYID_2);
16447    
16448                            query.append(_FINDER_COLUMN_C_NOTST_STATUS_2);
16449    
16450                            String sql = query.toString();
16451    
16452                            Session session = null;
16453    
16454                            try {
16455                                    session = openSession();
16456    
16457                                    Query q = session.createQuery(sql);
16458    
16459                                    QueryPos qPos = QueryPos.getInstance(q);
16460    
16461                                    qPos.add(companyId);
16462    
16463                                    qPos.add(status);
16464    
16465                                    count = (Long)q.uniqueResult();
16466    
16467                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
16468                            }
16469                            catch (Exception e) {
16470                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16471    
16472                                    throw processException(e);
16473                            }
16474                            finally {
16475                                    closeSession(session);
16476                            }
16477                    }
16478    
16479                    return count.intValue();
16480            }
16481    
16482            private static final String _FINDER_COLUMN_C_NOTST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
16483            private static final String _FINDER_COLUMN_C_NOTST_STATUS_2 = "journalArticle.status != ?";
16484            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16485                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
16486                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
16487                            "findByC_T",
16488                            new String[] {
16489                                    Long.class.getName(), String.class.getName(),
16490                                    
16491                            Integer.class.getName(), Integer.class.getName(),
16492                                    OrderByComparator.class.getName()
16493                            });
16494            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16495                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
16496                            JournalArticleImpl.class,
16497                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_T",
16498                            new String[] { Long.class.getName(), String.class.getName() },
16499                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
16500                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
16501                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
16502                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
16503            public static final FinderPath FINDER_PATH_COUNT_BY_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16504                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
16505                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_T",
16506                            new String[] { Long.class.getName(), String.class.getName() });
16507    
16508            /**
16509             * Returns all the journal articles where classNameId = &#63; and templateId = &#63;.
16510             *
16511             * @param classNameId the class name ID
16512             * @param templateId the template ID
16513             * @return the matching journal articles
16514             */
16515            @Override
16516            public List<JournalArticle> findByC_T(long classNameId, String templateId) {
16517                    return findByC_T(classNameId, templateId, QueryUtil.ALL_POS,
16518                            QueryUtil.ALL_POS, null);
16519            }
16520    
16521            /**
16522             * Returns a range of all the journal articles where classNameId = &#63; and templateId = &#63;.
16523             *
16524             * <p>
16525             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
16526             * </p>
16527             *
16528             * @param classNameId the class name ID
16529             * @param templateId the template ID
16530             * @param start the lower bound of the range of journal articles
16531             * @param end the upper bound of the range of journal articles (not inclusive)
16532             * @return the range of matching journal articles
16533             */
16534            @Override
16535            public List<JournalArticle> findByC_T(long classNameId, String templateId,
16536                    int start, int end) {
16537                    return findByC_T(classNameId, templateId, start, end, null);
16538            }
16539    
16540            /**
16541             * Returns an ordered range of all the journal articles where classNameId = &#63; and templateId = &#63;.
16542             *
16543             * <p>
16544             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
16545             * </p>
16546             *
16547             * @param classNameId the class name ID
16548             * @param templateId the template ID
16549             * @param start the lower bound of the range of journal articles
16550             * @param end the upper bound of the range of journal articles (not inclusive)
16551             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16552             * @return the ordered range of matching journal articles
16553             */
16554            @Override
16555            public List<JournalArticle> findByC_T(long classNameId, String templateId,
16556                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
16557                    boolean pagination = true;
16558                    FinderPath finderPath = null;
16559                    Object[] finderArgs = null;
16560    
16561                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
16562                                    (orderByComparator == null)) {
16563                            pagination = false;
16564                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T;
16565                            finderArgs = new Object[] { classNameId, templateId };
16566                    }
16567                    else {
16568                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_T;
16569                            finderArgs = new Object[] {
16570                                            classNameId, templateId,
16571                                            
16572                                            start, end, orderByComparator
16573                                    };
16574                    }
16575    
16576                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
16577                                    finderArgs, this);
16578    
16579                    if ((list != null) && !list.isEmpty()) {
16580                            for (JournalArticle journalArticle : list) {
16581                                    if ((classNameId != journalArticle.getClassNameId()) ||
16582                                                    !Validator.equals(templateId,
16583                                                            journalArticle.getTemplateId())) {
16584                                            list = null;
16585    
16586                                            break;
16587                                    }
16588                            }
16589                    }
16590    
16591                    if (list == null) {
16592                            StringBundler query = null;
16593    
16594                            if (orderByComparator != null) {
16595                                    query = new StringBundler(4 +
16596                                                    (orderByComparator.getOrderByFields().length * 3));
16597                            }
16598                            else {
16599                                    query = new StringBundler(4);
16600                            }
16601    
16602                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16603    
16604                            query.append(_FINDER_COLUMN_C_T_CLASSNAMEID_2);
16605    
16606                            boolean bindTemplateId = false;
16607    
16608                            if (templateId == null) {
16609                                    query.append(_FINDER_COLUMN_C_T_TEMPLATEID_1);
16610                            }
16611                            else if (templateId.equals(StringPool.BLANK)) {
16612                                    query.append(_FINDER_COLUMN_C_T_TEMPLATEID_3);
16613                            }
16614                            else {
16615                                    bindTemplateId = true;
16616    
16617                                    query.append(_FINDER_COLUMN_C_T_TEMPLATEID_2);
16618                            }
16619    
16620                            if (orderByComparator != null) {
16621                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16622                                            orderByComparator);
16623                            }
16624                            else
16625                             if (pagination) {
16626                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16627                            }
16628    
16629                            String sql = query.toString();
16630    
16631                            Session session = null;
16632    
16633                            try {
16634                                    session = openSession();
16635    
16636                                    Query q = session.createQuery(sql);
16637    
16638                                    QueryPos qPos = QueryPos.getInstance(q);
16639    
16640                                    qPos.add(classNameId);
16641    
16642                                    if (bindTemplateId) {
16643                                            qPos.add(templateId);
16644                                    }
16645    
16646                                    if (!pagination) {
16647                                            list = (List<JournalArticle>)QueryUtil.list(q,
16648                                                            getDialect(), start, end, false);
16649    
16650                                            Collections.sort(list);
16651    
16652                                            list = Collections.unmodifiableList(list);
16653                                    }
16654                                    else {
16655                                            list = (List<JournalArticle>)QueryUtil.list(q,
16656                                                            getDialect(), start, end);
16657                                    }
16658    
16659                                    cacheResult(list);
16660    
16661                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
16662                            }
16663                            catch (Exception e) {
16664                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16665    
16666                                    throw processException(e);
16667                            }
16668                            finally {
16669                                    closeSession(session);
16670                            }
16671                    }
16672    
16673                    return list;
16674            }
16675    
16676            /**
16677             * Returns the first journal article in the ordered set where classNameId = &#63; and templateId = &#63;.
16678             *
16679             * @param classNameId the class name ID
16680             * @param templateId the template ID
16681             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16682             * @return the first matching journal article
16683             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16684             */
16685            @Override
16686            public JournalArticle findByC_T_First(long classNameId, String templateId,
16687                    OrderByComparator<JournalArticle> orderByComparator)
16688                    throws NoSuchArticleException {
16689                    JournalArticle journalArticle = fetchByC_T_First(classNameId,
16690                                    templateId, orderByComparator);
16691    
16692                    if (journalArticle != null) {
16693                            return journalArticle;
16694                    }
16695    
16696                    StringBundler msg = new StringBundler(6);
16697    
16698                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16699    
16700                    msg.append("classNameId=");
16701                    msg.append(classNameId);
16702    
16703                    msg.append(", templateId=");
16704                    msg.append(templateId);
16705    
16706                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16707    
16708                    throw new NoSuchArticleException(msg.toString());
16709            }
16710    
16711            /**
16712             * Returns the first journal article in the ordered set where classNameId = &#63; and templateId = &#63;.
16713             *
16714             * @param classNameId the class name ID
16715             * @param templateId the template ID
16716             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16717             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
16718             */
16719            @Override
16720            public JournalArticle fetchByC_T_First(long classNameId, String templateId,
16721                    OrderByComparator<JournalArticle> orderByComparator) {
16722                    List<JournalArticle> list = findByC_T(classNameId, templateId, 0, 1,
16723                                    orderByComparator);
16724    
16725                    if (!list.isEmpty()) {
16726                            return list.get(0);
16727                    }
16728    
16729                    return null;
16730            }
16731    
16732            /**
16733             * Returns the last journal article in the ordered set where classNameId = &#63; and templateId = &#63;.
16734             *
16735             * @param classNameId the class name ID
16736             * @param templateId the template ID
16737             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16738             * @return the last matching journal article
16739             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16740             */
16741            @Override
16742            public JournalArticle findByC_T_Last(long classNameId, String templateId,
16743                    OrderByComparator<JournalArticle> orderByComparator)
16744                    throws NoSuchArticleException {
16745                    JournalArticle journalArticle = fetchByC_T_Last(classNameId,
16746                                    templateId, orderByComparator);
16747    
16748                    if (journalArticle != null) {
16749                            return journalArticle;
16750                    }
16751    
16752                    StringBundler msg = new StringBundler(6);
16753    
16754                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16755    
16756                    msg.append("classNameId=");
16757                    msg.append(classNameId);
16758    
16759                    msg.append(", templateId=");
16760                    msg.append(templateId);
16761    
16762                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16763    
16764                    throw new NoSuchArticleException(msg.toString());
16765            }
16766    
16767            /**
16768             * Returns the last journal article in the ordered set where classNameId = &#63; and templateId = &#63;.
16769             *
16770             * @param classNameId the class name ID
16771             * @param templateId the template ID
16772             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16773             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
16774             */
16775            @Override
16776            public JournalArticle fetchByC_T_Last(long classNameId, String templateId,
16777                    OrderByComparator<JournalArticle> orderByComparator) {
16778                    int count = countByC_T(classNameId, templateId);
16779    
16780                    if (count == 0) {
16781                            return null;
16782                    }
16783    
16784                    List<JournalArticle> list = findByC_T(classNameId, templateId,
16785                                    count - 1, count, orderByComparator);
16786    
16787                    if (!list.isEmpty()) {
16788                            return list.get(0);
16789                    }
16790    
16791                    return null;
16792            }
16793    
16794            /**
16795             * Returns the journal articles before and after the current journal article in the ordered set where classNameId = &#63; and templateId = &#63;.
16796             *
16797             * @param id the primary key of the current journal article
16798             * @param classNameId the class name ID
16799             * @param templateId the template ID
16800             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16801             * @return the previous, current, and next journal article
16802             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
16803             */
16804            @Override
16805            public JournalArticle[] findByC_T_PrevAndNext(long id, long classNameId,
16806                    String templateId, OrderByComparator<JournalArticle> orderByComparator)
16807                    throws NoSuchArticleException {
16808                    JournalArticle journalArticle = findByPrimaryKey(id);
16809    
16810                    Session session = null;
16811    
16812                    try {
16813                            session = openSession();
16814    
16815                            JournalArticle[] array = new JournalArticleImpl[3];
16816    
16817                            array[0] = getByC_T_PrevAndNext(session, journalArticle,
16818                                            classNameId, templateId, orderByComparator, true);
16819    
16820                            array[1] = journalArticle;
16821    
16822                            array[2] = getByC_T_PrevAndNext(session, journalArticle,
16823                                            classNameId, templateId, orderByComparator, false);
16824    
16825                            return array;
16826                    }
16827                    catch (Exception e) {
16828                            throw processException(e);
16829                    }
16830                    finally {
16831                            closeSession(session);
16832                    }
16833            }
16834    
16835            protected JournalArticle getByC_T_PrevAndNext(Session session,
16836                    JournalArticle journalArticle, long classNameId, String templateId,
16837                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
16838                    StringBundler query = null;
16839    
16840                    if (orderByComparator != null) {
16841                            query = new StringBundler(6 +
16842                                            (orderByComparator.getOrderByFields().length * 6));
16843                    }
16844                    else {
16845                            query = new StringBundler(3);
16846                    }
16847    
16848                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16849    
16850                    query.append(_FINDER_COLUMN_C_T_CLASSNAMEID_2);
16851    
16852                    boolean bindTemplateId = false;
16853    
16854                    if (templateId == null) {
16855                            query.append(_FINDER_COLUMN_C_T_TEMPLATEID_1);
16856                    }
16857                    else if (templateId.equals(StringPool.BLANK)) {
16858                            query.append(_FINDER_COLUMN_C_T_TEMPLATEID_3);
16859                    }
16860                    else {
16861                            bindTemplateId = true;
16862    
16863                            query.append(_FINDER_COLUMN_C_T_TEMPLATEID_2);
16864                    }
16865    
16866                    if (orderByComparator != null) {
16867                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16868    
16869                            if (orderByConditionFields.length > 0) {
16870                                    query.append(WHERE_AND);
16871                            }
16872    
16873                            for (int i = 0; i < orderByConditionFields.length; i++) {
16874                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16875                                    query.append(orderByConditionFields[i]);
16876    
16877                                    if ((i + 1) < orderByConditionFields.length) {
16878                                            if (orderByComparator.isAscending() ^ previous) {
16879                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16880                                            }
16881                                            else {
16882                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16883                                            }
16884                                    }
16885                                    else {
16886                                            if (orderByComparator.isAscending() ^ previous) {
16887                                                    query.append(WHERE_GREATER_THAN);
16888                                            }
16889                                            else {
16890                                                    query.append(WHERE_LESSER_THAN);
16891                                            }
16892                                    }
16893                            }
16894    
16895                            query.append(ORDER_BY_CLAUSE);
16896    
16897                            String[] orderByFields = orderByComparator.getOrderByFields();
16898    
16899                            for (int i = 0; i < orderByFields.length; i++) {
16900                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16901                                    query.append(orderByFields[i]);
16902    
16903                                    if ((i + 1) < orderByFields.length) {
16904                                            if (orderByComparator.isAscending() ^ previous) {
16905                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16906                                            }
16907                                            else {
16908                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16909                                            }
16910                                    }
16911                                    else {
16912                                            if (orderByComparator.isAscending() ^ previous) {
16913                                                    query.append(ORDER_BY_ASC);
16914                                            }
16915                                            else {
16916                                                    query.append(ORDER_BY_DESC);
16917                                            }
16918                                    }
16919                            }
16920                    }
16921                    else {
16922                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16923                    }
16924    
16925                    String sql = query.toString();
16926    
16927                    Query q = session.createQuery(sql);
16928    
16929                    q.setFirstResult(0);
16930                    q.setMaxResults(2);
16931    
16932                    QueryPos qPos = QueryPos.getInstance(q);
16933    
16934                    qPos.add(classNameId);
16935    
16936                    if (bindTemplateId) {
16937                            qPos.add(templateId);
16938                    }
16939    
16940                    if (orderByComparator != null) {
16941                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
16942    
16943                            for (Object value : values) {
16944                                    qPos.add(value);
16945                            }
16946                    }
16947    
16948                    List<JournalArticle> list = q.list();
16949    
16950                    if (list.size() == 2) {
16951                            return list.get(1);
16952                    }
16953                    else {
16954                            return null;
16955                    }
16956            }
16957    
16958            /**
16959             * Removes all the journal articles where classNameId = &#63; and templateId = &#63; from the database.
16960             *
16961             * @param classNameId the class name ID
16962             * @param templateId the template ID
16963             */
16964            @Override
16965            public void removeByC_T(long classNameId, String templateId) {
16966                    for (JournalArticle journalArticle : findByC_T(classNameId, templateId,
16967                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16968                            remove(journalArticle);
16969                    }
16970            }
16971    
16972            /**
16973             * Returns the number of journal articles where classNameId = &#63; and templateId = &#63;.
16974             *
16975             * @param classNameId the class name ID
16976             * @param templateId the template ID
16977             * @return the number of matching journal articles
16978             */
16979            @Override
16980            public int countByC_T(long classNameId, String templateId) {
16981                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_T;
16982    
16983                    Object[] finderArgs = new Object[] { classNameId, templateId };
16984    
16985                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
16986                                    this);
16987    
16988                    if (count == null) {
16989                            StringBundler query = new StringBundler(3);
16990    
16991                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16992    
16993                            query.append(_FINDER_COLUMN_C_T_CLASSNAMEID_2);
16994    
16995                            boolean bindTemplateId = false;
16996    
16997                            if (templateId == null) {
16998                                    query.append(_FINDER_COLUMN_C_T_TEMPLATEID_1);
16999                            }
17000                            else if (templateId.equals(StringPool.BLANK)) {
17001                                    query.append(_FINDER_COLUMN_C_T_TEMPLATEID_3);
17002                            }
17003                            else {
17004                                    bindTemplateId = true;
17005    
17006                                    query.append(_FINDER_COLUMN_C_T_TEMPLATEID_2);
17007                            }
17008    
17009                            String sql = query.toString();
17010    
17011                            Session session = null;
17012    
17013                            try {
17014                                    session = openSession();
17015    
17016                                    Query q = session.createQuery(sql);
17017    
17018                                    QueryPos qPos = QueryPos.getInstance(q);
17019    
17020                                    qPos.add(classNameId);
17021    
17022                                    if (bindTemplateId) {
17023                                            qPos.add(templateId);
17024                                    }
17025    
17026                                    count = (Long)q.uniqueResult();
17027    
17028                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
17029                            }
17030                            catch (Exception e) {
17031                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17032    
17033                                    throw processException(e);
17034                            }
17035                            finally {
17036                                    closeSession(session);
17037                            }
17038                    }
17039    
17040                    return count.intValue();
17041            }
17042    
17043            private static final String _FINDER_COLUMN_C_T_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
17044            private static final String _FINDER_COLUMN_C_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
17045            private static final String _FINDER_COLUMN_C_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
17046            private static final String _FINDER_COLUMN_C_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = '')";
17047            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17048                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
17049                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
17050                            "findByLtD_S",
17051                            new String[] {
17052                                    Date.class.getName(), Integer.class.getName(),
17053                                    
17054                            Integer.class.getName(), Integer.class.getName(),
17055                                    OrderByComparator.class.getName()
17056                            });
17057            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17058                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
17059                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByLtD_S",
17060                            new String[] { Date.class.getName(), Integer.class.getName() });
17061    
17062            /**
17063             * Returns all the journal articles where displayDate &lt; &#63; and status = &#63;.
17064             *
17065             * @param displayDate the display date
17066             * @param status the status
17067             * @return the matching journal articles
17068             */
17069            @Override
17070            public List<JournalArticle> findByLtD_S(Date displayDate, int status) {
17071                    return findByLtD_S(displayDate, status, QueryUtil.ALL_POS,
17072                            QueryUtil.ALL_POS, null);
17073            }
17074    
17075            /**
17076             * Returns a range of all the journal articles where displayDate &lt; &#63; and status = &#63;.
17077             *
17078             * <p>
17079             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
17080             * </p>
17081             *
17082             * @param displayDate the display date
17083             * @param status the status
17084             * @param start the lower bound of the range of journal articles
17085             * @param end the upper bound of the range of journal articles (not inclusive)
17086             * @return the range of matching journal articles
17087             */
17088            @Override
17089            public List<JournalArticle> findByLtD_S(Date displayDate, int status,
17090                    int start, int end) {
17091                    return findByLtD_S(displayDate, status, start, end, null);
17092            }
17093    
17094            /**
17095             * Returns an ordered range of all the journal articles where displayDate &lt; &#63; and status = &#63;.
17096             *
17097             * <p>
17098             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
17099             * </p>
17100             *
17101             * @param displayDate the display date
17102             * @param status the status
17103             * @param start the lower bound of the range of journal articles
17104             * @param end the upper bound of the range of journal articles (not inclusive)
17105             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17106             * @return the ordered range of matching journal articles
17107             */
17108            @Override
17109            public List<JournalArticle> findByLtD_S(Date displayDate, int status,
17110                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
17111                    boolean pagination = true;
17112                    FinderPath finderPath = null;
17113                    Object[] finderArgs = null;
17114    
17115                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S;
17116                    finderArgs = new Object[] {
17117                                    displayDate, status,
17118                                    
17119                                    start, end, orderByComparator
17120                            };
17121    
17122                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
17123                                    finderArgs, this);
17124    
17125                    if ((list != null) && !list.isEmpty()) {
17126                            for (JournalArticle journalArticle : list) {
17127                                    if ((displayDate.getTime() <= journalArticle.getDisplayDate()
17128                                                                                                                                    .getTime()) ||
17129                                                    (status != journalArticle.getStatus())) {
17130                                            list = null;
17131    
17132                                            break;
17133                                    }
17134                            }
17135                    }
17136    
17137                    if (list == null) {
17138                            StringBundler query = null;
17139    
17140                            if (orderByComparator != null) {
17141                                    query = new StringBundler(4 +
17142                                                    (orderByComparator.getOrderByFields().length * 3));
17143                            }
17144                            else {
17145                                    query = new StringBundler(4);
17146                            }
17147    
17148                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17149    
17150                            boolean bindDisplayDate = false;
17151    
17152                            if (displayDate == null) {
17153                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
17154                            }
17155                            else {
17156                                    bindDisplayDate = true;
17157    
17158                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
17159                            }
17160    
17161                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
17162    
17163                            if (orderByComparator != null) {
17164                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17165                                            orderByComparator);
17166                            }
17167                            else
17168                             if (pagination) {
17169                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17170                            }
17171    
17172                            String sql = query.toString();
17173    
17174                            Session session = null;
17175    
17176                            try {
17177                                    session = openSession();
17178    
17179                                    Query q = session.createQuery(sql);
17180    
17181                                    QueryPos qPos = QueryPos.getInstance(q);
17182    
17183                                    if (bindDisplayDate) {
17184                                            qPos.add(new Timestamp(displayDate.getTime()));
17185                                    }
17186    
17187                                    qPos.add(status);
17188    
17189                                    if (!pagination) {
17190                                            list = (List<JournalArticle>)QueryUtil.list(q,
17191                                                            getDialect(), start, end, false);
17192    
17193                                            Collections.sort(list);
17194    
17195                                            list = Collections.unmodifiableList(list);
17196                                    }
17197                                    else {
17198                                            list = (List<JournalArticle>)QueryUtil.list(q,
17199                                                            getDialect(), start, end);
17200                                    }
17201    
17202                                    cacheResult(list);
17203    
17204                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
17205                            }
17206                            catch (Exception e) {
17207                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17208    
17209                                    throw processException(e);
17210                            }
17211                            finally {
17212                                    closeSession(session);
17213                            }
17214                    }
17215    
17216                    return list;
17217            }
17218    
17219            /**
17220             * Returns the first journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
17221             *
17222             * @param displayDate the display date
17223             * @param status the status
17224             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17225             * @return the first matching journal article
17226             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17227             */
17228            @Override
17229            public JournalArticle findByLtD_S_First(Date displayDate, int status,
17230                    OrderByComparator<JournalArticle> orderByComparator)
17231                    throws NoSuchArticleException {
17232                    JournalArticle journalArticle = fetchByLtD_S_First(displayDate, status,
17233                                    orderByComparator);
17234    
17235                    if (journalArticle != null) {
17236                            return journalArticle;
17237                    }
17238    
17239                    StringBundler msg = new StringBundler(6);
17240    
17241                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17242    
17243                    msg.append("displayDate=");
17244                    msg.append(displayDate);
17245    
17246                    msg.append(", status=");
17247                    msg.append(status);
17248    
17249                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17250    
17251                    throw new NoSuchArticleException(msg.toString());
17252            }
17253    
17254            /**
17255             * Returns the first journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
17256             *
17257             * @param displayDate the display date
17258             * @param status the status
17259             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17260             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
17261             */
17262            @Override
17263            public JournalArticle fetchByLtD_S_First(Date displayDate, int status,
17264                    OrderByComparator<JournalArticle> orderByComparator) {
17265                    List<JournalArticle> list = findByLtD_S(displayDate, status, 0, 1,
17266                                    orderByComparator);
17267    
17268                    if (!list.isEmpty()) {
17269                            return list.get(0);
17270                    }
17271    
17272                    return null;
17273            }
17274    
17275            /**
17276             * Returns the last journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
17277             *
17278             * @param displayDate the display date
17279             * @param status the status
17280             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17281             * @return the last matching journal article
17282             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17283             */
17284            @Override
17285            public JournalArticle findByLtD_S_Last(Date displayDate, int status,
17286                    OrderByComparator<JournalArticle> orderByComparator)
17287                    throws NoSuchArticleException {
17288                    JournalArticle journalArticle = fetchByLtD_S_Last(displayDate, status,
17289                                    orderByComparator);
17290    
17291                    if (journalArticle != null) {
17292                            return journalArticle;
17293                    }
17294    
17295                    StringBundler msg = new StringBundler(6);
17296    
17297                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17298    
17299                    msg.append("displayDate=");
17300                    msg.append(displayDate);
17301    
17302                    msg.append(", status=");
17303                    msg.append(status);
17304    
17305                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17306    
17307                    throw new NoSuchArticleException(msg.toString());
17308            }
17309    
17310            /**
17311             * Returns the last journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
17312             *
17313             * @param displayDate the display date
17314             * @param status the status
17315             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17316             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
17317             */
17318            @Override
17319            public JournalArticle fetchByLtD_S_Last(Date displayDate, int status,
17320                    OrderByComparator<JournalArticle> orderByComparator) {
17321                    int count = countByLtD_S(displayDate, status);
17322    
17323                    if (count == 0) {
17324                            return null;
17325                    }
17326    
17327                    List<JournalArticle> list = findByLtD_S(displayDate, status, count - 1,
17328                                    count, orderByComparator);
17329    
17330                    if (!list.isEmpty()) {
17331                            return list.get(0);
17332                    }
17333    
17334                    return null;
17335            }
17336    
17337            /**
17338             * Returns the journal articles before and after the current journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
17339             *
17340             * @param id the primary key of the current journal article
17341             * @param displayDate the display date
17342             * @param status the status
17343             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17344             * @return the previous, current, and next journal article
17345             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
17346             */
17347            @Override
17348            public JournalArticle[] findByLtD_S_PrevAndNext(long id, Date displayDate,
17349                    int status, OrderByComparator<JournalArticle> orderByComparator)
17350                    throws NoSuchArticleException {
17351                    JournalArticle journalArticle = findByPrimaryKey(id);
17352    
17353                    Session session = null;
17354    
17355                    try {
17356                            session = openSession();
17357    
17358                            JournalArticle[] array = new JournalArticleImpl[3];
17359    
17360                            array[0] = getByLtD_S_PrevAndNext(session, journalArticle,
17361                                            displayDate, status, orderByComparator, true);
17362    
17363                            array[1] = journalArticle;
17364    
17365                            array[2] = getByLtD_S_PrevAndNext(session, journalArticle,
17366                                            displayDate, status, orderByComparator, false);
17367    
17368                            return array;
17369                    }
17370                    catch (Exception e) {
17371                            throw processException(e);
17372                    }
17373                    finally {
17374                            closeSession(session);
17375                    }
17376            }
17377    
17378            protected JournalArticle getByLtD_S_PrevAndNext(Session session,
17379                    JournalArticle journalArticle, Date displayDate, int status,
17380                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
17381                    StringBundler query = null;
17382    
17383                    if (orderByComparator != null) {
17384                            query = new StringBundler(6 +
17385                                            (orderByComparator.getOrderByFields().length * 6));
17386                    }
17387                    else {
17388                            query = new StringBundler(3);
17389                    }
17390    
17391                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17392    
17393                    boolean bindDisplayDate = false;
17394    
17395                    if (displayDate == null) {
17396                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
17397                    }
17398                    else {
17399                            bindDisplayDate = true;
17400    
17401                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
17402                    }
17403    
17404                    query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
17405    
17406                    if (orderByComparator != null) {
17407                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17408    
17409                            if (orderByConditionFields.length > 0) {
17410                                    query.append(WHERE_AND);
17411                            }
17412    
17413                            for (int i = 0; i < orderByConditionFields.length; i++) {
17414                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17415                                    query.append(orderByConditionFields[i]);
17416    
17417                                    if ((i + 1) < orderByConditionFields.length) {
17418                                            if (orderByComparator.isAscending() ^ previous) {
17419                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17420                                            }
17421                                            else {
17422                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17423                                            }
17424                                    }
17425                                    else {
17426                                            if (orderByComparator.isAscending() ^ previous) {
17427                                                    query.append(WHERE_GREATER_THAN);
17428                                            }
17429                                            else {
17430                                                    query.append(WHERE_LESSER_THAN);
17431                                            }
17432                                    }
17433                            }
17434    
17435                            query.append(ORDER_BY_CLAUSE);
17436    
17437                            String[] orderByFields = orderByComparator.getOrderByFields();
17438    
17439                            for (int i = 0; i < orderByFields.length; i++) {
17440                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17441                                    query.append(orderByFields[i]);
17442    
17443                                    if ((i + 1) < orderByFields.length) {
17444                                            if (orderByComparator.isAscending() ^ previous) {
17445                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17446                                            }
17447                                            else {
17448                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17449                                            }
17450                                    }
17451                                    else {
17452                                            if (orderByComparator.isAscending() ^ previous) {
17453                                                    query.append(ORDER_BY_ASC);
17454                                            }
17455                                            else {
17456                                                    query.append(ORDER_BY_DESC);
17457                                            }
17458                                    }
17459                            }
17460                    }
17461                    else {
17462                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17463                    }
17464    
17465                    String sql = query.toString();
17466    
17467                    Query q = session.createQuery(sql);
17468    
17469                    q.setFirstResult(0);
17470                    q.setMaxResults(2);
17471    
17472                    QueryPos qPos = QueryPos.getInstance(q);
17473    
17474                    if (bindDisplayDate) {
17475                            qPos.add(new Timestamp(displayDate.getTime()));
17476                    }
17477    
17478                    qPos.add(status);
17479    
17480                    if (orderByComparator != null) {
17481                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
17482    
17483                            for (Object value : values) {
17484                                    qPos.add(value);
17485                            }
17486                    }
17487    
17488                    List<JournalArticle> list = q.list();
17489    
17490                    if (list.size() == 2) {
17491                            return list.get(1);
17492                    }
17493                    else {
17494                            return null;
17495                    }
17496            }
17497    
17498            /**
17499             * Removes all the journal articles where displayDate &lt; &#63; and status = &#63; from the database.
17500             *
17501             * @param displayDate the display date
17502             * @param status the status
17503             */
17504            @Override
17505            public void removeByLtD_S(Date displayDate, int status) {
17506                    for (JournalArticle journalArticle : findByLtD_S(displayDate, status,
17507                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
17508                            remove(journalArticle);
17509                    }
17510            }
17511    
17512            /**
17513             * Returns the number of journal articles where displayDate &lt; &#63; and status = &#63;.
17514             *
17515             * @param displayDate the display date
17516             * @param status the status
17517             * @return the number of matching journal articles
17518             */
17519            @Override
17520            public int countByLtD_S(Date displayDate, int status) {
17521                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S;
17522    
17523                    Object[] finderArgs = new Object[] { displayDate, status };
17524    
17525                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
17526                                    this);
17527    
17528                    if (count == null) {
17529                            StringBundler query = new StringBundler(3);
17530    
17531                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17532    
17533                            boolean bindDisplayDate = false;
17534    
17535                            if (displayDate == null) {
17536                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
17537                            }
17538                            else {
17539                                    bindDisplayDate = true;
17540    
17541                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
17542                            }
17543    
17544                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
17545    
17546                            String sql = query.toString();
17547    
17548                            Session session = null;
17549    
17550                            try {
17551                                    session = openSession();
17552    
17553                                    Query q = session.createQuery(sql);
17554    
17555                                    QueryPos qPos = QueryPos.getInstance(q);
17556    
17557                                    if (bindDisplayDate) {
17558                                            qPos.add(new Timestamp(displayDate.getTime()));
17559                                    }
17560    
17561                                    qPos.add(status);
17562    
17563                                    count = (Long)q.uniqueResult();
17564    
17565                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
17566                            }
17567                            catch (Exception e) {
17568                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17569    
17570                                    throw processException(e);
17571                            }
17572                            finally {
17573                                    closeSession(session);
17574                            }
17575                    }
17576    
17577                    return count.intValue();
17578            }
17579    
17580            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_1 = "journalArticle.displayDate < NULL AND ";
17581            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_2 = "journalArticle.displayDate < ? AND ";
17582            private static final String _FINDER_COLUMN_LTD_S_STATUS_2 = "journalArticle.status = ?";
17583            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17584                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
17585                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
17586                            "findByR_I_S",
17587                            new String[] {
17588                                    Long.class.getName(), Boolean.class.getName(),
17589                                    Integer.class.getName(),
17590                                    
17591                            Integer.class.getName(), Integer.class.getName(),
17592                                    OrderByComparator.class.getName()
17593                            });
17594            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17595                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
17596                            JournalArticleImpl.class,
17597                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_I_S",
17598                            new String[] {
17599                                    Long.class.getName(), Boolean.class.getName(),
17600                                    Integer.class.getName()
17601                            },
17602                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
17603                            JournalArticleModelImpl.INDEXABLE_COLUMN_BITMASK |
17604                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
17605                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
17606                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
17607            public static final FinderPath FINDER_PATH_COUNT_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17608                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
17609                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_I_S",
17610                            new String[] {
17611                                    Long.class.getName(), Boolean.class.getName(),
17612                                    Integer.class.getName()
17613                            });
17614            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17615                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
17616                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByR_I_S",
17617                            new String[] {
17618                                    Long.class.getName(), Boolean.class.getName(),
17619                                    Integer.class.getName()
17620                            });
17621    
17622            /**
17623             * Returns all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
17624             *
17625             * @param resourcePrimKey the resource prim key
17626             * @param indexable the indexable
17627             * @param status the status
17628             * @return the matching journal articles
17629             */
17630            @Override
17631            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
17632                    boolean indexable, int status) {
17633                    return findByR_I_S(resourcePrimKey, indexable, status,
17634                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
17635            }
17636    
17637            /**
17638             * Returns a range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
17639             *
17640             * <p>
17641             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
17642             * </p>
17643             *
17644             * @param resourcePrimKey the resource prim key
17645             * @param indexable the indexable
17646             * @param status the status
17647             * @param start the lower bound of the range of journal articles
17648             * @param end the upper bound of the range of journal articles (not inclusive)
17649             * @return the range of matching journal articles
17650             */
17651            @Override
17652            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
17653                    boolean indexable, int status, int start, int end) {
17654                    return findByR_I_S(resourcePrimKey, indexable, status, start, end, null);
17655            }
17656    
17657            /**
17658             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
17659             *
17660             * <p>
17661             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
17662             * </p>
17663             *
17664             * @param resourcePrimKey the resource prim key
17665             * @param indexable the indexable
17666             * @param status the status
17667             * @param start the lower bound of the range of journal articles
17668             * @param end the upper bound of the range of journal articles (not inclusive)
17669             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17670             * @return the ordered range of matching journal articles
17671             */
17672            @Override
17673            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
17674                    boolean indexable, int status, int start, int end,
17675                    OrderByComparator<JournalArticle> orderByComparator) {
17676                    boolean pagination = true;
17677                    FinderPath finderPath = null;
17678                    Object[] finderArgs = null;
17679    
17680                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
17681                                    (orderByComparator == null)) {
17682                            pagination = false;
17683                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S;
17684                            finderArgs = new Object[] { resourcePrimKey, indexable, status };
17685                    }
17686                    else {
17687                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S;
17688                            finderArgs = new Object[] {
17689                                            resourcePrimKey, indexable, status,
17690                                            
17691                                            start, end, orderByComparator
17692                                    };
17693                    }
17694    
17695                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
17696                                    finderArgs, this);
17697    
17698                    if ((list != null) && !list.isEmpty()) {
17699                            for (JournalArticle journalArticle : list) {
17700                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
17701                                                    (indexable != journalArticle.getIndexable()) ||
17702                                                    (status != journalArticle.getStatus())) {
17703                                            list = null;
17704    
17705                                            break;
17706                                    }
17707                            }
17708                    }
17709    
17710                    if (list == null) {
17711                            StringBundler query = null;
17712    
17713                            if (orderByComparator != null) {
17714                                    query = new StringBundler(5 +
17715                                                    (orderByComparator.getOrderByFields().length * 3));
17716                            }
17717                            else {
17718                                    query = new StringBundler(5);
17719                            }
17720    
17721                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17722    
17723                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2);
17724    
17725                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_2);
17726    
17727                            query.append(_FINDER_COLUMN_R_I_S_STATUS_2);
17728    
17729                            if (orderByComparator != null) {
17730                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17731                                            orderByComparator);
17732                            }
17733                            else
17734                             if (pagination) {
17735                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17736                            }
17737    
17738                            String sql = query.toString();
17739    
17740                            Session session = null;
17741    
17742                            try {
17743                                    session = openSession();
17744    
17745                                    Query q = session.createQuery(sql);
17746    
17747                                    QueryPos qPos = QueryPos.getInstance(q);
17748    
17749                                    qPos.add(resourcePrimKey);
17750    
17751                                    qPos.add(indexable);
17752    
17753                                    qPos.add(status);
17754    
17755                                    if (!pagination) {
17756                                            list = (List<JournalArticle>)QueryUtil.list(q,
17757                                                            getDialect(), start, end, false);
17758    
17759                                            Collections.sort(list);
17760    
17761                                            list = Collections.unmodifiableList(list);
17762                                    }
17763                                    else {
17764                                            list = (List<JournalArticle>)QueryUtil.list(q,
17765                                                            getDialect(), start, end);
17766                                    }
17767    
17768                                    cacheResult(list);
17769    
17770                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
17771                            }
17772                            catch (Exception e) {
17773                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17774    
17775                                    throw processException(e);
17776                            }
17777                            finally {
17778                                    closeSession(session);
17779                            }
17780                    }
17781    
17782                    return list;
17783            }
17784    
17785            /**
17786             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
17787             *
17788             * @param resourcePrimKey the resource prim key
17789             * @param indexable the indexable
17790             * @param status the status
17791             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17792             * @return the first matching journal article
17793             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17794             */
17795            @Override
17796            public JournalArticle findByR_I_S_First(long resourcePrimKey,
17797                    boolean indexable, int status,
17798                    OrderByComparator<JournalArticle> orderByComparator)
17799                    throws NoSuchArticleException {
17800                    JournalArticle journalArticle = fetchByR_I_S_First(resourcePrimKey,
17801                                    indexable, status, orderByComparator);
17802    
17803                    if (journalArticle != null) {
17804                            return journalArticle;
17805                    }
17806    
17807                    StringBundler msg = new StringBundler(8);
17808    
17809                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17810    
17811                    msg.append("resourcePrimKey=");
17812                    msg.append(resourcePrimKey);
17813    
17814                    msg.append(", indexable=");
17815                    msg.append(indexable);
17816    
17817                    msg.append(", status=");
17818                    msg.append(status);
17819    
17820                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17821    
17822                    throw new NoSuchArticleException(msg.toString());
17823            }
17824    
17825            /**
17826             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
17827             *
17828             * @param resourcePrimKey the resource prim key
17829             * @param indexable the indexable
17830             * @param status the status
17831             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17832             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
17833             */
17834            @Override
17835            public JournalArticle fetchByR_I_S_First(long resourcePrimKey,
17836                    boolean indexable, int status,
17837                    OrderByComparator<JournalArticle> orderByComparator) {
17838                    List<JournalArticle> list = findByR_I_S(resourcePrimKey, indexable,
17839                                    status, 0, 1, orderByComparator);
17840    
17841                    if (!list.isEmpty()) {
17842                            return list.get(0);
17843                    }
17844    
17845                    return null;
17846            }
17847    
17848            /**
17849             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
17850             *
17851             * @param resourcePrimKey the resource prim key
17852             * @param indexable the indexable
17853             * @param status the status
17854             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17855             * @return the last matching journal article
17856             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17857             */
17858            @Override
17859            public JournalArticle findByR_I_S_Last(long resourcePrimKey,
17860                    boolean indexable, int status,
17861                    OrderByComparator<JournalArticle> orderByComparator)
17862                    throws NoSuchArticleException {
17863                    JournalArticle journalArticle = fetchByR_I_S_Last(resourcePrimKey,
17864                                    indexable, status, orderByComparator);
17865    
17866                    if (journalArticle != null) {
17867                            return journalArticle;
17868                    }
17869    
17870                    StringBundler msg = new StringBundler(8);
17871    
17872                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17873    
17874                    msg.append("resourcePrimKey=");
17875                    msg.append(resourcePrimKey);
17876    
17877                    msg.append(", indexable=");
17878                    msg.append(indexable);
17879    
17880                    msg.append(", status=");
17881                    msg.append(status);
17882    
17883                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17884    
17885                    throw new NoSuchArticleException(msg.toString());
17886            }
17887    
17888            /**
17889             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
17890             *
17891             * @param resourcePrimKey the resource prim key
17892             * @param indexable the indexable
17893             * @param status the status
17894             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17895             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
17896             */
17897            @Override
17898            public JournalArticle fetchByR_I_S_Last(long resourcePrimKey,
17899                    boolean indexable, int status,
17900                    OrderByComparator<JournalArticle> orderByComparator) {
17901                    int count = countByR_I_S(resourcePrimKey, indexable, status);
17902    
17903                    if (count == 0) {
17904                            return null;
17905                    }
17906    
17907                    List<JournalArticle> list = findByR_I_S(resourcePrimKey, indexable,
17908                                    status, count - 1, count, orderByComparator);
17909    
17910                    if (!list.isEmpty()) {
17911                            return list.get(0);
17912                    }
17913    
17914                    return null;
17915            }
17916    
17917            /**
17918             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
17919             *
17920             * @param id the primary key of the current journal article
17921             * @param resourcePrimKey the resource prim key
17922             * @param indexable the indexable
17923             * @param status the status
17924             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17925             * @return the previous, current, and next journal article
17926             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
17927             */
17928            @Override
17929            public JournalArticle[] findByR_I_S_PrevAndNext(long id,
17930                    long resourcePrimKey, boolean indexable, int status,
17931                    OrderByComparator<JournalArticle> orderByComparator)
17932                    throws NoSuchArticleException {
17933                    JournalArticle journalArticle = findByPrimaryKey(id);
17934    
17935                    Session session = null;
17936    
17937                    try {
17938                            session = openSession();
17939    
17940                            JournalArticle[] array = new JournalArticleImpl[3];
17941    
17942                            array[0] = getByR_I_S_PrevAndNext(session, journalArticle,
17943                                            resourcePrimKey, indexable, status, orderByComparator, true);
17944    
17945                            array[1] = journalArticle;
17946    
17947                            array[2] = getByR_I_S_PrevAndNext(session, journalArticle,
17948                                            resourcePrimKey, indexable, status, orderByComparator, false);
17949    
17950                            return array;
17951                    }
17952                    catch (Exception e) {
17953                            throw processException(e);
17954                    }
17955                    finally {
17956                            closeSession(session);
17957                    }
17958            }
17959    
17960            protected JournalArticle getByR_I_S_PrevAndNext(Session session,
17961                    JournalArticle journalArticle, long resourcePrimKey, boolean indexable,
17962                    int status, OrderByComparator<JournalArticle> orderByComparator,
17963                    boolean previous) {
17964                    StringBundler query = null;
17965    
17966                    if (orderByComparator != null) {
17967                            query = new StringBundler(6 +
17968                                            (orderByComparator.getOrderByFields().length * 6));
17969                    }
17970                    else {
17971                            query = new StringBundler(3);
17972                    }
17973    
17974                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17975    
17976                    query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2);
17977    
17978                    query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_2);
17979    
17980                    query.append(_FINDER_COLUMN_R_I_S_STATUS_2);
17981    
17982                    if (orderByComparator != null) {
17983                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17984    
17985                            if (orderByConditionFields.length > 0) {
17986                                    query.append(WHERE_AND);
17987                            }
17988    
17989                            for (int i = 0; i < orderByConditionFields.length; i++) {
17990                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17991                                    query.append(orderByConditionFields[i]);
17992    
17993                                    if ((i + 1) < orderByConditionFields.length) {
17994                                            if (orderByComparator.isAscending() ^ previous) {
17995                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17996                                            }
17997                                            else {
17998                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17999                                            }
18000                                    }
18001                                    else {
18002                                            if (orderByComparator.isAscending() ^ previous) {
18003                                                    query.append(WHERE_GREATER_THAN);
18004                                            }
18005                                            else {
18006                                                    query.append(WHERE_LESSER_THAN);
18007                                            }
18008                                    }
18009                            }
18010    
18011                            query.append(ORDER_BY_CLAUSE);
18012    
18013                            String[] orderByFields = orderByComparator.getOrderByFields();
18014    
18015                            for (int i = 0; i < orderByFields.length; i++) {
18016                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18017                                    query.append(orderByFields[i]);
18018    
18019                                    if ((i + 1) < orderByFields.length) {
18020                                            if (orderByComparator.isAscending() ^ previous) {
18021                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
18022                                            }
18023                                            else {
18024                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
18025                                            }
18026                                    }
18027                                    else {
18028                                            if (orderByComparator.isAscending() ^ previous) {
18029                                                    query.append(ORDER_BY_ASC);
18030                                            }
18031                                            else {
18032                                                    query.append(ORDER_BY_DESC);
18033                                            }
18034                                    }
18035                            }
18036                    }
18037                    else {
18038                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18039                    }
18040    
18041                    String sql = query.toString();
18042    
18043                    Query q = session.createQuery(sql);
18044    
18045                    q.setFirstResult(0);
18046                    q.setMaxResults(2);
18047    
18048                    QueryPos qPos = QueryPos.getInstance(q);
18049    
18050                    qPos.add(resourcePrimKey);
18051    
18052                    qPos.add(indexable);
18053    
18054                    qPos.add(status);
18055    
18056                    if (orderByComparator != null) {
18057                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
18058    
18059                            for (Object value : values) {
18060                                    qPos.add(value);
18061                            }
18062                    }
18063    
18064                    List<JournalArticle> list = q.list();
18065    
18066                    if (list.size() == 2) {
18067                            return list.get(1);
18068                    }
18069                    else {
18070                            return null;
18071                    }
18072            }
18073    
18074            /**
18075             * Returns all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
18076             *
18077             * <p>
18078             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
18079             * </p>
18080             *
18081             * @param resourcePrimKey the resource prim key
18082             * @param indexable the indexable
18083             * @param statuses the statuses
18084             * @return the matching journal articles
18085             */
18086            @Override
18087            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
18088                    boolean indexable, int[] statuses) {
18089                    return findByR_I_S(resourcePrimKey, indexable, statuses,
18090                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
18091            }
18092    
18093            /**
18094             * Returns a range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
18095             *
18096             * <p>
18097             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
18098             * </p>
18099             *
18100             * @param resourcePrimKey the resource prim key
18101             * @param indexable the indexable
18102             * @param statuses the statuses
18103             * @param start the lower bound of the range of journal articles
18104             * @param end the upper bound of the range of journal articles (not inclusive)
18105             * @return the range of matching journal articles
18106             */
18107            @Override
18108            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
18109                    boolean indexable, int[] statuses, int start, int end) {
18110                    return findByR_I_S(resourcePrimKey, indexable, statuses, start, end,
18111                            null);
18112            }
18113    
18114            /**
18115             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
18116             *
18117             * <p>
18118             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
18119             * </p>
18120             *
18121             * @param resourcePrimKey the resource prim key
18122             * @param indexable the indexable
18123             * @param statuses the statuses
18124             * @param start the lower bound of the range of journal articles
18125             * @param end the upper bound of the range of journal articles (not inclusive)
18126             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18127             * @return the ordered range of matching journal articles
18128             */
18129            @Override
18130            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
18131                    boolean indexable, int[] statuses, int start, int end,
18132                    OrderByComparator<JournalArticle> orderByComparator) {
18133                    if (statuses == null) {
18134                            statuses = new int[0];
18135                    }
18136                    else {
18137                            statuses = ArrayUtil.unique(statuses);
18138                    }
18139    
18140                    if (statuses.length == 1) {
18141                            return findByR_I_S(resourcePrimKey, indexable, statuses[0], start,
18142                                    end, orderByComparator);
18143                    }
18144    
18145                    boolean pagination = true;
18146                    Object[] finderArgs = null;
18147    
18148                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
18149                                    (orderByComparator == null)) {
18150                            pagination = false;
18151                            finderArgs = new Object[] {
18152                                            resourcePrimKey, indexable, StringUtil.merge(statuses)
18153                                    };
18154                    }
18155                    else {
18156                            finderArgs = new Object[] {
18157                                            resourcePrimKey, indexable, StringUtil.merge(statuses),
18158                                            
18159                                            start, end, orderByComparator
18160                                    };
18161                    }
18162    
18163                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S,
18164                                    finderArgs, this);
18165    
18166                    if ((list != null) && !list.isEmpty()) {
18167                            for (JournalArticle journalArticle : list) {
18168                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
18169                                                    (indexable != journalArticle.getIndexable()) ||
18170                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
18171                                            list = null;
18172    
18173                                            break;
18174                                    }
18175                            }
18176                    }
18177    
18178                    if (list == null) {
18179                            StringBundler query = new StringBundler();
18180    
18181                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18182    
18183                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2);
18184    
18185                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_2);
18186    
18187                            if (statuses.length > 0) {
18188                                    query.append(StringPool.OPEN_PARENTHESIS);
18189    
18190                                    query.append(_FINDER_COLUMN_R_I_S_STATUS_7);
18191    
18192                                    query.append(StringUtil.merge(statuses));
18193    
18194                                    query.append(StringPool.CLOSE_PARENTHESIS);
18195    
18196                                    query.append(StringPool.CLOSE_PARENTHESIS);
18197                            }
18198    
18199                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
18200                                                    1)), query.index() - 1);
18201    
18202                            if (orderByComparator != null) {
18203                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18204                                            orderByComparator);
18205                            }
18206                            else
18207                             if (pagination) {
18208                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18209                            }
18210    
18211                            String sql = query.toString();
18212    
18213                            Session session = null;
18214    
18215                            try {
18216                                    session = openSession();
18217    
18218                                    Query q = session.createQuery(sql);
18219    
18220                                    QueryPos qPos = QueryPos.getInstance(q);
18221    
18222                                    qPos.add(resourcePrimKey);
18223    
18224                                    qPos.add(indexable);
18225    
18226                                    if (!pagination) {
18227                                            list = (List<JournalArticle>)QueryUtil.list(q,
18228                                                            getDialect(), start, end, false);
18229    
18230                                            Collections.sort(list);
18231    
18232                                            list = Collections.unmodifiableList(list);
18233                                    }
18234                                    else {
18235                                            list = (List<JournalArticle>)QueryUtil.list(q,
18236                                                            getDialect(), start, end);
18237                                    }
18238    
18239                                    cacheResult(list);
18240    
18241                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S,
18242                                            finderArgs, list);
18243                            }
18244                            catch (Exception e) {
18245                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S,
18246                                            finderArgs);
18247    
18248                                    throw processException(e);
18249                            }
18250                            finally {
18251                                    closeSession(session);
18252                            }
18253                    }
18254    
18255                    return list;
18256            }
18257    
18258            /**
18259             * Removes all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63; from the database.
18260             *
18261             * @param resourcePrimKey the resource prim key
18262             * @param indexable the indexable
18263             * @param status the status
18264             */
18265            @Override
18266            public void removeByR_I_S(long resourcePrimKey, boolean indexable,
18267                    int status) {
18268                    for (JournalArticle journalArticle : findByR_I_S(resourcePrimKey,
18269                                    indexable, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
18270                            remove(journalArticle);
18271                    }
18272            }
18273    
18274            /**
18275             * Returns the number of journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
18276             *
18277             * @param resourcePrimKey the resource prim key
18278             * @param indexable the indexable
18279             * @param status the status
18280             * @return the number of matching journal articles
18281             */
18282            @Override
18283            public int countByR_I_S(long resourcePrimKey, boolean indexable, int status) {
18284                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_I_S;
18285    
18286                    Object[] finderArgs = new Object[] { resourcePrimKey, indexable, status };
18287    
18288                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
18289                                    this);
18290    
18291                    if (count == null) {
18292                            StringBundler query = new StringBundler(4);
18293    
18294                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18295    
18296                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2);
18297    
18298                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_2);
18299    
18300                            query.append(_FINDER_COLUMN_R_I_S_STATUS_2);
18301    
18302                            String sql = query.toString();
18303    
18304                            Session session = null;
18305    
18306                            try {
18307                                    session = openSession();
18308    
18309                                    Query q = session.createQuery(sql);
18310    
18311                                    QueryPos qPos = QueryPos.getInstance(q);
18312    
18313                                    qPos.add(resourcePrimKey);
18314    
18315                                    qPos.add(indexable);
18316    
18317                                    qPos.add(status);
18318    
18319                                    count = (Long)q.uniqueResult();
18320    
18321                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
18322                            }
18323                            catch (Exception e) {
18324                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18325    
18326                                    throw processException(e);
18327                            }
18328                            finally {
18329                                    closeSession(session);
18330                            }
18331                    }
18332    
18333                    return count.intValue();
18334            }
18335    
18336            /**
18337             * Returns the number of journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
18338             *
18339             * @param resourcePrimKey the resource prim key
18340             * @param indexable the indexable
18341             * @param statuses the statuses
18342             * @return the number of matching journal articles
18343             */
18344            @Override
18345            public int countByR_I_S(long resourcePrimKey, boolean indexable,
18346                    int[] statuses) {
18347                    if (statuses == null) {
18348                            statuses = new int[0];
18349                    }
18350                    else {
18351                            statuses = ArrayUtil.unique(statuses);
18352                    }
18353    
18354                    Object[] finderArgs = new Object[] {
18355                                    resourcePrimKey, indexable, StringUtil.merge(statuses)
18356                            };
18357    
18358                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S,
18359                                    finderArgs, this);
18360    
18361                    if (count == null) {
18362                            StringBundler query = new StringBundler();
18363    
18364                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18365    
18366                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2);
18367    
18368                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_2);
18369    
18370                            if (statuses.length > 0) {
18371                                    query.append(StringPool.OPEN_PARENTHESIS);
18372    
18373                                    query.append(_FINDER_COLUMN_R_I_S_STATUS_7);
18374    
18375                                    query.append(StringUtil.merge(statuses));
18376    
18377                                    query.append(StringPool.CLOSE_PARENTHESIS);
18378    
18379                                    query.append(StringPool.CLOSE_PARENTHESIS);
18380                            }
18381    
18382                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
18383                                                    1)), query.index() - 1);
18384    
18385                            String sql = query.toString();
18386    
18387                            Session session = null;
18388    
18389                            try {
18390                                    session = openSession();
18391    
18392                                    Query q = session.createQuery(sql);
18393    
18394                                    QueryPos qPos = QueryPos.getInstance(q);
18395    
18396                                    qPos.add(resourcePrimKey);
18397    
18398                                    qPos.add(indexable);
18399    
18400                                    count = (Long)q.uniqueResult();
18401    
18402                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S,
18403                                            finderArgs, count);
18404                            }
18405                            catch (Exception e) {
18406                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S,
18407                                            finderArgs);
18408    
18409                                    throw processException(e);
18410                            }
18411                            finally {
18412                                    closeSession(session);
18413                            }
18414                    }
18415    
18416                    return count.intValue();
18417            }
18418    
18419            private static final String _FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
18420            private static final String _FINDER_COLUMN_R_I_S_INDEXABLE_2 = "journalArticle.indexable = ? AND ";
18421            private static final String _FINDER_COLUMN_R_I_S_STATUS_2 = "journalArticle.status = ?";
18422            private static final String _FINDER_COLUMN_R_I_S_STATUS_7 = "journalArticle.status IN (";
18423            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18424                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
18425                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
18426                            "findByG_U_C",
18427                            new String[] {
18428                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
18429                                    
18430                            Integer.class.getName(), Integer.class.getName(),
18431                                    OrderByComparator.class.getName()
18432                            });
18433            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18434                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
18435                            JournalArticleImpl.class,
18436                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_C",
18437                            new String[] {
18438                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
18439                            },
18440                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
18441                            JournalArticleModelImpl.USERID_COLUMN_BITMASK |
18442                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
18443                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
18444                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
18445            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18446                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
18447                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_C",
18448                            new String[] {
18449                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
18450                            });
18451    
18452            /**
18453             * Returns all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18454             *
18455             * @param groupId the group ID
18456             * @param userId the user ID
18457             * @param classNameId the class name ID
18458             * @return the matching journal articles
18459             */
18460            @Override
18461            public List<JournalArticle> findByG_U_C(long groupId, long userId,
18462                    long classNameId) {
18463                    return findByG_U_C(groupId, userId, classNameId, QueryUtil.ALL_POS,
18464                            QueryUtil.ALL_POS, null);
18465            }
18466    
18467            /**
18468             * Returns a range of all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18469             *
18470             * <p>
18471             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
18472             * </p>
18473             *
18474             * @param groupId the group ID
18475             * @param userId the user ID
18476             * @param classNameId the class name ID
18477             * @param start the lower bound of the range of journal articles
18478             * @param end the upper bound of the range of journal articles (not inclusive)
18479             * @return the range of matching journal articles
18480             */
18481            @Override
18482            public List<JournalArticle> findByG_U_C(long groupId, long userId,
18483                    long classNameId, int start, int end) {
18484                    return findByG_U_C(groupId, userId, classNameId, start, end, null);
18485            }
18486    
18487            /**
18488             * Returns an ordered range of all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18489             *
18490             * <p>
18491             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
18492             * </p>
18493             *
18494             * @param groupId the group ID
18495             * @param userId the user ID
18496             * @param classNameId the class name ID
18497             * @param start the lower bound of the range of journal articles
18498             * @param end the upper bound of the range of journal articles (not inclusive)
18499             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18500             * @return the ordered range of matching journal articles
18501             */
18502            @Override
18503            public List<JournalArticle> findByG_U_C(long groupId, long userId,
18504                    long classNameId, int start, int end,
18505                    OrderByComparator<JournalArticle> orderByComparator) {
18506                    boolean pagination = true;
18507                    FinderPath finderPath = null;
18508                    Object[] finderArgs = null;
18509    
18510                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
18511                                    (orderByComparator == null)) {
18512                            pagination = false;
18513                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C;
18514                            finderArgs = new Object[] { groupId, userId, classNameId };
18515                    }
18516                    else {
18517                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_C;
18518                            finderArgs = new Object[] {
18519                                            groupId, userId, classNameId,
18520                                            
18521                                            start, end, orderByComparator
18522                                    };
18523                    }
18524    
18525                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
18526                                    finderArgs, this);
18527    
18528                    if ((list != null) && !list.isEmpty()) {
18529                            for (JournalArticle journalArticle : list) {
18530                                    if ((groupId != journalArticle.getGroupId()) ||
18531                                                    (userId != journalArticle.getUserId()) ||
18532                                                    (classNameId != journalArticle.getClassNameId())) {
18533                                            list = null;
18534    
18535                                            break;
18536                                    }
18537                            }
18538                    }
18539    
18540                    if (list == null) {
18541                            StringBundler query = null;
18542    
18543                            if (orderByComparator != null) {
18544                                    query = new StringBundler(5 +
18545                                                    (orderByComparator.getOrderByFields().length * 3));
18546                            }
18547                            else {
18548                                    query = new StringBundler(5);
18549                            }
18550    
18551                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18552    
18553                            query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
18554    
18555                            query.append(_FINDER_COLUMN_G_U_C_USERID_2);
18556    
18557                            query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
18558    
18559                            if (orderByComparator != null) {
18560                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18561                                            orderByComparator);
18562                            }
18563                            else
18564                             if (pagination) {
18565                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18566                            }
18567    
18568                            String sql = query.toString();
18569    
18570                            Session session = null;
18571    
18572                            try {
18573                                    session = openSession();
18574    
18575                                    Query q = session.createQuery(sql);
18576    
18577                                    QueryPos qPos = QueryPos.getInstance(q);
18578    
18579                                    qPos.add(groupId);
18580    
18581                                    qPos.add(userId);
18582    
18583                                    qPos.add(classNameId);
18584    
18585                                    if (!pagination) {
18586                                            list = (List<JournalArticle>)QueryUtil.list(q,
18587                                                            getDialect(), start, end, false);
18588    
18589                                            Collections.sort(list);
18590    
18591                                            list = Collections.unmodifiableList(list);
18592                                    }
18593                                    else {
18594                                            list = (List<JournalArticle>)QueryUtil.list(q,
18595                                                            getDialect(), start, end);
18596                                    }
18597    
18598                                    cacheResult(list);
18599    
18600                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
18601                            }
18602                            catch (Exception e) {
18603                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18604    
18605                                    throw processException(e);
18606                            }
18607                            finally {
18608                                    closeSession(session);
18609                            }
18610                    }
18611    
18612                    return list;
18613            }
18614    
18615            /**
18616             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18617             *
18618             * @param groupId the group ID
18619             * @param userId the user ID
18620             * @param classNameId the class name ID
18621             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18622             * @return the first matching journal article
18623             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
18624             */
18625            @Override
18626            public JournalArticle findByG_U_C_First(long groupId, long userId,
18627                    long classNameId, OrderByComparator<JournalArticle> orderByComparator)
18628                    throws NoSuchArticleException {
18629                    JournalArticle journalArticle = fetchByG_U_C_First(groupId, userId,
18630                                    classNameId, orderByComparator);
18631    
18632                    if (journalArticle != null) {
18633                            return journalArticle;
18634                    }
18635    
18636                    StringBundler msg = new StringBundler(8);
18637    
18638                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
18639    
18640                    msg.append("groupId=");
18641                    msg.append(groupId);
18642    
18643                    msg.append(", userId=");
18644                    msg.append(userId);
18645    
18646                    msg.append(", classNameId=");
18647                    msg.append(classNameId);
18648    
18649                    msg.append(StringPool.CLOSE_CURLY_BRACE);
18650    
18651                    throw new NoSuchArticleException(msg.toString());
18652            }
18653    
18654            /**
18655             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18656             *
18657             * @param groupId the group ID
18658             * @param userId the user ID
18659             * @param classNameId the class name ID
18660             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18661             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
18662             */
18663            @Override
18664            public JournalArticle fetchByG_U_C_First(long groupId, long userId,
18665                    long classNameId, OrderByComparator<JournalArticle> orderByComparator) {
18666                    List<JournalArticle> list = findByG_U_C(groupId, userId, classNameId,
18667                                    0, 1, orderByComparator);
18668    
18669                    if (!list.isEmpty()) {
18670                            return list.get(0);
18671                    }
18672    
18673                    return null;
18674            }
18675    
18676            /**
18677             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18678             *
18679             * @param groupId the group ID
18680             * @param userId the user ID
18681             * @param classNameId the class name ID
18682             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18683             * @return the last matching journal article
18684             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
18685             */
18686            @Override
18687            public JournalArticle findByG_U_C_Last(long groupId, long userId,
18688                    long classNameId, OrderByComparator<JournalArticle> orderByComparator)
18689                    throws NoSuchArticleException {
18690                    JournalArticle journalArticle = fetchByG_U_C_Last(groupId, userId,
18691                                    classNameId, orderByComparator);
18692    
18693                    if (journalArticle != null) {
18694                            return journalArticle;
18695                    }
18696    
18697                    StringBundler msg = new StringBundler(8);
18698    
18699                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
18700    
18701                    msg.append("groupId=");
18702                    msg.append(groupId);
18703    
18704                    msg.append(", userId=");
18705                    msg.append(userId);
18706    
18707                    msg.append(", classNameId=");
18708                    msg.append(classNameId);
18709    
18710                    msg.append(StringPool.CLOSE_CURLY_BRACE);
18711    
18712                    throw new NoSuchArticleException(msg.toString());
18713            }
18714    
18715            /**
18716             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18717             *
18718             * @param groupId the group ID
18719             * @param userId the user ID
18720             * @param classNameId the class name ID
18721             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18722             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
18723             */
18724            @Override
18725            public JournalArticle fetchByG_U_C_Last(long groupId, long userId,
18726                    long classNameId, OrderByComparator<JournalArticle> orderByComparator) {
18727                    int count = countByG_U_C(groupId, userId, classNameId);
18728    
18729                    if (count == 0) {
18730                            return null;
18731                    }
18732    
18733                    List<JournalArticle> list = findByG_U_C(groupId, userId, classNameId,
18734                                    count - 1, count, orderByComparator);
18735    
18736                    if (!list.isEmpty()) {
18737                            return list.get(0);
18738                    }
18739    
18740                    return null;
18741            }
18742    
18743            /**
18744             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18745             *
18746             * @param id the primary key of the current journal article
18747             * @param groupId the group ID
18748             * @param userId the user ID
18749             * @param classNameId the class name ID
18750             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18751             * @return the previous, current, and next journal article
18752             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
18753             */
18754            @Override
18755            public JournalArticle[] findByG_U_C_PrevAndNext(long id, long groupId,
18756                    long userId, long classNameId,
18757                    OrderByComparator<JournalArticle> orderByComparator)
18758                    throws NoSuchArticleException {
18759                    JournalArticle journalArticle = findByPrimaryKey(id);
18760    
18761                    Session session = null;
18762    
18763                    try {
18764                            session = openSession();
18765    
18766                            JournalArticle[] array = new JournalArticleImpl[3];
18767    
18768                            array[0] = getByG_U_C_PrevAndNext(session, journalArticle, groupId,
18769                                            userId, classNameId, orderByComparator, true);
18770    
18771                            array[1] = journalArticle;
18772    
18773                            array[2] = getByG_U_C_PrevAndNext(session, journalArticle, groupId,
18774                                            userId, classNameId, orderByComparator, false);
18775    
18776                            return array;
18777                    }
18778                    catch (Exception e) {
18779                            throw processException(e);
18780                    }
18781                    finally {
18782                            closeSession(session);
18783                    }
18784            }
18785    
18786            protected JournalArticle getByG_U_C_PrevAndNext(Session session,
18787                    JournalArticle journalArticle, long groupId, long userId,
18788                    long classNameId, OrderByComparator<JournalArticle> orderByComparator,
18789                    boolean previous) {
18790                    StringBundler query = null;
18791    
18792                    if (orderByComparator != null) {
18793                            query = new StringBundler(6 +
18794                                            (orderByComparator.getOrderByFields().length * 6));
18795                    }
18796                    else {
18797                            query = new StringBundler(3);
18798                    }
18799    
18800                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18801    
18802                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
18803    
18804                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
18805    
18806                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
18807    
18808                    if (orderByComparator != null) {
18809                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
18810    
18811                            if (orderByConditionFields.length > 0) {
18812                                    query.append(WHERE_AND);
18813                            }
18814    
18815                            for (int i = 0; i < orderByConditionFields.length; i++) {
18816                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18817                                    query.append(orderByConditionFields[i]);
18818    
18819                                    if ((i + 1) < orderByConditionFields.length) {
18820                                            if (orderByComparator.isAscending() ^ previous) {
18821                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
18822                                            }
18823                                            else {
18824                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
18825                                            }
18826                                    }
18827                                    else {
18828                                            if (orderByComparator.isAscending() ^ previous) {
18829                                                    query.append(WHERE_GREATER_THAN);
18830                                            }
18831                                            else {
18832                                                    query.append(WHERE_LESSER_THAN);
18833                                            }
18834                                    }
18835                            }
18836    
18837                            query.append(ORDER_BY_CLAUSE);
18838    
18839                            String[] orderByFields = orderByComparator.getOrderByFields();
18840    
18841                            for (int i = 0; i < orderByFields.length; i++) {
18842                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18843                                    query.append(orderByFields[i]);
18844    
18845                                    if ((i + 1) < orderByFields.length) {
18846                                            if (orderByComparator.isAscending() ^ previous) {
18847                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
18848                                            }
18849                                            else {
18850                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
18851                                            }
18852                                    }
18853                                    else {
18854                                            if (orderByComparator.isAscending() ^ previous) {
18855                                                    query.append(ORDER_BY_ASC);
18856                                            }
18857                                            else {
18858                                                    query.append(ORDER_BY_DESC);
18859                                            }
18860                                    }
18861                            }
18862                    }
18863                    else {
18864                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18865                    }
18866    
18867                    String sql = query.toString();
18868    
18869                    Query q = session.createQuery(sql);
18870    
18871                    q.setFirstResult(0);
18872                    q.setMaxResults(2);
18873    
18874                    QueryPos qPos = QueryPos.getInstance(q);
18875    
18876                    qPos.add(groupId);
18877    
18878                    qPos.add(userId);
18879    
18880                    qPos.add(classNameId);
18881    
18882                    if (orderByComparator != null) {
18883                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
18884    
18885                            for (Object value : values) {
18886                                    qPos.add(value);
18887                            }
18888                    }
18889    
18890                    List<JournalArticle> list = q.list();
18891    
18892                    if (list.size() == 2) {
18893                            return list.get(1);
18894                    }
18895                    else {
18896                            return null;
18897                    }
18898            }
18899    
18900            /**
18901             * Returns all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18902             *
18903             * @param groupId the group ID
18904             * @param userId the user ID
18905             * @param classNameId the class name ID
18906             * @return the matching journal articles that the user has permission to view
18907             */
18908            @Override
18909            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
18910                    long classNameId) {
18911                    return filterFindByG_U_C(groupId, userId, classNameId,
18912                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
18913            }
18914    
18915            /**
18916             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18917             *
18918             * <p>
18919             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
18920             * </p>
18921             *
18922             * @param groupId the group ID
18923             * @param userId the user ID
18924             * @param classNameId the class name ID
18925             * @param start the lower bound of the range of journal articles
18926             * @param end the upper bound of the range of journal articles (not inclusive)
18927             * @return the range of matching journal articles that the user has permission to view
18928             */
18929            @Override
18930            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
18931                    long classNameId, int start, int end) {
18932                    return filterFindByG_U_C(groupId, userId, classNameId, start, end, null);
18933            }
18934    
18935            /**
18936             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18937             *
18938             * <p>
18939             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
18940             * </p>
18941             *
18942             * @param groupId the group ID
18943             * @param userId the user ID
18944             * @param classNameId the class name ID
18945             * @param start the lower bound of the range of journal articles
18946             * @param end the upper bound of the range of journal articles (not inclusive)
18947             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18948             * @return the ordered range of matching journal articles that the user has permission to view
18949             */
18950            @Override
18951            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
18952                    long classNameId, int start, int end,
18953                    OrderByComparator<JournalArticle> orderByComparator) {
18954                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18955                            return findByG_U_C(groupId, userId, classNameId, start, end,
18956                                    orderByComparator);
18957                    }
18958    
18959                    StringBundler query = null;
18960    
18961                    if (orderByComparator != null) {
18962                            query = new StringBundler(5 +
18963                                            (orderByComparator.getOrderByFields().length * 3));
18964                    }
18965                    else {
18966                            query = new StringBundler(5);
18967                    }
18968    
18969                    if (getDB().isSupportsInlineDistinct()) {
18970                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
18971                    }
18972                    else {
18973                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
18974                    }
18975    
18976                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
18977    
18978                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
18979    
18980                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
18981    
18982                    if (!getDB().isSupportsInlineDistinct()) {
18983                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
18984                    }
18985    
18986                    if (orderByComparator != null) {
18987                            if (getDB().isSupportsInlineDistinct()) {
18988                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18989                                            orderByComparator, true);
18990                            }
18991                            else {
18992                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
18993                                            orderByComparator, true);
18994                            }
18995                    }
18996                    else {
18997                            if (getDB().isSupportsInlineDistinct()) {
18998                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18999                            }
19000                            else {
19001                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
19002                            }
19003                    }
19004    
19005                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19006                                    JournalArticle.class.getName(),
19007                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19008    
19009                    Session session = null;
19010    
19011                    try {
19012                            session = openSession();
19013    
19014                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
19015    
19016                            if (getDB().isSupportsInlineDistinct()) {
19017                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
19018                            }
19019                            else {
19020                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
19021                            }
19022    
19023                            QueryPos qPos = QueryPos.getInstance(q);
19024    
19025                            qPos.add(groupId);
19026    
19027                            qPos.add(userId);
19028    
19029                            qPos.add(classNameId);
19030    
19031                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
19032                                    end);
19033                    }
19034                    catch (Exception e) {
19035                            throw processException(e);
19036                    }
19037                    finally {
19038                            closeSession(session);
19039                    }
19040            }
19041    
19042            /**
19043             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19044             *
19045             * @param id the primary key of the current journal article
19046             * @param groupId the group ID
19047             * @param userId the user ID
19048             * @param classNameId the class name ID
19049             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19050             * @return the previous, current, and next journal article
19051             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
19052             */
19053            @Override
19054            public JournalArticle[] filterFindByG_U_C_PrevAndNext(long id,
19055                    long groupId, long userId, long classNameId,
19056                    OrderByComparator<JournalArticle> orderByComparator)
19057                    throws NoSuchArticleException {
19058                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19059                            return findByG_U_C_PrevAndNext(id, groupId, userId, classNameId,
19060                                    orderByComparator);
19061                    }
19062    
19063                    JournalArticle journalArticle = findByPrimaryKey(id);
19064    
19065                    Session session = null;
19066    
19067                    try {
19068                            session = openSession();
19069    
19070                            JournalArticle[] array = new JournalArticleImpl[3];
19071    
19072                            array[0] = filterGetByG_U_C_PrevAndNext(session, journalArticle,
19073                                            groupId, userId, classNameId, orderByComparator, true);
19074    
19075                            array[1] = journalArticle;
19076    
19077                            array[2] = filterGetByG_U_C_PrevAndNext(session, journalArticle,
19078                                            groupId, userId, classNameId, orderByComparator, false);
19079    
19080                            return array;
19081                    }
19082                    catch (Exception e) {
19083                            throw processException(e);
19084                    }
19085                    finally {
19086                            closeSession(session);
19087                    }
19088            }
19089    
19090            protected JournalArticle filterGetByG_U_C_PrevAndNext(Session session,
19091                    JournalArticle journalArticle, long groupId, long userId,
19092                    long classNameId, OrderByComparator<JournalArticle> orderByComparator,
19093                    boolean previous) {
19094                    StringBundler query = null;
19095    
19096                    if (orderByComparator != null) {
19097                            query = new StringBundler(6 +
19098                                            (orderByComparator.getOrderByFields().length * 6));
19099                    }
19100                    else {
19101                            query = new StringBundler(3);
19102                    }
19103    
19104                    if (getDB().isSupportsInlineDistinct()) {
19105                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
19106                    }
19107                    else {
19108                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
19109                    }
19110    
19111                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
19112    
19113                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
19114    
19115                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
19116    
19117                    if (!getDB().isSupportsInlineDistinct()) {
19118                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
19119                    }
19120    
19121                    if (orderByComparator != null) {
19122                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
19123    
19124                            if (orderByConditionFields.length > 0) {
19125                                    query.append(WHERE_AND);
19126                            }
19127    
19128                            for (int i = 0; i < orderByConditionFields.length; i++) {
19129                                    if (getDB().isSupportsInlineDistinct()) {
19130                                            query.append(_ORDER_BY_ENTITY_ALIAS);
19131                                    }
19132                                    else {
19133                                            query.append(_ORDER_BY_ENTITY_TABLE);
19134                                    }
19135    
19136                                    query.append(orderByConditionFields[i]);
19137    
19138                                    if ((i + 1) < orderByConditionFields.length) {
19139                                            if (orderByComparator.isAscending() ^ previous) {
19140                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
19141                                            }
19142                                            else {
19143                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
19144                                            }
19145                                    }
19146                                    else {
19147                                            if (orderByComparator.isAscending() ^ previous) {
19148                                                    query.append(WHERE_GREATER_THAN);
19149                                            }
19150                                            else {
19151                                                    query.append(WHERE_LESSER_THAN);
19152                                            }
19153                                    }
19154                            }
19155    
19156                            query.append(ORDER_BY_CLAUSE);
19157    
19158                            String[] orderByFields = orderByComparator.getOrderByFields();
19159    
19160                            for (int i = 0; i < orderByFields.length; i++) {
19161                                    if (getDB().isSupportsInlineDistinct()) {
19162                                            query.append(_ORDER_BY_ENTITY_ALIAS);
19163                                    }
19164                                    else {
19165                                            query.append(_ORDER_BY_ENTITY_TABLE);
19166                                    }
19167    
19168                                    query.append(orderByFields[i]);
19169    
19170                                    if ((i + 1) < orderByFields.length) {
19171                                            if (orderByComparator.isAscending() ^ previous) {
19172                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
19173                                            }
19174                                            else {
19175                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
19176                                            }
19177                                    }
19178                                    else {
19179                                            if (orderByComparator.isAscending() ^ previous) {
19180                                                    query.append(ORDER_BY_ASC);
19181                                            }
19182                                            else {
19183                                                    query.append(ORDER_BY_DESC);
19184                                            }
19185                                    }
19186                            }
19187                    }
19188                    else {
19189                            if (getDB().isSupportsInlineDistinct()) {
19190                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19191                            }
19192                            else {
19193                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
19194                            }
19195                    }
19196    
19197                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19198                                    JournalArticle.class.getName(),
19199                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19200    
19201                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
19202    
19203                    q.setFirstResult(0);
19204                    q.setMaxResults(2);
19205    
19206                    if (getDB().isSupportsInlineDistinct()) {
19207                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
19208                    }
19209                    else {
19210                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
19211                    }
19212    
19213                    QueryPos qPos = QueryPos.getInstance(q);
19214    
19215                    qPos.add(groupId);
19216    
19217                    qPos.add(userId);
19218    
19219                    qPos.add(classNameId);
19220    
19221                    if (orderByComparator != null) {
19222                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
19223    
19224                            for (Object value : values) {
19225                                    qPos.add(value);
19226                            }
19227                    }
19228    
19229                    List<JournalArticle> list = q.list();
19230    
19231                    if (list.size() == 2) {
19232                            return list.get(1);
19233                    }
19234                    else {
19235                            return null;
19236                    }
19237            }
19238    
19239            /**
19240             * Removes all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63; from the database.
19241             *
19242             * @param groupId the group ID
19243             * @param userId the user ID
19244             * @param classNameId the class name ID
19245             */
19246            @Override
19247            public void removeByG_U_C(long groupId, long userId, long classNameId) {
19248                    for (JournalArticle journalArticle : findByG_U_C(groupId, userId,
19249                                    classNameId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
19250                            remove(journalArticle);
19251                    }
19252            }
19253    
19254            /**
19255             * Returns the number of journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19256             *
19257             * @param groupId the group ID
19258             * @param userId the user ID
19259             * @param classNameId the class name ID
19260             * @return the number of matching journal articles
19261             */
19262            @Override
19263            public int countByG_U_C(long groupId, long userId, long classNameId) {
19264                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_C;
19265    
19266                    Object[] finderArgs = new Object[] { groupId, userId, classNameId };
19267    
19268                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
19269                                    this);
19270    
19271                    if (count == null) {
19272                            StringBundler query = new StringBundler(4);
19273    
19274                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
19275    
19276                            query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
19277    
19278                            query.append(_FINDER_COLUMN_G_U_C_USERID_2);
19279    
19280                            query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
19281    
19282                            String sql = query.toString();
19283    
19284                            Session session = null;
19285    
19286                            try {
19287                                    session = openSession();
19288    
19289                                    Query q = session.createQuery(sql);
19290    
19291                                    QueryPos qPos = QueryPos.getInstance(q);
19292    
19293                                    qPos.add(groupId);
19294    
19295                                    qPos.add(userId);
19296    
19297                                    qPos.add(classNameId);
19298    
19299                                    count = (Long)q.uniqueResult();
19300    
19301                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
19302                            }
19303                            catch (Exception e) {
19304                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
19305    
19306                                    throw processException(e);
19307                            }
19308                            finally {
19309                                    closeSession(session);
19310                            }
19311                    }
19312    
19313                    return count.intValue();
19314            }
19315    
19316            /**
19317             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19318             *
19319             * @param groupId the group ID
19320             * @param userId the user ID
19321             * @param classNameId the class name ID
19322             * @return the number of matching journal articles that the user has permission to view
19323             */
19324            @Override
19325            public int filterCountByG_U_C(long groupId, long userId, long classNameId) {
19326                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19327                            return countByG_U_C(groupId, userId, classNameId);
19328                    }
19329    
19330                    StringBundler query = new StringBundler(4);
19331    
19332                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
19333    
19334                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
19335    
19336                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
19337    
19338                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
19339    
19340                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19341                                    JournalArticle.class.getName(),
19342                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19343    
19344                    Session session = null;
19345    
19346                    try {
19347                            session = openSession();
19348    
19349                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
19350    
19351                            q.addScalar(COUNT_COLUMN_NAME,
19352                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
19353    
19354                            QueryPos qPos = QueryPos.getInstance(q);
19355    
19356                            qPos.add(groupId);
19357    
19358                            qPos.add(userId);
19359    
19360                            qPos.add(classNameId);
19361    
19362                            Long count = (Long)q.uniqueResult();
19363    
19364                            return count.intValue();
19365                    }
19366                    catch (Exception e) {
19367                            throw processException(e);
19368                    }
19369                    finally {
19370                            closeSession(session);
19371                    }
19372            }
19373    
19374            private static final String _FINDER_COLUMN_G_U_C_GROUPID_2 = "journalArticle.groupId = ? AND ";
19375            private static final String _FINDER_COLUMN_G_U_C_USERID_2 = "journalArticle.userId = ? AND ";
19376            private static final String _FINDER_COLUMN_G_U_C_CLASSNAMEID_2 = "journalArticle.classNameId = ?";
19377            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19378                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
19379                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
19380                            "findByG_F_ST",
19381                            new String[] {
19382                                    Long.class.getName(), Long.class.getName(),
19383                                    Integer.class.getName(),
19384                                    
19385                            Integer.class.getName(), Integer.class.getName(),
19386                                    OrderByComparator.class.getName()
19387                            });
19388            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST =
19389                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19390                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
19391                            JournalArticleImpl.class,
19392                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F_ST",
19393                            new String[] {
19394                                    Long.class.getName(), Long.class.getName(),
19395                                    Integer.class.getName()
19396                            },
19397                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
19398                            JournalArticleModelImpl.FOLDERID_COLUMN_BITMASK |
19399                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
19400                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
19401                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
19402            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19403                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
19404                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_ST",
19405                            new String[] {
19406                                    Long.class.getName(), Long.class.getName(),
19407                                    Integer.class.getName()
19408                            });
19409            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19410                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
19411                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F_ST",
19412                            new String[] {
19413                                    Long.class.getName(), Long.class.getName(),
19414                                    Integer.class.getName()
19415                            });
19416    
19417            /**
19418             * Returns all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
19419             *
19420             * @param groupId the group ID
19421             * @param folderId the folder ID
19422             * @param status the status
19423             * @return the matching journal articles
19424             */
19425            @Override
19426            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
19427                    int status) {
19428                    return findByG_F_ST(groupId, folderId, status, QueryUtil.ALL_POS,
19429                            QueryUtil.ALL_POS, null);
19430            }
19431    
19432            /**
19433             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
19434             *
19435             * <p>
19436             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
19437             * </p>
19438             *
19439             * @param groupId the group ID
19440             * @param folderId the folder ID
19441             * @param status the status
19442             * @param start the lower bound of the range of journal articles
19443             * @param end the upper bound of the range of journal articles (not inclusive)
19444             * @return the range of matching journal articles
19445             */
19446            @Override
19447            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
19448                    int status, int start, int end) {
19449                    return findByG_F_ST(groupId, folderId, status, start, end, null);
19450            }
19451    
19452            /**
19453             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
19454             *
19455             * <p>
19456             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
19457             * </p>
19458             *
19459             * @param groupId the group ID
19460             * @param folderId the folder ID
19461             * @param status the status
19462             * @param start the lower bound of the range of journal articles
19463             * @param end the upper bound of the range of journal articles (not inclusive)
19464             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19465             * @return the ordered range of matching journal articles
19466             */
19467            @Override
19468            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
19469                    int status, int start, int end,
19470                    OrderByComparator<JournalArticle> orderByComparator) {
19471                    boolean pagination = true;
19472                    FinderPath finderPath = null;
19473                    Object[] finderArgs = null;
19474    
19475                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
19476                                    (orderByComparator == null)) {
19477                            pagination = false;
19478                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST;
19479                            finderArgs = new Object[] { groupId, folderId, status };
19480                    }
19481                    else {
19482                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST;
19483                            finderArgs = new Object[] {
19484                                            groupId, folderId, status,
19485                                            
19486                                            start, end, orderByComparator
19487                                    };
19488                    }
19489    
19490                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
19491                                    finderArgs, this);
19492    
19493                    if ((list != null) && !list.isEmpty()) {
19494                            for (JournalArticle journalArticle : list) {
19495                                    if ((groupId != journalArticle.getGroupId()) ||
19496                                                    (folderId != journalArticle.getFolderId()) ||
19497                                                    (status != journalArticle.getStatus())) {
19498                                            list = null;
19499    
19500                                            break;
19501                                    }
19502                            }
19503                    }
19504    
19505                    if (list == null) {
19506                            StringBundler query = null;
19507    
19508                            if (orderByComparator != null) {
19509                                    query = new StringBundler(5 +
19510                                                    (orderByComparator.getOrderByFields().length * 3));
19511                            }
19512                            else {
19513                                    query = new StringBundler(5);
19514                            }
19515    
19516                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
19517    
19518                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
19519    
19520                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
19521    
19522                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
19523    
19524                            if (orderByComparator != null) {
19525                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
19526                                            orderByComparator);
19527                            }
19528                            else
19529                             if (pagination) {
19530                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19531                            }
19532    
19533                            String sql = query.toString();
19534    
19535                            Session session = null;
19536    
19537                            try {
19538                                    session = openSession();
19539    
19540                                    Query q = session.createQuery(sql);
19541    
19542                                    QueryPos qPos = QueryPos.getInstance(q);
19543    
19544                                    qPos.add(groupId);
19545    
19546                                    qPos.add(folderId);
19547    
19548                                    qPos.add(status);
19549    
19550                                    if (!pagination) {
19551                                            list = (List<JournalArticle>)QueryUtil.list(q,
19552                                                            getDialect(), start, end, false);
19553    
19554                                            Collections.sort(list);
19555    
19556                                            list = Collections.unmodifiableList(list);
19557                                    }
19558                                    else {
19559                                            list = (List<JournalArticle>)QueryUtil.list(q,
19560                                                            getDialect(), start, end);
19561                                    }
19562    
19563                                    cacheResult(list);
19564    
19565                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
19566                            }
19567                            catch (Exception e) {
19568                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
19569    
19570                                    throw processException(e);
19571                            }
19572                            finally {
19573                                    closeSession(session);
19574                            }
19575                    }
19576    
19577                    return list;
19578            }
19579    
19580            /**
19581             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
19582             *
19583             * @param groupId the group ID
19584             * @param folderId the folder ID
19585             * @param status the status
19586             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19587             * @return the first matching journal article
19588             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
19589             */
19590            @Override
19591            public JournalArticle findByG_F_ST_First(long groupId, long folderId,
19592                    int status, OrderByComparator<JournalArticle> orderByComparator)
19593                    throws NoSuchArticleException {
19594                    JournalArticle journalArticle = fetchByG_F_ST_First(groupId, folderId,
19595                                    status, orderByComparator);
19596    
19597                    if (journalArticle != null) {
19598                            return journalArticle;
19599                    }
19600    
19601                    StringBundler msg = new StringBundler(8);
19602    
19603                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
19604    
19605                    msg.append("groupId=");
19606                    msg.append(groupId);
19607    
19608                    msg.append(", folderId=");
19609                    msg.append(folderId);
19610    
19611                    msg.append(", status=");
19612                    msg.append(status);
19613    
19614                    msg.append(StringPool.CLOSE_CURLY_BRACE);
19615    
19616                    throw new NoSuchArticleException(msg.toString());
19617            }
19618    
19619            /**
19620             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
19621             *
19622             * @param groupId the group ID
19623             * @param folderId the folder ID
19624             * @param status the status
19625             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19626             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
19627             */
19628            @Override
19629            public JournalArticle fetchByG_F_ST_First(long groupId, long folderId,
19630                    int status, OrderByComparator<JournalArticle> orderByComparator) {
19631                    List<JournalArticle> list = findByG_F_ST(groupId, folderId, status, 0,
19632                                    1, orderByComparator);
19633    
19634                    if (!list.isEmpty()) {
19635                            return list.get(0);
19636                    }
19637    
19638                    return null;
19639            }
19640    
19641            /**
19642             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
19643             *
19644             * @param groupId the group ID
19645             * @param folderId the folder ID
19646             * @param status the status
19647             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19648             * @return the last matching journal article
19649             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
19650             */
19651            @Override
19652            public JournalArticle findByG_F_ST_Last(long groupId, long folderId,
19653                    int status, OrderByComparator<JournalArticle> orderByComparator)
19654                    throws NoSuchArticleException {
19655                    JournalArticle journalArticle = fetchByG_F_ST_Last(groupId, folderId,
19656                                    status, orderByComparator);
19657    
19658                    if (journalArticle != null) {
19659                            return journalArticle;
19660                    }
19661    
19662                    StringBundler msg = new StringBundler(8);
19663    
19664                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
19665    
19666                    msg.append("groupId=");
19667                    msg.append(groupId);
19668    
19669                    msg.append(", folderId=");
19670                    msg.append(folderId);
19671    
19672                    msg.append(", status=");
19673                    msg.append(status);
19674    
19675                    msg.append(StringPool.CLOSE_CURLY_BRACE);
19676    
19677                    throw new NoSuchArticleException(msg.toString());
19678            }
19679    
19680            /**
19681             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
19682             *
19683             * @param groupId the group ID
19684             * @param folderId the folder ID
19685             * @param status the status
19686             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19687             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
19688             */
19689            @Override
19690            public JournalArticle fetchByG_F_ST_Last(long groupId, long folderId,
19691                    int status, OrderByComparator<JournalArticle> orderByComparator) {
19692                    int count = countByG_F_ST(groupId, folderId, status);
19693    
19694                    if (count == 0) {
19695                            return null;
19696                    }
19697    
19698                    List<JournalArticle> list = findByG_F_ST(groupId, folderId, status,
19699                                    count - 1, count, orderByComparator);
19700    
19701                    if (!list.isEmpty()) {
19702                            return list.get(0);
19703                    }
19704    
19705                    return null;
19706            }
19707    
19708            /**
19709             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
19710             *
19711             * @param id the primary key of the current journal article
19712             * @param groupId the group ID
19713             * @param folderId the folder ID
19714             * @param status the status
19715             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19716             * @return the previous, current, and next journal article
19717             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
19718             */
19719            @Override
19720            public JournalArticle[] findByG_F_ST_PrevAndNext(long id, long groupId,
19721                    long folderId, int status,
19722                    OrderByComparator<JournalArticle> orderByComparator)
19723                    throws NoSuchArticleException {
19724                    JournalArticle journalArticle = findByPrimaryKey(id);
19725    
19726                    Session session = null;
19727    
19728                    try {
19729                            session = openSession();
19730    
19731                            JournalArticle[] array = new JournalArticleImpl[3];
19732    
19733                            array[0] = getByG_F_ST_PrevAndNext(session, journalArticle,
19734                                            groupId, folderId, status, orderByComparator, true);
19735    
19736                            array[1] = journalArticle;
19737    
19738                            array[2] = getByG_F_ST_PrevAndNext(session, journalArticle,
19739                                            groupId, folderId, status, orderByComparator, false);
19740    
19741                            return array;
19742                    }
19743                    catch (Exception e) {
19744                            throw processException(e);
19745                    }
19746                    finally {
19747                            closeSession(session);
19748                    }
19749            }
19750    
19751            protected JournalArticle getByG_F_ST_PrevAndNext(Session session,
19752                    JournalArticle journalArticle, long groupId, long folderId, int status,
19753                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
19754                    StringBundler query = null;
19755    
19756                    if (orderByComparator != null) {
19757                            query = new StringBundler(6 +
19758                                            (orderByComparator.getOrderByFields().length * 6));
19759                    }
19760                    else {
19761                            query = new StringBundler(3);
19762                    }
19763    
19764                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
19765    
19766                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
19767    
19768                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
19769    
19770                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
19771    
19772                    if (orderByComparator != null) {
19773                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
19774    
19775                            if (orderByConditionFields.length > 0) {
19776                                    query.append(WHERE_AND);
19777                            }
19778    
19779                            for (int i = 0; i < orderByConditionFields.length; i++) {
19780                                    query.append(_ORDER_BY_ENTITY_ALIAS);
19781                                    query.append(orderByConditionFields[i]);
19782    
19783                                    if ((i + 1) < orderByConditionFields.length) {
19784                                            if (orderByComparator.isAscending() ^ previous) {
19785                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
19786                                            }
19787                                            else {
19788                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
19789                                            }
19790                                    }
19791                                    else {
19792                                            if (orderByComparator.isAscending() ^ previous) {
19793                                                    query.append(WHERE_GREATER_THAN);
19794                                            }
19795                                            else {
19796                                                    query.append(WHERE_LESSER_THAN);
19797                                            }
19798                                    }
19799                            }
19800    
19801                            query.append(ORDER_BY_CLAUSE);
19802    
19803                            String[] orderByFields = orderByComparator.getOrderByFields();
19804    
19805                            for (int i = 0; i < orderByFields.length; i++) {
19806                                    query.append(_ORDER_BY_ENTITY_ALIAS);
19807                                    query.append(orderByFields[i]);
19808    
19809                                    if ((i + 1) < orderByFields.length) {
19810                                            if (orderByComparator.isAscending() ^ previous) {
19811                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
19812                                            }
19813                                            else {
19814                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
19815                                            }
19816                                    }
19817                                    else {
19818                                            if (orderByComparator.isAscending() ^ previous) {
19819                                                    query.append(ORDER_BY_ASC);
19820                                            }
19821                                            else {
19822                                                    query.append(ORDER_BY_DESC);
19823                                            }
19824                                    }
19825                            }
19826                    }
19827                    else {
19828                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19829                    }
19830    
19831                    String sql = query.toString();
19832    
19833                    Query q = session.createQuery(sql);
19834    
19835                    q.setFirstResult(0);
19836                    q.setMaxResults(2);
19837    
19838                    QueryPos qPos = QueryPos.getInstance(q);
19839    
19840                    qPos.add(groupId);
19841    
19842                    qPos.add(folderId);
19843    
19844                    qPos.add(status);
19845    
19846                    if (orderByComparator != null) {
19847                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
19848    
19849                            for (Object value : values) {
19850                                    qPos.add(value);
19851                            }
19852                    }
19853    
19854                    List<JournalArticle> list = q.list();
19855    
19856                    if (list.size() == 2) {
19857                            return list.get(1);
19858                    }
19859                    else {
19860                            return null;
19861                    }
19862            }
19863    
19864            /**
19865             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
19866             *
19867             * @param groupId the group ID
19868             * @param folderId the folder ID
19869             * @param status the status
19870             * @return the matching journal articles that the user has permission to view
19871             */
19872            @Override
19873            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
19874                    int status) {
19875                    return filterFindByG_F_ST(groupId, folderId, status, QueryUtil.ALL_POS,
19876                            QueryUtil.ALL_POS, null);
19877            }
19878    
19879            /**
19880             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
19881             *
19882             * <p>
19883             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
19884             * </p>
19885             *
19886             * @param groupId the group ID
19887             * @param folderId the folder ID
19888             * @param status the status
19889             * @param start the lower bound of the range of journal articles
19890             * @param end the upper bound of the range of journal articles (not inclusive)
19891             * @return the range of matching journal articles that the user has permission to view
19892             */
19893            @Override
19894            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
19895                    int status, int start, int end) {
19896                    return filterFindByG_F_ST(groupId, folderId, status, start, end, null);
19897            }
19898    
19899            /**
19900             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and folderId = &#63; and status = &#63;.
19901             *
19902             * <p>
19903             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
19904             * </p>
19905             *
19906             * @param groupId the group ID
19907             * @param folderId the folder ID
19908             * @param status the status
19909             * @param start the lower bound of the range of journal articles
19910             * @param end the upper bound of the range of journal articles (not inclusive)
19911             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19912             * @return the ordered range of matching journal articles that the user has permission to view
19913             */
19914            @Override
19915            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
19916                    int status, int start, int end,
19917                    OrderByComparator<JournalArticle> orderByComparator) {
19918                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19919                            return findByG_F_ST(groupId, folderId, status, start, end,
19920                                    orderByComparator);
19921                    }
19922    
19923                    StringBundler query = null;
19924    
19925                    if (orderByComparator != null) {
19926                            query = new StringBundler(5 +
19927                                            (orderByComparator.getOrderByFields().length * 3));
19928                    }
19929                    else {
19930                            query = new StringBundler(5);
19931                    }
19932    
19933                    if (getDB().isSupportsInlineDistinct()) {
19934                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
19935                    }
19936                    else {
19937                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
19938                    }
19939    
19940                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
19941    
19942                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
19943    
19944                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
19945    
19946                    if (!getDB().isSupportsInlineDistinct()) {
19947                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
19948                    }
19949    
19950                    if (orderByComparator != null) {
19951                            if (getDB().isSupportsInlineDistinct()) {
19952                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
19953                                            orderByComparator, true);
19954                            }
19955                            else {
19956                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
19957                                            orderByComparator, true);
19958                            }
19959                    }
19960                    else {
19961                            if (getDB().isSupportsInlineDistinct()) {
19962                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19963                            }
19964                            else {
19965                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
19966                            }
19967                    }
19968    
19969                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19970                                    JournalArticle.class.getName(),
19971                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19972    
19973                    Session session = null;
19974    
19975                    try {
19976                            session = openSession();
19977    
19978                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
19979    
19980                            if (getDB().isSupportsInlineDistinct()) {
19981                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
19982                            }
19983                            else {
19984                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
19985                            }
19986    
19987                            QueryPos qPos = QueryPos.getInstance(q);
19988    
19989                            qPos.add(groupId);
19990    
19991                            qPos.add(folderId);
19992    
19993                            qPos.add(status);
19994    
19995                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
19996                                    end);
19997                    }
19998                    catch (Exception e) {
19999                            throw processException(e);
20000                    }
20001                    finally {
20002                            closeSession(session);
20003                    }
20004            }
20005    
20006            /**
20007             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
20008             *
20009             * @param id the primary key of the current journal article
20010             * @param groupId the group ID
20011             * @param folderId the folder ID
20012             * @param status the status
20013             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20014             * @return the previous, current, and next journal article
20015             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
20016             */
20017            @Override
20018            public JournalArticle[] filterFindByG_F_ST_PrevAndNext(long id,
20019                    long groupId, long folderId, int status,
20020                    OrderByComparator<JournalArticle> orderByComparator)
20021                    throws NoSuchArticleException {
20022                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20023                            return findByG_F_ST_PrevAndNext(id, groupId, folderId, status,
20024                                    orderByComparator);
20025                    }
20026    
20027                    JournalArticle journalArticle = findByPrimaryKey(id);
20028    
20029                    Session session = null;
20030    
20031                    try {
20032                            session = openSession();
20033    
20034                            JournalArticle[] array = new JournalArticleImpl[3];
20035    
20036                            array[0] = filterGetByG_F_ST_PrevAndNext(session, journalArticle,
20037                                            groupId, folderId, status, orderByComparator, true);
20038    
20039                            array[1] = journalArticle;
20040    
20041                            array[2] = filterGetByG_F_ST_PrevAndNext(session, journalArticle,
20042                                            groupId, folderId, status, orderByComparator, false);
20043    
20044                            return array;
20045                    }
20046                    catch (Exception e) {
20047                            throw processException(e);
20048                    }
20049                    finally {
20050                            closeSession(session);
20051                    }
20052            }
20053    
20054            protected JournalArticle filterGetByG_F_ST_PrevAndNext(Session session,
20055                    JournalArticle journalArticle, long groupId, long folderId, int status,
20056                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
20057                    StringBundler query = null;
20058    
20059                    if (orderByComparator != null) {
20060                            query = new StringBundler(6 +
20061                                            (orderByComparator.getOrderByFields().length * 6));
20062                    }
20063                    else {
20064                            query = new StringBundler(3);
20065                    }
20066    
20067                    if (getDB().isSupportsInlineDistinct()) {
20068                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
20069                    }
20070                    else {
20071                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
20072                    }
20073    
20074                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
20075    
20076                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
20077    
20078                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
20079    
20080                    if (!getDB().isSupportsInlineDistinct()) {
20081                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
20082                    }
20083    
20084                    if (orderByComparator != null) {
20085                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
20086    
20087                            if (orderByConditionFields.length > 0) {
20088                                    query.append(WHERE_AND);
20089                            }
20090    
20091                            for (int i = 0; i < orderByConditionFields.length; i++) {
20092                                    if (getDB().isSupportsInlineDistinct()) {
20093                                            query.append(_ORDER_BY_ENTITY_ALIAS);
20094                                    }
20095                                    else {
20096                                            query.append(_ORDER_BY_ENTITY_TABLE);
20097                                    }
20098    
20099                                    query.append(orderByConditionFields[i]);
20100    
20101                                    if ((i + 1) < orderByConditionFields.length) {
20102                                            if (orderByComparator.isAscending() ^ previous) {
20103                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
20104                                            }
20105                                            else {
20106                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
20107                                            }
20108                                    }
20109                                    else {
20110                                            if (orderByComparator.isAscending() ^ previous) {
20111                                                    query.append(WHERE_GREATER_THAN);
20112                                            }
20113                                            else {
20114                                                    query.append(WHERE_LESSER_THAN);
20115                                            }
20116                                    }
20117                            }
20118    
20119                            query.append(ORDER_BY_CLAUSE);
20120    
20121                            String[] orderByFields = orderByComparator.getOrderByFields();
20122    
20123                            for (int i = 0; i < orderByFields.length; i++) {
20124                                    if (getDB().isSupportsInlineDistinct()) {
20125                                            query.append(_ORDER_BY_ENTITY_ALIAS);
20126                                    }
20127                                    else {
20128                                            query.append(_ORDER_BY_ENTITY_TABLE);
20129                                    }
20130    
20131                                    query.append(orderByFields[i]);
20132    
20133                                    if ((i + 1) < orderByFields.length) {
20134                                            if (orderByComparator.isAscending() ^ previous) {
20135                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
20136                                            }
20137                                            else {
20138                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
20139                                            }
20140                                    }
20141                                    else {
20142                                            if (orderByComparator.isAscending() ^ previous) {
20143                                                    query.append(ORDER_BY_ASC);
20144                                            }
20145                                            else {
20146                                                    query.append(ORDER_BY_DESC);
20147                                            }
20148                                    }
20149                            }
20150                    }
20151                    else {
20152                            if (getDB().isSupportsInlineDistinct()) {
20153                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20154                            }
20155                            else {
20156                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
20157                            }
20158                    }
20159    
20160                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20161                                    JournalArticle.class.getName(),
20162                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20163    
20164                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
20165    
20166                    q.setFirstResult(0);
20167                    q.setMaxResults(2);
20168    
20169                    if (getDB().isSupportsInlineDistinct()) {
20170                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
20171                    }
20172                    else {
20173                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
20174                    }
20175    
20176                    QueryPos qPos = QueryPos.getInstance(q);
20177    
20178                    qPos.add(groupId);
20179    
20180                    qPos.add(folderId);
20181    
20182                    qPos.add(status);
20183    
20184                    if (orderByComparator != null) {
20185                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
20186    
20187                            for (Object value : values) {
20188                                    qPos.add(value);
20189                            }
20190                    }
20191    
20192                    List<JournalArticle> list = q.list();
20193    
20194                    if (list.size() == 2) {
20195                            return list.get(1);
20196                    }
20197                    else {
20198                            return null;
20199                    }
20200            }
20201    
20202            /**
20203             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = any &#63;.
20204             *
20205             * @param groupId the group ID
20206             * @param folderId the folder ID
20207             * @param statuses the statuses
20208             * @return the matching journal articles that the user has permission to view
20209             */
20210            @Override
20211            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
20212                    int[] statuses) {
20213                    return filterFindByG_F_ST(groupId, folderId, statuses,
20214                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
20215            }
20216    
20217            /**
20218             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = any &#63;.
20219             *
20220             * <p>
20221             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
20222             * </p>
20223             *
20224             * @param groupId the group ID
20225             * @param folderId the folder ID
20226             * @param statuses the statuses
20227             * @param start the lower bound of the range of journal articles
20228             * @param end the upper bound of the range of journal articles (not inclusive)
20229             * @return the range of matching journal articles that the user has permission to view
20230             */
20231            @Override
20232            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
20233                    int[] statuses, int start, int end) {
20234                    return filterFindByG_F_ST(groupId, folderId, statuses, start, end, null);
20235            }
20236    
20237            /**
20238             * Returns an ordered range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = any &#63;.
20239             *
20240             * <p>
20241             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
20242             * </p>
20243             *
20244             * @param groupId the group ID
20245             * @param folderId the folder ID
20246             * @param statuses the statuses
20247             * @param start the lower bound of the range of journal articles
20248             * @param end the upper bound of the range of journal articles (not inclusive)
20249             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
20250             * @return the ordered range of matching journal articles that the user has permission to view
20251             */
20252            @Override
20253            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
20254                    int[] statuses, int start, int end,
20255                    OrderByComparator<JournalArticle> orderByComparator) {
20256                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20257                            return findByG_F_ST(groupId, folderId, statuses, start, end,
20258                                    orderByComparator);
20259                    }
20260    
20261                    if (statuses == null) {
20262                            statuses = new int[0];
20263                    }
20264                    else {
20265                            statuses = ArrayUtil.unique(statuses);
20266                    }
20267    
20268                    StringBundler query = new StringBundler();
20269    
20270                    if (getDB().isSupportsInlineDistinct()) {
20271                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
20272                    }
20273                    else {
20274                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
20275                    }
20276    
20277                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
20278    
20279                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
20280    
20281                    if (statuses.length > 0) {
20282                            query.append(StringPool.OPEN_PARENTHESIS);
20283    
20284                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_7);
20285    
20286                            query.append(StringUtil.merge(statuses));
20287    
20288                            query.append(StringPool.CLOSE_PARENTHESIS);
20289    
20290                            query.append(StringPool.CLOSE_PARENTHESIS);
20291                    }
20292    
20293                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
20294                            query.index() - 1);
20295    
20296                    if (!getDB().isSupportsInlineDistinct()) {
20297                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
20298                    }
20299    
20300                    if (orderByComparator != null) {
20301                            if (getDB().isSupportsInlineDistinct()) {
20302                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
20303                                            orderByComparator, true);
20304                            }
20305                            else {
20306                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
20307                                            orderByComparator, true);
20308                            }
20309                    }
20310                    else {
20311                            if (getDB().isSupportsInlineDistinct()) {
20312                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20313                            }
20314                            else {
20315                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
20316                            }
20317                    }
20318    
20319                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20320                                    JournalArticle.class.getName(),
20321                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20322    
20323                    Session session = null;
20324    
20325                    try {
20326                            session = openSession();
20327    
20328                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
20329    
20330                            if (getDB().isSupportsInlineDistinct()) {
20331                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
20332                            }
20333                            else {
20334                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
20335                            }
20336    
20337                            QueryPos qPos = QueryPos.getInstance(q);
20338    
20339                            qPos.add(groupId);
20340    
20341                            qPos.add(folderId);
20342    
20343                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
20344                                    end);
20345                    }
20346                    catch (Exception e) {
20347                            throw processException(e);
20348                    }
20349                    finally {
20350                            closeSession(session);
20351                    }
20352            }
20353    
20354            /**
20355             * Returns all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
20356             *
20357             * <p>
20358             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
20359             * </p>
20360             *
20361             * @param groupId the group ID
20362             * @param folderId the folder ID
20363             * @param statuses the statuses
20364             * @return the matching journal articles
20365             */
20366            @Override
20367            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
20368                    int[] statuses) {
20369                    return findByG_F_ST(groupId, folderId, statuses, QueryUtil.ALL_POS,
20370                            QueryUtil.ALL_POS, null);
20371            }
20372    
20373            /**
20374             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
20375             *
20376             * <p>
20377             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
20378             * </p>
20379             *
20380             * @param groupId the group ID
20381             * @param folderId the folder ID
20382             * @param statuses the statuses
20383             * @param start the lower bound of the range of journal articles
20384             * @param end the upper bound of the range of journal articles (not inclusive)
20385             * @return the range of matching journal articles
20386             */
20387            @Override
20388            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
20389                    int[] statuses, int start, int end) {
20390                    return findByG_F_ST(groupId, folderId, statuses, start, end, null);
20391            }
20392    
20393            /**
20394             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
20395             *
20396             * <p>
20397             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
20398             * </p>
20399             *
20400             * @param groupId the group ID
20401             * @param folderId the folder ID
20402             * @param statuses the statuses
20403             * @param start the lower bound of the range of journal articles
20404             * @param end the upper bound of the range of journal articles (not inclusive)
20405             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
20406             * @return the ordered range of matching journal articles
20407             */
20408            @Override
20409            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
20410                    int[] statuses, int start, int end,
20411                    OrderByComparator<JournalArticle> orderByComparator) {
20412                    if (statuses == null) {
20413                            statuses = new int[0];
20414                    }
20415                    else {
20416                            statuses = ArrayUtil.unique(statuses);
20417                    }
20418    
20419                    if (statuses.length == 1) {
20420                            return findByG_F_ST(groupId, folderId, statuses[0], start, end,
20421                                    orderByComparator);
20422                    }
20423    
20424                    boolean pagination = true;
20425                    Object[] finderArgs = null;
20426    
20427                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
20428                                    (orderByComparator == null)) {
20429                            pagination = false;
20430                            finderArgs = new Object[] {
20431                                            groupId, folderId, StringUtil.merge(statuses)
20432                                    };
20433                    }
20434                    else {
20435                            finderArgs = new Object[] {
20436                                            groupId, folderId, StringUtil.merge(statuses),
20437                                            
20438                                            start, end, orderByComparator
20439                                    };
20440                    }
20441    
20442                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
20443                                    finderArgs, this);
20444    
20445                    if ((list != null) && !list.isEmpty()) {
20446                            for (JournalArticle journalArticle : list) {
20447                                    if ((groupId != journalArticle.getGroupId()) ||
20448                                                    (folderId != journalArticle.getFolderId()) ||
20449                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
20450                                            list = null;
20451    
20452                                            break;
20453                                    }
20454                            }
20455                    }
20456    
20457                    if (list == null) {
20458                            StringBundler query = new StringBundler();
20459    
20460                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
20461    
20462                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
20463    
20464                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
20465    
20466                            if (statuses.length > 0) {
20467                                    query.append(StringPool.OPEN_PARENTHESIS);
20468    
20469                                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_7);
20470    
20471                                    query.append(StringUtil.merge(statuses));
20472    
20473                                    query.append(StringPool.CLOSE_PARENTHESIS);
20474    
20475                                    query.append(StringPool.CLOSE_PARENTHESIS);
20476                            }
20477    
20478                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
20479                                                    1)), query.index() - 1);
20480    
20481                            if (orderByComparator != null) {
20482                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
20483                                            orderByComparator);
20484                            }
20485                            else
20486                             if (pagination) {
20487                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20488                            }
20489    
20490                            String sql = query.toString();
20491    
20492                            Session session = null;
20493    
20494                            try {
20495                                    session = openSession();
20496    
20497                                    Query q = session.createQuery(sql);
20498    
20499                                    QueryPos qPos = QueryPos.getInstance(q);
20500    
20501                                    qPos.add(groupId);
20502    
20503                                    qPos.add(folderId);
20504    
20505                                    if (!pagination) {
20506                                            list = (List<JournalArticle>)QueryUtil.list(q,
20507                                                            getDialect(), start, end, false);
20508    
20509                                            Collections.sort(list);
20510    
20511                                            list = Collections.unmodifiableList(list);
20512                                    }
20513                                    else {
20514                                            list = (List<JournalArticle>)QueryUtil.list(q,
20515                                                            getDialect(), start, end);
20516                                    }
20517    
20518                                    cacheResult(list);
20519    
20520                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
20521                                            finderArgs, list);
20522                            }
20523                            catch (Exception e) {
20524                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
20525                                            finderArgs);
20526    
20527                                    throw processException(e);
20528                            }
20529                            finally {
20530                                    closeSession(session);
20531                            }
20532                    }
20533    
20534                    return list;
20535            }
20536    
20537            /**
20538             * Removes all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63; from the database.
20539             *
20540             * @param groupId the group ID
20541             * @param folderId the folder ID
20542             * @param status the status
20543             */
20544            @Override
20545            public void removeByG_F_ST(long groupId, long folderId, int status) {
20546                    for (JournalArticle journalArticle : findByG_F_ST(groupId, folderId,
20547                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
20548                            remove(journalArticle);
20549                    }
20550            }
20551    
20552            /**
20553             * Returns the number of journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
20554             *
20555             * @param groupId the group ID
20556             * @param folderId the folder ID
20557             * @param status the status
20558             * @return the number of matching journal articles
20559             */
20560            @Override
20561            public int countByG_F_ST(long groupId, long folderId, int status) {
20562                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_ST;
20563    
20564                    Object[] finderArgs = new Object[] { groupId, folderId, status };
20565    
20566                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
20567                                    this);
20568    
20569                    if (count == null) {
20570                            StringBundler query = new StringBundler(4);
20571    
20572                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
20573    
20574                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
20575    
20576                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
20577    
20578                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
20579    
20580                            String sql = query.toString();
20581    
20582                            Session session = null;
20583    
20584                            try {
20585                                    session = openSession();
20586    
20587                                    Query q = session.createQuery(sql);
20588    
20589                                    QueryPos qPos = QueryPos.getInstance(q);
20590    
20591                                    qPos.add(groupId);
20592    
20593                                    qPos.add(folderId);
20594    
20595                                    qPos.add(status);
20596    
20597                                    count = (Long)q.uniqueResult();
20598    
20599                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
20600                            }
20601                            catch (Exception e) {
20602                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
20603    
20604                                    throw processException(e);
20605                            }
20606                            finally {
20607                                    closeSession(session);
20608                            }
20609                    }
20610    
20611                    return count.intValue();
20612            }
20613    
20614            /**
20615             * Returns the number of journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
20616             *
20617             * @param groupId the group ID
20618             * @param folderId the folder ID
20619             * @param statuses the statuses
20620             * @return the number of matching journal articles
20621             */
20622            @Override
20623            public int countByG_F_ST(long groupId, long folderId, int[] statuses) {
20624                    if (statuses == null) {
20625                            statuses = new int[0];
20626                    }
20627                    else {
20628                            statuses = ArrayUtil.unique(statuses);
20629                    }
20630    
20631                    Object[] finderArgs = new Object[] {
20632                                    groupId, folderId, StringUtil.merge(statuses)
20633                            };
20634    
20635                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
20636                                    finderArgs, this);
20637    
20638                    if (count == null) {
20639                            StringBundler query = new StringBundler();
20640    
20641                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
20642    
20643                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
20644    
20645                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
20646    
20647                            if (statuses.length > 0) {
20648                                    query.append(StringPool.OPEN_PARENTHESIS);
20649    
20650                                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_7);
20651    
20652                                    query.append(StringUtil.merge(statuses));
20653    
20654                                    query.append(StringPool.CLOSE_PARENTHESIS);
20655    
20656                                    query.append(StringPool.CLOSE_PARENTHESIS);
20657                            }
20658    
20659                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
20660                                                    1)), query.index() - 1);
20661    
20662                            String sql = query.toString();
20663    
20664                            Session session = null;
20665    
20666                            try {
20667                                    session = openSession();
20668    
20669                                    Query q = session.createQuery(sql);
20670    
20671                                    QueryPos qPos = QueryPos.getInstance(q);
20672    
20673                                    qPos.add(groupId);
20674    
20675                                    qPos.add(folderId);
20676    
20677                                    count = (Long)q.uniqueResult();
20678    
20679                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
20680                                            finderArgs, count);
20681                            }
20682                            catch (Exception e) {
20683                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
20684                                            finderArgs);
20685    
20686                                    throw processException(e);
20687                            }
20688                            finally {
20689                                    closeSession(session);
20690                            }
20691                    }
20692    
20693                    return count.intValue();
20694            }
20695    
20696            /**
20697             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
20698             *
20699             * @param groupId the group ID
20700             * @param folderId the folder ID
20701             * @param status the status
20702             * @return the number of matching journal articles that the user has permission to view
20703             */
20704            @Override
20705            public int filterCountByG_F_ST(long groupId, long folderId, int status) {
20706                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20707                            return countByG_F_ST(groupId, folderId, status);
20708                    }
20709    
20710                    StringBundler query = new StringBundler(4);
20711    
20712                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
20713    
20714                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
20715    
20716                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
20717    
20718                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
20719    
20720                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20721                                    JournalArticle.class.getName(),
20722                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20723    
20724                    Session session = null;
20725    
20726                    try {
20727                            session = openSession();
20728    
20729                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
20730    
20731                            q.addScalar(COUNT_COLUMN_NAME,
20732                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
20733    
20734                            QueryPos qPos = QueryPos.getInstance(q);
20735    
20736                            qPos.add(groupId);
20737    
20738                            qPos.add(folderId);
20739    
20740                            qPos.add(status);
20741    
20742                            Long count = (Long)q.uniqueResult();
20743    
20744                            return count.intValue();
20745                    }
20746                    catch (Exception e) {
20747                            throw processException(e);
20748                    }
20749                    finally {
20750                            closeSession(session);
20751                    }
20752            }
20753    
20754            /**
20755             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = any &#63;.
20756             *
20757             * @param groupId the group ID
20758             * @param folderId the folder ID
20759             * @param statuses the statuses
20760             * @return the number of matching journal articles that the user has permission to view
20761             */
20762            @Override
20763            public int filterCountByG_F_ST(long groupId, long folderId, int[] statuses) {
20764                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20765                            return countByG_F_ST(groupId, folderId, statuses);
20766                    }
20767    
20768                    if (statuses == null) {
20769                            statuses = new int[0];
20770                    }
20771                    else {
20772                            statuses = ArrayUtil.unique(statuses);
20773                    }
20774    
20775                    StringBundler query = new StringBundler();
20776    
20777                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
20778    
20779                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
20780    
20781                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
20782    
20783                    if (statuses.length > 0) {
20784                            query.append(StringPool.OPEN_PARENTHESIS);
20785    
20786                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_7);
20787    
20788                            query.append(StringUtil.merge(statuses));
20789    
20790                            query.append(StringPool.CLOSE_PARENTHESIS);
20791    
20792                            query.append(StringPool.CLOSE_PARENTHESIS);
20793                    }
20794    
20795                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
20796                            query.index() - 1);
20797    
20798                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20799                                    JournalArticle.class.getName(),
20800                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20801    
20802                    Session session = null;
20803    
20804                    try {
20805                            session = openSession();
20806    
20807                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
20808    
20809                            q.addScalar(COUNT_COLUMN_NAME,
20810                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
20811    
20812                            QueryPos qPos = QueryPos.getInstance(q);
20813    
20814                            qPos.add(groupId);
20815    
20816                            qPos.add(folderId);
20817    
20818                            Long count = (Long)q.uniqueResult();
20819    
20820                            return count.intValue();
20821                    }
20822                    catch (Exception e) {
20823                            throw processException(e);
20824                    }
20825                    finally {
20826                            closeSession(session);
20827                    }
20828            }
20829    
20830            private static final String _FINDER_COLUMN_G_F_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
20831            private static final String _FINDER_COLUMN_G_F_ST_FOLDERID_2 = "journalArticle.folderId = ? AND ";
20832            private static final String _FINDER_COLUMN_G_F_ST_STATUS_2 = "journalArticle.status = ?";
20833            private static final String _FINDER_COLUMN_G_F_ST_STATUS_7 = "journalArticle.status IN (";
20834            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20835                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
20836                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
20837                            "findByG_C_C",
20838                            new String[] {
20839                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
20840                                    
20841                            Integer.class.getName(), Integer.class.getName(),
20842                                    OrderByComparator.class.getName()
20843                            });
20844            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20845                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
20846                            JournalArticleImpl.class,
20847                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_C",
20848                            new String[] {
20849                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
20850                            },
20851                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
20852                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
20853                            JournalArticleModelImpl.CLASSPK_COLUMN_BITMASK |
20854                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
20855                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
20856            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20857                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
20858                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_C",
20859                            new String[] {
20860                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
20861                            });
20862    
20863            /**
20864             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
20865             *
20866             * @param groupId the group ID
20867             * @param classNameId the class name ID
20868             * @param classPK the class p k
20869             * @return the matching journal articles
20870             */
20871            @Override
20872            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
20873                    long classPK) {
20874                    return findByG_C_C(groupId, classNameId, classPK, QueryUtil.ALL_POS,
20875                            QueryUtil.ALL_POS, null);
20876            }
20877    
20878            /**
20879             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
20880             *
20881             * <p>
20882             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
20883             * </p>
20884             *
20885             * @param groupId the group ID
20886             * @param classNameId the class name ID
20887             * @param classPK the class p k
20888             * @param start the lower bound of the range of journal articles
20889             * @param end the upper bound of the range of journal articles (not inclusive)
20890             * @return the range of matching journal articles
20891             */
20892            @Override
20893            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
20894                    long classPK, int start, int end) {
20895                    return findByG_C_C(groupId, classNameId, classPK, start, end, null);
20896            }
20897    
20898            /**
20899             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
20900             *
20901             * <p>
20902             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
20903             * </p>
20904             *
20905             * @param groupId the group ID
20906             * @param classNameId the class name ID
20907             * @param classPK the class p k
20908             * @param start the lower bound of the range of journal articles
20909             * @param end the upper bound of the range of journal articles (not inclusive)
20910             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
20911             * @return the ordered range of matching journal articles
20912             */
20913            @Override
20914            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
20915                    long classPK, int start, int end,
20916                    OrderByComparator<JournalArticle> orderByComparator) {
20917                    boolean pagination = true;
20918                    FinderPath finderPath = null;
20919                    Object[] finderArgs = null;
20920    
20921                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
20922                                    (orderByComparator == null)) {
20923                            pagination = false;
20924                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C;
20925                            finderArgs = new Object[] { groupId, classNameId, classPK };
20926                    }
20927                    else {
20928                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C;
20929                            finderArgs = new Object[] {
20930                                            groupId, classNameId, classPK,
20931                                            
20932                                            start, end, orderByComparator
20933                                    };
20934                    }
20935    
20936                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
20937                                    finderArgs, this);
20938    
20939                    if ((list != null) && !list.isEmpty()) {
20940                            for (JournalArticle journalArticle : list) {
20941                                    if ((groupId != journalArticle.getGroupId()) ||
20942                                                    (classNameId != journalArticle.getClassNameId()) ||
20943                                                    (classPK != journalArticle.getClassPK())) {
20944                                            list = null;
20945    
20946                                            break;
20947                                    }
20948                            }
20949                    }
20950    
20951                    if (list == null) {
20952                            StringBundler query = null;
20953    
20954                            if (orderByComparator != null) {
20955                                    query = new StringBundler(5 +
20956                                                    (orderByComparator.getOrderByFields().length * 3));
20957                            }
20958                            else {
20959                                    query = new StringBundler(5);
20960                            }
20961    
20962                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
20963    
20964                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
20965    
20966                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
20967    
20968                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
20969    
20970                            if (orderByComparator != null) {
20971                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
20972                                            orderByComparator);
20973                            }
20974                            else
20975                             if (pagination) {
20976                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20977                            }
20978    
20979                            String sql = query.toString();
20980    
20981                            Session session = null;
20982    
20983                            try {
20984                                    session = openSession();
20985    
20986                                    Query q = session.createQuery(sql);
20987    
20988                                    QueryPos qPos = QueryPos.getInstance(q);
20989    
20990                                    qPos.add(groupId);
20991    
20992                                    qPos.add(classNameId);
20993    
20994                                    qPos.add(classPK);
20995    
20996                                    if (!pagination) {
20997                                            list = (List<JournalArticle>)QueryUtil.list(q,
20998                                                            getDialect(), start, end, false);
20999    
21000                                            Collections.sort(list);
21001    
21002                                            list = Collections.unmodifiableList(list);
21003                                    }
21004                                    else {
21005                                            list = (List<JournalArticle>)QueryUtil.list(q,
21006                                                            getDialect(), start, end);
21007                                    }
21008    
21009                                    cacheResult(list);
21010    
21011                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
21012                            }
21013                            catch (Exception e) {
21014                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
21015    
21016                                    throw processException(e);
21017                            }
21018                            finally {
21019                                    closeSession(session);
21020                            }
21021                    }
21022    
21023                    return list;
21024            }
21025    
21026            /**
21027             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21028             *
21029             * @param groupId the group ID
21030             * @param classNameId the class name ID
21031             * @param classPK the class p k
21032             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21033             * @return the first matching journal article
21034             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
21035             */
21036            @Override
21037            public JournalArticle findByG_C_C_First(long groupId, long classNameId,
21038                    long classPK, OrderByComparator<JournalArticle> orderByComparator)
21039                    throws NoSuchArticleException {
21040                    JournalArticle journalArticle = fetchByG_C_C_First(groupId,
21041                                    classNameId, classPK, orderByComparator);
21042    
21043                    if (journalArticle != null) {
21044                            return journalArticle;
21045                    }
21046    
21047                    StringBundler msg = new StringBundler(8);
21048    
21049                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
21050    
21051                    msg.append("groupId=");
21052                    msg.append(groupId);
21053    
21054                    msg.append(", classNameId=");
21055                    msg.append(classNameId);
21056    
21057                    msg.append(", classPK=");
21058                    msg.append(classPK);
21059    
21060                    msg.append(StringPool.CLOSE_CURLY_BRACE);
21061    
21062                    throw new NoSuchArticleException(msg.toString());
21063            }
21064    
21065            /**
21066             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21067             *
21068             * @param groupId the group ID
21069             * @param classNameId the class name ID
21070             * @param classPK the class p k
21071             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21072             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
21073             */
21074            @Override
21075            public JournalArticle fetchByG_C_C_First(long groupId, long classNameId,
21076                    long classPK, OrderByComparator<JournalArticle> orderByComparator) {
21077                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
21078                                    0, 1, orderByComparator);
21079    
21080                    if (!list.isEmpty()) {
21081                            return list.get(0);
21082                    }
21083    
21084                    return null;
21085            }
21086    
21087            /**
21088             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21089             *
21090             * @param groupId the group ID
21091             * @param classNameId the class name ID
21092             * @param classPK the class p k
21093             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21094             * @return the last matching journal article
21095             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
21096             */
21097            @Override
21098            public JournalArticle findByG_C_C_Last(long groupId, long classNameId,
21099                    long classPK, OrderByComparator<JournalArticle> orderByComparator)
21100                    throws NoSuchArticleException {
21101                    JournalArticle journalArticle = fetchByG_C_C_Last(groupId, classNameId,
21102                                    classPK, orderByComparator);
21103    
21104                    if (journalArticle != null) {
21105                            return journalArticle;
21106                    }
21107    
21108                    StringBundler msg = new StringBundler(8);
21109    
21110                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
21111    
21112                    msg.append("groupId=");
21113                    msg.append(groupId);
21114    
21115                    msg.append(", classNameId=");
21116                    msg.append(classNameId);
21117    
21118                    msg.append(", classPK=");
21119                    msg.append(classPK);
21120    
21121                    msg.append(StringPool.CLOSE_CURLY_BRACE);
21122    
21123                    throw new NoSuchArticleException(msg.toString());
21124            }
21125    
21126            /**
21127             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21128             *
21129             * @param groupId the group ID
21130             * @param classNameId the class name ID
21131             * @param classPK the class p k
21132             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21133             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
21134             */
21135            @Override
21136            public JournalArticle fetchByG_C_C_Last(long groupId, long classNameId,
21137                    long classPK, OrderByComparator<JournalArticle> orderByComparator) {
21138                    int count = countByG_C_C(groupId, classNameId, classPK);
21139    
21140                    if (count == 0) {
21141                            return null;
21142                    }
21143    
21144                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
21145                                    count - 1, count, orderByComparator);
21146    
21147                    if (!list.isEmpty()) {
21148                            return list.get(0);
21149                    }
21150    
21151                    return null;
21152            }
21153    
21154            /**
21155             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21156             *
21157             * @param id the primary key of the current journal article
21158             * @param groupId the group ID
21159             * @param classNameId the class name ID
21160             * @param classPK the class p k
21161             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21162             * @return the previous, current, and next journal article
21163             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
21164             */
21165            @Override
21166            public JournalArticle[] findByG_C_C_PrevAndNext(long id, long groupId,
21167                    long classNameId, long classPK,
21168                    OrderByComparator<JournalArticle> orderByComparator)
21169                    throws NoSuchArticleException {
21170                    JournalArticle journalArticle = findByPrimaryKey(id);
21171    
21172                    Session session = null;
21173    
21174                    try {
21175                            session = openSession();
21176    
21177                            JournalArticle[] array = new JournalArticleImpl[3];
21178    
21179                            array[0] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
21180                                            classNameId, classPK, orderByComparator, true);
21181    
21182                            array[1] = journalArticle;
21183    
21184                            array[2] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
21185                                            classNameId, classPK, orderByComparator, false);
21186    
21187                            return array;
21188                    }
21189                    catch (Exception e) {
21190                            throw processException(e);
21191                    }
21192                    finally {
21193                            closeSession(session);
21194                    }
21195            }
21196    
21197            protected JournalArticle getByG_C_C_PrevAndNext(Session session,
21198                    JournalArticle journalArticle, long groupId, long classNameId,
21199                    long classPK, OrderByComparator<JournalArticle> orderByComparator,
21200                    boolean previous) {
21201                    StringBundler query = null;
21202    
21203                    if (orderByComparator != null) {
21204                            query = new StringBundler(6 +
21205                                            (orderByComparator.getOrderByFields().length * 6));
21206                    }
21207                    else {
21208                            query = new StringBundler(3);
21209                    }
21210    
21211                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
21212    
21213                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
21214    
21215                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
21216    
21217                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
21218    
21219                    if (orderByComparator != null) {
21220                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
21221    
21222                            if (orderByConditionFields.length > 0) {
21223                                    query.append(WHERE_AND);
21224                            }
21225    
21226                            for (int i = 0; i < orderByConditionFields.length; i++) {
21227                                    query.append(_ORDER_BY_ENTITY_ALIAS);
21228                                    query.append(orderByConditionFields[i]);
21229    
21230                                    if ((i + 1) < orderByConditionFields.length) {
21231                                            if (orderByComparator.isAscending() ^ previous) {
21232                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
21233                                            }
21234                                            else {
21235                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
21236                                            }
21237                                    }
21238                                    else {
21239                                            if (orderByComparator.isAscending() ^ previous) {
21240                                                    query.append(WHERE_GREATER_THAN);
21241                                            }
21242                                            else {
21243                                                    query.append(WHERE_LESSER_THAN);
21244                                            }
21245                                    }
21246                            }
21247    
21248                            query.append(ORDER_BY_CLAUSE);
21249    
21250                            String[] orderByFields = orderByComparator.getOrderByFields();
21251    
21252                            for (int i = 0; i < orderByFields.length; i++) {
21253                                    query.append(_ORDER_BY_ENTITY_ALIAS);
21254                                    query.append(orderByFields[i]);
21255    
21256                                    if ((i + 1) < orderByFields.length) {
21257                                            if (orderByComparator.isAscending() ^ previous) {
21258                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
21259                                            }
21260                                            else {
21261                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
21262                                            }
21263                                    }
21264                                    else {
21265                                            if (orderByComparator.isAscending() ^ previous) {
21266                                                    query.append(ORDER_BY_ASC);
21267                                            }
21268                                            else {
21269                                                    query.append(ORDER_BY_DESC);
21270                                            }
21271                                    }
21272                            }
21273                    }
21274                    else {
21275                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21276                    }
21277    
21278                    String sql = query.toString();
21279    
21280                    Query q = session.createQuery(sql);
21281    
21282                    q.setFirstResult(0);
21283                    q.setMaxResults(2);
21284    
21285                    QueryPos qPos = QueryPos.getInstance(q);
21286    
21287                    qPos.add(groupId);
21288    
21289                    qPos.add(classNameId);
21290    
21291                    qPos.add(classPK);
21292    
21293                    if (orderByComparator != null) {
21294                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
21295    
21296                            for (Object value : values) {
21297                                    qPos.add(value);
21298                            }
21299                    }
21300    
21301                    List<JournalArticle> list = q.list();
21302    
21303                    if (list.size() == 2) {
21304                            return list.get(1);
21305                    }
21306                    else {
21307                            return null;
21308                    }
21309            }
21310    
21311            /**
21312             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21313             *
21314             * @param groupId the group ID
21315             * @param classNameId the class name ID
21316             * @param classPK the class p k
21317             * @return the matching journal articles that the user has permission to view
21318             */
21319            @Override
21320            public List<JournalArticle> filterFindByG_C_C(long groupId,
21321                    long classNameId, long classPK) {
21322                    return filterFindByG_C_C(groupId, classNameId, classPK,
21323                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
21324            }
21325    
21326            /**
21327             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21328             *
21329             * <p>
21330             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
21331             * </p>
21332             *
21333             * @param groupId the group ID
21334             * @param classNameId the class name ID
21335             * @param classPK the class p k
21336             * @param start the lower bound of the range of journal articles
21337             * @param end the upper bound of the range of journal articles (not inclusive)
21338             * @return the range of matching journal articles that the user has permission to view
21339             */
21340            @Override
21341            public List<JournalArticle> filterFindByG_C_C(long groupId,
21342                    long classNameId, long classPK, int start, int end) {
21343                    return filterFindByG_C_C(groupId, classNameId, classPK, start, end, null);
21344            }
21345    
21346            /**
21347             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21348             *
21349             * <p>
21350             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
21351             * </p>
21352             *
21353             * @param groupId the group ID
21354             * @param classNameId the class name ID
21355             * @param classPK the class p k
21356             * @param start the lower bound of the range of journal articles
21357             * @param end the upper bound of the range of journal articles (not inclusive)
21358             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
21359             * @return the ordered range of matching journal articles that the user has permission to view
21360             */
21361            @Override
21362            public List<JournalArticle> filterFindByG_C_C(long groupId,
21363                    long classNameId, long classPK, int start, int end,
21364                    OrderByComparator<JournalArticle> orderByComparator) {
21365                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21366                            return findByG_C_C(groupId, classNameId, classPK, start, end,
21367                                    orderByComparator);
21368                    }
21369    
21370                    StringBundler query = null;
21371    
21372                    if (orderByComparator != null) {
21373                            query = new StringBundler(5 +
21374                                            (orderByComparator.getOrderByFields().length * 3));
21375                    }
21376                    else {
21377                            query = new StringBundler(5);
21378                    }
21379    
21380                    if (getDB().isSupportsInlineDistinct()) {
21381                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
21382                    }
21383                    else {
21384                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
21385                    }
21386    
21387                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
21388    
21389                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
21390    
21391                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
21392    
21393                    if (!getDB().isSupportsInlineDistinct()) {
21394                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
21395                    }
21396    
21397                    if (orderByComparator != null) {
21398                            if (getDB().isSupportsInlineDistinct()) {
21399                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
21400                                            orderByComparator, true);
21401                            }
21402                            else {
21403                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
21404                                            orderByComparator, true);
21405                            }
21406                    }
21407                    else {
21408                            if (getDB().isSupportsInlineDistinct()) {
21409                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21410                            }
21411                            else {
21412                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
21413                            }
21414                    }
21415    
21416                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21417                                    JournalArticle.class.getName(),
21418                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21419    
21420                    Session session = null;
21421    
21422                    try {
21423                            session = openSession();
21424    
21425                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
21426    
21427                            if (getDB().isSupportsInlineDistinct()) {
21428                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
21429                            }
21430                            else {
21431                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
21432                            }
21433    
21434                            QueryPos qPos = QueryPos.getInstance(q);
21435    
21436                            qPos.add(groupId);
21437    
21438                            qPos.add(classNameId);
21439    
21440                            qPos.add(classPK);
21441    
21442                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
21443                                    end);
21444                    }
21445                    catch (Exception e) {
21446                            throw processException(e);
21447                    }
21448                    finally {
21449                            closeSession(session);
21450                    }
21451            }
21452    
21453            /**
21454             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21455             *
21456             * @param id the primary key of the current journal article
21457             * @param groupId the group ID
21458             * @param classNameId the class name ID
21459             * @param classPK the class p k
21460             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21461             * @return the previous, current, and next journal article
21462             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
21463             */
21464            @Override
21465            public JournalArticle[] filterFindByG_C_C_PrevAndNext(long id,
21466                    long groupId, long classNameId, long classPK,
21467                    OrderByComparator<JournalArticle> orderByComparator)
21468                    throws NoSuchArticleException {
21469                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21470                            return findByG_C_C_PrevAndNext(id, groupId, classNameId, classPK,
21471                                    orderByComparator);
21472                    }
21473    
21474                    JournalArticle journalArticle = findByPrimaryKey(id);
21475    
21476                    Session session = null;
21477    
21478                    try {
21479                            session = openSession();
21480    
21481                            JournalArticle[] array = new JournalArticleImpl[3];
21482    
21483                            array[0] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
21484                                            groupId, classNameId, classPK, orderByComparator, true);
21485    
21486                            array[1] = journalArticle;
21487    
21488                            array[2] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
21489                                            groupId, classNameId, classPK, orderByComparator, false);
21490    
21491                            return array;
21492                    }
21493                    catch (Exception e) {
21494                            throw processException(e);
21495                    }
21496                    finally {
21497                            closeSession(session);
21498                    }
21499            }
21500    
21501            protected JournalArticle filterGetByG_C_C_PrevAndNext(Session session,
21502                    JournalArticle journalArticle, long groupId, long classNameId,
21503                    long classPK, OrderByComparator<JournalArticle> orderByComparator,
21504                    boolean previous) {
21505                    StringBundler query = null;
21506    
21507                    if (orderByComparator != null) {
21508                            query = new StringBundler(6 +
21509                                            (orderByComparator.getOrderByFields().length * 6));
21510                    }
21511                    else {
21512                            query = new StringBundler(3);
21513                    }
21514    
21515                    if (getDB().isSupportsInlineDistinct()) {
21516                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
21517                    }
21518                    else {
21519                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
21520                    }
21521    
21522                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
21523    
21524                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
21525    
21526                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
21527    
21528                    if (!getDB().isSupportsInlineDistinct()) {
21529                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
21530                    }
21531    
21532                    if (orderByComparator != null) {
21533                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
21534    
21535                            if (orderByConditionFields.length > 0) {
21536                                    query.append(WHERE_AND);
21537                            }
21538    
21539                            for (int i = 0; i < orderByConditionFields.length; i++) {
21540                                    if (getDB().isSupportsInlineDistinct()) {
21541                                            query.append(_ORDER_BY_ENTITY_ALIAS);
21542                                    }
21543                                    else {
21544                                            query.append(_ORDER_BY_ENTITY_TABLE);
21545                                    }
21546    
21547                                    query.append(orderByConditionFields[i]);
21548    
21549                                    if ((i + 1) < orderByConditionFields.length) {
21550                                            if (orderByComparator.isAscending() ^ previous) {
21551                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
21552                                            }
21553                                            else {
21554                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
21555                                            }
21556                                    }
21557                                    else {
21558                                            if (orderByComparator.isAscending() ^ previous) {
21559                                                    query.append(WHERE_GREATER_THAN);
21560                                            }
21561                                            else {
21562                                                    query.append(WHERE_LESSER_THAN);
21563                                            }
21564                                    }
21565                            }
21566    
21567                            query.append(ORDER_BY_CLAUSE);
21568    
21569                            String[] orderByFields = orderByComparator.getOrderByFields();
21570    
21571                            for (int i = 0; i < orderByFields.length; i++) {
21572                                    if (getDB().isSupportsInlineDistinct()) {
21573                                            query.append(_ORDER_BY_ENTITY_ALIAS);
21574                                    }
21575                                    else {
21576                                            query.append(_ORDER_BY_ENTITY_TABLE);
21577                                    }
21578    
21579                                    query.append(orderByFields[i]);
21580    
21581                                    if ((i + 1) < orderByFields.length) {
21582                                            if (orderByComparator.isAscending() ^ previous) {
21583                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
21584                                            }
21585                                            else {
21586                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
21587                                            }
21588                                    }
21589                                    else {
21590                                            if (orderByComparator.isAscending() ^ previous) {
21591                                                    query.append(ORDER_BY_ASC);
21592                                            }
21593                                            else {
21594                                                    query.append(ORDER_BY_DESC);
21595                                            }
21596                                    }
21597                            }
21598                    }
21599                    else {
21600                            if (getDB().isSupportsInlineDistinct()) {
21601                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21602                            }
21603                            else {
21604                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
21605                            }
21606                    }
21607    
21608                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21609                                    JournalArticle.class.getName(),
21610                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21611    
21612                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
21613    
21614                    q.setFirstResult(0);
21615                    q.setMaxResults(2);
21616    
21617                    if (getDB().isSupportsInlineDistinct()) {
21618                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
21619                    }
21620                    else {
21621                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
21622                    }
21623    
21624                    QueryPos qPos = QueryPos.getInstance(q);
21625    
21626                    qPos.add(groupId);
21627    
21628                    qPos.add(classNameId);
21629    
21630                    qPos.add(classPK);
21631    
21632                    if (orderByComparator != null) {
21633                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
21634    
21635                            for (Object value : values) {
21636                                    qPos.add(value);
21637                            }
21638                    }
21639    
21640                    List<JournalArticle> list = q.list();
21641    
21642                    if (list.size() == 2) {
21643                            return list.get(1);
21644                    }
21645                    else {
21646                            return null;
21647                    }
21648            }
21649    
21650            /**
21651             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
21652             *
21653             * @param groupId the group ID
21654             * @param classNameId the class name ID
21655             * @param classPK the class p k
21656             */
21657            @Override
21658            public void removeByG_C_C(long groupId, long classNameId, long classPK) {
21659                    for (JournalArticle journalArticle : findByG_C_C(groupId, classNameId,
21660                                    classPK, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
21661                            remove(journalArticle);
21662                    }
21663            }
21664    
21665            /**
21666             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21667             *
21668             * @param groupId the group ID
21669             * @param classNameId the class name ID
21670             * @param classPK the class p k
21671             * @return the number of matching journal articles
21672             */
21673            @Override
21674            public int countByG_C_C(long groupId, long classNameId, long classPK) {
21675                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_C;
21676    
21677                    Object[] finderArgs = new Object[] { groupId, classNameId, classPK };
21678    
21679                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
21680                                    this);
21681    
21682                    if (count == null) {
21683                            StringBundler query = new StringBundler(4);
21684    
21685                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
21686    
21687                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
21688    
21689                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
21690    
21691                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
21692    
21693                            String sql = query.toString();
21694    
21695                            Session session = null;
21696    
21697                            try {
21698                                    session = openSession();
21699    
21700                                    Query q = session.createQuery(sql);
21701    
21702                                    QueryPos qPos = QueryPos.getInstance(q);
21703    
21704                                    qPos.add(groupId);
21705    
21706                                    qPos.add(classNameId);
21707    
21708                                    qPos.add(classPK);
21709    
21710                                    count = (Long)q.uniqueResult();
21711    
21712                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
21713                            }
21714                            catch (Exception e) {
21715                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
21716    
21717                                    throw processException(e);
21718                            }
21719                            finally {
21720                                    closeSession(session);
21721                            }
21722                    }
21723    
21724                    return count.intValue();
21725            }
21726    
21727            /**
21728             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21729             *
21730             * @param groupId the group ID
21731             * @param classNameId the class name ID
21732             * @param classPK the class p k
21733             * @return the number of matching journal articles that the user has permission to view
21734             */
21735            @Override
21736            public int filterCountByG_C_C(long groupId, long classNameId, long classPK) {
21737                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21738                            return countByG_C_C(groupId, classNameId, classPK);
21739                    }
21740    
21741                    StringBundler query = new StringBundler(4);
21742    
21743                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
21744    
21745                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
21746    
21747                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
21748    
21749                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
21750    
21751                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21752                                    JournalArticle.class.getName(),
21753                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21754    
21755                    Session session = null;
21756    
21757                    try {
21758                            session = openSession();
21759    
21760                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
21761    
21762                            q.addScalar(COUNT_COLUMN_NAME,
21763                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
21764    
21765                            QueryPos qPos = QueryPos.getInstance(q);
21766    
21767                            qPos.add(groupId);
21768    
21769                            qPos.add(classNameId);
21770    
21771                            qPos.add(classPK);
21772    
21773                            Long count = (Long)q.uniqueResult();
21774    
21775                            return count.intValue();
21776                    }
21777                    catch (Exception e) {
21778                            throw processException(e);
21779                    }
21780                    finally {
21781                            closeSession(session);
21782                    }
21783            }
21784    
21785            private static final String _FINDER_COLUMN_G_C_C_GROUPID_2 = "journalArticle.groupId = ? AND ";
21786            private static final String _FINDER_COLUMN_G_C_C_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
21787            private static final String _FINDER_COLUMN_G_C_C_CLASSPK_2 = "journalArticle.classPK = ?";
21788            public static final FinderPath FINDER_PATH_FETCH_BY_G_C_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21789                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
21790                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_C_S",
21791                            new String[] {
21792                                    Long.class.getName(), Long.class.getName(),
21793                                    String.class.getName()
21794                            },
21795                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
21796                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
21797                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK);
21798            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21799                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
21800                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_S",
21801                            new String[] {
21802                                    Long.class.getName(), Long.class.getName(),
21803                                    String.class.getName()
21804                            });
21805    
21806            /**
21807             * Returns the journal article where groupId = &#63; and classNameId = &#63; and structureId = &#63; or throws a {@link com.liferay.portlet.journal.NoSuchArticleException} if it could not be found.
21808             *
21809             * @param groupId the group ID
21810             * @param classNameId the class name ID
21811             * @param structureId the structure ID
21812             * @return the matching journal article
21813             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
21814             */
21815            @Override
21816            public JournalArticle findByG_C_S(long groupId, long classNameId,
21817                    String structureId) throws NoSuchArticleException {
21818                    JournalArticle journalArticle = fetchByG_C_S(groupId, classNameId,
21819                                    structureId);
21820    
21821                    if (journalArticle == null) {
21822                            StringBundler msg = new StringBundler(8);
21823    
21824                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
21825    
21826                            msg.append("groupId=");
21827                            msg.append(groupId);
21828    
21829                            msg.append(", classNameId=");
21830                            msg.append(classNameId);
21831    
21832                            msg.append(", structureId=");
21833                            msg.append(structureId);
21834    
21835                            msg.append(StringPool.CLOSE_CURLY_BRACE);
21836    
21837                            if (_log.isWarnEnabled()) {
21838                                    _log.warn(msg.toString());
21839                            }
21840    
21841                            throw new NoSuchArticleException(msg.toString());
21842                    }
21843    
21844                    return journalArticle;
21845            }
21846    
21847            /**
21848             * Returns the journal article where groupId = &#63; and classNameId = &#63; and structureId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
21849             *
21850             * @param groupId the group ID
21851             * @param classNameId the class name ID
21852             * @param structureId the structure ID
21853             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
21854             */
21855            @Override
21856            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
21857                    String structureId) {
21858                    return fetchByG_C_S(groupId, classNameId, structureId, true);
21859            }
21860    
21861            /**
21862             * Returns the journal article where groupId = &#63; and classNameId = &#63; and structureId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
21863             *
21864             * @param groupId the group ID
21865             * @param classNameId the class name ID
21866             * @param structureId the structure ID
21867             * @param retrieveFromCache whether to use the finder cache
21868             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
21869             */
21870            @Override
21871            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
21872                    String structureId, boolean retrieveFromCache) {
21873                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
21874    
21875                    Object result = null;
21876    
21877                    if (retrieveFromCache) {
21878                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_C_S,
21879                                            finderArgs, this);
21880                    }
21881    
21882                    if (result instanceof JournalArticle) {
21883                            JournalArticle journalArticle = (JournalArticle)result;
21884    
21885                            if ((groupId != journalArticle.getGroupId()) ||
21886                                            (classNameId != journalArticle.getClassNameId()) ||
21887                                            !Validator.equals(structureId,
21888                                                    journalArticle.getStructureId())) {
21889                                    result = null;
21890                            }
21891                    }
21892    
21893                    if (result == null) {
21894                            StringBundler query = new StringBundler(5);
21895    
21896                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
21897    
21898                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
21899    
21900                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
21901    
21902                            boolean bindStructureId = false;
21903    
21904                            if (structureId == null) {
21905                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
21906                            }
21907                            else if (structureId.equals(StringPool.BLANK)) {
21908                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
21909                            }
21910                            else {
21911                                    bindStructureId = true;
21912    
21913                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
21914                            }
21915    
21916                            String sql = query.toString();
21917    
21918                            Session session = null;
21919    
21920                            try {
21921                                    session = openSession();
21922    
21923                                    Query q = session.createQuery(sql);
21924    
21925                                    QueryPos qPos = QueryPos.getInstance(q);
21926    
21927                                    qPos.add(groupId);
21928    
21929                                    qPos.add(classNameId);
21930    
21931                                    if (bindStructureId) {
21932                                            qPos.add(structureId);
21933                                    }
21934    
21935                                    List<JournalArticle> list = q.list();
21936    
21937                                    if (list.isEmpty()) {
21938                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
21939                                                    finderArgs, list);
21940                                    }
21941                                    else {
21942                                            if ((list.size() > 1) && _log.isWarnEnabled()) {
21943                                                    _log.warn(
21944                                                            "JournalArticlePersistenceImpl.fetchByG_C_S(long, long, String, boolean) with parameters (" +
21945                                                            StringUtil.merge(finderArgs) +
21946                                                            ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder.");
21947                                            }
21948    
21949                                            JournalArticle journalArticle = list.get(0);
21950    
21951                                            result = journalArticle;
21952    
21953                                            cacheResult(journalArticle);
21954    
21955                                            if ((journalArticle.getGroupId() != groupId) ||
21956                                                            (journalArticle.getClassNameId() != classNameId) ||
21957                                                            (journalArticle.getStructureId() == null) ||
21958                                                            !journalArticle.getStructureId().equals(structureId)) {
21959                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
21960                                                            finderArgs, journalArticle);
21961                                            }
21962                                    }
21963                            }
21964                            catch (Exception e) {
21965                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S,
21966                                            finderArgs);
21967    
21968                                    throw processException(e);
21969                            }
21970                            finally {
21971                                    closeSession(session);
21972                            }
21973                    }
21974    
21975                    if (result instanceof List<?>) {
21976                            return null;
21977                    }
21978                    else {
21979                            return (JournalArticle)result;
21980                    }
21981            }
21982    
21983            /**
21984             * Removes the journal article where groupId = &#63; and classNameId = &#63; and structureId = &#63; from the database.
21985             *
21986             * @param groupId the group ID
21987             * @param classNameId the class name ID
21988             * @param structureId the structure ID
21989             * @return the journal article that was removed
21990             */
21991            @Override
21992            public JournalArticle removeByG_C_S(long groupId, long classNameId,
21993                    String structureId) throws NoSuchArticleException {
21994                    JournalArticle journalArticle = findByG_C_S(groupId, classNameId,
21995                                    structureId);
21996    
21997                    return remove(journalArticle);
21998            }
21999    
22000            /**
22001             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and structureId = &#63;.
22002             *
22003             * @param groupId the group ID
22004             * @param classNameId the class name ID
22005             * @param structureId the structure ID
22006             * @return the number of matching journal articles
22007             */
22008            @Override
22009            public int countByG_C_S(long groupId, long classNameId, String structureId) {
22010                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_S;
22011    
22012                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
22013    
22014                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
22015                                    this);
22016    
22017                    if (count == null) {
22018                            StringBundler query = new StringBundler(4);
22019    
22020                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
22021    
22022                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
22023    
22024                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
22025    
22026                            boolean bindStructureId = false;
22027    
22028                            if (structureId == null) {
22029                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
22030                            }
22031                            else if (structureId.equals(StringPool.BLANK)) {
22032                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
22033                            }
22034                            else {
22035                                    bindStructureId = true;
22036    
22037                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
22038                            }
22039    
22040                            String sql = query.toString();
22041    
22042                            Session session = null;
22043    
22044                            try {
22045                                    session = openSession();
22046    
22047                                    Query q = session.createQuery(sql);
22048    
22049                                    QueryPos qPos = QueryPos.getInstance(q);
22050    
22051                                    qPos.add(groupId);
22052    
22053                                    qPos.add(classNameId);
22054    
22055                                    if (bindStructureId) {
22056                                            qPos.add(structureId);
22057                                    }
22058    
22059                                    count = (Long)q.uniqueResult();
22060    
22061                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
22062                            }
22063                            catch (Exception e) {
22064                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
22065    
22066                                    throw processException(e);
22067                            }
22068                            finally {
22069                                    closeSession(session);
22070                            }
22071                    }
22072    
22073                    return count.intValue();
22074            }
22075    
22076            private static final String _FINDER_COLUMN_G_C_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
22077            private static final String _FINDER_COLUMN_G_C_S_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
22078            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
22079            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
22080            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = '')";
22081            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22082                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
22083                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
22084                            "findByG_C_T",
22085                            new String[] {
22086                                    Long.class.getName(), Long.class.getName(),
22087                                    String.class.getName(),
22088                                    
22089                            Integer.class.getName(), Integer.class.getName(),
22090                                    OrderByComparator.class.getName()
22091                            });
22092            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22093                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
22094                            JournalArticleImpl.class,
22095                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_T",
22096                            new String[] {
22097                                    Long.class.getName(), Long.class.getName(),
22098                                    String.class.getName()
22099                            },
22100                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
22101                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
22102                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
22103                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
22104                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
22105            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22106                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
22107                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_T",
22108                            new String[] {
22109                                    Long.class.getName(), Long.class.getName(),
22110                                    String.class.getName()
22111                            });
22112    
22113            /**
22114             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22115             *
22116             * @param groupId the group ID
22117             * @param classNameId the class name ID
22118             * @param templateId the template ID
22119             * @return the matching journal articles
22120             */
22121            @Override
22122            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
22123                    String templateId) {
22124                    return findByG_C_T(groupId, classNameId, templateId, QueryUtil.ALL_POS,
22125                            QueryUtil.ALL_POS, null);
22126            }
22127    
22128            /**
22129             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22130             *
22131             * <p>
22132             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
22133             * </p>
22134             *
22135             * @param groupId the group ID
22136             * @param classNameId the class name ID
22137             * @param templateId the template ID
22138             * @param start the lower bound of the range of journal articles
22139             * @param end the upper bound of the range of journal articles (not inclusive)
22140             * @return the range of matching journal articles
22141             */
22142            @Override
22143            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
22144                    String templateId, int start, int end) {
22145                    return findByG_C_T(groupId, classNameId, templateId, start, end, null);
22146            }
22147    
22148            /**
22149             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22150             *
22151             * <p>
22152             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
22153             * </p>
22154             *
22155             * @param groupId the group ID
22156             * @param classNameId the class name ID
22157             * @param templateId the template ID
22158             * @param start the lower bound of the range of journal articles
22159             * @param end the upper bound of the range of journal articles (not inclusive)
22160             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
22161             * @return the ordered range of matching journal articles
22162             */
22163            @Override
22164            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
22165                    String templateId, int start, int end,
22166                    OrderByComparator<JournalArticle> orderByComparator) {
22167                    boolean pagination = true;
22168                    FinderPath finderPath = null;
22169                    Object[] finderArgs = null;
22170    
22171                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
22172                                    (orderByComparator == null)) {
22173                            pagination = false;
22174                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T;
22175                            finderArgs = new Object[] { groupId, classNameId, templateId };
22176                    }
22177                    else {
22178                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T;
22179                            finderArgs = new Object[] {
22180                                            groupId, classNameId, templateId,
22181                                            
22182                                            start, end, orderByComparator
22183                                    };
22184                    }
22185    
22186                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
22187                                    finderArgs, this);
22188    
22189                    if ((list != null) && !list.isEmpty()) {
22190                            for (JournalArticle journalArticle : list) {
22191                                    if ((groupId != journalArticle.getGroupId()) ||
22192                                                    (classNameId != journalArticle.getClassNameId()) ||
22193                                                    !Validator.equals(templateId,
22194                                                            journalArticle.getTemplateId())) {
22195                                            list = null;
22196    
22197                                            break;
22198                                    }
22199                            }
22200                    }
22201    
22202                    if (list == null) {
22203                            StringBundler query = null;
22204    
22205                            if (orderByComparator != null) {
22206                                    query = new StringBundler(5 +
22207                                                    (orderByComparator.getOrderByFields().length * 3));
22208                            }
22209                            else {
22210                                    query = new StringBundler(5);
22211                            }
22212    
22213                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
22214    
22215                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
22216    
22217                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
22218    
22219                            boolean bindTemplateId = false;
22220    
22221                            if (templateId == null) {
22222                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
22223                            }
22224                            else if (templateId.equals(StringPool.BLANK)) {
22225                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
22226                            }
22227                            else {
22228                                    bindTemplateId = true;
22229    
22230                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
22231                            }
22232    
22233                            if (orderByComparator != null) {
22234                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
22235                                            orderByComparator);
22236                            }
22237                            else
22238                             if (pagination) {
22239                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22240                            }
22241    
22242                            String sql = query.toString();
22243    
22244                            Session session = null;
22245    
22246                            try {
22247                                    session = openSession();
22248    
22249                                    Query q = session.createQuery(sql);
22250    
22251                                    QueryPos qPos = QueryPos.getInstance(q);
22252    
22253                                    qPos.add(groupId);
22254    
22255                                    qPos.add(classNameId);
22256    
22257                                    if (bindTemplateId) {
22258                                            qPos.add(templateId);
22259                                    }
22260    
22261                                    if (!pagination) {
22262                                            list = (List<JournalArticle>)QueryUtil.list(q,
22263                                                            getDialect(), start, end, false);
22264    
22265                                            Collections.sort(list);
22266    
22267                                            list = Collections.unmodifiableList(list);
22268                                    }
22269                                    else {
22270                                            list = (List<JournalArticle>)QueryUtil.list(q,
22271                                                            getDialect(), start, end);
22272                                    }
22273    
22274                                    cacheResult(list);
22275    
22276                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
22277                            }
22278                            catch (Exception e) {
22279                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
22280    
22281                                    throw processException(e);
22282                            }
22283                            finally {
22284                                    closeSession(session);
22285                            }
22286                    }
22287    
22288                    return list;
22289            }
22290    
22291            /**
22292             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22293             *
22294             * @param groupId the group ID
22295             * @param classNameId the class name ID
22296             * @param templateId the template ID
22297             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22298             * @return the first matching journal article
22299             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
22300             */
22301            @Override
22302            public JournalArticle findByG_C_T_First(long groupId, long classNameId,
22303                    String templateId, OrderByComparator<JournalArticle> orderByComparator)
22304                    throws NoSuchArticleException {
22305                    JournalArticle journalArticle = fetchByG_C_T_First(groupId,
22306                                    classNameId, templateId, orderByComparator);
22307    
22308                    if (journalArticle != null) {
22309                            return journalArticle;
22310                    }
22311    
22312                    StringBundler msg = new StringBundler(8);
22313    
22314                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
22315    
22316                    msg.append("groupId=");
22317                    msg.append(groupId);
22318    
22319                    msg.append(", classNameId=");
22320                    msg.append(classNameId);
22321    
22322                    msg.append(", templateId=");
22323                    msg.append(templateId);
22324    
22325                    msg.append(StringPool.CLOSE_CURLY_BRACE);
22326    
22327                    throw new NoSuchArticleException(msg.toString());
22328            }
22329    
22330            /**
22331             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22332             *
22333             * @param groupId the group ID
22334             * @param classNameId the class name ID
22335             * @param templateId the template ID
22336             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22337             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
22338             */
22339            @Override
22340            public JournalArticle fetchByG_C_T_First(long groupId, long classNameId,
22341                    String templateId, OrderByComparator<JournalArticle> orderByComparator) {
22342                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
22343                                    templateId, 0, 1, orderByComparator);
22344    
22345                    if (!list.isEmpty()) {
22346                            return list.get(0);
22347                    }
22348    
22349                    return null;
22350            }
22351    
22352            /**
22353             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22354             *
22355             * @param groupId the group ID
22356             * @param classNameId the class name ID
22357             * @param templateId the template ID
22358             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22359             * @return the last matching journal article
22360             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
22361             */
22362            @Override
22363            public JournalArticle findByG_C_T_Last(long groupId, long classNameId,
22364                    String templateId, OrderByComparator<JournalArticle> orderByComparator)
22365                    throws NoSuchArticleException {
22366                    JournalArticle journalArticle = fetchByG_C_T_Last(groupId, classNameId,
22367                                    templateId, orderByComparator);
22368    
22369                    if (journalArticle != null) {
22370                            return journalArticle;
22371                    }
22372    
22373                    StringBundler msg = new StringBundler(8);
22374    
22375                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
22376    
22377                    msg.append("groupId=");
22378                    msg.append(groupId);
22379    
22380                    msg.append(", classNameId=");
22381                    msg.append(classNameId);
22382    
22383                    msg.append(", templateId=");
22384                    msg.append(templateId);
22385    
22386                    msg.append(StringPool.CLOSE_CURLY_BRACE);
22387    
22388                    throw new NoSuchArticleException(msg.toString());
22389            }
22390    
22391            /**
22392             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22393             *
22394             * @param groupId the group ID
22395             * @param classNameId the class name ID
22396             * @param templateId the template ID
22397             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22398             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
22399             */
22400            @Override
22401            public JournalArticle fetchByG_C_T_Last(long groupId, long classNameId,
22402                    String templateId, OrderByComparator<JournalArticle> orderByComparator) {
22403                    int count = countByG_C_T(groupId, classNameId, templateId);
22404    
22405                    if (count == 0) {
22406                            return null;
22407                    }
22408    
22409                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
22410                                    templateId, count - 1, count, orderByComparator);
22411    
22412                    if (!list.isEmpty()) {
22413                            return list.get(0);
22414                    }
22415    
22416                    return null;
22417            }
22418    
22419            /**
22420             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22421             *
22422             * @param id the primary key of the current journal article
22423             * @param groupId the group ID
22424             * @param classNameId the class name ID
22425             * @param templateId the template ID
22426             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22427             * @return the previous, current, and next journal article
22428             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
22429             */
22430            @Override
22431            public JournalArticle[] findByG_C_T_PrevAndNext(long id, long groupId,
22432                    long classNameId, String templateId,
22433                    OrderByComparator<JournalArticle> orderByComparator)
22434                    throws NoSuchArticleException {
22435                    JournalArticle journalArticle = findByPrimaryKey(id);
22436    
22437                    Session session = null;
22438    
22439                    try {
22440                            session = openSession();
22441    
22442                            JournalArticle[] array = new JournalArticleImpl[3];
22443    
22444                            array[0] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
22445                                            classNameId, templateId, orderByComparator, true);
22446    
22447                            array[1] = journalArticle;
22448    
22449                            array[2] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
22450                                            classNameId, templateId, orderByComparator, false);
22451    
22452                            return array;
22453                    }
22454                    catch (Exception e) {
22455                            throw processException(e);
22456                    }
22457                    finally {
22458                            closeSession(session);
22459                    }
22460            }
22461    
22462            protected JournalArticle getByG_C_T_PrevAndNext(Session session,
22463                    JournalArticle journalArticle, long groupId, long classNameId,
22464                    String templateId, OrderByComparator<JournalArticle> orderByComparator,
22465                    boolean previous) {
22466                    StringBundler query = null;
22467    
22468                    if (orderByComparator != null) {
22469                            query = new StringBundler(6 +
22470                                            (orderByComparator.getOrderByFields().length * 6));
22471                    }
22472                    else {
22473                            query = new StringBundler(3);
22474                    }
22475    
22476                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
22477    
22478                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
22479    
22480                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
22481    
22482                    boolean bindTemplateId = false;
22483    
22484                    if (templateId == null) {
22485                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
22486                    }
22487                    else if (templateId.equals(StringPool.BLANK)) {
22488                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
22489                    }
22490                    else {
22491                            bindTemplateId = true;
22492    
22493                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
22494                    }
22495    
22496                    if (orderByComparator != null) {
22497                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
22498    
22499                            if (orderByConditionFields.length > 0) {
22500                                    query.append(WHERE_AND);
22501                            }
22502    
22503                            for (int i = 0; i < orderByConditionFields.length; i++) {
22504                                    query.append(_ORDER_BY_ENTITY_ALIAS);
22505                                    query.append(orderByConditionFields[i]);
22506    
22507                                    if ((i + 1) < orderByConditionFields.length) {
22508                                            if (orderByComparator.isAscending() ^ previous) {
22509                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
22510                                            }
22511                                            else {
22512                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
22513                                            }
22514                                    }
22515                                    else {
22516                                            if (orderByComparator.isAscending() ^ previous) {
22517                                                    query.append(WHERE_GREATER_THAN);
22518                                            }
22519                                            else {
22520                                                    query.append(WHERE_LESSER_THAN);
22521                                            }
22522                                    }
22523                            }
22524    
22525                            query.append(ORDER_BY_CLAUSE);
22526    
22527                            String[] orderByFields = orderByComparator.getOrderByFields();
22528    
22529                            for (int i = 0; i < orderByFields.length; i++) {
22530                                    query.append(_ORDER_BY_ENTITY_ALIAS);
22531                                    query.append(orderByFields[i]);
22532    
22533                                    if ((i + 1) < orderByFields.length) {
22534                                            if (orderByComparator.isAscending() ^ previous) {
22535                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
22536                                            }
22537                                            else {
22538                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
22539                                            }
22540                                    }
22541                                    else {
22542                                            if (orderByComparator.isAscending() ^ previous) {
22543                                                    query.append(ORDER_BY_ASC);
22544                                            }
22545                                            else {
22546                                                    query.append(ORDER_BY_DESC);
22547                                            }
22548                                    }
22549                            }
22550                    }
22551                    else {
22552                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22553                    }
22554    
22555                    String sql = query.toString();
22556    
22557                    Query q = session.createQuery(sql);
22558    
22559                    q.setFirstResult(0);
22560                    q.setMaxResults(2);
22561    
22562                    QueryPos qPos = QueryPos.getInstance(q);
22563    
22564                    qPos.add(groupId);
22565    
22566                    qPos.add(classNameId);
22567    
22568                    if (bindTemplateId) {
22569                            qPos.add(templateId);
22570                    }
22571    
22572                    if (orderByComparator != null) {
22573                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
22574    
22575                            for (Object value : values) {
22576                                    qPos.add(value);
22577                            }
22578                    }
22579    
22580                    List<JournalArticle> list = q.list();
22581    
22582                    if (list.size() == 2) {
22583                            return list.get(1);
22584                    }
22585                    else {
22586                            return null;
22587                    }
22588            }
22589    
22590            /**
22591             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22592             *
22593             * @param groupId the group ID
22594             * @param classNameId the class name ID
22595             * @param templateId the template ID
22596             * @return the matching journal articles that the user has permission to view
22597             */
22598            @Override
22599            public List<JournalArticle> filterFindByG_C_T(long groupId,
22600                    long classNameId, String templateId) {
22601                    return filterFindByG_C_T(groupId, classNameId, templateId,
22602                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
22603            }
22604    
22605            /**
22606             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22607             *
22608             * <p>
22609             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
22610             * </p>
22611             *
22612             * @param groupId the group ID
22613             * @param classNameId the class name ID
22614             * @param templateId the template ID
22615             * @param start the lower bound of the range of journal articles
22616             * @param end the upper bound of the range of journal articles (not inclusive)
22617             * @return the range of matching journal articles that the user has permission to view
22618             */
22619            @Override
22620            public List<JournalArticle> filterFindByG_C_T(long groupId,
22621                    long classNameId, String templateId, int start, int end) {
22622                    return filterFindByG_C_T(groupId, classNameId, templateId, start, end,
22623                            null);
22624            }
22625    
22626            /**
22627             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22628             *
22629             * <p>
22630             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
22631             * </p>
22632             *
22633             * @param groupId the group ID
22634             * @param classNameId the class name ID
22635             * @param templateId the template ID
22636             * @param start the lower bound of the range of journal articles
22637             * @param end the upper bound of the range of journal articles (not inclusive)
22638             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
22639             * @return the ordered range of matching journal articles that the user has permission to view
22640             */
22641            @Override
22642            public List<JournalArticle> filterFindByG_C_T(long groupId,
22643                    long classNameId, String templateId, int start, int end,
22644                    OrderByComparator<JournalArticle> orderByComparator) {
22645                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22646                            return findByG_C_T(groupId, classNameId, templateId, start, end,
22647                                    orderByComparator);
22648                    }
22649    
22650                    StringBundler query = null;
22651    
22652                    if (orderByComparator != null) {
22653                            query = new StringBundler(5 +
22654                                            (orderByComparator.getOrderByFields().length * 3));
22655                    }
22656                    else {
22657                            query = new StringBundler(5);
22658                    }
22659    
22660                    if (getDB().isSupportsInlineDistinct()) {
22661                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
22662                    }
22663                    else {
22664                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
22665                    }
22666    
22667                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
22668    
22669                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
22670    
22671                    boolean bindTemplateId = false;
22672    
22673                    if (templateId == null) {
22674                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
22675                    }
22676                    else if (templateId.equals(StringPool.BLANK)) {
22677                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
22678                    }
22679                    else {
22680                            bindTemplateId = true;
22681    
22682                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
22683                    }
22684    
22685                    if (!getDB().isSupportsInlineDistinct()) {
22686                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
22687                    }
22688    
22689                    if (orderByComparator != null) {
22690                            if (getDB().isSupportsInlineDistinct()) {
22691                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
22692                                            orderByComparator, true);
22693                            }
22694                            else {
22695                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
22696                                            orderByComparator, true);
22697                            }
22698                    }
22699                    else {
22700                            if (getDB().isSupportsInlineDistinct()) {
22701                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22702                            }
22703                            else {
22704                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
22705                            }
22706                    }
22707    
22708                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22709                                    JournalArticle.class.getName(),
22710                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22711    
22712                    Session session = null;
22713    
22714                    try {
22715                            session = openSession();
22716    
22717                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
22718    
22719                            if (getDB().isSupportsInlineDistinct()) {
22720                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
22721                            }
22722                            else {
22723                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
22724                            }
22725    
22726                            QueryPos qPos = QueryPos.getInstance(q);
22727    
22728                            qPos.add(groupId);
22729    
22730                            qPos.add(classNameId);
22731    
22732                            if (bindTemplateId) {
22733                                    qPos.add(templateId);
22734                            }
22735    
22736                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
22737                                    end);
22738                    }
22739                    catch (Exception e) {
22740                            throw processException(e);
22741                    }
22742                    finally {
22743                            closeSession(session);
22744                    }
22745            }
22746    
22747            /**
22748             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22749             *
22750             * @param id the primary key of the current journal article
22751             * @param groupId the group ID
22752             * @param classNameId the class name ID
22753             * @param templateId the template ID
22754             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22755             * @return the previous, current, and next journal article
22756             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
22757             */
22758            @Override
22759            public JournalArticle[] filterFindByG_C_T_PrevAndNext(long id,
22760                    long groupId, long classNameId, String templateId,
22761                    OrderByComparator<JournalArticle> orderByComparator)
22762                    throws NoSuchArticleException {
22763                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22764                            return findByG_C_T_PrevAndNext(id, groupId, classNameId,
22765                                    templateId, orderByComparator);
22766                    }
22767    
22768                    JournalArticle journalArticle = findByPrimaryKey(id);
22769    
22770                    Session session = null;
22771    
22772                    try {
22773                            session = openSession();
22774    
22775                            JournalArticle[] array = new JournalArticleImpl[3];
22776    
22777                            array[0] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
22778                                            groupId, classNameId, templateId, orderByComparator, true);
22779    
22780                            array[1] = journalArticle;
22781    
22782                            array[2] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
22783                                            groupId, classNameId, templateId, orderByComparator, false);
22784    
22785                            return array;
22786                    }
22787                    catch (Exception e) {
22788                            throw processException(e);
22789                    }
22790                    finally {
22791                            closeSession(session);
22792                    }
22793            }
22794    
22795            protected JournalArticle filterGetByG_C_T_PrevAndNext(Session session,
22796                    JournalArticle journalArticle, long groupId, long classNameId,
22797                    String templateId, OrderByComparator<JournalArticle> orderByComparator,
22798                    boolean previous) {
22799                    StringBundler query = null;
22800    
22801                    if (orderByComparator != null) {
22802                            query = new StringBundler(6 +
22803                                            (orderByComparator.getOrderByFields().length * 6));
22804                    }
22805                    else {
22806                            query = new StringBundler(3);
22807                    }
22808    
22809                    if (getDB().isSupportsInlineDistinct()) {
22810                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
22811                    }
22812                    else {
22813                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
22814                    }
22815    
22816                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
22817    
22818                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
22819    
22820                    boolean bindTemplateId = false;
22821    
22822                    if (templateId == null) {
22823                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
22824                    }
22825                    else if (templateId.equals(StringPool.BLANK)) {
22826                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
22827                    }
22828                    else {
22829                            bindTemplateId = true;
22830    
22831                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
22832                    }
22833    
22834                    if (!getDB().isSupportsInlineDistinct()) {
22835                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
22836                    }
22837    
22838                    if (orderByComparator != null) {
22839                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
22840    
22841                            if (orderByConditionFields.length > 0) {
22842                                    query.append(WHERE_AND);
22843                            }
22844    
22845                            for (int i = 0; i < orderByConditionFields.length; i++) {
22846                                    if (getDB().isSupportsInlineDistinct()) {
22847                                            query.append(_ORDER_BY_ENTITY_ALIAS);
22848                                    }
22849                                    else {
22850                                            query.append(_ORDER_BY_ENTITY_TABLE);
22851                                    }
22852    
22853                                    query.append(orderByConditionFields[i]);
22854    
22855                                    if ((i + 1) < orderByConditionFields.length) {
22856                                            if (orderByComparator.isAscending() ^ previous) {
22857                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
22858                                            }
22859                                            else {
22860                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
22861                                            }
22862                                    }
22863                                    else {
22864                                            if (orderByComparator.isAscending() ^ previous) {
22865                                                    query.append(WHERE_GREATER_THAN);
22866                                            }
22867                                            else {
22868                                                    query.append(WHERE_LESSER_THAN);
22869                                            }
22870                                    }
22871                            }
22872    
22873                            query.append(ORDER_BY_CLAUSE);
22874    
22875                            String[] orderByFields = orderByComparator.getOrderByFields();
22876    
22877                            for (int i = 0; i < orderByFields.length; i++) {
22878                                    if (getDB().isSupportsInlineDistinct()) {
22879                                            query.append(_ORDER_BY_ENTITY_ALIAS);
22880                                    }
22881                                    else {
22882                                            query.append(_ORDER_BY_ENTITY_TABLE);
22883                                    }
22884    
22885                                    query.append(orderByFields[i]);
22886    
22887                                    if ((i + 1) < orderByFields.length) {
22888                                            if (orderByComparator.isAscending() ^ previous) {
22889                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
22890                                            }
22891                                            else {
22892                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
22893                                            }
22894                                    }
22895                                    else {
22896                                            if (orderByComparator.isAscending() ^ previous) {
22897                                                    query.append(ORDER_BY_ASC);
22898                                            }
22899                                            else {
22900                                                    query.append(ORDER_BY_DESC);
22901                                            }
22902                                    }
22903                            }
22904                    }
22905                    else {
22906                            if (getDB().isSupportsInlineDistinct()) {
22907                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22908                            }
22909                            else {
22910                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
22911                            }
22912                    }
22913    
22914                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22915                                    JournalArticle.class.getName(),
22916                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22917    
22918                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
22919    
22920                    q.setFirstResult(0);
22921                    q.setMaxResults(2);
22922    
22923                    if (getDB().isSupportsInlineDistinct()) {
22924                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
22925                    }
22926                    else {
22927                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
22928                    }
22929    
22930                    QueryPos qPos = QueryPos.getInstance(q);
22931    
22932                    qPos.add(groupId);
22933    
22934                    qPos.add(classNameId);
22935    
22936                    if (bindTemplateId) {
22937                            qPos.add(templateId);
22938                    }
22939    
22940                    if (orderByComparator != null) {
22941                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
22942    
22943                            for (Object value : values) {
22944                                    qPos.add(value);
22945                            }
22946                    }
22947    
22948                    List<JournalArticle> list = q.list();
22949    
22950                    if (list.size() == 2) {
22951                            return list.get(1);
22952                    }
22953                    else {
22954                            return null;
22955                    }
22956            }
22957    
22958            /**
22959             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63; from the database.
22960             *
22961             * @param groupId the group ID
22962             * @param classNameId the class name ID
22963             * @param templateId the template ID
22964             */
22965            @Override
22966            public void removeByG_C_T(long groupId, long classNameId, String templateId) {
22967                    for (JournalArticle journalArticle : findByG_C_T(groupId, classNameId,
22968                                    templateId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
22969                            remove(journalArticle);
22970                    }
22971            }
22972    
22973            /**
22974             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
22975             *
22976             * @param groupId the group ID
22977             * @param classNameId the class name ID
22978             * @param templateId the template ID
22979             * @return the number of matching journal articles
22980             */
22981            @Override
22982            public int countByG_C_T(long groupId, long classNameId, String templateId) {
22983                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_T;
22984    
22985                    Object[] finderArgs = new Object[] { groupId, classNameId, templateId };
22986    
22987                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
22988                                    this);
22989    
22990                    if (count == null) {
22991                            StringBundler query = new StringBundler(4);
22992    
22993                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
22994    
22995                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
22996    
22997                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
22998    
22999                            boolean bindTemplateId = false;
23000    
23001                            if (templateId == null) {
23002                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
23003                            }
23004                            else if (templateId.equals(StringPool.BLANK)) {
23005                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
23006                            }
23007                            else {
23008                                    bindTemplateId = true;
23009    
23010                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
23011                            }
23012    
23013                            String sql = query.toString();
23014    
23015                            Session session = null;
23016    
23017                            try {
23018                                    session = openSession();
23019    
23020                                    Query q = session.createQuery(sql);
23021    
23022                                    QueryPos qPos = QueryPos.getInstance(q);
23023    
23024                                    qPos.add(groupId);
23025    
23026                                    qPos.add(classNameId);
23027    
23028                                    if (bindTemplateId) {
23029                                            qPos.add(templateId);
23030                                    }
23031    
23032                                    count = (Long)q.uniqueResult();
23033    
23034                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
23035                            }
23036                            catch (Exception e) {
23037                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
23038    
23039                                    throw processException(e);
23040                            }
23041                            finally {
23042                                    closeSession(session);
23043                            }
23044                    }
23045    
23046                    return count.intValue();
23047            }
23048    
23049            /**
23050             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
23051             *
23052             * @param groupId the group ID
23053             * @param classNameId the class name ID
23054             * @param templateId the template ID
23055             * @return the number of matching journal articles that the user has permission to view
23056             */
23057            @Override
23058            public int filterCountByG_C_T(long groupId, long classNameId,
23059                    String templateId) {
23060                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23061                            return countByG_C_T(groupId, classNameId, templateId);
23062                    }
23063    
23064                    StringBundler query = new StringBundler(4);
23065    
23066                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
23067    
23068                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
23069    
23070                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
23071    
23072                    boolean bindTemplateId = false;
23073    
23074                    if (templateId == null) {
23075                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
23076                    }
23077                    else if (templateId.equals(StringPool.BLANK)) {
23078                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
23079                    }
23080                    else {
23081                            bindTemplateId = true;
23082    
23083                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
23084                    }
23085    
23086                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23087                                    JournalArticle.class.getName(),
23088                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23089    
23090                    Session session = null;
23091    
23092                    try {
23093                            session = openSession();
23094    
23095                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
23096    
23097                            q.addScalar(COUNT_COLUMN_NAME,
23098                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
23099    
23100                            QueryPos qPos = QueryPos.getInstance(q);
23101    
23102                            qPos.add(groupId);
23103    
23104                            qPos.add(classNameId);
23105    
23106                            if (bindTemplateId) {
23107                                    qPos.add(templateId);
23108                            }
23109    
23110                            Long count = (Long)q.uniqueResult();
23111    
23112                            return count.intValue();
23113                    }
23114                    catch (Exception e) {
23115                            throw processException(e);
23116                    }
23117                    finally {
23118                            closeSession(session);
23119                    }
23120            }
23121    
23122            private static final String _FINDER_COLUMN_G_C_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
23123            private static final String _FINDER_COLUMN_G_C_T_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
23124            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
23125            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
23126            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = '')";
23127            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23128                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
23129                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
23130                            "findByG_C_L",
23131                            new String[] {
23132                                    Long.class.getName(), Long.class.getName(),
23133                                    String.class.getName(),
23134                                    
23135                            Integer.class.getName(), Integer.class.getName(),
23136                                    OrderByComparator.class.getName()
23137                            });
23138            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23139                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
23140                            JournalArticleImpl.class,
23141                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_L",
23142                            new String[] {
23143                                    Long.class.getName(), Long.class.getName(),
23144                                    String.class.getName()
23145                            },
23146                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
23147                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
23148                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
23149                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
23150                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
23151            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23152                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
23153                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_L",
23154                            new String[] {
23155                                    Long.class.getName(), Long.class.getName(),
23156                                    String.class.getName()
23157                            });
23158    
23159            /**
23160             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23161             *
23162             * @param groupId the group ID
23163             * @param classNameId the class name ID
23164             * @param layoutUuid the layout uuid
23165             * @return the matching journal articles
23166             */
23167            @Override
23168            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
23169                    String layoutUuid) {
23170                    return findByG_C_L(groupId, classNameId, layoutUuid, QueryUtil.ALL_POS,
23171                            QueryUtil.ALL_POS, null);
23172            }
23173    
23174            /**
23175             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23176             *
23177             * <p>
23178             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
23179             * </p>
23180             *
23181             * @param groupId the group ID
23182             * @param classNameId the class name ID
23183             * @param layoutUuid the layout uuid
23184             * @param start the lower bound of the range of journal articles
23185             * @param end the upper bound of the range of journal articles (not inclusive)
23186             * @return the range of matching journal articles
23187             */
23188            @Override
23189            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
23190                    String layoutUuid, int start, int end) {
23191                    return findByG_C_L(groupId, classNameId, layoutUuid, start, end, null);
23192            }
23193    
23194            /**
23195             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23196             *
23197             * <p>
23198             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
23199             * </p>
23200             *
23201             * @param groupId the group ID
23202             * @param classNameId the class name ID
23203             * @param layoutUuid the layout uuid
23204             * @param start the lower bound of the range of journal articles
23205             * @param end the upper bound of the range of journal articles (not inclusive)
23206             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
23207             * @return the ordered range of matching journal articles
23208             */
23209            @Override
23210            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
23211                    String layoutUuid, int start, int end,
23212                    OrderByComparator<JournalArticle> orderByComparator) {
23213                    boolean pagination = true;
23214                    FinderPath finderPath = null;
23215                    Object[] finderArgs = null;
23216    
23217                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
23218                                    (orderByComparator == null)) {
23219                            pagination = false;
23220                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L;
23221                            finderArgs = new Object[] { groupId, classNameId, layoutUuid };
23222                    }
23223                    else {
23224                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L;
23225                            finderArgs = new Object[] {
23226                                            groupId, classNameId, layoutUuid,
23227                                            
23228                                            start, end, orderByComparator
23229                                    };
23230                    }
23231    
23232                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
23233                                    finderArgs, this);
23234    
23235                    if ((list != null) && !list.isEmpty()) {
23236                            for (JournalArticle journalArticle : list) {
23237                                    if ((groupId != journalArticle.getGroupId()) ||
23238                                                    (classNameId != journalArticle.getClassNameId()) ||
23239                                                    !Validator.equals(layoutUuid,
23240                                                            journalArticle.getLayoutUuid())) {
23241                                            list = null;
23242    
23243                                            break;
23244                                    }
23245                            }
23246                    }
23247    
23248                    if (list == null) {
23249                            StringBundler query = null;
23250    
23251                            if (orderByComparator != null) {
23252                                    query = new StringBundler(5 +
23253                                                    (orderByComparator.getOrderByFields().length * 3));
23254                            }
23255                            else {
23256                                    query = new StringBundler(5);
23257                            }
23258    
23259                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
23260    
23261                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
23262    
23263                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
23264    
23265                            boolean bindLayoutUuid = false;
23266    
23267                            if (layoutUuid == null) {
23268                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
23269                            }
23270                            else if (layoutUuid.equals(StringPool.BLANK)) {
23271                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
23272                            }
23273                            else {
23274                                    bindLayoutUuid = true;
23275    
23276                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
23277                            }
23278    
23279                            if (orderByComparator != null) {
23280                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
23281                                            orderByComparator);
23282                            }
23283                            else
23284                             if (pagination) {
23285                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23286                            }
23287    
23288                            String sql = query.toString();
23289    
23290                            Session session = null;
23291    
23292                            try {
23293                                    session = openSession();
23294    
23295                                    Query q = session.createQuery(sql);
23296    
23297                                    QueryPos qPos = QueryPos.getInstance(q);
23298    
23299                                    qPos.add(groupId);
23300    
23301                                    qPos.add(classNameId);
23302    
23303                                    if (bindLayoutUuid) {
23304                                            qPos.add(layoutUuid);
23305                                    }
23306    
23307                                    if (!pagination) {
23308                                            list = (List<JournalArticle>)QueryUtil.list(q,
23309                                                            getDialect(), start, end, false);
23310    
23311                                            Collections.sort(list);
23312    
23313                                            list = Collections.unmodifiableList(list);
23314                                    }
23315                                    else {
23316                                            list = (List<JournalArticle>)QueryUtil.list(q,
23317                                                            getDialect(), start, end);
23318                                    }
23319    
23320                                    cacheResult(list);
23321    
23322                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
23323                            }
23324                            catch (Exception e) {
23325                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
23326    
23327                                    throw processException(e);
23328                            }
23329                            finally {
23330                                    closeSession(session);
23331                            }
23332                    }
23333    
23334                    return list;
23335            }
23336    
23337            /**
23338             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23339             *
23340             * @param groupId the group ID
23341             * @param classNameId the class name ID
23342             * @param layoutUuid the layout uuid
23343             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23344             * @return the first matching journal article
23345             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
23346             */
23347            @Override
23348            public JournalArticle findByG_C_L_First(long groupId, long classNameId,
23349                    String layoutUuid, OrderByComparator<JournalArticle> orderByComparator)
23350                    throws NoSuchArticleException {
23351                    JournalArticle journalArticle = fetchByG_C_L_First(groupId,
23352                                    classNameId, layoutUuid, orderByComparator);
23353    
23354                    if (journalArticle != null) {
23355                            return journalArticle;
23356                    }
23357    
23358                    StringBundler msg = new StringBundler(8);
23359    
23360                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
23361    
23362                    msg.append("groupId=");
23363                    msg.append(groupId);
23364    
23365                    msg.append(", classNameId=");
23366                    msg.append(classNameId);
23367    
23368                    msg.append(", layoutUuid=");
23369                    msg.append(layoutUuid);
23370    
23371                    msg.append(StringPool.CLOSE_CURLY_BRACE);
23372    
23373                    throw new NoSuchArticleException(msg.toString());
23374            }
23375    
23376            /**
23377             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23378             *
23379             * @param groupId the group ID
23380             * @param classNameId the class name ID
23381             * @param layoutUuid the layout uuid
23382             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23383             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
23384             */
23385            @Override
23386            public JournalArticle fetchByG_C_L_First(long groupId, long classNameId,
23387                    String layoutUuid, OrderByComparator<JournalArticle> orderByComparator) {
23388                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
23389                                    layoutUuid, 0, 1, orderByComparator);
23390    
23391                    if (!list.isEmpty()) {
23392                            return list.get(0);
23393                    }
23394    
23395                    return null;
23396            }
23397    
23398            /**
23399             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23400             *
23401             * @param groupId the group ID
23402             * @param classNameId the class name ID
23403             * @param layoutUuid the layout uuid
23404             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23405             * @return the last matching journal article
23406             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
23407             */
23408            @Override
23409            public JournalArticle findByG_C_L_Last(long groupId, long classNameId,
23410                    String layoutUuid, OrderByComparator<JournalArticle> orderByComparator)
23411                    throws NoSuchArticleException {
23412                    JournalArticle journalArticle = fetchByG_C_L_Last(groupId, classNameId,
23413                                    layoutUuid, orderByComparator);
23414    
23415                    if (journalArticle != null) {
23416                            return journalArticle;
23417                    }
23418    
23419                    StringBundler msg = new StringBundler(8);
23420    
23421                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
23422    
23423                    msg.append("groupId=");
23424                    msg.append(groupId);
23425    
23426                    msg.append(", classNameId=");
23427                    msg.append(classNameId);
23428    
23429                    msg.append(", layoutUuid=");
23430                    msg.append(layoutUuid);
23431    
23432                    msg.append(StringPool.CLOSE_CURLY_BRACE);
23433    
23434                    throw new NoSuchArticleException(msg.toString());
23435            }
23436    
23437            /**
23438             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23439             *
23440             * @param groupId the group ID
23441             * @param classNameId the class name ID
23442             * @param layoutUuid the layout uuid
23443             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23444             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
23445             */
23446            @Override
23447            public JournalArticle fetchByG_C_L_Last(long groupId, long classNameId,
23448                    String layoutUuid, OrderByComparator<JournalArticle> orderByComparator) {
23449                    int count = countByG_C_L(groupId, classNameId, layoutUuid);
23450    
23451                    if (count == 0) {
23452                            return null;
23453                    }
23454    
23455                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
23456                                    layoutUuid, count - 1, count, orderByComparator);
23457    
23458                    if (!list.isEmpty()) {
23459                            return list.get(0);
23460                    }
23461    
23462                    return null;
23463            }
23464    
23465            /**
23466             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23467             *
23468             * @param id the primary key of the current journal article
23469             * @param groupId the group ID
23470             * @param classNameId the class name ID
23471             * @param layoutUuid the layout uuid
23472             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23473             * @return the previous, current, and next journal article
23474             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
23475             */
23476            @Override
23477            public JournalArticle[] findByG_C_L_PrevAndNext(long id, long groupId,
23478                    long classNameId, String layoutUuid,
23479                    OrderByComparator<JournalArticle> orderByComparator)
23480                    throws NoSuchArticleException {
23481                    JournalArticle journalArticle = findByPrimaryKey(id);
23482    
23483                    Session session = null;
23484    
23485                    try {
23486                            session = openSession();
23487    
23488                            JournalArticle[] array = new JournalArticleImpl[3];
23489    
23490                            array[0] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
23491                                            classNameId, layoutUuid, orderByComparator, true);
23492    
23493                            array[1] = journalArticle;
23494    
23495                            array[2] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
23496                                            classNameId, layoutUuid, orderByComparator, false);
23497    
23498                            return array;
23499                    }
23500                    catch (Exception e) {
23501                            throw processException(e);
23502                    }
23503                    finally {
23504                            closeSession(session);
23505                    }
23506            }
23507    
23508            protected JournalArticle getByG_C_L_PrevAndNext(Session session,
23509                    JournalArticle journalArticle, long groupId, long classNameId,
23510                    String layoutUuid, OrderByComparator<JournalArticle> orderByComparator,
23511                    boolean previous) {
23512                    StringBundler query = null;
23513    
23514                    if (orderByComparator != null) {
23515                            query = new StringBundler(6 +
23516                                            (orderByComparator.getOrderByFields().length * 6));
23517                    }
23518                    else {
23519                            query = new StringBundler(3);
23520                    }
23521    
23522                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
23523    
23524                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
23525    
23526                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
23527    
23528                    boolean bindLayoutUuid = false;
23529    
23530                    if (layoutUuid == null) {
23531                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
23532                    }
23533                    else if (layoutUuid.equals(StringPool.BLANK)) {
23534                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
23535                    }
23536                    else {
23537                            bindLayoutUuid = true;
23538    
23539                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
23540                    }
23541    
23542                    if (orderByComparator != null) {
23543                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
23544    
23545                            if (orderByConditionFields.length > 0) {
23546                                    query.append(WHERE_AND);
23547                            }
23548    
23549                            for (int i = 0; i < orderByConditionFields.length; i++) {
23550                                    query.append(_ORDER_BY_ENTITY_ALIAS);
23551                                    query.append(orderByConditionFields[i]);
23552    
23553                                    if ((i + 1) < orderByConditionFields.length) {
23554                                            if (orderByComparator.isAscending() ^ previous) {
23555                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
23556                                            }
23557                                            else {
23558                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
23559                                            }
23560                                    }
23561                                    else {
23562                                            if (orderByComparator.isAscending() ^ previous) {
23563                                                    query.append(WHERE_GREATER_THAN);
23564                                            }
23565                                            else {
23566                                                    query.append(WHERE_LESSER_THAN);
23567                                            }
23568                                    }
23569                            }
23570    
23571                            query.append(ORDER_BY_CLAUSE);
23572    
23573                            String[] orderByFields = orderByComparator.getOrderByFields();
23574    
23575                            for (int i = 0; i < orderByFields.length; i++) {
23576                                    query.append(_ORDER_BY_ENTITY_ALIAS);
23577                                    query.append(orderByFields[i]);
23578    
23579                                    if ((i + 1) < orderByFields.length) {
23580                                            if (orderByComparator.isAscending() ^ previous) {
23581                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
23582                                            }
23583                                            else {
23584                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
23585                                            }
23586                                    }
23587                                    else {
23588                                            if (orderByComparator.isAscending() ^ previous) {
23589                                                    query.append(ORDER_BY_ASC);
23590                                            }
23591                                            else {
23592                                                    query.append(ORDER_BY_DESC);
23593                                            }
23594                                    }
23595                            }
23596                    }
23597                    else {
23598                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23599                    }
23600    
23601                    String sql = query.toString();
23602    
23603                    Query q = session.createQuery(sql);
23604    
23605                    q.setFirstResult(0);
23606                    q.setMaxResults(2);
23607    
23608                    QueryPos qPos = QueryPos.getInstance(q);
23609    
23610                    qPos.add(groupId);
23611    
23612                    qPos.add(classNameId);
23613    
23614                    if (bindLayoutUuid) {
23615                            qPos.add(layoutUuid);
23616                    }
23617    
23618                    if (orderByComparator != null) {
23619                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
23620    
23621                            for (Object value : values) {
23622                                    qPos.add(value);
23623                            }
23624                    }
23625    
23626                    List<JournalArticle> list = q.list();
23627    
23628                    if (list.size() == 2) {
23629                            return list.get(1);
23630                    }
23631                    else {
23632                            return null;
23633                    }
23634            }
23635    
23636            /**
23637             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23638             *
23639             * @param groupId the group ID
23640             * @param classNameId the class name ID
23641             * @param layoutUuid the layout uuid
23642             * @return the matching journal articles that the user has permission to view
23643             */
23644            @Override
23645            public List<JournalArticle> filterFindByG_C_L(long groupId,
23646                    long classNameId, String layoutUuid) {
23647                    return filterFindByG_C_L(groupId, classNameId, layoutUuid,
23648                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
23649            }
23650    
23651            /**
23652             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23653             *
23654             * <p>
23655             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
23656             * </p>
23657             *
23658             * @param groupId the group ID
23659             * @param classNameId the class name ID
23660             * @param layoutUuid the layout uuid
23661             * @param start the lower bound of the range of journal articles
23662             * @param end the upper bound of the range of journal articles (not inclusive)
23663             * @return the range of matching journal articles that the user has permission to view
23664             */
23665            @Override
23666            public List<JournalArticle> filterFindByG_C_L(long groupId,
23667                    long classNameId, String layoutUuid, int start, int end) {
23668                    return filterFindByG_C_L(groupId, classNameId, layoutUuid, start, end,
23669                            null);
23670            }
23671    
23672            /**
23673             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23674             *
23675             * <p>
23676             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
23677             * </p>
23678             *
23679             * @param groupId the group ID
23680             * @param classNameId the class name ID
23681             * @param layoutUuid the layout uuid
23682             * @param start the lower bound of the range of journal articles
23683             * @param end the upper bound of the range of journal articles (not inclusive)
23684             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
23685             * @return the ordered range of matching journal articles that the user has permission to view
23686             */
23687            @Override
23688            public List<JournalArticle> filterFindByG_C_L(long groupId,
23689                    long classNameId, String layoutUuid, int start, int end,
23690                    OrderByComparator<JournalArticle> orderByComparator) {
23691                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23692                            return findByG_C_L(groupId, classNameId, layoutUuid, start, end,
23693                                    orderByComparator);
23694                    }
23695    
23696                    StringBundler query = null;
23697    
23698                    if (orderByComparator != null) {
23699                            query = new StringBundler(5 +
23700                                            (orderByComparator.getOrderByFields().length * 3));
23701                    }
23702                    else {
23703                            query = new StringBundler(5);
23704                    }
23705    
23706                    if (getDB().isSupportsInlineDistinct()) {
23707                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
23708                    }
23709                    else {
23710                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
23711                    }
23712    
23713                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
23714    
23715                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
23716    
23717                    boolean bindLayoutUuid = false;
23718    
23719                    if (layoutUuid == null) {
23720                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
23721                    }
23722                    else if (layoutUuid.equals(StringPool.BLANK)) {
23723                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
23724                    }
23725                    else {
23726                            bindLayoutUuid = true;
23727    
23728                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
23729                    }
23730    
23731                    if (!getDB().isSupportsInlineDistinct()) {
23732                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
23733                    }
23734    
23735                    if (orderByComparator != null) {
23736                            if (getDB().isSupportsInlineDistinct()) {
23737                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
23738                                            orderByComparator, true);
23739                            }
23740                            else {
23741                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
23742                                            orderByComparator, true);
23743                            }
23744                    }
23745                    else {
23746                            if (getDB().isSupportsInlineDistinct()) {
23747                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23748                            }
23749                            else {
23750                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
23751                            }
23752                    }
23753    
23754                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23755                                    JournalArticle.class.getName(),
23756                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23757    
23758                    Session session = null;
23759    
23760                    try {
23761                            session = openSession();
23762    
23763                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
23764    
23765                            if (getDB().isSupportsInlineDistinct()) {
23766                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
23767                            }
23768                            else {
23769                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
23770                            }
23771    
23772                            QueryPos qPos = QueryPos.getInstance(q);
23773    
23774                            qPos.add(groupId);
23775    
23776                            qPos.add(classNameId);
23777    
23778                            if (bindLayoutUuid) {
23779                                    qPos.add(layoutUuid);
23780                            }
23781    
23782                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
23783                                    end);
23784                    }
23785                    catch (Exception e) {
23786                            throw processException(e);
23787                    }
23788                    finally {
23789                            closeSession(session);
23790                    }
23791            }
23792    
23793            /**
23794             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23795             *
23796             * @param id the primary key of the current journal article
23797             * @param groupId the group ID
23798             * @param classNameId the class name ID
23799             * @param layoutUuid the layout uuid
23800             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23801             * @return the previous, current, and next journal article
23802             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
23803             */
23804            @Override
23805            public JournalArticle[] filterFindByG_C_L_PrevAndNext(long id,
23806                    long groupId, long classNameId, String layoutUuid,
23807                    OrderByComparator<JournalArticle> orderByComparator)
23808                    throws NoSuchArticleException {
23809                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23810                            return findByG_C_L_PrevAndNext(id, groupId, classNameId,
23811                                    layoutUuid, orderByComparator);
23812                    }
23813    
23814                    JournalArticle journalArticle = findByPrimaryKey(id);
23815    
23816                    Session session = null;
23817    
23818                    try {
23819                            session = openSession();
23820    
23821                            JournalArticle[] array = new JournalArticleImpl[3];
23822    
23823                            array[0] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
23824                                            groupId, classNameId, layoutUuid, orderByComparator, true);
23825    
23826                            array[1] = journalArticle;
23827    
23828                            array[2] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
23829                                            groupId, classNameId, layoutUuid, orderByComparator, false);
23830    
23831                            return array;
23832                    }
23833                    catch (Exception e) {
23834                            throw processException(e);
23835                    }
23836                    finally {
23837                            closeSession(session);
23838                    }
23839            }
23840    
23841            protected JournalArticle filterGetByG_C_L_PrevAndNext(Session session,
23842                    JournalArticle journalArticle, long groupId, long classNameId,
23843                    String layoutUuid, OrderByComparator<JournalArticle> orderByComparator,
23844                    boolean previous) {
23845                    StringBundler query = null;
23846    
23847                    if (orderByComparator != null) {
23848                            query = new StringBundler(6 +
23849                                            (orderByComparator.getOrderByFields().length * 6));
23850                    }
23851                    else {
23852                            query = new StringBundler(3);
23853                    }
23854    
23855                    if (getDB().isSupportsInlineDistinct()) {
23856                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
23857                    }
23858                    else {
23859                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
23860                    }
23861    
23862                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
23863    
23864                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
23865    
23866                    boolean bindLayoutUuid = false;
23867    
23868                    if (layoutUuid == null) {
23869                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
23870                    }
23871                    else if (layoutUuid.equals(StringPool.BLANK)) {
23872                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
23873                    }
23874                    else {
23875                            bindLayoutUuid = true;
23876    
23877                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
23878                    }
23879    
23880                    if (!getDB().isSupportsInlineDistinct()) {
23881                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
23882                    }
23883    
23884                    if (orderByComparator != null) {
23885                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
23886    
23887                            if (orderByConditionFields.length > 0) {
23888                                    query.append(WHERE_AND);
23889                            }
23890    
23891                            for (int i = 0; i < orderByConditionFields.length; i++) {
23892                                    if (getDB().isSupportsInlineDistinct()) {
23893                                            query.append(_ORDER_BY_ENTITY_ALIAS);
23894                                    }
23895                                    else {
23896                                            query.append(_ORDER_BY_ENTITY_TABLE);
23897                                    }
23898    
23899                                    query.append(orderByConditionFields[i]);
23900    
23901                                    if ((i + 1) < orderByConditionFields.length) {
23902                                            if (orderByComparator.isAscending() ^ previous) {
23903                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
23904                                            }
23905                                            else {
23906                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
23907                                            }
23908                                    }
23909                                    else {
23910                                            if (orderByComparator.isAscending() ^ previous) {
23911                                                    query.append(WHERE_GREATER_THAN);
23912                                            }
23913                                            else {
23914                                                    query.append(WHERE_LESSER_THAN);
23915                                            }
23916                                    }
23917                            }
23918    
23919                            query.append(ORDER_BY_CLAUSE);
23920    
23921                            String[] orderByFields = orderByComparator.getOrderByFields();
23922    
23923                            for (int i = 0; i < orderByFields.length; i++) {
23924                                    if (getDB().isSupportsInlineDistinct()) {
23925                                            query.append(_ORDER_BY_ENTITY_ALIAS);
23926                                    }
23927                                    else {
23928                                            query.append(_ORDER_BY_ENTITY_TABLE);
23929                                    }
23930    
23931                                    query.append(orderByFields[i]);
23932    
23933                                    if ((i + 1) < orderByFields.length) {
23934                                            if (orderByComparator.isAscending() ^ previous) {
23935                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
23936                                            }
23937                                            else {
23938                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
23939                                            }
23940                                    }
23941                                    else {
23942                                            if (orderByComparator.isAscending() ^ previous) {
23943                                                    query.append(ORDER_BY_ASC);
23944                                            }
23945                                            else {
23946                                                    query.append(ORDER_BY_DESC);
23947                                            }
23948                                    }
23949                            }
23950                    }
23951                    else {
23952                            if (getDB().isSupportsInlineDistinct()) {
23953                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23954                            }
23955                            else {
23956                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
23957                            }
23958                    }
23959    
23960                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23961                                    JournalArticle.class.getName(),
23962                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23963    
23964                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
23965    
23966                    q.setFirstResult(0);
23967                    q.setMaxResults(2);
23968    
23969                    if (getDB().isSupportsInlineDistinct()) {
23970                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
23971                    }
23972                    else {
23973                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
23974                    }
23975    
23976                    QueryPos qPos = QueryPos.getInstance(q);
23977    
23978                    qPos.add(groupId);
23979    
23980                    qPos.add(classNameId);
23981    
23982                    if (bindLayoutUuid) {
23983                            qPos.add(layoutUuid);
23984                    }
23985    
23986                    if (orderByComparator != null) {
23987                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
23988    
23989                            for (Object value : values) {
23990                                    qPos.add(value);
23991                            }
23992                    }
23993    
23994                    List<JournalArticle> list = q.list();
23995    
23996                    if (list.size() == 2) {
23997                            return list.get(1);
23998                    }
23999                    else {
24000                            return null;
24001                    }
24002            }
24003    
24004            /**
24005             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63; from the database.
24006             *
24007             * @param groupId the group ID
24008             * @param classNameId the class name ID
24009             * @param layoutUuid the layout uuid
24010             */
24011            @Override
24012            public void removeByG_C_L(long groupId, long classNameId, String layoutUuid) {
24013                    for (JournalArticle journalArticle : findByG_C_L(groupId, classNameId,
24014                                    layoutUuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
24015                            remove(journalArticle);
24016                    }
24017            }
24018    
24019            /**
24020             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
24021             *
24022             * @param groupId the group ID
24023             * @param classNameId the class name ID
24024             * @param layoutUuid the layout uuid
24025             * @return the number of matching journal articles
24026             */
24027            @Override
24028            public int countByG_C_L(long groupId, long classNameId, String layoutUuid) {
24029                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_L;
24030    
24031                    Object[] finderArgs = new Object[] { groupId, classNameId, layoutUuid };
24032    
24033                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
24034                                    this);
24035    
24036                    if (count == null) {
24037                            StringBundler query = new StringBundler(4);
24038    
24039                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
24040    
24041                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
24042    
24043                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
24044    
24045                            boolean bindLayoutUuid = false;
24046    
24047                            if (layoutUuid == null) {
24048                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
24049                            }
24050                            else if (layoutUuid.equals(StringPool.BLANK)) {
24051                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
24052                            }
24053                            else {
24054                                    bindLayoutUuid = true;
24055    
24056                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
24057                            }
24058    
24059                            String sql = query.toString();
24060    
24061                            Session session = null;
24062    
24063                            try {
24064                                    session = openSession();
24065    
24066                                    Query q = session.createQuery(sql);
24067    
24068                                    QueryPos qPos = QueryPos.getInstance(q);
24069    
24070                                    qPos.add(groupId);
24071    
24072                                    qPos.add(classNameId);
24073    
24074                                    if (bindLayoutUuid) {
24075                                            qPos.add(layoutUuid);
24076                                    }
24077    
24078                                    count = (Long)q.uniqueResult();
24079    
24080                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
24081                            }
24082                            catch (Exception e) {
24083                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
24084    
24085                                    throw processException(e);
24086                            }
24087                            finally {
24088                                    closeSession(session);
24089                            }
24090                    }
24091    
24092                    return count.intValue();
24093            }
24094    
24095            /**
24096             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
24097             *
24098             * @param groupId the group ID
24099             * @param classNameId the class name ID
24100             * @param layoutUuid the layout uuid
24101             * @return the number of matching journal articles that the user has permission to view
24102             */
24103            @Override
24104            public int filterCountByG_C_L(long groupId, long classNameId,
24105                    String layoutUuid) {
24106                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
24107                            return countByG_C_L(groupId, classNameId, layoutUuid);
24108                    }
24109    
24110                    StringBundler query = new StringBundler(4);
24111    
24112                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
24113    
24114                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
24115    
24116                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
24117    
24118                    boolean bindLayoutUuid = false;
24119    
24120                    if (layoutUuid == null) {
24121                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
24122                    }
24123                    else if (layoutUuid.equals(StringPool.BLANK)) {
24124                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
24125                    }
24126                    else {
24127                            bindLayoutUuid = true;
24128    
24129                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
24130                    }
24131    
24132                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
24133                                    JournalArticle.class.getName(),
24134                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
24135    
24136                    Session session = null;
24137    
24138                    try {
24139                            session = openSession();
24140    
24141                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
24142    
24143                            q.addScalar(COUNT_COLUMN_NAME,
24144                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
24145    
24146                            QueryPos qPos = QueryPos.getInstance(q);
24147    
24148                            qPos.add(groupId);
24149    
24150                            qPos.add(classNameId);
24151    
24152                            if (bindLayoutUuid) {
24153                                    qPos.add(layoutUuid);
24154                            }
24155    
24156                            Long count = (Long)q.uniqueResult();
24157    
24158                            return count.intValue();
24159                    }
24160                    catch (Exception e) {
24161                            throw processException(e);
24162                    }
24163                    finally {
24164                            closeSession(session);
24165                    }
24166            }
24167    
24168            private static final String _FINDER_COLUMN_G_C_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
24169            private static final String _FINDER_COLUMN_G_C_L_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
24170            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
24171            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
24172            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = '')";
24173            public static final FinderPath FINDER_PATH_FETCH_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24174                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
24175                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_A_V",
24176                            new String[] {
24177                                    Long.class.getName(), String.class.getName(),
24178                                    Double.class.getName()
24179                            },
24180                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
24181                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
24182                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
24183            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24184                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
24185                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_V",
24186                            new String[] {
24187                                    Long.class.getName(), String.class.getName(),
24188                                    Double.class.getName()
24189                            });
24190    
24191            /**
24192             * Returns the journal article where groupId = &#63; and articleId = &#63; and version = &#63; or throws a {@link com.liferay.portlet.journal.NoSuchArticleException} if it could not be found.
24193             *
24194             * @param groupId the group ID
24195             * @param articleId the article ID
24196             * @param version the version
24197             * @return the matching journal article
24198             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
24199             */
24200            @Override
24201            public JournalArticle findByG_A_V(long groupId, String articleId,
24202                    double version) throws NoSuchArticleException {
24203                    JournalArticle journalArticle = fetchByG_A_V(groupId, articleId, version);
24204    
24205                    if (journalArticle == null) {
24206                            StringBundler msg = new StringBundler(8);
24207    
24208                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
24209    
24210                            msg.append("groupId=");
24211                            msg.append(groupId);
24212    
24213                            msg.append(", articleId=");
24214                            msg.append(articleId);
24215    
24216                            msg.append(", version=");
24217                            msg.append(version);
24218    
24219                            msg.append(StringPool.CLOSE_CURLY_BRACE);
24220    
24221                            if (_log.isWarnEnabled()) {
24222                                    _log.warn(msg.toString());
24223                            }
24224    
24225                            throw new NoSuchArticleException(msg.toString());
24226                    }
24227    
24228                    return journalArticle;
24229            }
24230    
24231            /**
24232             * Returns the journal article where groupId = &#63; and articleId = &#63; and version = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
24233             *
24234             * @param groupId the group ID
24235             * @param articleId the article ID
24236             * @param version the version
24237             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
24238             */
24239            @Override
24240            public JournalArticle fetchByG_A_V(long groupId, String articleId,
24241                    double version) {
24242                    return fetchByG_A_V(groupId, articleId, version, true);
24243            }
24244    
24245            /**
24246             * Returns the journal article where groupId = &#63; and articleId = &#63; and version = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
24247             *
24248             * @param groupId the group ID
24249             * @param articleId the article ID
24250             * @param version the version
24251             * @param retrieveFromCache whether to use the finder cache
24252             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
24253             */
24254            @Override
24255            public JournalArticle fetchByG_A_V(long groupId, String articleId,
24256                    double version, boolean retrieveFromCache) {
24257                    Object[] finderArgs = new Object[] { groupId, articleId, version };
24258    
24259                    Object result = null;
24260    
24261                    if (retrieveFromCache) {
24262                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_A_V,
24263                                            finderArgs, this);
24264                    }
24265    
24266                    if (result instanceof JournalArticle) {
24267                            JournalArticle journalArticle = (JournalArticle)result;
24268    
24269                            if ((groupId != journalArticle.getGroupId()) ||
24270                                            !Validator.equals(articleId, journalArticle.getArticleId()) ||
24271                                            (version != journalArticle.getVersion())) {
24272                                    result = null;
24273                            }
24274                    }
24275    
24276                    if (result == null) {
24277                            StringBundler query = new StringBundler(5);
24278    
24279                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
24280    
24281                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
24282    
24283                            boolean bindArticleId = false;
24284    
24285                            if (articleId == null) {
24286                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
24287                            }
24288                            else if (articleId.equals(StringPool.BLANK)) {
24289                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
24290                            }
24291                            else {
24292                                    bindArticleId = true;
24293    
24294                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
24295                            }
24296    
24297                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
24298    
24299                            String sql = query.toString();
24300    
24301                            Session session = null;
24302    
24303                            try {
24304                                    session = openSession();
24305    
24306                                    Query q = session.createQuery(sql);
24307    
24308                                    QueryPos qPos = QueryPos.getInstance(q);
24309    
24310                                    qPos.add(groupId);
24311    
24312                                    if (bindArticleId) {
24313                                            qPos.add(articleId);
24314                                    }
24315    
24316                                    qPos.add(version);
24317    
24318                                    List<JournalArticle> list = q.list();
24319    
24320                                    if (list.isEmpty()) {
24321                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
24322                                                    finderArgs, list);
24323                                    }
24324                                    else {
24325                                            JournalArticle journalArticle = list.get(0);
24326    
24327                                            result = journalArticle;
24328    
24329                                            cacheResult(journalArticle);
24330    
24331                                            if ((journalArticle.getGroupId() != groupId) ||
24332                                                            (journalArticle.getArticleId() == null) ||
24333                                                            !journalArticle.getArticleId().equals(articleId) ||
24334                                                            (journalArticle.getVersion() != version)) {
24335                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
24336                                                            finderArgs, journalArticle);
24337                                            }
24338                                    }
24339                            }
24340                            catch (Exception e) {
24341                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V,
24342                                            finderArgs);
24343    
24344                                    throw processException(e);
24345                            }
24346                            finally {
24347                                    closeSession(session);
24348                            }
24349                    }
24350    
24351                    if (result instanceof List<?>) {
24352                            return null;
24353                    }
24354                    else {
24355                            return (JournalArticle)result;
24356                    }
24357            }
24358    
24359            /**
24360             * Removes the journal article where groupId = &#63; and articleId = &#63; and version = &#63; from the database.
24361             *
24362             * @param groupId the group ID
24363             * @param articleId the article ID
24364             * @param version the version
24365             * @return the journal article that was removed
24366             */
24367            @Override
24368            public JournalArticle removeByG_A_V(long groupId, String articleId,
24369                    double version) throws NoSuchArticleException {
24370                    JournalArticle journalArticle = findByG_A_V(groupId, articleId, version);
24371    
24372                    return remove(journalArticle);
24373            }
24374    
24375            /**
24376             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and version = &#63;.
24377             *
24378             * @param groupId the group ID
24379             * @param articleId the article ID
24380             * @param version the version
24381             * @return the number of matching journal articles
24382             */
24383            @Override
24384            public int countByG_A_V(long groupId, String articleId, double version) {
24385                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A_V;
24386    
24387                    Object[] finderArgs = new Object[] { groupId, articleId, version };
24388    
24389                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
24390                                    this);
24391    
24392                    if (count == null) {
24393                            StringBundler query = new StringBundler(4);
24394    
24395                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
24396    
24397                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
24398    
24399                            boolean bindArticleId = false;
24400    
24401                            if (articleId == null) {
24402                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
24403                            }
24404                            else if (articleId.equals(StringPool.BLANK)) {
24405                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
24406                            }
24407                            else {
24408                                    bindArticleId = true;
24409    
24410                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
24411                            }
24412    
24413                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
24414    
24415                            String sql = query.toString();
24416    
24417                            Session session = null;
24418    
24419                            try {
24420                                    session = openSession();
24421    
24422                                    Query q = session.createQuery(sql);
24423    
24424                                    QueryPos qPos = QueryPos.getInstance(q);
24425    
24426                                    qPos.add(groupId);
24427    
24428                                    if (bindArticleId) {
24429                                            qPos.add(articleId);
24430                                    }
24431    
24432                                    qPos.add(version);
24433    
24434                                    count = (Long)q.uniqueResult();
24435    
24436                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
24437                            }
24438                            catch (Exception e) {
24439                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
24440    
24441                                    throw processException(e);
24442                            }
24443                            finally {
24444                                    closeSession(session);
24445                            }
24446                    }
24447    
24448                    return count.intValue();
24449            }
24450    
24451            private static final String _FINDER_COLUMN_G_A_V_GROUPID_2 = "journalArticle.groupId = ? AND ";
24452            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
24453            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
24454            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '') AND ";
24455            private static final String _FINDER_COLUMN_G_A_V_VERSION_2 = "journalArticle.version = ?";
24456            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24457                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
24458                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
24459                            "findByG_A_ST",
24460                            new String[] {
24461                                    Long.class.getName(), String.class.getName(),
24462                                    Integer.class.getName(),
24463                                    
24464                            Integer.class.getName(), Integer.class.getName(),
24465                                    OrderByComparator.class.getName()
24466                            });
24467            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST =
24468                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24469                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
24470                            JournalArticleImpl.class,
24471                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A_ST",
24472                            new String[] {
24473                                    Long.class.getName(), String.class.getName(),
24474                                    Integer.class.getName()
24475                            },
24476                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
24477                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
24478                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
24479                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
24480            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24481                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
24482                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_ST",
24483                            new String[] {
24484                                    Long.class.getName(), String.class.getName(),
24485                                    Integer.class.getName()
24486                            });
24487            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24488                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
24489                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_A_ST",
24490                            new String[] {
24491                                    Long.class.getName(), String.class.getName(),
24492                                    Integer.class.getName()
24493                            });
24494    
24495            /**
24496             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
24497             *
24498             * @param groupId the group ID
24499             * @param articleId the article ID
24500             * @param status the status
24501             * @return the matching journal articles
24502             */
24503            @Override
24504            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
24505                    int status) {
24506                    return findByG_A_ST(groupId, articleId, status, QueryUtil.ALL_POS,
24507                            QueryUtil.ALL_POS, null);
24508            }
24509    
24510            /**
24511             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
24512             *
24513             * <p>
24514             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
24515             * </p>
24516             *
24517             * @param groupId the group ID
24518             * @param articleId the article ID
24519             * @param status the status
24520             * @param start the lower bound of the range of journal articles
24521             * @param end the upper bound of the range of journal articles (not inclusive)
24522             * @return the range of matching journal articles
24523             */
24524            @Override
24525            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
24526                    int status, int start, int end) {
24527                    return findByG_A_ST(groupId, articleId, status, start, end, null);
24528            }
24529    
24530            /**
24531             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
24532             *
24533             * <p>
24534             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
24535             * </p>
24536             *
24537             * @param groupId the group ID
24538             * @param articleId the article ID
24539             * @param status the status
24540             * @param start the lower bound of the range of journal articles
24541             * @param end the upper bound of the range of journal articles (not inclusive)
24542             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
24543             * @return the ordered range of matching journal articles
24544             */
24545            @Override
24546            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
24547                    int status, int start, int end,
24548                    OrderByComparator<JournalArticle> orderByComparator) {
24549                    boolean pagination = true;
24550                    FinderPath finderPath = null;
24551                    Object[] finderArgs = null;
24552    
24553                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
24554                                    (orderByComparator == null)) {
24555                            pagination = false;
24556                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST;
24557                            finderArgs = new Object[] { groupId, articleId, status };
24558                    }
24559                    else {
24560                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST;
24561                            finderArgs = new Object[] {
24562                                            groupId, articleId, status,
24563                                            
24564                                            start, end, orderByComparator
24565                                    };
24566                    }
24567    
24568                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
24569                                    finderArgs, this);
24570    
24571                    if ((list != null) && !list.isEmpty()) {
24572                            for (JournalArticle journalArticle : list) {
24573                                    if ((groupId != journalArticle.getGroupId()) ||
24574                                                    !Validator.equals(articleId,
24575                                                            journalArticle.getArticleId()) ||
24576                                                    (status != journalArticle.getStatus())) {
24577                                            list = null;
24578    
24579                                            break;
24580                                    }
24581                            }
24582                    }
24583    
24584                    if (list == null) {
24585                            StringBundler query = null;
24586    
24587                            if (orderByComparator != null) {
24588                                    query = new StringBundler(5 +
24589                                                    (orderByComparator.getOrderByFields().length * 3));
24590                            }
24591                            else {
24592                                    query = new StringBundler(5);
24593                            }
24594    
24595                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
24596    
24597                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
24598    
24599                            boolean bindArticleId = false;
24600    
24601                            if (articleId == null) {
24602                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
24603                            }
24604                            else if (articleId.equals(StringPool.BLANK)) {
24605                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
24606                            }
24607                            else {
24608                                    bindArticleId = true;
24609    
24610                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
24611                            }
24612    
24613                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
24614    
24615                            if (orderByComparator != null) {
24616                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
24617                                            orderByComparator);
24618                            }
24619                            else
24620                             if (pagination) {
24621                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24622                            }
24623    
24624                            String sql = query.toString();
24625    
24626                            Session session = null;
24627    
24628                            try {
24629                                    session = openSession();
24630    
24631                                    Query q = session.createQuery(sql);
24632    
24633                                    QueryPos qPos = QueryPos.getInstance(q);
24634    
24635                                    qPos.add(groupId);
24636    
24637                                    if (bindArticleId) {
24638                                            qPos.add(articleId);
24639                                    }
24640    
24641                                    qPos.add(status);
24642    
24643                                    if (!pagination) {
24644                                            list = (List<JournalArticle>)QueryUtil.list(q,
24645                                                            getDialect(), start, end, false);
24646    
24647                                            Collections.sort(list);
24648    
24649                                            list = Collections.unmodifiableList(list);
24650                                    }
24651                                    else {
24652                                            list = (List<JournalArticle>)QueryUtil.list(q,
24653                                                            getDialect(), start, end);
24654                                    }
24655    
24656                                    cacheResult(list);
24657    
24658                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
24659                            }
24660                            catch (Exception e) {
24661                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
24662    
24663                                    throw processException(e);
24664                            }
24665                            finally {
24666                                    closeSession(session);
24667                            }
24668                    }
24669    
24670                    return list;
24671            }
24672    
24673            /**
24674             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
24675             *
24676             * @param groupId the group ID
24677             * @param articleId the article ID
24678             * @param status the status
24679             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24680             * @return the first matching journal article
24681             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
24682             */
24683            @Override
24684            public JournalArticle findByG_A_ST_First(long groupId, String articleId,
24685                    int status, OrderByComparator<JournalArticle> orderByComparator)
24686                    throws NoSuchArticleException {
24687                    JournalArticle journalArticle = fetchByG_A_ST_First(groupId, articleId,
24688                                    status, orderByComparator);
24689    
24690                    if (journalArticle != null) {
24691                            return journalArticle;
24692                    }
24693    
24694                    StringBundler msg = new StringBundler(8);
24695    
24696                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
24697    
24698                    msg.append("groupId=");
24699                    msg.append(groupId);
24700    
24701                    msg.append(", articleId=");
24702                    msg.append(articleId);
24703    
24704                    msg.append(", status=");
24705                    msg.append(status);
24706    
24707                    msg.append(StringPool.CLOSE_CURLY_BRACE);
24708    
24709                    throw new NoSuchArticleException(msg.toString());
24710            }
24711    
24712            /**
24713             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
24714             *
24715             * @param groupId the group ID
24716             * @param articleId the article ID
24717             * @param status the status
24718             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24719             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
24720             */
24721            @Override
24722            public JournalArticle fetchByG_A_ST_First(long groupId, String articleId,
24723                    int status, OrderByComparator<JournalArticle> orderByComparator) {
24724                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status, 0,
24725                                    1, orderByComparator);
24726    
24727                    if (!list.isEmpty()) {
24728                            return list.get(0);
24729                    }
24730    
24731                    return null;
24732            }
24733    
24734            /**
24735             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
24736             *
24737             * @param groupId the group ID
24738             * @param articleId the article ID
24739             * @param status the status
24740             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24741             * @return the last matching journal article
24742             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
24743             */
24744            @Override
24745            public JournalArticle findByG_A_ST_Last(long groupId, String articleId,
24746                    int status, OrderByComparator<JournalArticle> orderByComparator)
24747                    throws NoSuchArticleException {
24748                    JournalArticle journalArticle = fetchByG_A_ST_Last(groupId, articleId,
24749                                    status, orderByComparator);
24750    
24751                    if (journalArticle != null) {
24752                            return journalArticle;
24753                    }
24754    
24755                    StringBundler msg = new StringBundler(8);
24756    
24757                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
24758    
24759                    msg.append("groupId=");
24760                    msg.append(groupId);
24761    
24762                    msg.append(", articleId=");
24763                    msg.append(articleId);
24764    
24765                    msg.append(", status=");
24766                    msg.append(status);
24767    
24768                    msg.append(StringPool.CLOSE_CURLY_BRACE);
24769    
24770                    throw new NoSuchArticleException(msg.toString());
24771            }
24772    
24773            /**
24774             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
24775             *
24776             * @param groupId the group ID
24777             * @param articleId the article ID
24778             * @param status the status
24779             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24780             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
24781             */
24782            @Override
24783            public JournalArticle fetchByG_A_ST_Last(long groupId, String articleId,
24784                    int status, OrderByComparator<JournalArticle> orderByComparator) {
24785                    int count = countByG_A_ST(groupId, articleId, status);
24786    
24787                    if (count == 0) {
24788                            return null;
24789                    }
24790    
24791                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status,
24792                                    count - 1, count, orderByComparator);
24793    
24794                    if (!list.isEmpty()) {
24795                            return list.get(0);
24796                    }
24797    
24798                    return null;
24799            }
24800    
24801            /**
24802             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
24803             *
24804             * @param id the primary key of the current journal article
24805             * @param groupId the group ID
24806             * @param articleId the article ID
24807             * @param status the status
24808             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24809             * @return the previous, current, and next journal article
24810             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
24811             */
24812            @Override
24813            public JournalArticle[] findByG_A_ST_PrevAndNext(long id, long groupId,
24814                    String articleId, int status,
24815                    OrderByComparator<JournalArticle> orderByComparator)
24816                    throws NoSuchArticleException {
24817                    JournalArticle journalArticle = findByPrimaryKey(id);
24818    
24819                    Session session = null;
24820    
24821                    try {
24822                            session = openSession();
24823    
24824                            JournalArticle[] array = new JournalArticleImpl[3];
24825    
24826                            array[0] = getByG_A_ST_PrevAndNext(session, journalArticle,
24827                                            groupId, articleId, status, orderByComparator, true);
24828    
24829                            array[1] = journalArticle;
24830    
24831                            array[2] = getByG_A_ST_PrevAndNext(session, journalArticle,
24832                                            groupId, articleId, status, orderByComparator, false);
24833    
24834                            return array;
24835                    }
24836                    catch (Exception e) {
24837                            throw processException(e);
24838                    }
24839                    finally {
24840                            closeSession(session);
24841                    }
24842            }
24843    
24844            protected JournalArticle getByG_A_ST_PrevAndNext(Session session,
24845                    JournalArticle journalArticle, long groupId, String articleId,
24846                    int status, OrderByComparator<JournalArticle> orderByComparator,
24847                    boolean previous) {
24848                    StringBundler query = null;
24849    
24850                    if (orderByComparator != null) {
24851                            query = new StringBundler(6 +
24852                                            (orderByComparator.getOrderByFields().length * 6));
24853                    }
24854                    else {
24855                            query = new StringBundler(3);
24856                    }
24857    
24858                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
24859    
24860                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
24861    
24862                    boolean bindArticleId = false;
24863    
24864                    if (articleId == null) {
24865                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
24866                    }
24867                    else if (articleId.equals(StringPool.BLANK)) {
24868                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
24869                    }
24870                    else {
24871                            bindArticleId = true;
24872    
24873                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
24874                    }
24875    
24876                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
24877    
24878                    if (orderByComparator != null) {
24879                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
24880    
24881                            if (orderByConditionFields.length > 0) {
24882                                    query.append(WHERE_AND);
24883                            }
24884    
24885                            for (int i = 0; i < orderByConditionFields.length; i++) {
24886                                    query.append(_ORDER_BY_ENTITY_ALIAS);
24887                                    query.append(orderByConditionFields[i]);
24888    
24889                                    if ((i + 1) < orderByConditionFields.length) {
24890                                            if (orderByComparator.isAscending() ^ previous) {
24891                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
24892                                            }
24893                                            else {
24894                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
24895                                            }
24896                                    }
24897                                    else {
24898                                            if (orderByComparator.isAscending() ^ previous) {
24899                                                    query.append(WHERE_GREATER_THAN);
24900                                            }
24901                                            else {
24902                                                    query.append(WHERE_LESSER_THAN);
24903                                            }
24904                                    }
24905                            }
24906    
24907                            query.append(ORDER_BY_CLAUSE);
24908    
24909                            String[] orderByFields = orderByComparator.getOrderByFields();
24910    
24911                            for (int i = 0; i < orderByFields.length; i++) {
24912                                    query.append(_ORDER_BY_ENTITY_ALIAS);
24913                                    query.append(orderByFields[i]);
24914    
24915                                    if ((i + 1) < orderByFields.length) {
24916                                            if (orderByComparator.isAscending() ^ previous) {
24917                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
24918                                            }
24919                                            else {
24920                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
24921                                            }
24922                                    }
24923                                    else {
24924                                            if (orderByComparator.isAscending() ^ previous) {
24925                                                    query.append(ORDER_BY_ASC);
24926                                            }
24927                                            else {
24928                                                    query.append(ORDER_BY_DESC);
24929                                            }
24930                                    }
24931                            }
24932                    }
24933                    else {
24934                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24935                    }
24936    
24937                    String sql = query.toString();
24938    
24939                    Query q = session.createQuery(sql);
24940    
24941                    q.setFirstResult(0);
24942                    q.setMaxResults(2);
24943    
24944                    QueryPos qPos = QueryPos.getInstance(q);
24945    
24946                    qPos.add(groupId);
24947    
24948                    if (bindArticleId) {
24949                            qPos.add(articleId);
24950                    }
24951    
24952                    qPos.add(status);
24953    
24954                    if (orderByComparator != null) {
24955                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
24956    
24957                            for (Object value : values) {
24958                                    qPos.add(value);
24959                            }
24960                    }
24961    
24962                    List<JournalArticle> list = q.list();
24963    
24964                    if (list.size() == 2) {
24965                            return list.get(1);
24966                    }
24967                    else {
24968                            return null;
24969                    }
24970            }
24971    
24972            /**
24973             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
24974             *
24975             * @param groupId the group ID
24976             * @param articleId the article ID
24977             * @param status the status
24978             * @return the matching journal articles that the user has permission to view
24979             */
24980            @Override
24981            public List<JournalArticle> filterFindByG_A_ST(long groupId,
24982                    String articleId, int status) {
24983                    return filterFindByG_A_ST(groupId, articleId, status,
24984                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
24985            }
24986    
24987            /**
24988             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
24989             *
24990             * <p>
24991             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
24992             * </p>
24993             *
24994             * @param groupId the group ID
24995             * @param articleId the article ID
24996             * @param status the status
24997             * @param start the lower bound of the range of journal articles
24998             * @param end the upper bound of the range of journal articles (not inclusive)
24999             * @return the range of matching journal articles that the user has permission to view
25000             */
25001            @Override
25002            public List<JournalArticle> filterFindByG_A_ST(long groupId,
25003                    String articleId, int status, int start, int end) {
25004                    return filterFindByG_A_ST(groupId, articleId, status, start, end, null);
25005            }
25006    
25007            /**
25008             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and articleId = &#63; and status = &#63;.
25009             *
25010             * <p>
25011             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
25012             * </p>
25013             *
25014             * @param groupId the group ID
25015             * @param articleId the article ID
25016             * @param status the status
25017             * @param start the lower bound of the range of journal articles
25018             * @param end the upper bound of the range of journal articles (not inclusive)
25019             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
25020             * @return the ordered range of matching journal articles that the user has permission to view
25021             */
25022            @Override
25023            public List<JournalArticle> filterFindByG_A_ST(long groupId,
25024                    String articleId, int status, int start, int end,
25025                    OrderByComparator<JournalArticle> orderByComparator) {
25026                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
25027                            return findByG_A_ST(groupId, articleId, status, start, end,
25028                                    orderByComparator);
25029                    }
25030    
25031                    StringBundler query = null;
25032    
25033                    if (orderByComparator != null) {
25034                            query = new StringBundler(5 +
25035                                            (orderByComparator.getOrderByFields().length * 3));
25036                    }
25037                    else {
25038                            query = new StringBundler(5);
25039                    }
25040    
25041                    if (getDB().isSupportsInlineDistinct()) {
25042                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
25043                    }
25044                    else {
25045                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
25046                    }
25047    
25048                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
25049    
25050                    boolean bindArticleId = false;
25051    
25052                    if (articleId == null) {
25053                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
25054                    }
25055                    else if (articleId.equals(StringPool.BLANK)) {
25056                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
25057                    }
25058                    else {
25059                            bindArticleId = true;
25060    
25061                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
25062                    }
25063    
25064                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
25065    
25066                    if (!getDB().isSupportsInlineDistinct()) {
25067                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
25068                    }
25069    
25070                    if (orderByComparator != null) {
25071                            if (getDB().isSupportsInlineDistinct()) {
25072                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
25073                                            orderByComparator, true);
25074                            }
25075                            else {
25076                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
25077                                            orderByComparator, true);
25078                            }
25079                    }
25080                    else {
25081                            if (getDB().isSupportsInlineDistinct()) {
25082                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
25083                            }
25084                            else {
25085                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
25086                            }
25087                    }
25088    
25089                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
25090                                    JournalArticle.class.getName(),
25091                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
25092    
25093                    Session session = null;
25094    
25095                    try {
25096                            session = openSession();
25097    
25098                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
25099    
25100                            if (getDB().isSupportsInlineDistinct()) {
25101                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
25102                            }
25103                            else {
25104                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
25105                            }
25106    
25107                            QueryPos qPos = QueryPos.getInstance(q);
25108    
25109                            qPos.add(groupId);
25110    
25111                            if (bindArticleId) {
25112                                    qPos.add(articleId);
25113                            }
25114    
25115                            qPos.add(status);
25116    
25117                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
25118                                    end);
25119                    }
25120                    catch (Exception e) {
25121                            throw processException(e);
25122                    }
25123                    finally {
25124                            closeSession(session);
25125                    }
25126            }
25127    
25128            /**
25129             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
25130             *
25131             * @param id the primary key of the current journal article
25132             * @param groupId the group ID
25133             * @param articleId the article ID
25134             * @param status the status
25135             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25136             * @return the previous, current, and next journal article
25137             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
25138             */
25139            @Override
25140            public JournalArticle[] filterFindByG_A_ST_PrevAndNext(long id,
25141                    long groupId, String articleId, int status,
25142                    OrderByComparator<JournalArticle> orderByComparator)
25143                    throws NoSuchArticleException {
25144                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
25145                            return findByG_A_ST_PrevAndNext(id, groupId, articleId, status,
25146                                    orderByComparator);
25147                    }
25148    
25149                    JournalArticle journalArticle = findByPrimaryKey(id);
25150    
25151                    Session session = null;
25152    
25153                    try {
25154                            session = openSession();
25155    
25156                            JournalArticle[] array = new JournalArticleImpl[3];
25157    
25158                            array[0] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
25159                                            groupId, articleId, status, orderByComparator, true);
25160    
25161                            array[1] = journalArticle;
25162    
25163                            array[2] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
25164                                            groupId, articleId, status, orderByComparator, false);
25165    
25166                            return array;
25167                    }
25168                    catch (Exception e) {
25169                            throw processException(e);
25170                    }
25171                    finally {
25172                            closeSession(session);
25173                    }
25174            }
25175    
25176            protected JournalArticle filterGetByG_A_ST_PrevAndNext(Session session,
25177                    JournalArticle journalArticle, long groupId, String articleId,
25178                    int status, OrderByComparator<JournalArticle> orderByComparator,
25179                    boolean previous) {
25180                    StringBundler query = null;
25181    
25182                    if (orderByComparator != null) {
25183                            query = new StringBundler(6 +
25184                                            (orderByComparator.getOrderByFields().length * 6));
25185                    }
25186                    else {
25187                            query = new StringBundler(3);
25188                    }
25189    
25190                    if (getDB().isSupportsInlineDistinct()) {
25191                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
25192                    }
25193                    else {
25194                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
25195                    }
25196    
25197                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
25198    
25199                    boolean bindArticleId = false;
25200    
25201                    if (articleId == null) {
25202                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
25203                    }
25204                    else if (articleId.equals(StringPool.BLANK)) {
25205                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
25206                    }
25207                    else {
25208                            bindArticleId = true;
25209    
25210                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
25211                    }
25212    
25213                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
25214    
25215                    if (!getDB().isSupportsInlineDistinct()) {
25216                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
25217                    }
25218    
25219                    if (orderByComparator != null) {
25220                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
25221    
25222                            if (orderByConditionFields.length > 0) {
25223                                    query.append(WHERE_AND);
25224                            }
25225    
25226                            for (int i = 0; i < orderByConditionFields.length; i++) {
25227                                    if (getDB().isSupportsInlineDistinct()) {
25228                                            query.append(_ORDER_BY_ENTITY_ALIAS);
25229                                    }
25230                                    else {
25231                                            query.append(_ORDER_BY_ENTITY_TABLE);
25232                                    }
25233    
25234                                    query.append(orderByConditionFields[i]);
25235    
25236                                    if ((i + 1) < orderByConditionFields.length) {
25237                                            if (orderByComparator.isAscending() ^ previous) {
25238                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
25239                                            }
25240                                            else {
25241                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
25242                                            }
25243                                    }
25244                                    else {
25245                                            if (orderByComparator.isAscending() ^ previous) {
25246                                                    query.append(WHERE_GREATER_THAN);
25247                                            }
25248                                            else {
25249                                                    query.append(WHERE_LESSER_THAN);
25250                                            }
25251                                    }
25252                            }
25253    
25254                            query.append(ORDER_BY_CLAUSE);
25255    
25256                            String[] orderByFields = orderByComparator.getOrderByFields();
25257    
25258                            for (int i = 0; i < orderByFields.length; i++) {
25259                                    if (getDB().isSupportsInlineDistinct()) {
25260                                            query.append(_ORDER_BY_ENTITY_ALIAS);
25261                                    }
25262                                    else {
25263                                            query.append(_ORDER_BY_ENTITY_TABLE);
25264                                    }
25265    
25266                                    query.append(orderByFields[i]);
25267    
25268                                    if ((i + 1) < orderByFields.length) {
25269                                            if (orderByComparator.isAscending() ^ previous) {
25270                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
25271                                            }
25272                                            else {
25273                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
25274                                            }
25275                                    }
25276                                    else {
25277                                            if (orderByComparator.isAscending() ^ previous) {
25278                                                    query.append(ORDER_BY_ASC);
25279                                            }
25280                                            else {
25281                                                    query.append(ORDER_BY_DESC);
25282                                            }
25283                                    }
25284                            }
25285                    }
25286                    else {
25287                            if (getDB().isSupportsInlineDistinct()) {
25288                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
25289                            }
25290                            else {
25291                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
25292                            }
25293                    }
25294    
25295                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
25296                                    JournalArticle.class.getName(),
25297                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
25298    
25299                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
25300    
25301                    q.setFirstResult(0);
25302                    q.setMaxResults(2);
25303    
25304                    if (getDB().isSupportsInlineDistinct()) {
25305                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
25306                    }
25307                    else {
25308                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
25309                    }
25310    
25311                    QueryPos qPos = QueryPos.getInstance(q);
25312    
25313                    qPos.add(groupId);
25314    
25315                    if (bindArticleId) {
25316                            qPos.add(articleId);
25317                    }
25318    
25319                    qPos.add(status);
25320    
25321                    if (orderByComparator != null) {
25322                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
25323    
25324                            for (Object value : values) {
25325                                    qPos.add(value);
25326                            }
25327                    }
25328    
25329                    List<JournalArticle> list = q.list();
25330    
25331                    if (list.size() == 2) {
25332                            return list.get(1);
25333                    }
25334                    else {
25335                            return null;
25336                    }
25337            }
25338    
25339            /**
25340             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
25341             *
25342             * @param groupId the group ID
25343             * @param articleId the article ID
25344             * @param statuses the statuses
25345             * @return the matching journal articles that the user has permission to view
25346             */
25347            @Override
25348            public List<JournalArticle> filterFindByG_A_ST(long groupId,
25349                    String articleId, int[] statuses) {
25350                    return filterFindByG_A_ST(groupId, articleId, statuses,
25351                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
25352            }
25353    
25354            /**
25355             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
25356             *
25357             * <p>
25358             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
25359             * </p>
25360             *
25361             * @param groupId the group ID
25362             * @param articleId the article ID
25363             * @param statuses the statuses
25364             * @param start the lower bound of the range of journal articles
25365             * @param end the upper bound of the range of journal articles (not inclusive)
25366             * @return the range of matching journal articles that the user has permission to view
25367             */
25368            @Override
25369            public List<JournalArticle> filterFindByG_A_ST(long groupId,
25370                    String articleId, int[] statuses, int start, int end) {
25371                    return filterFindByG_A_ST(groupId, articleId, statuses, start, end, null);
25372            }
25373    
25374            /**
25375             * Returns an ordered range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
25376             *
25377             * <p>
25378             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
25379             * </p>
25380             *
25381             * @param groupId the group ID
25382             * @param articleId the article ID
25383             * @param statuses the statuses
25384             * @param start the lower bound of the range of journal articles
25385             * @param end the upper bound of the range of journal articles (not inclusive)
25386             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
25387             * @return the ordered range of matching journal articles that the user has permission to view
25388             */
25389            @Override
25390            public List<JournalArticle> filterFindByG_A_ST(long groupId,
25391                    String articleId, int[] statuses, int start, int end,
25392                    OrderByComparator<JournalArticle> orderByComparator) {
25393                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
25394                            return findByG_A_ST(groupId, articleId, statuses, start, end,
25395                                    orderByComparator);
25396                    }
25397    
25398                    if (statuses == null) {
25399                            statuses = new int[0];
25400                    }
25401                    else {
25402                            statuses = ArrayUtil.unique(statuses);
25403                    }
25404    
25405                    StringBundler query = new StringBundler();
25406    
25407                    if (getDB().isSupportsInlineDistinct()) {
25408                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
25409                    }
25410                    else {
25411                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
25412                    }
25413    
25414                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
25415    
25416                    boolean bindArticleId = false;
25417    
25418                    if (articleId == null) {
25419                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
25420                    }
25421                    else if (articleId.equals(StringPool.BLANK)) {
25422                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
25423                    }
25424                    else {
25425                            bindArticleId = true;
25426    
25427                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
25428                    }
25429    
25430                    if (statuses.length > 0) {
25431                            query.append(StringPool.OPEN_PARENTHESIS);
25432    
25433                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_7);
25434    
25435                            query.append(StringUtil.merge(statuses));
25436    
25437                            query.append(StringPool.CLOSE_PARENTHESIS);
25438    
25439                            query.append(StringPool.CLOSE_PARENTHESIS);
25440                    }
25441    
25442                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
25443                            query.index() - 1);
25444    
25445                    if (!getDB().isSupportsInlineDistinct()) {
25446                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
25447                    }
25448    
25449                    if (orderByComparator != null) {
25450                            if (getDB().isSupportsInlineDistinct()) {
25451                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
25452                                            orderByComparator, true);
25453                            }
25454                            else {
25455                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
25456                                            orderByComparator, true);
25457                            }
25458                    }
25459                    else {
25460                            if (getDB().isSupportsInlineDistinct()) {
25461                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
25462                            }
25463                            else {
25464                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
25465                            }
25466                    }
25467    
25468                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
25469                                    JournalArticle.class.getName(),
25470                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
25471    
25472                    Session session = null;
25473    
25474                    try {
25475                            session = openSession();
25476    
25477                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
25478    
25479                            if (getDB().isSupportsInlineDistinct()) {
25480                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
25481                            }
25482                            else {
25483                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
25484                            }
25485    
25486                            QueryPos qPos = QueryPos.getInstance(q);
25487    
25488                            qPos.add(groupId);
25489    
25490                            if (bindArticleId) {
25491                                    qPos.add(articleId);
25492                            }
25493    
25494                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
25495                                    end);
25496                    }
25497                    catch (Exception e) {
25498                            throw processException(e);
25499                    }
25500                    finally {
25501                            closeSession(session);
25502                    }
25503            }
25504    
25505            /**
25506             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
25507             *
25508             * <p>
25509             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
25510             * </p>
25511             *
25512             * @param groupId the group ID
25513             * @param articleId the article ID
25514             * @param statuses the statuses
25515             * @return the matching journal articles
25516             */
25517            @Override
25518            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
25519                    int[] statuses) {
25520                    return findByG_A_ST(groupId, articleId, statuses, QueryUtil.ALL_POS,
25521                            QueryUtil.ALL_POS, null);
25522            }
25523    
25524            /**
25525             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
25526             *
25527             * <p>
25528             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
25529             * </p>
25530             *
25531             * @param groupId the group ID
25532             * @param articleId the article ID
25533             * @param statuses the statuses
25534             * @param start the lower bound of the range of journal articles
25535             * @param end the upper bound of the range of journal articles (not inclusive)
25536             * @return the range of matching journal articles
25537             */
25538            @Override
25539            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
25540                    int[] statuses, int start, int end) {
25541                    return findByG_A_ST(groupId, articleId, statuses, start, end, null);
25542            }
25543    
25544            /**
25545             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
25546             *
25547             * <p>
25548             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
25549             * </p>
25550             *
25551             * @param groupId the group ID
25552             * @param articleId the article ID
25553             * @param statuses the statuses
25554             * @param start the lower bound of the range of journal articles
25555             * @param end the upper bound of the range of journal articles (not inclusive)
25556             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
25557             * @return the ordered range of matching journal articles
25558             */
25559            @Override
25560            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
25561                    int[] statuses, int start, int end,
25562                    OrderByComparator<JournalArticle> orderByComparator) {
25563                    if (statuses == null) {
25564                            statuses = new int[0];
25565                    }
25566                    else {
25567                            statuses = ArrayUtil.unique(statuses);
25568                    }
25569    
25570                    if (statuses.length == 1) {
25571                            return findByG_A_ST(groupId, articleId, statuses[0], start, end,
25572                                    orderByComparator);
25573                    }
25574    
25575                    boolean pagination = true;
25576                    Object[] finderArgs = null;
25577    
25578                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
25579                                    (orderByComparator == null)) {
25580                            pagination = false;
25581                            finderArgs = new Object[] {
25582                                            groupId, articleId, StringUtil.merge(statuses)
25583                                    };
25584                    }
25585                    else {
25586                            finderArgs = new Object[] {
25587                                            groupId, articleId, StringUtil.merge(statuses),
25588                                            
25589                                            start, end, orderByComparator
25590                                    };
25591                    }
25592    
25593                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
25594                                    finderArgs, this);
25595    
25596                    if ((list != null) && !list.isEmpty()) {
25597                            for (JournalArticle journalArticle : list) {
25598                                    if ((groupId != journalArticle.getGroupId()) ||
25599                                                    !Validator.equals(articleId,
25600                                                            journalArticle.getArticleId()) ||
25601                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
25602                                            list = null;
25603    
25604                                            break;
25605                                    }
25606                            }
25607                    }
25608    
25609                    if (list == null) {
25610                            StringBundler query = new StringBundler();
25611    
25612                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
25613    
25614                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
25615    
25616                            boolean bindArticleId = false;
25617    
25618                            if (articleId == null) {
25619                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
25620                            }
25621                            else if (articleId.equals(StringPool.BLANK)) {
25622                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
25623                            }
25624                            else {
25625                                    bindArticleId = true;
25626    
25627                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
25628                            }
25629    
25630                            if (statuses.length > 0) {
25631                                    query.append(StringPool.OPEN_PARENTHESIS);
25632    
25633                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_7);
25634    
25635                                    query.append(StringUtil.merge(statuses));
25636    
25637                                    query.append(StringPool.CLOSE_PARENTHESIS);
25638    
25639                                    query.append(StringPool.CLOSE_PARENTHESIS);
25640                            }
25641    
25642                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
25643                                                    1)), query.index() - 1);
25644    
25645                            if (orderByComparator != null) {
25646                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
25647                                            orderByComparator);
25648                            }
25649                            else
25650                             if (pagination) {
25651                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
25652                            }
25653    
25654                            String sql = query.toString();
25655    
25656                            Session session = null;
25657    
25658                            try {
25659                                    session = openSession();
25660    
25661                                    Query q = session.createQuery(sql);
25662    
25663                                    QueryPos qPos = QueryPos.getInstance(q);
25664    
25665                                    qPos.add(groupId);
25666    
25667                                    if (bindArticleId) {
25668                                            qPos.add(articleId);
25669                                    }
25670    
25671                                    if (!pagination) {
25672                                            list = (List<JournalArticle>)QueryUtil.list(q,
25673                                                            getDialect(), start, end, false);
25674    
25675                                            Collections.sort(list);
25676    
25677                                            list = Collections.unmodifiableList(list);
25678                                    }
25679                                    else {
25680                                            list = (List<JournalArticle>)QueryUtil.list(q,
25681                                                            getDialect(), start, end);
25682                                    }
25683    
25684                                    cacheResult(list);
25685    
25686                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
25687                                            finderArgs, list);
25688                            }
25689                            catch (Exception e) {
25690                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
25691                                            finderArgs);
25692    
25693                                    throw processException(e);
25694                            }
25695                            finally {
25696                                    closeSession(session);
25697                            }
25698                    }
25699    
25700                    return list;
25701            }
25702    
25703            /**
25704             * Removes all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63; from the database.
25705             *
25706             * @param groupId the group ID
25707             * @param articleId the article ID
25708             * @param status the status
25709             */
25710            @Override
25711            public void removeByG_A_ST(long groupId, String articleId, int status) {
25712                    for (JournalArticle journalArticle : findByG_A_ST(groupId, articleId,
25713                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
25714                            remove(journalArticle);
25715                    }
25716            }
25717    
25718            /**
25719             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
25720             *
25721             * @param groupId the group ID
25722             * @param articleId the article ID
25723             * @param status the status
25724             * @return the number of matching journal articles
25725             */
25726            @Override
25727            public int countByG_A_ST(long groupId, String articleId, int status) {
25728                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A_ST;
25729    
25730                    Object[] finderArgs = new Object[] { groupId, articleId, status };
25731    
25732                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
25733                                    this);
25734    
25735                    if (count == null) {
25736                            StringBundler query = new StringBundler(4);
25737    
25738                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
25739    
25740                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
25741    
25742                            boolean bindArticleId = false;
25743    
25744                            if (articleId == null) {
25745                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
25746                            }
25747                            else if (articleId.equals(StringPool.BLANK)) {
25748                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
25749                            }
25750                            else {
25751                                    bindArticleId = true;
25752    
25753                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
25754                            }
25755    
25756                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
25757    
25758                            String sql = query.toString();
25759    
25760                            Session session = null;
25761    
25762                            try {
25763                                    session = openSession();
25764    
25765                                    Query q = session.createQuery(sql);
25766    
25767                                    QueryPos qPos = QueryPos.getInstance(q);
25768    
25769                                    qPos.add(groupId);
25770    
25771                                    if (bindArticleId) {
25772                                            qPos.add(articleId);
25773                                    }
25774    
25775                                    qPos.add(status);
25776    
25777                                    count = (Long)q.uniqueResult();
25778    
25779                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
25780                            }
25781                            catch (Exception e) {
25782                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
25783    
25784                                    throw processException(e);
25785                            }
25786                            finally {
25787                                    closeSession(session);
25788                            }
25789                    }
25790    
25791                    return count.intValue();
25792            }
25793    
25794            /**
25795             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
25796             *
25797             * @param groupId the group ID
25798             * @param articleId the article ID
25799             * @param statuses the statuses
25800             * @return the number of matching journal articles
25801             */
25802            @Override
25803            public int countByG_A_ST(long groupId, String articleId, int[] statuses) {
25804                    if (statuses == null) {
25805                            statuses = new int[0];
25806                    }
25807                    else {
25808                            statuses = ArrayUtil.unique(statuses);
25809                    }
25810    
25811                    Object[] finderArgs = new Object[] {
25812                                    groupId, articleId, StringUtil.merge(statuses)
25813                            };
25814    
25815                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
25816                                    finderArgs, this);
25817    
25818                    if (count == null) {
25819                            StringBundler query = new StringBundler();
25820    
25821                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
25822    
25823                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
25824    
25825                            boolean bindArticleId = false;
25826    
25827                            if (articleId == null) {
25828                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
25829                            }
25830                            else if (articleId.equals(StringPool.BLANK)) {
25831                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
25832                            }
25833                            else {
25834                                    bindArticleId = true;
25835    
25836                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
25837                            }
25838    
25839                            if (statuses.length > 0) {
25840                                    query.append(StringPool.OPEN_PARENTHESIS);
25841    
25842                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_7);
25843    
25844                                    query.append(StringUtil.merge(statuses));
25845    
25846                                    query.append(StringPool.CLOSE_PARENTHESIS);
25847    
25848                                    query.append(StringPool.CLOSE_PARENTHESIS);
25849                            }
25850    
25851                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
25852                                                    1)), query.index() - 1);
25853    
25854                            String sql = query.toString();
25855    
25856                            Session session = null;
25857    
25858                            try {
25859                                    session = openSession();
25860    
25861                                    Query q = session.createQuery(sql);
25862    
25863                                    QueryPos qPos = QueryPos.getInstance(q);
25864    
25865                                    qPos.add(groupId);
25866    
25867                                    if (bindArticleId) {
25868                                            qPos.add(articleId);
25869                                    }
25870    
25871                                    count = (Long)q.uniqueResult();
25872    
25873                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
25874                                            finderArgs, count);
25875                            }
25876                            catch (Exception e) {
25877                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
25878                                            finderArgs);
25879    
25880                                    throw processException(e);
25881                            }
25882                            finally {
25883                                    closeSession(session);
25884                            }
25885                    }
25886    
25887                    return count.intValue();
25888            }
25889    
25890            /**
25891             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
25892             *
25893             * @param groupId the group ID
25894             * @param articleId the article ID
25895             * @param status the status
25896             * @return the number of matching journal articles that the user has permission to view
25897             */
25898            @Override
25899            public int filterCountByG_A_ST(long groupId, String articleId, int status) {
25900                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
25901                            return countByG_A_ST(groupId, articleId, status);
25902                    }
25903    
25904                    StringBundler query = new StringBundler(4);
25905    
25906                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
25907    
25908                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
25909    
25910                    boolean bindArticleId = false;
25911    
25912                    if (articleId == null) {
25913                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
25914                    }
25915                    else if (articleId.equals(StringPool.BLANK)) {
25916                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
25917                    }
25918                    else {
25919                            bindArticleId = true;
25920    
25921                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
25922                    }
25923    
25924                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
25925    
25926                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
25927                                    JournalArticle.class.getName(),
25928                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
25929    
25930                    Session session = null;
25931    
25932                    try {
25933                            session = openSession();
25934    
25935                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
25936    
25937                            q.addScalar(COUNT_COLUMN_NAME,
25938                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
25939    
25940                            QueryPos qPos = QueryPos.getInstance(q);
25941    
25942                            qPos.add(groupId);
25943    
25944                            if (bindArticleId) {
25945                                    qPos.add(articleId);
25946                            }
25947    
25948                            qPos.add(status);
25949    
25950                            Long count = (Long)q.uniqueResult();
25951    
25952                            return count.intValue();
25953                    }
25954                    catch (Exception e) {
25955                            throw processException(e);
25956                    }
25957                    finally {
25958                            closeSession(session);
25959                    }
25960            }
25961    
25962            /**
25963             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
25964             *
25965             * @param groupId the group ID
25966             * @param articleId the article ID
25967             * @param statuses the statuses
25968             * @return the number of matching journal articles that the user has permission to view
25969             */
25970            @Override
25971            public int filterCountByG_A_ST(long groupId, String articleId,
25972                    int[] statuses) {
25973                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
25974                            return countByG_A_ST(groupId, articleId, statuses);
25975                    }
25976    
25977                    if (statuses == null) {
25978                            statuses = new int[0];
25979                    }
25980                    else {
25981                            statuses = ArrayUtil.unique(statuses);
25982                    }
25983    
25984                    StringBundler query = new StringBundler();
25985    
25986                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
25987    
25988                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
25989    
25990                    boolean bindArticleId = false;
25991    
25992                    if (articleId == null) {
25993                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
25994                    }
25995                    else if (articleId.equals(StringPool.BLANK)) {
25996                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
25997                    }
25998                    else {
25999                            bindArticleId = true;
26000    
26001                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
26002                    }
26003    
26004                    if (statuses.length > 0) {
26005                            query.append(StringPool.OPEN_PARENTHESIS);
26006    
26007                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_7);
26008    
26009                            query.append(StringUtil.merge(statuses));
26010    
26011                            query.append(StringPool.CLOSE_PARENTHESIS);
26012    
26013                            query.append(StringPool.CLOSE_PARENTHESIS);
26014                    }
26015    
26016                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
26017                            query.index() - 1);
26018    
26019                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
26020                                    JournalArticle.class.getName(),
26021                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
26022    
26023                    Session session = null;
26024    
26025                    try {
26026                            session = openSession();
26027    
26028                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
26029    
26030                            q.addScalar(COUNT_COLUMN_NAME,
26031                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
26032    
26033                            QueryPos qPos = QueryPos.getInstance(q);
26034    
26035                            qPos.add(groupId);
26036    
26037                            if (bindArticleId) {
26038                                    qPos.add(articleId);
26039                            }
26040    
26041                            Long count = (Long)q.uniqueResult();
26042    
26043                            return count.intValue();
26044                    }
26045                    catch (Exception e) {
26046                            throw processException(e);
26047                    }
26048                    finally {
26049                            closeSession(session);
26050                    }
26051            }
26052    
26053            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
26054            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
26055            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
26056            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '') AND ";
26057            private static final String _FINDER_COLUMN_G_A_ST_STATUS_2 = "journalArticle.status = ?";
26058            private static final String _FINDER_COLUMN_G_A_ST_STATUS_7 = "journalArticle.status IN (";
26059            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_NOTST =
26060                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
26061                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
26062                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
26063                            "findByG_A_NotST",
26064                            new String[] {
26065                                    Long.class.getName(), String.class.getName(),
26066                                    Integer.class.getName(),
26067                                    
26068                            Integer.class.getName(), Integer.class.getName(),
26069                                    OrderByComparator.class.getName()
26070                            });
26071            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_NOTST =
26072                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
26073                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
26074                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_A_NotST",
26075                            new String[] {
26076                                    Long.class.getName(), String.class.getName(),
26077                                    Integer.class.getName()
26078                            });
26079    
26080            /**
26081             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26082             *
26083             * @param groupId the group ID
26084             * @param articleId the article ID
26085             * @param status the status
26086             * @return the matching journal articles
26087             */
26088            @Override
26089            public List<JournalArticle> findByG_A_NotST(long groupId, String articleId,
26090                    int status) {
26091                    return findByG_A_NotST(groupId, articleId, status, QueryUtil.ALL_POS,
26092                            QueryUtil.ALL_POS, null);
26093            }
26094    
26095            /**
26096             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26097             *
26098             * <p>
26099             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
26100             * </p>
26101             *
26102             * @param groupId the group ID
26103             * @param articleId the article ID
26104             * @param status the status
26105             * @param start the lower bound of the range of journal articles
26106             * @param end the upper bound of the range of journal articles (not inclusive)
26107             * @return the range of matching journal articles
26108             */
26109            @Override
26110            public List<JournalArticle> findByG_A_NotST(long groupId, String articleId,
26111                    int status, int start, int end) {
26112                    return findByG_A_NotST(groupId, articleId, status, start, end, null);
26113            }
26114    
26115            /**
26116             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26117             *
26118             * <p>
26119             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
26120             * </p>
26121             *
26122             * @param groupId the group ID
26123             * @param articleId the article ID
26124             * @param status the status
26125             * @param start the lower bound of the range of journal articles
26126             * @param end the upper bound of the range of journal articles (not inclusive)
26127             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
26128             * @return the ordered range of matching journal articles
26129             */
26130            @Override
26131            public List<JournalArticle> findByG_A_NotST(long groupId, String articleId,
26132                    int status, int start, int end,
26133                    OrderByComparator<JournalArticle> orderByComparator) {
26134                    boolean pagination = true;
26135                    FinderPath finderPath = null;
26136                    Object[] finderArgs = null;
26137    
26138                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_NOTST;
26139                    finderArgs = new Object[] {
26140                                    groupId, articleId, status,
26141                                    
26142                                    start, end, orderByComparator
26143                            };
26144    
26145                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
26146                                    finderArgs, this);
26147    
26148                    if ((list != null) && !list.isEmpty()) {
26149                            for (JournalArticle journalArticle : list) {
26150                                    if ((groupId != journalArticle.getGroupId()) ||
26151                                                    !Validator.equals(articleId,
26152                                                            journalArticle.getArticleId()) ||
26153                                                    (status == journalArticle.getStatus())) {
26154                                            list = null;
26155    
26156                                            break;
26157                                    }
26158                            }
26159                    }
26160    
26161                    if (list == null) {
26162                            StringBundler query = null;
26163    
26164                            if (orderByComparator != null) {
26165                                    query = new StringBundler(5 +
26166                                                    (orderByComparator.getOrderByFields().length * 3));
26167                            }
26168                            else {
26169                                    query = new StringBundler(5);
26170                            }
26171    
26172                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
26173    
26174                            query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
26175    
26176                            boolean bindArticleId = false;
26177    
26178                            if (articleId == null) {
26179                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
26180                            }
26181                            else if (articleId.equals(StringPool.BLANK)) {
26182                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
26183                            }
26184                            else {
26185                                    bindArticleId = true;
26186    
26187                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
26188                            }
26189    
26190                            query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
26191    
26192                            if (orderByComparator != null) {
26193                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
26194                                            orderByComparator);
26195                            }
26196                            else
26197                             if (pagination) {
26198                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
26199                            }
26200    
26201                            String sql = query.toString();
26202    
26203                            Session session = null;
26204    
26205                            try {
26206                                    session = openSession();
26207    
26208                                    Query q = session.createQuery(sql);
26209    
26210                                    QueryPos qPos = QueryPos.getInstance(q);
26211    
26212                                    qPos.add(groupId);
26213    
26214                                    if (bindArticleId) {
26215                                            qPos.add(articleId);
26216                                    }
26217    
26218                                    qPos.add(status);
26219    
26220                                    if (!pagination) {
26221                                            list = (List<JournalArticle>)QueryUtil.list(q,
26222                                                            getDialect(), start, end, false);
26223    
26224                                            Collections.sort(list);
26225    
26226                                            list = Collections.unmodifiableList(list);
26227                                    }
26228                                    else {
26229                                            list = (List<JournalArticle>)QueryUtil.list(q,
26230                                                            getDialect(), start, end);
26231                                    }
26232    
26233                                    cacheResult(list);
26234    
26235                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
26236                            }
26237                            catch (Exception e) {
26238                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
26239    
26240                                    throw processException(e);
26241                            }
26242                            finally {
26243                                    closeSession(session);
26244                            }
26245                    }
26246    
26247                    return list;
26248            }
26249    
26250            /**
26251             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26252             *
26253             * @param groupId the group ID
26254             * @param articleId the article ID
26255             * @param status the status
26256             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26257             * @return the first matching journal article
26258             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
26259             */
26260            @Override
26261            public JournalArticle findByG_A_NotST_First(long groupId, String articleId,
26262                    int status, OrderByComparator<JournalArticle> orderByComparator)
26263                    throws NoSuchArticleException {
26264                    JournalArticle journalArticle = fetchByG_A_NotST_First(groupId,
26265                                    articleId, status, orderByComparator);
26266    
26267                    if (journalArticle != null) {
26268                            return journalArticle;
26269                    }
26270    
26271                    StringBundler msg = new StringBundler(8);
26272    
26273                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
26274    
26275                    msg.append("groupId=");
26276                    msg.append(groupId);
26277    
26278                    msg.append(", articleId=");
26279                    msg.append(articleId);
26280    
26281                    msg.append(", status=");
26282                    msg.append(status);
26283    
26284                    msg.append(StringPool.CLOSE_CURLY_BRACE);
26285    
26286                    throw new NoSuchArticleException(msg.toString());
26287            }
26288    
26289            /**
26290             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26291             *
26292             * @param groupId the group ID
26293             * @param articleId the article ID
26294             * @param status the status
26295             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26296             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
26297             */
26298            @Override
26299            public JournalArticle fetchByG_A_NotST_First(long groupId,
26300                    String articleId, int status,
26301                    OrderByComparator<JournalArticle> orderByComparator) {
26302                    List<JournalArticle> list = findByG_A_NotST(groupId, articleId, status,
26303                                    0, 1, orderByComparator);
26304    
26305                    if (!list.isEmpty()) {
26306                            return list.get(0);
26307                    }
26308    
26309                    return null;
26310            }
26311    
26312            /**
26313             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26314             *
26315             * @param groupId the group ID
26316             * @param articleId the article ID
26317             * @param status the status
26318             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26319             * @return the last matching journal article
26320             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
26321             */
26322            @Override
26323            public JournalArticle findByG_A_NotST_Last(long groupId, String articleId,
26324                    int status, OrderByComparator<JournalArticle> orderByComparator)
26325                    throws NoSuchArticleException {
26326                    JournalArticle journalArticle = fetchByG_A_NotST_Last(groupId,
26327                                    articleId, status, orderByComparator);
26328    
26329                    if (journalArticle != null) {
26330                            return journalArticle;
26331                    }
26332    
26333                    StringBundler msg = new StringBundler(8);
26334    
26335                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
26336    
26337                    msg.append("groupId=");
26338                    msg.append(groupId);
26339    
26340                    msg.append(", articleId=");
26341                    msg.append(articleId);
26342    
26343                    msg.append(", status=");
26344                    msg.append(status);
26345    
26346                    msg.append(StringPool.CLOSE_CURLY_BRACE);
26347    
26348                    throw new NoSuchArticleException(msg.toString());
26349            }
26350    
26351            /**
26352             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26353             *
26354             * @param groupId the group ID
26355             * @param articleId the article ID
26356             * @param status the status
26357             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26358             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
26359             */
26360            @Override
26361            public JournalArticle fetchByG_A_NotST_Last(long groupId, String articleId,
26362                    int status, OrderByComparator<JournalArticle> orderByComparator) {
26363                    int count = countByG_A_NotST(groupId, articleId, status);
26364    
26365                    if (count == 0) {
26366                            return null;
26367                    }
26368    
26369                    List<JournalArticle> list = findByG_A_NotST(groupId, articleId, status,
26370                                    count - 1, count, orderByComparator);
26371    
26372                    if (!list.isEmpty()) {
26373                            return list.get(0);
26374                    }
26375    
26376                    return null;
26377            }
26378    
26379            /**
26380             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26381             *
26382             * @param id the primary key of the current journal article
26383             * @param groupId the group ID
26384             * @param articleId the article ID
26385             * @param status the status
26386             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26387             * @return the previous, current, and next journal article
26388             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
26389             */
26390            @Override
26391            public JournalArticle[] findByG_A_NotST_PrevAndNext(long id, long groupId,
26392                    String articleId, int status,
26393                    OrderByComparator<JournalArticle> orderByComparator)
26394                    throws NoSuchArticleException {
26395                    JournalArticle journalArticle = findByPrimaryKey(id);
26396    
26397                    Session session = null;
26398    
26399                    try {
26400                            session = openSession();
26401    
26402                            JournalArticle[] array = new JournalArticleImpl[3];
26403    
26404                            array[0] = getByG_A_NotST_PrevAndNext(session, journalArticle,
26405                                            groupId, articleId, status, orderByComparator, true);
26406    
26407                            array[1] = journalArticle;
26408    
26409                            array[2] = getByG_A_NotST_PrevAndNext(session, journalArticle,
26410                                            groupId, articleId, status, orderByComparator, false);
26411    
26412                            return array;
26413                    }
26414                    catch (Exception e) {
26415                            throw processException(e);
26416                    }
26417                    finally {
26418                            closeSession(session);
26419                    }
26420            }
26421    
26422            protected JournalArticle getByG_A_NotST_PrevAndNext(Session session,
26423                    JournalArticle journalArticle, long groupId, String articleId,
26424                    int status, OrderByComparator<JournalArticle> orderByComparator,
26425                    boolean previous) {
26426                    StringBundler query = null;
26427    
26428                    if (orderByComparator != null) {
26429                            query = new StringBundler(6 +
26430                                            (orderByComparator.getOrderByFields().length * 6));
26431                    }
26432                    else {
26433                            query = new StringBundler(3);
26434                    }
26435    
26436                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
26437    
26438                    query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
26439    
26440                    boolean bindArticleId = false;
26441    
26442                    if (articleId == null) {
26443                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
26444                    }
26445                    else if (articleId.equals(StringPool.BLANK)) {
26446                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
26447                    }
26448                    else {
26449                            bindArticleId = true;
26450    
26451                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
26452                    }
26453    
26454                    query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
26455    
26456                    if (orderByComparator != null) {
26457                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
26458    
26459                            if (orderByConditionFields.length > 0) {
26460                                    query.append(WHERE_AND);
26461                            }
26462    
26463                            for (int i = 0; i < orderByConditionFields.length; i++) {
26464                                    query.append(_ORDER_BY_ENTITY_ALIAS);
26465                                    query.append(orderByConditionFields[i]);
26466    
26467                                    if ((i + 1) < orderByConditionFields.length) {
26468                                            if (orderByComparator.isAscending() ^ previous) {
26469                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
26470                                            }
26471                                            else {
26472                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
26473                                            }
26474                                    }
26475                                    else {
26476                                            if (orderByComparator.isAscending() ^ previous) {
26477                                                    query.append(WHERE_GREATER_THAN);
26478                                            }
26479                                            else {
26480                                                    query.append(WHERE_LESSER_THAN);
26481                                            }
26482                                    }
26483                            }
26484    
26485                            query.append(ORDER_BY_CLAUSE);
26486    
26487                            String[] orderByFields = orderByComparator.getOrderByFields();
26488    
26489                            for (int i = 0; i < orderByFields.length; i++) {
26490                                    query.append(_ORDER_BY_ENTITY_ALIAS);
26491                                    query.append(orderByFields[i]);
26492    
26493                                    if ((i + 1) < orderByFields.length) {
26494                                            if (orderByComparator.isAscending() ^ previous) {
26495                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
26496                                            }
26497                                            else {
26498                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
26499                                            }
26500                                    }
26501                                    else {
26502                                            if (orderByComparator.isAscending() ^ previous) {
26503                                                    query.append(ORDER_BY_ASC);
26504                                            }
26505                                            else {
26506                                                    query.append(ORDER_BY_DESC);
26507                                            }
26508                                    }
26509                            }
26510                    }
26511                    else {
26512                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
26513                    }
26514    
26515                    String sql = query.toString();
26516    
26517                    Query q = session.createQuery(sql);
26518    
26519                    q.setFirstResult(0);
26520                    q.setMaxResults(2);
26521    
26522                    QueryPos qPos = QueryPos.getInstance(q);
26523    
26524                    qPos.add(groupId);
26525    
26526                    if (bindArticleId) {
26527                            qPos.add(articleId);
26528                    }
26529    
26530                    qPos.add(status);
26531    
26532                    if (orderByComparator != null) {
26533                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
26534    
26535                            for (Object value : values) {
26536                                    qPos.add(value);
26537                            }
26538                    }
26539    
26540                    List<JournalArticle> list = q.list();
26541    
26542                    if (list.size() == 2) {
26543                            return list.get(1);
26544                    }
26545                    else {
26546                            return null;
26547                    }
26548            }
26549    
26550            /**
26551             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26552             *
26553             * @param groupId the group ID
26554             * @param articleId the article ID
26555             * @param status the status
26556             * @return the matching journal articles that the user has permission to view
26557             */
26558            @Override
26559            public List<JournalArticle> filterFindByG_A_NotST(long groupId,
26560                    String articleId, int status) {
26561                    return filterFindByG_A_NotST(groupId, articleId, status,
26562                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
26563            }
26564    
26565            /**
26566             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26567             *
26568             * <p>
26569             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
26570             * </p>
26571             *
26572             * @param groupId the group ID
26573             * @param articleId the article ID
26574             * @param status the status
26575             * @param start the lower bound of the range of journal articles
26576             * @param end the upper bound of the range of journal articles (not inclusive)
26577             * @return the range of matching journal articles that the user has permission to view
26578             */
26579            @Override
26580            public List<JournalArticle> filterFindByG_A_NotST(long groupId,
26581                    String articleId, int status, int start, int end) {
26582                    return filterFindByG_A_NotST(groupId, articleId, status, start, end,
26583                            null);
26584            }
26585    
26586            /**
26587             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26588             *
26589             * <p>
26590             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
26591             * </p>
26592             *
26593             * @param groupId the group ID
26594             * @param articleId the article ID
26595             * @param status the status
26596             * @param start the lower bound of the range of journal articles
26597             * @param end the upper bound of the range of journal articles (not inclusive)
26598             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
26599             * @return the ordered range of matching journal articles that the user has permission to view
26600             */
26601            @Override
26602            public List<JournalArticle> filterFindByG_A_NotST(long groupId,
26603                    String articleId, int status, int start, int end,
26604                    OrderByComparator<JournalArticle> orderByComparator) {
26605                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
26606                            return findByG_A_NotST(groupId, articleId, status, start, end,
26607                                    orderByComparator);
26608                    }
26609    
26610                    StringBundler query = null;
26611    
26612                    if (orderByComparator != null) {
26613                            query = new StringBundler(5 +
26614                                            (orderByComparator.getOrderByFields().length * 3));
26615                    }
26616                    else {
26617                            query = new StringBundler(5);
26618                    }
26619    
26620                    if (getDB().isSupportsInlineDistinct()) {
26621                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
26622                    }
26623                    else {
26624                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
26625                    }
26626    
26627                    query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
26628    
26629                    boolean bindArticleId = false;
26630    
26631                    if (articleId == null) {
26632                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
26633                    }
26634                    else if (articleId.equals(StringPool.BLANK)) {
26635                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
26636                    }
26637                    else {
26638                            bindArticleId = true;
26639    
26640                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
26641                    }
26642    
26643                    query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
26644    
26645                    if (!getDB().isSupportsInlineDistinct()) {
26646                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
26647                    }
26648    
26649                    if (orderByComparator != null) {
26650                            if (getDB().isSupportsInlineDistinct()) {
26651                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
26652                                            orderByComparator, true);
26653                            }
26654                            else {
26655                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
26656                                            orderByComparator, true);
26657                            }
26658                    }
26659                    else {
26660                            if (getDB().isSupportsInlineDistinct()) {
26661                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
26662                            }
26663                            else {
26664                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
26665                            }
26666                    }
26667    
26668                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
26669                                    JournalArticle.class.getName(),
26670                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
26671    
26672                    Session session = null;
26673    
26674                    try {
26675                            session = openSession();
26676    
26677                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
26678    
26679                            if (getDB().isSupportsInlineDistinct()) {
26680                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
26681                            }
26682                            else {
26683                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
26684                            }
26685    
26686                            QueryPos qPos = QueryPos.getInstance(q);
26687    
26688                            qPos.add(groupId);
26689    
26690                            if (bindArticleId) {
26691                                    qPos.add(articleId);
26692                            }
26693    
26694                            qPos.add(status);
26695    
26696                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
26697                                    end);
26698                    }
26699                    catch (Exception e) {
26700                            throw processException(e);
26701                    }
26702                    finally {
26703                            closeSession(session);
26704                    }
26705            }
26706    
26707            /**
26708             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26709             *
26710             * @param id the primary key of the current journal article
26711             * @param groupId the group ID
26712             * @param articleId the article ID
26713             * @param status the status
26714             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26715             * @return the previous, current, and next journal article
26716             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
26717             */
26718            @Override
26719            public JournalArticle[] filterFindByG_A_NotST_PrevAndNext(long id,
26720                    long groupId, String articleId, int status,
26721                    OrderByComparator<JournalArticle> orderByComparator)
26722                    throws NoSuchArticleException {
26723                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
26724                            return findByG_A_NotST_PrevAndNext(id, groupId, articleId, status,
26725                                    orderByComparator);
26726                    }
26727    
26728                    JournalArticle journalArticle = findByPrimaryKey(id);
26729    
26730                    Session session = null;
26731    
26732                    try {
26733                            session = openSession();
26734    
26735                            JournalArticle[] array = new JournalArticleImpl[3];
26736    
26737                            array[0] = filterGetByG_A_NotST_PrevAndNext(session,
26738                                            journalArticle, groupId, articleId, status,
26739                                            orderByComparator, true);
26740    
26741                            array[1] = journalArticle;
26742    
26743                            array[2] = filterGetByG_A_NotST_PrevAndNext(session,
26744                                            journalArticle, groupId, articleId, status,
26745                                            orderByComparator, false);
26746    
26747                            return array;
26748                    }
26749                    catch (Exception e) {
26750                            throw processException(e);
26751                    }
26752                    finally {
26753                            closeSession(session);
26754                    }
26755            }
26756    
26757            protected JournalArticle filterGetByG_A_NotST_PrevAndNext(Session session,
26758                    JournalArticle journalArticle, long groupId, String articleId,
26759                    int status, OrderByComparator<JournalArticle> orderByComparator,
26760                    boolean previous) {
26761                    StringBundler query = null;
26762    
26763                    if (orderByComparator != null) {
26764                            query = new StringBundler(6 +
26765                                            (orderByComparator.getOrderByFields().length * 6));
26766                    }
26767                    else {
26768                            query = new StringBundler(3);
26769                    }
26770    
26771                    if (getDB().isSupportsInlineDistinct()) {
26772                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
26773                    }
26774                    else {
26775                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
26776                    }
26777    
26778                    query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
26779    
26780                    boolean bindArticleId = false;
26781    
26782                    if (articleId == null) {
26783                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
26784                    }
26785                    else if (articleId.equals(StringPool.BLANK)) {
26786                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
26787                    }
26788                    else {
26789                            bindArticleId = true;
26790    
26791                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
26792                    }
26793    
26794                    query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
26795    
26796                    if (!getDB().isSupportsInlineDistinct()) {
26797                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
26798                    }
26799    
26800                    if (orderByComparator != null) {
26801                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
26802    
26803                            if (orderByConditionFields.length > 0) {
26804                                    query.append(WHERE_AND);
26805                            }
26806    
26807                            for (int i = 0; i < orderByConditionFields.length; i++) {
26808                                    if (getDB().isSupportsInlineDistinct()) {
26809                                            query.append(_ORDER_BY_ENTITY_ALIAS);
26810                                    }
26811                                    else {
26812                                            query.append(_ORDER_BY_ENTITY_TABLE);
26813                                    }
26814    
26815                                    query.append(orderByConditionFields[i]);
26816    
26817                                    if ((i + 1) < orderByConditionFields.length) {
26818                                            if (orderByComparator.isAscending() ^ previous) {
26819                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
26820                                            }
26821                                            else {
26822                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
26823                                            }
26824                                    }
26825                                    else {
26826                                            if (orderByComparator.isAscending() ^ previous) {
26827                                                    query.append(WHERE_GREATER_THAN);
26828                                            }
26829                                            else {
26830                                                    query.append(WHERE_LESSER_THAN);
26831                                            }
26832                                    }
26833                            }
26834    
26835                            query.append(ORDER_BY_CLAUSE);
26836    
26837                            String[] orderByFields = orderByComparator.getOrderByFields();
26838    
26839                            for (int i = 0; i < orderByFields.length; i++) {
26840                                    if (getDB().isSupportsInlineDistinct()) {
26841                                            query.append(_ORDER_BY_ENTITY_ALIAS);
26842                                    }
26843                                    else {
26844                                            query.append(_ORDER_BY_ENTITY_TABLE);
26845                                    }
26846    
26847                                    query.append(orderByFields[i]);
26848    
26849                                    if ((i + 1) < orderByFields.length) {
26850                                            if (orderByComparator.isAscending() ^ previous) {
26851                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
26852                                            }
26853                                            else {
26854                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
26855                                            }
26856                                    }
26857                                    else {
26858                                            if (orderByComparator.isAscending() ^ previous) {
26859                                                    query.append(ORDER_BY_ASC);
26860                                            }
26861                                            else {
26862                                                    query.append(ORDER_BY_DESC);
26863                                            }
26864                                    }
26865                            }
26866                    }
26867                    else {
26868                            if (getDB().isSupportsInlineDistinct()) {
26869                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
26870                            }
26871                            else {
26872                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
26873                            }
26874                    }
26875    
26876                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
26877                                    JournalArticle.class.getName(),
26878                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
26879    
26880                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
26881    
26882                    q.setFirstResult(0);
26883                    q.setMaxResults(2);
26884    
26885                    if (getDB().isSupportsInlineDistinct()) {
26886                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
26887                    }
26888                    else {
26889                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
26890                    }
26891    
26892                    QueryPos qPos = QueryPos.getInstance(q);
26893    
26894                    qPos.add(groupId);
26895    
26896                    if (bindArticleId) {
26897                            qPos.add(articleId);
26898                    }
26899    
26900                    qPos.add(status);
26901    
26902                    if (orderByComparator != null) {
26903                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
26904    
26905                            for (Object value : values) {
26906                                    qPos.add(value);
26907                            }
26908                    }
26909    
26910                    List<JournalArticle> list = q.list();
26911    
26912                    if (list.size() == 2) {
26913                            return list.get(1);
26914                    }
26915                    else {
26916                            return null;
26917                    }
26918            }
26919    
26920            /**
26921             * Removes all the journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63; from the database.
26922             *
26923             * @param groupId the group ID
26924             * @param articleId the article ID
26925             * @param status the status
26926             */
26927            @Override
26928            public void removeByG_A_NotST(long groupId, String articleId, int status) {
26929                    for (JournalArticle journalArticle : findByG_A_NotST(groupId,
26930                                    articleId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
26931                            remove(journalArticle);
26932                    }
26933            }
26934    
26935            /**
26936             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26937             *
26938             * @param groupId the group ID
26939             * @param articleId the article ID
26940             * @param status the status
26941             * @return the number of matching journal articles
26942             */
26943            @Override
26944            public int countByG_A_NotST(long groupId, String articleId, int status) {
26945                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_NOTST;
26946    
26947                    Object[] finderArgs = new Object[] { groupId, articleId, status };
26948    
26949                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
26950                                    this);
26951    
26952                    if (count == null) {
26953                            StringBundler query = new StringBundler(4);
26954    
26955                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
26956    
26957                            query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
26958    
26959                            boolean bindArticleId = false;
26960    
26961                            if (articleId == null) {
26962                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
26963                            }
26964                            else if (articleId.equals(StringPool.BLANK)) {
26965                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
26966                            }
26967                            else {
26968                                    bindArticleId = true;
26969    
26970                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
26971                            }
26972    
26973                            query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
26974    
26975                            String sql = query.toString();
26976    
26977                            Session session = null;
26978    
26979                            try {
26980                                    session = openSession();
26981    
26982                                    Query q = session.createQuery(sql);
26983    
26984                                    QueryPos qPos = QueryPos.getInstance(q);
26985    
26986                                    qPos.add(groupId);
26987    
26988                                    if (bindArticleId) {
26989                                            qPos.add(articleId);
26990                                    }
26991    
26992                                    qPos.add(status);
26993    
26994                                    count = (Long)q.uniqueResult();
26995    
26996                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
26997                            }
26998                            catch (Exception e) {
26999                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
27000    
27001                                    throw processException(e);
27002                            }
27003                            finally {
27004                                    closeSession(session);
27005                            }
27006                    }
27007    
27008                    return count.intValue();
27009            }
27010    
27011            /**
27012             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
27013             *
27014             * @param groupId the group ID
27015             * @param articleId the article ID
27016             * @param status the status
27017             * @return the number of matching journal articles that the user has permission to view
27018             */
27019            @Override
27020            public int filterCountByG_A_NotST(long groupId, String articleId, int status) {
27021                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
27022                            return countByG_A_NotST(groupId, articleId, status);
27023                    }
27024    
27025                    StringBundler query = new StringBundler(4);
27026    
27027                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
27028    
27029                    query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
27030    
27031                    boolean bindArticleId = false;
27032    
27033                    if (articleId == null) {
27034                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
27035                    }
27036                    else if (articleId.equals(StringPool.BLANK)) {
27037                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
27038                    }
27039                    else {
27040                            bindArticleId = true;
27041    
27042                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
27043                    }
27044    
27045                    query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
27046    
27047                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
27048                                    JournalArticle.class.getName(),
27049                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
27050    
27051                    Session session = null;
27052    
27053                    try {
27054                            session = openSession();
27055    
27056                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
27057    
27058                            q.addScalar(COUNT_COLUMN_NAME,
27059                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
27060    
27061                            QueryPos qPos = QueryPos.getInstance(q);
27062    
27063                            qPos.add(groupId);
27064    
27065                            if (bindArticleId) {
27066                                    qPos.add(articleId);
27067                            }
27068    
27069                            qPos.add(status);
27070    
27071                            Long count = (Long)q.uniqueResult();
27072    
27073                            return count.intValue();
27074                    }
27075                    catch (Exception e) {
27076                            throw processException(e);
27077                    }
27078                    finally {
27079                            closeSession(session);
27080                    }
27081            }
27082    
27083            private static final String _FINDER_COLUMN_G_A_NOTST_GROUPID_2 = "journalArticle.groupId = ? AND ";
27084            private static final String _FINDER_COLUMN_G_A_NOTST_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
27085            private static final String _FINDER_COLUMN_G_A_NOTST_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
27086            private static final String _FINDER_COLUMN_G_A_NOTST_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '') AND ";
27087            private static final String _FINDER_COLUMN_G_A_NOTST_STATUS_2 = "journalArticle.status != ?";
27088            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
27089                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
27090                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
27091                            "findByG_UT_ST",
27092                            new String[] {
27093                                    Long.class.getName(), String.class.getName(),
27094                                    Integer.class.getName(),
27095                                    
27096                            Integer.class.getName(), Integer.class.getName(),
27097                                    OrderByComparator.class.getName()
27098                            });
27099            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST =
27100                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
27101                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
27102                            JournalArticleImpl.class,
27103                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_UT_ST",
27104                            new String[] {
27105                                    Long.class.getName(), String.class.getName(),
27106                                    Integer.class.getName()
27107                            },
27108                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
27109                            JournalArticleModelImpl.URLTITLE_COLUMN_BITMASK |
27110                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
27111                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
27112                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
27113            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
27114                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
27115                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT_ST",
27116                            new String[] {
27117                                    Long.class.getName(), String.class.getName(),
27118                                    Integer.class.getName()
27119                            });
27120    
27121            /**
27122             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27123             *
27124             * @param groupId the group ID
27125             * @param urlTitle the url title
27126             * @param status the status
27127             * @return the matching journal articles
27128             */
27129            @Override
27130            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
27131                    int status) {
27132                    return findByG_UT_ST(groupId, urlTitle, status, QueryUtil.ALL_POS,
27133                            QueryUtil.ALL_POS, null);
27134            }
27135    
27136            /**
27137             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27138             *
27139             * <p>
27140             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
27141             * </p>
27142             *
27143             * @param groupId the group ID
27144             * @param urlTitle the url title
27145             * @param status the status
27146             * @param start the lower bound of the range of journal articles
27147             * @param end the upper bound of the range of journal articles (not inclusive)
27148             * @return the range of matching journal articles
27149             */
27150            @Override
27151            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
27152                    int status, int start, int end) {
27153                    return findByG_UT_ST(groupId, urlTitle, status, start, end, null);
27154            }
27155    
27156            /**
27157             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27158             *
27159             * <p>
27160             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
27161             * </p>
27162             *
27163             * @param groupId the group ID
27164             * @param urlTitle the url title
27165             * @param status the status
27166             * @param start the lower bound of the range of journal articles
27167             * @param end the upper bound of the range of journal articles (not inclusive)
27168             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
27169             * @return the ordered range of matching journal articles
27170             */
27171            @Override
27172            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
27173                    int status, int start, int end,
27174                    OrderByComparator<JournalArticle> orderByComparator) {
27175                    boolean pagination = true;
27176                    FinderPath finderPath = null;
27177                    Object[] finderArgs = null;
27178    
27179                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
27180                                    (orderByComparator == null)) {
27181                            pagination = false;
27182                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST;
27183                            finderArgs = new Object[] { groupId, urlTitle, status };
27184                    }
27185                    else {
27186                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST;
27187                            finderArgs = new Object[] {
27188                                            groupId, urlTitle, status,
27189                                            
27190                                            start, end, orderByComparator
27191                                    };
27192                    }
27193    
27194                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
27195                                    finderArgs, this);
27196    
27197                    if ((list != null) && !list.isEmpty()) {
27198                            for (JournalArticle journalArticle : list) {
27199                                    if ((groupId != journalArticle.getGroupId()) ||
27200                                                    !Validator.equals(urlTitle, journalArticle.getUrlTitle()) ||
27201                                                    (status != journalArticle.getStatus())) {
27202                                            list = null;
27203    
27204                                            break;
27205                                    }
27206                            }
27207                    }
27208    
27209                    if (list == null) {
27210                            StringBundler query = null;
27211    
27212                            if (orderByComparator != null) {
27213                                    query = new StringBundler(5 +
27214                                                    (orderByComparator.getOrderByFields().length * 3));
27215                            }
27216                            else {
27217                                    query = new StringBundler(5);
27218                            }
27219    
27220                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
27221    
27222                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
27223    
27224                            boolean bindUrlTitle = false;
27225    
27226                            if (urlTitle == null) {
27227                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
27228                            }
27229                            else if (urlTitle.equals(StringPool.BLANK)) {
27230                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
27231                            }
27232                            else {
27233                                    bindUrlTitle = true;
27234    
27235                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
27236                            }
27237    
27238                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
27239    
27240                            if (orderByComparator != null) {
27241                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
27242                                            orderByComparator);
27243                            }
27244                            else
27245                             if (pagination) {
27246                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
27247                            }
27248    
27249                            String sql = query.toString();
27250    
27251                            Session session = null;
27252    
27253                            try {
27254                                    session = openSession();
27255    
27256                                    Query q = session.createQuery(sql);
27257    
27258                                    QueryPos qPos = QueryPos.getInstance(q);
27259    
27260                                    qPos.add(groupId);
27261    
27262                                    if (bindUrlTitle) {
27263                                            qPos.add(urlTitle);
27264                                    }
27265    
27266                                    qPos.add(status);
27267    
27268                                    if (!pagination) {
27269                                            list = (List<JournalArticle>)QueryUtil.list(q,
27270                                                            getDialect(), start, end, false);
27271    
27272                                            Collections.sort(list);
27273    
27274                                            list = Collections.unmodifiableList(list);
27275                                    }
27276                                    else {
27277                                            list = (List<JournalArticle>)QueryUtil.list(q,
27278                                                            getDialect(), start, end);
27279                                    }
27280    
27281                                    cacheResult(list);
27282    
27283                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
27284                            }
27285                            catch (Exception e) {
27286                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
27287    
27288                                    throw processException(e);
27289                            }
27290                            finally {
27291                                    closeSession(session);
27292                            }
27293                    }
27294    
27295                    return list;
27296            }
27297    
27298            /**
27299             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27300             *
27301             * @param groupId the group ID
27302             * @param urlTitle the url title
27303             * @param status the status
27304             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27305             * @return the first matching journal article
27306             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
27307             */
27308            @Override
27309            public JournalArticle findByG_UT_ST_First(long groupId, String urlTitle,
27310                    int status, OrderByComparator<JournalArticle> orderByComparator)
27311                    throws NoSuchArticleException {
27312                    JournalArticle journalArticle = fetchByG_UT_ST_First(groupId, urlTitle,
27313                                    status, orderByComparator);
27314    
27315                    if (journalArticle != null) {
27316                            return journalArticle;
27317                    }
27318    
27319                    StringBundler msg = new StringBundler(8);
27320    
27321                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
27322    
27323                    msg.append("groupId=");
27324                    msg.append(groupId);
27325    
27326                    msg.append(", urlTitle=");
27327                    msg.append(urlTitle);
27328    
27329                    msg.append(", status=");
27330                    msg.append(status);
27331    
27332                    msg.append(StringPool.CLOSE_CURLY_BRACE);
27333    
27334                    throw new NoSuchArticleException(msg.toString());
27335            }
27336    
27337            /**
27338             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27339             *
27340             * @param groupId the group ID
27341             * @param urlTitle the url title
27342             * @param status the status
27343             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27344             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
27345             */
27346            @Override
27347            public JournalArticle fetchByG_UT_ST_First(long groupId, String urlTitle,
27348                    int status, OrderByComparator<JournalArticle> orderByComparator) {
27349                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status, 0,
27350                                    1, orderByComparator);
27351    
27352                    if (!list.isEmpty()) {
27353                            return list.get(0);
27354                    }
27355    
27356                    return null;
27357            }
27358    
27359            /**
27360             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27361             *
27362             * @param groupId the group ID
27363             * @param urlTitle the url title
27364             * @param status the status
27365             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27366             * @return the last matching journal article
27367             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
27368             */
27369            @Override
27370            public JournalArticle findByG_UT_ST_Last(long groupId, String urlTitle,
27371                    int status, OrderByComparator<JournalArticle> orderByComparator)
27372                    throws NoSuchArticleException {
27373                    JournalArticle journalArticle = fetchByG_UT_ST_Last(groupId, urlTitle,
27374                                    status, orderByComparator);
27375    
27376                    if (journalArticle != null) {
27377                            return journalArticle;
27378                    }
27379    
27380                    StringBundler msg = new StringBundler(8);
27381    
27382                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
27383    
27384                    msg.append("groupId=");
27385                    msg.append(groupId);
27386    
27387                    msg.append(", urlTitle=");
27388                    msg.append(urlTitle);
27389    
27390                    msg.append(", status=");
27391                    msg.append(status);
27392    
27393                    msg.append(StringPool.CLOSE_CURLY_BRACE);
27394    
27395                    throw new NoSuchArticleException(msg.toString());
27396            }
27397    
27398            /**
27399             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27400             *
27401             * @param groupId the group ID
27402             * @param urlTitle the url title
27403             * @param status the status
27404             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27405             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
27406             */
27407            @Override
27408            public JournalArticle fetchByG_UT_ST_Last(long groupId, String urlTitle,
27409                    int status, OrderByComparator<JournalArticle> orderByComparator) {
27410                    int count = countByG_UT_ST(groupId, urlTitle, status);
27411    
27412                    if (count == 0) {
27413                            return null;
27414                    }
27415    
27416                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status,
27417                                    count - 1, count, orderByComparator);
27418    
27419                    if (!list.isEmpty()) {
27420                            return list.get(0);
27421                    }
27422    
27423                    return null;
27424            }
27425    
27426            /**
27427             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27428             *
27429             * @param id the primary key of the current journal article
27430             * @param groupId the group ID
27431             * @param urlTitle the url title
27432             * @param status the status
27433             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27434             * @return the previous, current, and next journal article
27435             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
27436             */
27437            @Override
27438            public JournalArticle[] findByG_UT_ST_PrevAndNext(long id, long groupId,
27439                    String urlTitle, int status,
27440                    OrderByComparator<JournalArticle> orderByComparator)
27441                    throws NoSuchArticleException {
27442                    JournalArticle journalArticle = findByPrimaryKey(id);
27443    
27444                    Session session = null;
27445    
27446                    try {
27447                            session = openSession();
27448    
27449                            JournalArticle[] array = new JournalArticleImpl[3];
27450    
27451                            array[0] = getByG_UT_ST_PrevAndNext(session, journalArticle,
27452                                            groupId, urlTitle, status, orderByComparator, true);
27453    
27454                            array[1] = journalArticle;
27455    
27456                            array[2] = getByG_UT_ST_PrevAndNext(session, journalArticle,
27457                                            groupId, urlTitle, status, orderByComparator, false);
27458    
27459                            return array;
27460                    }
27461                    catch (Exception e) {
27462                            throw processException(e);
27463                    }
27464                    finally {
27465                            closeSession(session);
27466                    }
27467            }
27468    
27469            protected JournalArticle getByG_UT_ST_PrevAndNext(Session session,
27470                    JournalArticle journalArticle, long groupId, String urlTitle,
27471                    int status, OrderByComparator<JournalArticle> orderByComparator,
27472                    boolean previous) {
27473                    StringBundler query = null;
27474    
27475                    if (orderByComparator != null) {
27476                            query = new StringBundler(6 +
27477                                            (orderByComparator.getOrderByFields().length * 6));
27478                    }
27479                    else {
27480                            query = new StringBundler(3);
27481                    }
27482    
27483                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
27484    
27485                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
27486    
27487                    boolean bindUrlTitle = false;
27488    
27489                    if (urlTitle == null) {
27490                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
27491                    }
27492                    else if (urlTitle.equals(StringPool.BLANK)) {
27493                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
27494                    }
27495                    else {
27496                            bindUrlTitle = true;
27497    
27498                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
27499                    }
27500    
27501                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
27502    
27503                    if (orderByComparator != null) {
27504                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
27505    
27506                            if (orderByConditionFields.length > 0) {
27507                                    query.append(WHERE_AND);
27508                            }
27509    
27510                            for (int i = 0; i < orderByConditionFields.length; i++) {
27511                                    query.append(_ORDER_BY_ENTITY_ALIAS);
27512                                    query.append(orderByConditionFields[i]);
27513    
27514                                    if ((i + 1) < orderByConditionFields.length) {
27515                                            if (orderByComparator.isAscending() ^ previous) {
27516                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
27517                                            }
27518                                            else {
27519                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
27520                                            }
27521                                    }
27522                                    else {
27523                                            if (orderByComparator.isAscending() ^ previous) {
27524                                                    query.append(WHERE_GREATER_THAN);
27525                                            }
27526                                            else {
27527                                                    query.append(WHERE_LESSER_THAN);
27528                                            }
27529                                    }
27530                            }
27531    
27532                            query.append(ORDER_BY_CLAUSE);
27533    
27534                            String[] orderByFields = orderByComparator.getOrderByFields();
27535    
27536                            for (int i = 0; i < orderByFields.length; i++) {
27537                                    query.append(_ORDER_BY_ENTITY_ALIAS);
27538                                    query.append(orderByFields[i]);
27539    
27540                                    if ((i + 1) < orderByFields.length) {
27541                                            if (orderByComparator.isAscending() ^ previous) {
27542                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
27543                                            }
27544                                            else {
27545                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
27546                                            }
27547                                    }
27548                                    else {
27549                                            if (orderByComparator.isAscending() ^ previous) {
27550                                                    query.append(ORDER_BY_ASC);
27551                                            }
27552                                            else {
27553                                                    query.append(ORDER_BY_DESC);
27554                                            }
27555                                    }
27556                            }
27557                    }
27558                    else {
27559                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
27560                    }
27561    
27562                    String sql = query.toString();
27563    
27564                    Query q = session.createQuery(sql);
27565    
27566                    q.setFirstResult(0);
27567                    q.setMaxResults(2);
27568    
27569                    QueryPos qPos = QueryPos.getInstance(q);
27570    
27571                    qPos.add(groupId);
27572    
27573                    if (bindUrlTitle) {
27574                            qPos.add(urlTitle);
27575                    }
27576    
27577                    qPos.add(status);
27578    
27579                    if (orderByComparator != null) {
27580                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
27581    
27582                            for (Object value : values) {
27583                                    qPos.add(value);
27584                            }
27585                    }
27586    
27587                    List<JournalArticle> list = q.list();
27588    
27589                    if (list.size() == 2) {
27590                            return list.get(1);
27591                    }
27592                    else {
27593                            return null;
27594                    }
27595            }
27596    
27597            /**
27598             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27599             *
27600             * @param groupId the group ID
27601             * @param urlTitle the url title
27602             * @param status the status
27603             * @return the matching journal articles that the user has permission to view
27604             */
27605            @Override
27606            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
27607                    String urlTitle, int status) {
27608                    return filterFindByG_UT_ST(groupId, urlTitle, status,
27609                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
27610            }
27611    
27612            /**
27613             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27614             *
27615             * <p>
27616             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
27617             * </p>
27618             *
27619             * @param groupId the group ID
27620             * @param urlTitle the url title
27621             * @param status the status
27622             * @param start the lower bound of the range of journal articles
27623             * @param end the upper bound of the range of journal articles (not inclusive)
27624             * @return the range of matching journal articles that the user has permission to view
27625             */
27626            @Override
27627            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
27628                    String urlTitle, int status, int start, int end) {
27629                    return filterFindByG_UT_ST(groupId, urlTitle, status, start, end, null);
27630            }
27631    
27632            /**
27633             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27634             *
27635             * <p>
27636             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
27637             * </p>
27638             *
27639             * @param groupId the group ID
27640             * @param urlTitle the url title
27641             * @param status the status
27642             * @param start the lower bound of the range of journal articles
27643             * @param end the upper bound of the range of journal articles (not inclusive)
27644             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
27645             * @return the ordered range of matching journal articles that the user has permission to view
27646             */
27647            @Override
27648            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
27649                    String urlTitle, int status, int start, int end,
27650                    OrderByComparator<JournalArticle> orderByComparator) {
27651                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
27652                            return findByG_UT_ST(groupId, urlTitle, status, start, end,
27653                                    orderByComparator);
27654                    }
27655    
27656                    StringBundler query = null;
27657    
27658                    if (orderByComparator != null) {
27659                            query = new StringBundler(5 +
27660                                            (orderByComparator.getOrderByFields().length * 3));
27661                    }
27662                    else {
27663                            query = new StringBundler(5);
27664                    }
27665    
27666                    if (getDB().isSupportsInlineDistinct()) {
27667                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
27668                    }
27669                    else {
27670                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
27671                    }
27672    
27673                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
27674    
27675                    boolean bindUrlTitle = false;
27676    
27677                    if (urlTitle == null) {
27678                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
27679                    }
27680                    else if (urlTitle.equals(StringPool.BLANK)) {
27681                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
27682                    }
27683                    else {
27684                            bindUrlTitle = true;
27685    
27686                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
27687                    }
27688    
27689                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
27690    
27691                    if (!getDB().isSupportsInlineDistinct()) {
27692                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
27693                    }
27694    
27695                    if (orderByComparator != null) {
27696                            if (getDB().isSupportsInlineDistinct()) {
27697                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
27698                                            orderByComparator, true);
27699                            }
27700                            else {
27701                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
27702                                            orderByComparator, true);
27703                            }
27704                    }
27705                    else {
27706                            if (getDB().isSupportsInlineDistinct()) {
27707                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
27708                            }
27709                            else {
27710                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
27711                            }
27712                    }
27713    
27714                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
27715                                    JournalArticle.class.getName(),
27716                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
27717    
27718                    Session session = null;
27719    
27720                    try {
27721                            session = openSession();
27722    
27723                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
27724    
27725                            if (getDB().isSupportsInlineDistinct()) {
27726                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
27727                            }
27728                            else {
27729                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
27730                            }
27731    
27732                            QueryPos qPos = QueryPos.getInstance(q);
27733    
27734                            qPos.add(groupId);
27735    
27736                            if (bindUrlTitle) {
27737                                    qPos.add(urlTitle);
27738                            }
27739    
27740                            qPos.add(status);
27741    
27742                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
27743                                    end);
27744                    }
27745                    catch (Exception e) {
27746                            throw processException(e);
27747                    }
27748                    finally {
27749                            closeSession(session);
27750                    }
27751            }
27752    
27753            /**
27754             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27755             *
27756             * @param id the primary key of the current journal article
27757             * @param groupId the group ID
27758             * @param urlTitle the url title
27759             * @param status the status
27760             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27761             * @return the previous, current, and next journal article
27762             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
27763             */
27764            @Override
27765            public JournalArticle[] filterFindByG_UT_ST_PrevAndNext(long id,
27766                    long groupId, String urlTitle, int status,
27767                    OrderByComparator<JournalArticle> orderByComparator)
27768                    throws NoSuchArticleException {
27769                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
27770                            return findByG_UT_ST_PrevAndNext(id, groupId, urlTitle, status,
27771                                    orderByComparator);
27772                    }
27773    
27774                    JournalArticle journalArticle = findByPrimaryKey(id);
27775    
27776                    Session session = null;
27777    
27778                    try {
27779                            session = openSession();
27780    
27781                            JournalArticle[] array = new JournalArticleImpl[3];
27782    
27783                            array[0] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
27784                                            groupId, urlTitle, status, orderByComparator, true);
27785    
27786                            array[1] = journalArticle;
27787    
27788                            array[2] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
27789                                            groupId, urlTitle, status, orderByComparator, false);
27790    
27791                            return array;
27792                    }
27793                    catch (Exception e) {
27794                            throw processException(e);
27795                    }
27796                    finally {
27797                            closeSession(session);
27798                    }
27799            }
27800    
27801            protected JournalArticle filterGetByG_UT_ST_PrevAndNext(Session session,
27802                    JournalArticle journalArticle, long groupId, String urlTitle,
27803                    int status, OrderByComparator<JournalArticle> orderByComparator,
27804                    boolean previous) {
27805                    StringBundler query = null;
27806    
27807                    if (orderByComparator != null) {
27808                            query = new StringBundler(6 +
27809                                            (orderByComparator.getOrderByFields().length * 6));
27810                    }
27811                    else {
27812                            query = new StringBundler(3);
27813                    }
27814    
27815                    if (getDB().isSupportsInlineDistinct()) {
27816                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
27817                    }
27818                    else {
27819                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
27820                    }
27821    
27822                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
27823    
27824                    boolean bindUrlTitle = false;
27825    
27826                    if (urlTitle == null) {
27827                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
27828                    }
27829                    else if (urlTitle.equals(StringPool.BLANK)) {
27830                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
27831                    }
27832                    else {
27833                            bindUrlTitle = true;
27834    
27835                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
27836                    }
27837    
27838                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
27839    
27840                    if (!getDB().isSupportsInlineDistinct()) {
27841                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
27842                    }
27843    
27844                    if (orderByComparator != null) {
27845                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
27846    
27847                            if (orderByConditionFields.length > 0) {
27848                                    query.append(WHERE_AND);
27849                            }
27850    
27851                            for (int i = 0; i < orderByConditionFields.length; i++) {
27852                                    if (getDB().isSupportsInlineDistinct()) {
27853                                            query.append(_ORDER_BY_ENTITY_ALIAS);
27854                                    }
27855                                    else {
27856                                            query.append(_ORDER_BY_ENTITY_TABLE);
27857                                    }
27858    
27859                                    query.append(orderByConditionFields[i]);
27860    
27861                                    if ((i + 1) < orderByConditionFields.length) {
27862                                            if (orderByComparator.isAscending() ^ previous) {
27863                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
27864                                            }
27865                                            else {
27866                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
27867                                            }
27868                                    }
27869                                    else {
27870                                            if (orderByComparator.isAscending() ^ previous) {
27871                                                    query.append(WHERE_GREATER_THAN);
27872                                            }
27873                                            else {
27874                                                    query.append(WHERE_LESSER_THAN);
27875                                            }
27876                                    }
27877                            }
27878    
27879                            query.append(ORDER_BY_CLAUSE);
27880    
27881                            String[] orderByFields = orderByComparator.getOrderByFields();
27882    
27883                            for (int i = 0; i < orderByFields.length; i++) {
27884                                    if (getDB().isSupportsInlineDistinct()) {
27885                                            query.append(_ORDER_BY_ENTITY_ALIAS);
27886                                    }
27887                                    else {
27888                                            query.append(_ORDER_BY_ENTITY_TABLE);
27889                                    }
27890    
27891                                    query.append(orderByFields[i]);
27892    
27893                                    if ((i + 1) < orderByFields.length) {
27894                                            if (orderByComparator.isAscending() ^ previous) {
27895                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
27896                                            }
27897                                            else {
27898                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
27899                                            }
27900                                    }
27901                                    else {
27902                                            if (orderByComparator.isAscending() ^ previous) {
27903                                                    query.append(ORDER_BY_ASC);
27904                                            }
27905                                            else {
27906                                                    query.append(ORDER_BY_DESC);
27907                                            }
27908                                    }
27909                            }
27910                    }
27911                    else {
27912                            if (getDB().isSupportsInlineDistinct()) {
27913                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
27914                            }
27915                            else {
27916                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
27917                            }
27918                    }
27919    
27920                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
27921                                    JournalArticle.class.getName(),
27922                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
27923    
27924                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
27925    
27926                    q.setFirstResult(0);
27927                    q.setMaxResults(2);
27928    
27929                    if (getDB().isSupportsInlineDistinct()) {
27930                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
27931                    }
27932                    else {
27933                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
27934                    }
27935    
27936                    QueryPos qPos = QueryPos.getInstance(q);
27937    
27938                    qPos.add(groupId);
27939    
27940                    if (bindUrlTitle) {
27941                            qPos.add(urlTitle);
27942                    }
27943    
27944                    qPos.add(status);
27945    
27946                    if (orderByComparator != null) {
27947                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
27948    
27949                            for (Object value : values) {
27950                                    qPos.add(value);
27951                            }
27952                    }
27953    
27954                    List<JournalArticle> list = q.list();
27955    
27956                    if (list.size() == 2) {
27957                            return list.get(1);
27958                    }
27959                    else {
27960                            return null;
27961                    }
27962            }
27963    
27964            /**
27965             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63; from the database.
27966             *
27967             * @param groupId the group ID
27968             * @param urlTitle the url title
27969             * @param status the status
27970             */
27971            @Override
27972            public void removeByG_UT_ST(long groupId, String urlTitle, int status) {
27973                    for (JournalArticle journalArticle : findByG_UT_ST(groupId, urlTitle,
27974                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
27975                            remove(journalArticle);
27976                    }
27977            }
27978    
27979            /**
27980             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27981             *
27982             * @param groupId the group ID
27983             * @param urlTitle the url title
27984             * @param status the status
27985             * @return the number of matching journal articles
27986             */
27987            @Override
27988            public int countByG_UT_ST(long groupId, String urlTitle, int status) {
27989                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT_ST;
27990    
27991                    Object[] finderArgs = new Object[] { groupId, urlTitle, status };
27992    
27993                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
27994                                    this);
27995    
27996                    if (count == null) {
27997                            StringBundler query = new StringBundler(4);
27998    
27999                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
28000    
28001                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
28002    
28003                            boolean bindUrlTitle = false;
28004    
28005                            if (urlTitle == null) {
28006                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
28007                            }
28008                            else if (urlTitle.equals(StringPool.BLANK)) {
28009                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
28010                            }
28011                            else {
28012                                    bindUrlTitle = true;
28013    
28014                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
28015                            }
28016    
28017                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
28018    
28019                            String sql = query.toString();
28020    
28021                            Session session = null;
28022    
28023                            try {
28024                                    session = openSession();
28025    
28026                                    Query q = session.createQuery(sql);
28027    
28028                                    QueryPos qPos = QueryPos.getInstance(q);
28029    
28030                                    qPos.add(groupId);
28031    
28032                                    if (bindUrlTitle) {
28033                                            qPos.add(urlTitle);
28034                                    }
28035    
28036                                    qPos.add(status);
28037    
28038                                    count = (Long)q.uniqueResult();
28039    
28040                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
28041                            }
28042                            catch (Exception e) {
28043                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
28044    
28045                                    throw processException(e);
28046                            }
28047                            finally {
28048                                    closeSession(session);
28049                            }
28050                    }
28051    
28052                    return count.intValue();
28053            }
28054    
28055            /**
28056             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
28057             *
28058             * @param groupId the group ID
28059             * @param urlTitle the url title
28060             * @param status the status
28061             * @return the number of matching journal articles that the user has permission to view
28062             */
28063            @Override
28064            public int filterCountByG_UT_ST(long groupId, String urlTitle, int status) {
28065                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
28066                            return countByG_UT_ST(groupId, urlTitle, status);
28067                    }
28068    
28069                    StringBundler query = new StringBundler(4);
28070    
28071                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
28072    
28073                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
28074    
28075                    boolean bindUrlTitle = false;
28076    
28077                    if (urlTitle == null) {
28078                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
28079                    }
28080                    else if (urlTitle.equals(StringPool.BLANK)) {
28081                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
28082                    }
28083                    else {
28084                            bindUrlTitle = true;
28085    
28086                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
28087                    }
28088    
28089                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
28090    
28091                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
28092                                    JournalArticle.class.getName(),
28093                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
28094    
28095                    Session session = null;
28096    
28097                    try {
28098                            session = openSession();
28099    
28100                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
28101    
28102                            q.addScalar(COUNT_COLUMN_NAME,
28103                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
28104    
28105                            QueryPos qPos = QueryPos.getInstance(q);
28106    
28107                            qPos.add(groupId);
28108    
28109                            if (bindUrlTitle) {
28110                                    qPos.add(urlTitle);
28111                            }
28112    
28113                            qPos.add(status);
28114    
28115                            Long count = (Long)q.uniqueResult();
28116    
28117                            return count.intValue();
28118                    }
28119                    catch (Exception e) {
28120                            throw processException(e);
28121                    }
28122                    finally {
28123                            closeSession(session);
28124                    }
28125            }
28126    
28127            private static final String _FINDER_COLUMN_G_UT_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
28128            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_1 = "journalArticle.urlTitle IS NULL AND ";
28129            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_2 = "journalArticle.urlTitle = ? AND ";
28130            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = '') AND ";
28131            private static final String _FINDER_COLUMN_G_UT_ST_STATUS_2 = "journalArticle.status = ?";
28132            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28133                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
28134                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
28135                            "findByC_V_ST",
28136                            new String[] {
28137                                    Long.class.getName(), Double.class.getName(),
28138                                    Integer.class.getName(),
28139                                    
28140                            Integer.class.getName(), Integer.class.getName(),
28141                                    OrderByComparator.class.getName()
28142                            });
28143            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST =
28144                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28145                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
28146                            JournalArticleImpl.class,
28147                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_V_ST",
28148                            new String[] {
28149                                    Long.class.getName(), Double.class.getName(),
28150                                    Integer.class.getName()
28151                            },
28152                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
28153                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK |
28154                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
28155                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK);
28156            public static final FinderPath FINDER_PATH_COUNT_BY_C_V_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28157                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
28158                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_V_ST",
28159                            new String[] {
28160                                    Long.class.getName(), Double.class.getName(),
28161                                    Integer.class.getName()
28162                            });
28163    
28164            /**
28165             * Returns all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
28166             *
28167             * @param companyId the company ID
28168             * @param version the version
28169             * @param status the status
28170             * @return the matching journal articles
28171             */
28172            @Override
28173            public List<JournalArticle> findByC_V_ST(long companyId, double version,
28174                    int status) {
28175                    return findByC_V_ST(companyId, version, status, QueryUtil.ALL_POS,
28176                            QueryUtil.ALL_POS, null);
28177            }
28178    
28179            /**
28180             * Returns a range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
28181             *
28182             * <p>
28183             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
28184             * </p>
28185             *
28186             * @param companyId the company ID
28187             * @param version the version
28188             * @param status the status
28189             * @param start the lower bound of the range of journal articles
28190             * @param end the upper bound of the range of journal articles (not inclusive)
28191             * @return the range of matching journal articles
28192             */
28193            @Override
28194            public List<JournalArticle> findByC_V_ST(long companyId, double version,
28195                    int status, int start, int end) {
28196                    return findByC_V_ST(companyId, version, status, start, end, null);
28197            }
28198    
28199            /**
28200             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
28201             *
28202             * <p>
28203             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
28204             * </p>
28205             *
28206             * @param companyId the company ID
28207             * @param version the version
28208             * @param status the status
28209             * @param start the lower bound of the range of journal articles
28210             * @param end the upper bound of the range of journal articles (not inclusive)
28211             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
28212             * @return the ordered range of matching journal articles
28213             */
28214            @Override
28215            public List<JournalArticle> findByC_V_ST(long companyId, double version,
28216                    int status, int start, int end,
28217                    OrderByComparator<JournalArticle> orderByComparator) {
28218                    boolean pagination = true;
28219                    FinderPath finderPath = null;
28220                    Object[] finderArgs = null;
28221    
28222                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
28223                                    (orderByComparator == null)) {
28224                            pagination = false;
28225                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST;
28226                            finderArgs = new Object[] { companyId, version, status };
28227                    }
28228                    else {
28229                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST;
28230                            finderArgs = new Object[] {
28231                                            companyId, version, status,
28232                                            
28233                                            start, end, orderByComparator
28234                                    };
28235                    }
28236    
28237                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
28238                                    finderArgs, this);
28239    
28240                    if ((list != null) && !list.isEmpty()) {
28241                            for (JournalArticle journalArticle : list) {
28242                                    if ((companyId != journalArticle.getCompanyId()) ||
28243                                                    (version != journalArticle.getVersion()) ||
28244                                                    (status != journalArticle.getStatus())) {
28245                                            list = null;
28246    
28247                                            break;
28248                                    }
28249                            }
28250                    }
28251    
28252                    if (list == null) {
28253                            StringBundler query = null;
28254    
28255                            if (orderByComparator != null) {
28256                                    query = new StringBundler(5 +
28257                                                    (orderByComparator.getOrderByFields().length * 3));
28258                            }
28259                            else {
28260                                    query = new StringBundler(5);
28261                            }
28262    
28263                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
28264    
28265                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
28266    
28267                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
28268    
28269                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
28270    
28271                            if (orderByComparator != null) {
28272                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
28273                                            orderByComparator);
28274                            }
28275                            else
28276                             if (pagination) {
28277                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
28278                            }
28279    
28280                            String sql = query.toString();
28281    
28282                            Session session = null;
28283    
28284                            try {
28285                                    session = openSession();
28286    
28287                                    Query q = session.createQuery(sql);
28288    
28289                                    QueryPos qPos = QueryPos.getInstance(q);
28290    
28291                                    qPos.add(companyId);
28292    
28293                                    qPos.add(version);
28294    
28295                                    qPos.add(status);
28296    
28297                                    if (!pagination) {
28298                                            list = (List<JournalArticle>)QueryUtil.list(q,
28299                                                            getDialect(), start, end, false);
28300    
28301                                            Collections.sort(list);
28302    
28303                                            list = Collections.unmodifiableList(list);
28304                                    }
28305                                    else {
28306                                            list = (List<JournalArticle>)QueryUtil.list(q,
28307                                                            getDialect(), start, end);
28308                                    }
28309    
28310                                    cacheResult(list);
28311    
28312                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
28313                            }
28314                            catch (Exception e) {
28315                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
28316    
28317                                    throw processException(e);
28318                            }
28319                            finally {
28320                                    closeSession(session);
28321                            }
28322                    }
28323    
28324                    return list;
28325            }
28326    
28327            /**
28328             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
28329             *
28330             * @param companyId the company ID
28331             * @param version the version
28332             * @param status the status
28333             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28334             * @return the first matching journal article
28335             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
28336             */
28337            @Override
28338            public JournalArticle findByC_V_ST_First(long companyId, double version,
28339                    int status, OrderByComparator<JournalArticle> orderByComparator)
28340                    throws NoSuchArticleException {
28341                    JournalArticle journalArticle = fetchByC_V_ST_First(companyId, version,
28342                                    status, orderByComparator);
28343    
28344                    if (journalArticle != null) {
28345                            return journalArticle;
28346                    }
28347    
28348                    StringBundler msg = new StringBundler(8);
28349    
28350                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
28351    
28352                    msg.append("companyId=");
28353                    msg.append(companyId);
28354    
28355                    msg.append(", version=");
28356                    msg.append(version);
28357    
28358                    msg.append(", status=");
28359                    msg.append(status);
28360    
28361                    msg.append(StringPool.CLOSE_CURLY_BRACE);
28362    
28363                    throw new NoSuchArticleException(msg.toString());
28364            }
28365    
28366            /**
28367             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
28368             *
28369             * @param companyId the company ID
28370             * @param version the version
28371             * @param status the status
28372             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28373             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
28374             */
28375            @Override
28376            public JournalArticle fetchByC_V_ST_First(long companyId, double version,
28377                    int status, OrderByComparator<JournalArticle> orderByComparator) {
28378                    List<JournalArticle> list = findByC_V_ST(companyId, version, status, 0,
28379                                    1, orderByComparator);
28380    
28381                    if (!list.isEmpty()) {
28382                            return list.get(0);
28383                    }
28384    
28385                    return null;
28386            }
28387    
28388            /**
28389             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
28390             *
28391             * @param companyId the company ID
28392             * @param version the version
28393             * @param status the status
28394             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28395             * @return the last matching journal article
28396             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
28397             */
28398            @Override
28399            public JournalArticle findByC_V_ST_Last(long companyId, double version,
28400                    int status, OrderByComparator<JournalArticle> orderByComparator)
28401                    throws NoSuchArticleException {
28402                    JournalArticle journalArticle = fetchByC_V_ST_Last(companyId, version,
28403                                    status, orderByComparator);
28404    
28405                    if (journalArticle != null) {
28406                            return journalArticle;
28407                    }
28408    
28409                    StringBundler msg = new StringBundler(8);
28410    
28411                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
28412    
28413                    msg.append("companyId=");
28414                    msg.append(companyId);
28415    
28416                    msg.append(", version=");
28417                    msg.append(version);
28418    
28419                    msg.append(", status=");
28420                    msg.append(status);
28421    
28422                    msg.append(StringPool.CLOSE_CURLY_BRACE);
28423    
28424                    throw new NoSuchArticleException(msg.toString());
28425            }
28426    
28427            /**
28428             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
28429             *
28430             * @param companyId the company ID
28431             * @param version the version
28432             * @param status the status
28433             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28434             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
28435             */
28436            @Override
28437            public JournalArticle fetchByC_V_ST_Last(long companyId, double version,
28438                    int status, OrderByComparator<JournalArticle> orderByComparator) {
28439                    int count = countByC_V_ST(companyId, version, status);
28440    
28441                    if (count == 0) {
28442                            return null;
28443                    }
28444    
28445                    List<JournalArticle> list = findByC_V_ST(companyId, version, status,
28446                                    count - 1, count, orderByComparator);
28447    
28448                    if (!list.isEmpty()) {
28449                            return list.get(0);
28450                    }
28451    
28452                    return null;
28453            }
28454    
28455            /**
28456             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
28457             *
28458             * @param id the primary key of the current journal article
28459             * @param companyId the company ID
28460             * @param version the version
28461             * @param status the status
28462             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28463             * @return the previous, current, and next journal article
28464             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
28465             */
28466            @Override
28467            public JournalArticle[] findByC_V_ST_PrevAndNext(long id, long companyId,
28468                    double version, int status,
28469                    OrderByComparator<JournalArticle> orderByComparator)
28470                    throws NoSuchArticleException {
28471                    JournalArticle journalArticle = findByPrimaryKey(id);
28472    
28473                    Session session = null;
28474    
28475                    try {
28476                            session = openSession();
28477    
28478                            JournalArticle[] array = new JournalArticleImpl[3];
28479    
28480                            array[0] = getByC_V_ST_PrevAndNext(session, journalArticle,
28481                                            companyId, version, status, orderByComparator, true);
28482    
28483                            array[1] = journalArticle;
28484    
28485                            array[2] = getByC_V_ST_PrevAndNext(session, journalArticle,
28486                                            companyId, version, status, orderByComparator, false);
28487    
28488                            return array;
28489                    }
28490                    catch (Exception e) {
28491                            throw processException(e);
28492                    }
28493                    finally {
28494                            closeSession(session);
28495                    }
28496            }
28497    
28498            protected JournalArticle getByC_V_ST_PrevAndNext(Session session,
28499                    JournalArticle journalArticle, long companyId, double version,
28500                    int status, OrderByComparator<JournalArticle> orderByComparator,
28501                    boolean previous) {
28502                    StringBundler query = null;
28503    
28504                    if (orderByComparator != null) {
28505                            query = new StringBundler(6 +
28506                                            (orderByComparator.getOrderByFields().length * 6));
28507                    }
28508                    else {
28509                            query = new StringBundler(3);
28510                    }
28511    
28512                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
28513    
28514                    query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
28515    
28516                    query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
28517    
28518                    query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
28519    
28520                    if (orderByComparator != null) {
28521                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
28522    
28523                            if (orderByConditionFields.length > 0) {
28524                                    query.append(WHERE_AND);
28525                            }
28526    
28527                            for (int i = 0; i < orderByConditionFields.length; i++) {
28528                                    query.append(_ORDER_BY_ENTITY_ALIAS);
28529                                    query.append(orderByConditionFields[i]);
28530    
28531                                    if ((i + 1) < orderByConditionFields.length) {
28532                                            if (orderByComparator.isAscending() ^ previous) {
28533                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
28534                                            }
28535                                            else {
28536                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
28537                                            }
28538                                    }
28539                                    else {
28540                                            if (orderByComparator.isAscending() ^ previous) {
28541                                                    query.append(WHERE_GREATER_THAN);
28542                                            }
28543                                            else {
28544                                                    query.append(WHERE_LESSER_THAN);
28545                                            }
28546                                    }
28547                            }
28548    
28549                            query.append(ORDER_BY_CLAUSE);
28550    
28551                            String[] orderByFields = orderByComparator.getOrderByFields();
28552    
28553                            for (int i = 0; i < orderByFields.length; i++) {
28554                                    query.append(_ORDER_BY_ENTITY_ALIAS);
28555                                    query.append(orderByFields[i]);
28556    
28557                                    if ((i + 1) < orderByFields.length) {
28558                                            if (orderByComparator.isAscending() ^ previous) {
28559                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
28560                                            }
28561                                            else {
28562                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
28563                                            }
28564                                    }
28565                                    else {
28566                                            if (orderByComparator.isAscending() ^ previous) {
28567                                                    query.append(ORDER_BY_ASC);
28568                                            }
28569                                            else {
28570                                                    query.append(ORDER_BY_DESC);
28571                                            }
28572                                    }
28573                            }
28574                    }
28575                    else {
28576                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
28577                    }
28578    
28579                    String sql = query.toString();
28580    
28581                    Query q = session.createQuery(sql);
28582    
28583                    q.setFirstResult(0);
28584                    q.setMaxResults(2);
28585    
28586                    QueryPos qPos = QueryPos.getInstance(q);
28587    
28588                    qPos.add(companyId);
28589    
28590                    qPos.add(version);
28591    
28592                    qPos.add(status);
28593    
28594                    if (orderByComparator != null) {
28595                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
28596    
28597                            for (Object value : values) {
28598                                    qPos.add(value);
28599                            }
28600                    }
28601    
28602                    List<JournalArticle> list = q.list();
28603    
28604                    if (list.size() == 2) {
28605                            return list.get(1);
28606                    }
28607                    else {
28608                            return null;
28609                    }
28610            }
28611    
28612            /**
28613             * Removes all the journal articles where companyId = &#63; and version = &#63; and status = &#63; from the database.
28614             *
28615             * @param companyId the company ID
28616             * @param version the version
28617             * @param status the status
28618             */
28619            @Override
28620            public void removeByC_V_ST(long companyId, double version, int status) {
28621                    for (JournalArticle journalArticle : findByC_V_ST(companyId, version,
28622                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
28623                            remove(journalArticle);
28624                    }
28625            }
28626    
28627            /**
28628             * Returns the number of journal articles where companyId = &#63; and version = &#63; and status = &#63;.
28629             *
28630             * @param companyId the company ID
28631             * @param version the version
28632             * @param status the status
28633             * @return the number of matching journal articles
28634             */
28635            @Override
28636            public int countByC_V_ST(long companyId, double version, int status) {
28637                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_V_ST;
28638    
28639                    Object[] finderArgs = new Object[] { companyId, version, status };
28640    
28641                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
28642                                    this);
28643    
28644                    if (count == null) {
28645                            StringBundler query = new StringBundler(4);
28646    
28647                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
28648    
28649                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
28650    
28651                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
28652    
28653                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
28654    
28655                            String sql = query.toString();
28656    
28657                            Session session = null;
28658    
28659                            try {
28660                                    session = openSession();
28661    
28662                                    Query q = session.createQuery(sql);
28663    
28664                                    QueryPos qPos = QueryPos.getInstance(q);
28665    
28666                                    qPos.add(companyId);
28667    
28668                                    qPos.add(version);
28669    
28670                                    qPos.add(status);
28671    
28672                                    count = (Long)q.uniqueResult();
28673    
28674                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
28675                            }
28676                            catch (Exception e) {
28677                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
28678    
28679                                    throw processException(e);
28680                            }
28681                            finally {
28682                                    closeSession(session);
28683                            }
28684                    }
28685    
28686                    return count.intValue();
28687            }
28688    
28689            private static final String _FINDER_COLUMN_C_V_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
28690            private static final String _FINDER_COLUMN_C_V_ST_VERSION_2 = "journalArticle.version = ? AND ";
28691            private static final String _FINDER_COLUMN_C_V_ST_STATUS_2 = "journalArticle.status = ?";
28692    
28693            public JournalArticlePersistenceImpl() {
28694                    setModelClass(JournalArticle.class);
28695            }
28696    
28697            /**
28698             * Caches the journal article in the entity cache if it is enabled.
28699             *
28700             * @param journalArticle the journal article
28701             */
28702            @Override
28703            public void cacheResult(JournalArticle journalArticle) {
28704                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28705                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
28706                            journalArticle);
28707    
28708                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
28709                            new Object[] { journalArticle.getUuid(), journalArticle.getGroupId() },
28710                            journalArticle);
28711    
28712                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
28713                            new Object[] {
28714                                    journalArticle.getGroupId(), journalArticle.getClassNameId(),
28715                                    journalArticle.getStructureId()
28716                            }, journalArticle);
28717    
28718                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
28719                            new Object[] {
28720                                    journalArticle.getGroupId(), journalArticle.getArticleId(),
28721                                    journalArticle.getVersion()
28722                            }, journalArticle);
28723    
28724                    journalArticle.resetOriginalValues();
28725            }
28726    
28727            /**
28728             * Caches the journal articles in the entity cache if it is enabled.
28729             *
28730             * @param journalArticles the journal articles
28731             */
28732            @Override
28733            public void cacheResult(List<JournalArticle> journalArticles) {
28734                    for (JournalArticle journalArticle : journalArticles) {
28735                            if (EntityCacheUtil.getResult(
28736                                                    JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28737                                                    JournalArticleImpl.class, journalArticle.getPrimaryKey()) == null) {
28738                                    cacheResult(journalArticle);
28739                            }
28740                            else {
28741                                    journalArticle.resetOriginalValues();
28742                            }
28743                    }
28744            }
28745    
28746            /**
28747             * Clears the cache for all journal articles.
28748             *
28749             * <p>
28750             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
28751             * </p>
28752             */
28753            @Override
28754            public void clearCache() {
28755                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
28756                            CacheRegistryUtil.clear(JournalArticleImpl.class.getName());
28757                    }
28758    
28759                    EntityCacheUtil.clearCache(JournalArticleImpl.class);
28760    
28761                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
28762                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
28763                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
28764            }
28765    
28766            /**
28767             * Clears the cache for the journal article.
28768             *
28769             * <p>
28770             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
28771             * </p>
28772             */
28773            @Override
28774            public void clearCache(JournalArticle journalArticle) {
28775                    EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28776                            JournalArticleImpl.class, journalArticle.getPrimaryKey());
28777    
28778                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
28779                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
28780    
28781                    clearUniqueFindersCache(journalArticle);
28782            }
28783    
28784            @Override
28785            public void clearCache(List<JournalArticle> journalArticles) {
28786                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
28787                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
28788    
28789                    for (JournalArticle journalArticle : journalArticles) {
28790                            EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28791                                    JournalArticleImpl.class, journalArticle.getPrimaryKey());
28792    
28793                            clearUniqueFindersCache(journalArticle);
28794                    }
28795            }
28796    
28797            protected void cacheUniqueFindersCache(JournalArticle journalArticle) {
28798                    if (journalArticle.isNew()) {
28799                            Object[] args = new Object[] {
28800                                            journalArticle.getUuid(), journalArticle.getGroupId()
28801                                    };
28802    
28803                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
28804                                    Long.valueOf(1));
28805                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
28806                                    journalArticle);
28807    
28808                            args = new Object[] {
28809                                            journalArticle.getGroupId(), journalArticle.getClassNameId(),
28810                                            journalArticle.getStructureId()
28811                                    };
28812    
28813                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S, args,
28814                                    Long.valueOf(1));
28815                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S, args,
28816                                    journalArticle);
28817    
28818                            args = new Object[] {
28819                                            journalArticle.getGroupId(), journalArticle.getArticleId(),
28820                                            journalArticle.getVersion()
28821                                    };
28822    
28823                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V, args,
28824                                    Long.valueOf(1));
28825                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V, args,
28826                                    journalArticle);
28827                    }
28828                    else {
28829                            JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
28830    
28831                            if ((journalArticleModelImpl.getColumnBitmask() &
28832                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
28833                                    Object[] args = new Object[] {
28834                                                    journalArticle.getUuid(), journalArticle.getGroupId()
28835                                            };
28836    
28837                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
28838                                            Long.valueOf(1));
28839                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
28840                                            journalArticle);
28841                            }
28842    
28843                            if ((journalArticleModelImpl.getColumnBitmask() &
28844                                            FINDER_PATH_FETCH_BY_G_C_S.getColumnBitmask()) != 0) {
28845                                    Object[] args = new Object[] {
28846                                                    journalArticle.getGroupId(),
28847                                                    journalArticle.getClassNameId(),
28848                                                    journalArticle.getStructureId()
28849                                            };
28850    
28851                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S, args,
28852                                            Long.valueOf(1));
28853                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S, args,
28854                                            journalArticle);
28855                            }
28856    
28857                            if ((journalArticleModelImpl.getColumnBitmask() &
28858                                            FINDER_PATH_FETCH_BY_G_A_V.getColumnBitmask()) != 0) {
28859                                    Object[] args = new Object[] {
28860                                                    journalArticle.getGroupId(),
28861                                                    journalArticle.getArticleId(),
28862                                                    journalArticle.getVersion()
28863                                            };
28864    
28865                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V, args,
28866                                            Long.valueOf(1));
28867                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V, args,
28868                                            journalArticle);
28869                            }
28870                    }
28871            }
28872    
28873            protected void clearUniqueFindersCache(JournalArticle journalArticle) {
28874                    JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
28875    
28876                    Object[] args = new Object[] {
28877                                    journalArticle.getUuid(), journalArticle.getGroupId()
28878                            };
28879    
28880                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
28881                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
28882    
28883                    if ((journalArticleModelImpl.getColumnBitmask() &
28884                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
28885                            args = new Object[] {
28886                                            journalArticleModelImpl.getOriginalUuid(),
28887                                            journalArticleModelImpl.getOriginalGroupId()
28888                                    };
28889    
28890                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
28891                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
28892                    }
28893    
28894                    args = new Object[] {
28895                                    journalArticle.getGroupId(), journalArticle.getClassNameId(),
28896                                    journalArticle.getStructureId()
28897                            };
28898    
28899                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
28900                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S, args);
28901    
28902                    if ((journalArticleModelImpl.getColumnBitmask() &
28903                                    FINDER_PATH_FETCH_BY_G_C_S.getColumnBitmask()) != 0) {
28904                            args = new Object[] {
28905                                            journalArticleModelImpl.getOriginalGroupId(),
28906                                            journalArticleModelImpl.getOriginalClassNameId(),
28907                                            journalArticleModelImpl.getOriginalStructureId()
28908                                    };
28909    
28910                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
28911                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S, args);
28912                    }
28913    
28914                    args = new Object[] {
28915                                    journalArticle.getGroupId(), journalArticle.getArticleId(),
28916                                    journalArticle.getVersion()
28917                            };
28918    
28919                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V, args);
28920                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V, args);
28921    
28922                    if ((journalArticleModelImpl.getColumnBitmask() &
28923                                    FINDER_PATH_FETCH_BY_G_A_V.getColumnBitmask()) != 0) {
28924                            args = new Object[] {
28925                                            journalArticleModelImpl.getOriginalGroupId(),
28926                                            journalArticleModelImpl.getOriginalArticleId(),
28927                                            journalArticleModelImpl.getOriginalVersion()
28928                                    };
28929    
28930                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V, args);
28931                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V, args);
28932                    }
28933            }
28934    
28935            /**
28936             * Creates a new journal article with the primary key. Does not add the journal article to the database.
28937             *
28938             * @param id the primary key for the new journal article
28939             * @return the new journal article
28940             */
28941            @Override
28942            public JournalArticle create(long id) {
28943                    JournalArticle journalArticle = new JournalArticleImpl();
28944    
28945                    journalArticle.setNew(true);
28946                    journalArticle.setPrimaryKey(id);
28947    
28948                    String uuid = PortalUUIDUtil.generate();
28949    
28950                    journalArticle.setUuid(uuid);
28951    
28952                    return journalArticle;
28953            }
28954    
28955            /**
28956             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
28957             *
28958             * @param id the primary key of the journal article
28959             * @return the journal article that was removed
28960             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
28961             */
28962            @Override
28963            public JournalArticle remove(long id) throws NoSuchArticleException {
28964                    return remove((Serializable)id);
28965            }
28966    
28967            /**
28968             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
28969             *
28970             * @param primaryKey the primary key of the journal article
28971             * @return the journal article that was removed
28972             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
28973             */
28974            @Override
28975            public JournalArticle remove(Serializable primaryKey)
28976                    throws NoSuchArticleException {
28977                    Session session = null;
28978    
28979                    try {
28980                            session = openSession();
28981    
28982                            JournalArticle journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
28983                                            primaryKey);
28984    
28985                            if (journalArticle == null) {
28986                                    if (_log.isWarnEnabled()) {
28987                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
28988                                    }
28989    
28990                                    throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
28991                                            primaryKey);
28992                            }
28993    
28994                            return remove(journalArticle);
28995                    }
28996                    catch (NoSuchArticleException nsee) {
28997                            throw nsee;
28998                    }
28999                    catch (Exception e) {
29000                            throw processException(e);
29001                    }
29002                    finally {
29003                            closeSession(session);
29004                    }
29005            }
29006    
29007            @Override
29008            protected JournalArticle removeImpl(JournalArticle journalArticle) {
29009                    journalArticle = toUnwrappedModel(journalArticle);
29010    
29011                    Session session = null;
29012    
29013                    try {
29014                            session = openSession();
29015    
29016                            if (!session.contains(journalArticle)) {
29017                                    journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
29018                                                    journalArticle.getPrimaryKeyObj());
29019                            }
29020    
29021                            if (journalArticle != null) {
29022                                    session.delete(journalArticle);
29023                            }
29024                    }
29025                    catch (Exception e) {
29026                            throw processException(e);
29027                    }
29028                    finally {
29029                            closeSession(session);
29030                    }
29031    
29032                    if (journalArticle != null) {
29033                            clearCache(journalArticle);
29034                    }
29035    
29036                    return journalArticle;
29037            }
29038    
29039            @Override
29040            public JournalArticle updateImpl(
29041                    com.liferay.portlet.journal.model.JournalArticle journalArticle) {
29042                    journalArticle = toUnwrappedModel(journalArticle);
29043    
29044                    boolean isNew = journalArticle.isNew();
29045    
29046                    JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
29047    
29048                    if (Validator.isNull(journalArticle.getUuid())) {
29049                            String uuid = PortalUUIDUtil.generate();
29050    
29051                            journalArticle.setUuid(uuid);
29052                    }
29053    
29054                    Session session = null;
29055    
29056                    try {
29057                            session = openSession();
29058    
29059                            if (journalArticle.isNew()) {
29060                                    session.save(journalArticle);
29061    
29062                                    journalArticle.setNew(false);
29063                            }
29064                            else {
29065                                    session.merge(journalArticle);
29066                            }
29067                    }
29068                    catch (Exception e) {
29069                            throw processException(e);
29070                    }
29071                    finally {
29072                            closeSession(session);
29073                    }
29074    
29075                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
29076    
29077                    if (isNew || !JournalArticleModelImpl.COLUMN_BITMASK_ENABLED) {
29078                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
29079                    }
29080    
29081                    else {
29082                            if ((journalArticleModelImpl.getColumnBitmask() &
29083                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
29084                                    Object[] args = new Object[] {
29085                                                    journalArticleModelImpl.getOriginalUuid()
29086                                            };
29087    
29088                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
29089                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
29090                                            args);
29091    
29092                                    args = new Object[] { journalArticleModelImpl.getUuid() };
29093    
29094                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
29095                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
29096                                            args);
29097                            }
29098    
29099                            if ((journalArticleModelImpl.getColumnBitmask() &
29100                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
29101                                    Object[] args = new Object[] {
29102                                                    journalArticleModelImpl.getOriginalUuid(),
29103                                                    journalArticleModelImpl.getOriginalCompanyId()
29104                                            };
29105    
29106                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
29107                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
29108                                            args);
29109    
29110                                    args = new Object[] {
29111                                                    journalArticleModelImpl.getUuid(),
29112                                                    journalArticleModelImpl.getCompanyId()
29113                                            };
29114    
29115                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
29116                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
29117                                            args);
29118                            }
29119    
29120                            if ((journalArticleModelImpl.getColumnBitmask() &
29121                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY.getColumnBitmask()) != 0) {
29122                                    Object[] args = new Object[] {
29123                                                    journalArticleModelImpl.getOriginalResourcePrimKey()
29124                                            };
29125    
29126                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
29127                                            args);
29128                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
29129                                            args);
29130    
29131                                    args = new Object[] { journalArticleModelImpl.getResourcePrimKey() };
29132    
29133                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
29134                                            args);
29135                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
29136                                            args);
29137                            }
29138    
29139                            if ((journalArticleModelImpl.getColumnBitmask() &
29140                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
29141                                    Object[] args = new Object[] {
29142                                                    journalArticleModelImpl.getOriginalGroupId()
29143                                            };
29144    
29145                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
29146                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
29147                                            args);
29148    
29149                                    args = new Object[] { journalArticleModelImpl.getGroupId() };
29150    
29151                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
29152                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
29153                                            args);
29154                            }
29155    
29156                            if ((journalArticleModelImpl.getColumnBitmask() &
29157                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
29158                                    Object[] args = new Object[] {
29159                                                    journalArticleModelImpl.getOriginalCompanyId()
29160                                            };
29161    
29162                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
29163                                            args);
29164                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
29165                                            args);
29166    
29167                                    args = new Object[] { journalArticleModelImpl.getCompanyId() };
29168    
29169                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
29170                                            args);
29171                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
29172                                            args);
29173                            }
29174    
29175                            if ((journalArticleModelImpl.getColumnBitmask() &
29176                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID.getColumnBitmask()) != 0) {
29177                                    Object[] args = new Object[] {
29178                                                    journalArticleModelImpl.getOriginalStructureId()
29179                                            };
29180    
29181                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
29182                                            args);
29183                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
29184                                            args);
29185    
29186                                    args = new Object[] { journalArticleModelImpl.getStructureId() };
29187    
29188                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
29189                                            args);
29190                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
29191                                            args);
29192                            }
29193    
29194                            if ((journalArticleModelImpl.getColumnBitmask() &
29195                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID.getColumnBitmask()) != 0) {
29196                                    Object[] args = new Object[] {
29197                                                    journalArticleModelImpl.getOriginalTemplateId()
29198                                            };
29199    
29200                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
29201                                            args);
29202                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID,
29203                                            args);
29204    
29205                                    args = new Object[] { journalArticleModelImpl.getTemplateId() };
29206    
29207                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
29208                                            args);
29209                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID,
29210                                            args);
29211                            }
29212    
29213                            if ((journalArticleModelImpl.getColumnBitmask() &
29214                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID.getColumnBitmask()) != 0) {
29215                                    Object[] args = new Object[] {
29216                                                    journalArticleModelImpl.getOriginalLayoutUuid()
29217                                            };
29218    
29219                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
29220                                            args);
29221                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
29222                                            args);
29223    
29224                                    args = new Object[] { journalArticleModelImpl.getLayoutUuid() };
29225    
29226                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
29227                                            args);
29228                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
29229                                            args);
29230                            }
29231    
29232                            if ((journalArticleModelImpl.getColumnBitmask() &
29233                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID.getColumnBitmask()) != 0) {
29234                                    Object[] args = new Object[] {
29235                                                    journalArticleModelImpl.getOriginalSmallImageId()
29236                                            };
29237    
29238                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
29239                                            args);
29240                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
29241                                            args);
29242    
29243                                    args = new Object[] { journalArticleModelImpl.getSmallImageId() };
29244    
29245                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
29246                                            args);
29247                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
29248                                            args);
29249                            }
29250    
29251                            if ((journalArticleModelImpl.getColumnBitmask() &
29252                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I.getColumnBitmask()) != 0) {
29253                                    Object[] args = new Object[] {
29254                                                    journalArticleModelImpl.getOriginalResourcePrimKey(),
29255                                                    journalArticleModelImpl.getOriginalIndexable()
29256                                            };
29257    
29258                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_I, args);
29259                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I,
29260                                            args);
29261    
29262                                    args = new Object[] {
29263                                                    journalArticleModelImpl.getResourcePrimKey(),
29264                                                    journalArticleModelImpl.getIndexable()
29265                                            };
29266    
29267                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_I, args);
29268                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I,
29269                                            args);
29270                            }
29271    
29272                            if ((journalArticleModelImpl.getColumnBitmask() &
29273                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST.getColumnBitmask()) != 0) {
29274                                    Object[] args = new Object[] {
29275                                                    journalArticleModelImpl.getOriginalResourcePrimKey(),
29276                                                    journalArticleModelImpl.getOriginalStatus()
29277                                            };
29278    
29279                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
29280                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
29281                                            args);
29282    
29283                                    args = new Object[] {
29284                                                    journalArticleModelImpl.getResourcePrimKey(),
29285                                                    journalArticleModelImpl.getStatus()
29286                                            };
29287    
29288                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
29289                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
29290                                            args);
29291                            }
29292    
29293                            if ((journalArticleModelImpl.getColumnBitmask() &
29294                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) {
29295                                    Object[] args = new Object[] {
29296                                                    journalArticleModelImpl.getOriginalGroupId(),
29297                                                    journalArticleModelImpl.getOriginalUserId()
29298                                            };
29299    
29300                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
29301                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
29302                                            args);
29303    
29304                                    args = new Object[] {
29305                                                    journalArticleModelImpl.getGroupId(),
29306                                                    journalArticleModelImpl.getUserId()
29307                                            };
29308    
29309                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
29310                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
29311                                            args);
29312                            }
29313    
29314                            if ((journalArticleModelImpl.getColumnBitmask() &
29315                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F.getColumnBitmask()) != 0) {
29316                                    Object[] args = new Object[] {
29317                                                    journalArticleModelImpl.getOriginalGroupId(),
29318                                                    journalArticleModelImpl.getOriginalFolderId()
29319                                            };
29320    
29321                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
29322                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
29323                                            args);
29324    
29325                                    args = new Object[] {
29326                                                    journalArticleModelImpl.getGroupId(),
29327                                                    journalArticleModelImpl.getFolderId()
29328                                            };
29329    
29330                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
29331                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
29332                                            args);
29333                            }
29334    
29335                            if ((journalArticleModelImpl.getColumnBitmask() &
29336                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A.getColumnBitmask()) != 0) {
29337                                    Object[] args = new Object[] {
29338                                                    journalArticleModelImpl.getOriginalGroupId(),
29339                                                    journalArticleModelImpl.getOriginalArticleId()
29340                                            };
29341    
29342                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
29343                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
29344                                            args);
29345    
29346                                    args = new Object[] {
29347                                                    journalArticleModelImpl.getGroupId(),
29348                                                    journalArticleModelImpl.getArticleId()
29349                                            };
29350    
29351                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
29352                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
29353                                            args);
29354                            }
29355    
29356                            if ((journalArticleModelImpl.getColumnBitmask() &
29357                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT.getColumnBitmask()) != 0) {
29358                                    Object[] args = new Object[] {
29359                                                    journalArticleModelImpl.getOriginalGroupId(),
29360                                                    journalArticleModelImpl.getOriginalUrlTitle()
29361                                            };
29362    
29363                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
29364                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
29365                                            args);
29366    
29367                                    args = new Object[] {
29368                                                    journalArticleModelImpl.getGroupId(),
29369                                                    journalArticleModelImpl.getUrlTitle()
29370                                            };
29371    
29372                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
29373                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
29374                                            args);
29375                            }
29376    
29377                            if ((journalArticleModelImpl.getColumnBitmask() &
29378                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
29379                                    Object[] args = new Object[] {
29380                                                    journalArticleModelImpl.getOriginalGroupId(),
29381                                                    journalArticleModelImpl.getOriginalStructureId()
29382                                            };
29383    
29384                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
29385                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
29386                                            args);
29387    
29388                                    args = new Object[] {
29389                                                    journalArticleModelImpl.getGroupId(),
29390                                                    journalArticleModelImpl.getStructureId()
29391                                            };
29392    
29393                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
29394                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
29395                                            args);
29396                            }
29397    
29398                            if ((journalArticleModelImpl.getColumnBitmask() &
29399                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T.getColumnBitmask()) != 0) {
29400                                    Object[] args = new Object[] {
29401                                                    journalArticleModelImpl.getOriginalGroupId(),
29402                                                    journalArticleModelImpl.getOriginalTemplateId()
29403                                            };
29404    
29405                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
29406                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
29407                                            args);
29408    
29409                                    args = new Object[] {
29410                                                    journalArticleModelImpl.getGroupId(),
29411                                                    journalArticleModelImpl.getTemplateId()
29412                                            };
29413    
29414                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
29415                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
29416                                            args);
29417                            }
29418    
29419                            if ((journalArticleModelImpl.getColumnBitmask() &
29420                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L.getColumnBitmask()) != 0) {
29421                                    Object[] args = new Object[] {
29422                                                    journalArticleModelImpl.getOriginalGroupId(),
29423                                                    journalArticleModelImpl.getOriginalLayoutUuid()
29424                                            };
29425    
29426                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
29427                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
29428                                            args);
29429    
29430                                    args = new Object[] {
29431                                                    journalArticleModelImpl.getGroupId(),
29432                                                    journalArticleModelImpl.getLayoutUuid()
29433                                            };
29434    
29435                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
29436                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
29437                                            args);
29438                            }
29439    
29440                            if ((journalArticleModelImpl.getColumnBitmask() &
29441                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST.getColumnBitmask()) != 0) {
29442                                    Object[] args = new Object[] {
29443                                                    journalArticleModelImpl.getOriginalGroupId(),
29444                                                    journalArticleModelImpl.getOriginalStatus()
29445                                            };
29446    
29447                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
29448                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
29449                                            args);
29450    
29451                                    args = new Object[] {
29452                                                    journalArticleModelImpl.getGroupId(),
29453                                                    journalArticleModelImpl.getStatus()
29454                                            };
29455    
29456                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
29457                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
29458                                            args);
29459                            }
29460    
29461                            if ((journalArticleModelImpl.getColumnBitmask() &
29462                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V.getColumnBitmask()) != 0) {
29463                                    Object[] args = new Object[] {
29464                                                    journalArticleModelImpl.getOriginalCompanyId(),
29465                                                    journalArticleModelImpl.getOriginalVersion()
29466                                            };
29467    
29468                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
29469                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
29470                                            args);
29471    
29472                                    args = new Object[] {
29473                                                    journalArticleModelImpl.getCompanyId(),
29474                                                    journalArticleModelImpl.getVersion()
29475                                            };
29476    
29477                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
29478                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
29479                                            args);
29480                            }
29481    
29482                            if ((journalArticleModelImpl.getColumnBitmask() &
29483                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST.getColumnBitmask()) != 0) {
29484                                    Object[] args = new Object[] {
29485                                                    journalArticleModelImpl.getOriginalCompanyId(),
29486                                                    journalArticleModelImpl.getOriginalStatus()
29487                                            };
29488    
29489                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
29490                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
29491                                            args);
29492    
29493                                    args = new Object[] {
29494                                                    journalArticleModelImpl.getCompanyId(),
29495                                                    journalArticleModelImpl.getStatus()
29496                                            };
29497    
29498                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
29499                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
29500                                            args);
29501                            }
29502    
29503                            if ((journalArticleModelImpl.getColumnBitmask() &
29504                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T.getColumnBitmask()) != 0) {
29505                                    Object[] args = new Object[] {
29506                                                    journalArticleModelImpl.getOriginalClassNameId(),
29507                                                    journalArticleModelImpl.getOriginalTemplateId()
29508                                            };
29509    
29510                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_T, args);
29511                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T,
29512                                            args);
29513    
29514                                    args = new Object[] {
29515                                                    journalArticleModelImpl.getClassNameId(),
29516                                                    journalArticleModelImpl.getTemplateId()
29517                                            };
29518    
29519                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_T, args);
29520                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T,
29521                                            args);
29522                            }
29523    
29524                            if ((journalArticleModelImpl.getColumnBitmask() &
29525                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S.getColumnBitmask()) != 0) {
29526                                    Object[] args = new Object[] {
29527                                                    journalArticleModelImpl.getOriginalResourcePrimKey(),
29528                                                    journalArticleModelImpl.getOriginalIndexable(),
29529                                                    journalArticleModelImpl.getOriginalStatus()
29530                                            };
29531    
29532                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_I_S, args);
29533                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S,
29534                                            args);
29535    
29536                                    args = new Object[] {
29537                                                    journalArticleModelImpl.getResourcePrimKey(),
29538                                                    journalArticleModelImpl.getIndexable(),
29539                                                    journalArticleModelImpl.getStatus()
29540                                            };
29541    
29542                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_I_S, args);
29543                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S,
29544                                            args);
29545                            }
29546    
29547                            if ((journalArticleModelImpl.getColumnBitmask() &
29548                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C.getColumnBitmask()) != 0) {
29549                                    Object[] args = new Object[] {
29550                                                    journalArticleModelImpl.getOriginalGroupId(),
29551                                                    journalArticleModelImpl.getOriginalUserId(),
29552                                                    journalArticleModelImpl.getOriginalClassNameId()
29553                                            };
29554    
29555                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_C, args);
29556                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C,
29557                                            args);
29558    
29559                                    args = new Object[] {
29560                                                    journalArticleModelImpl.getGroupId(),
29561                                                    journalArticleModelImpl.getUserId(),
29562                                                    journalArticleModelImpl.getClassNameId()
29563                                            };
29564    
29565                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_C, args);
29566                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C,
29567                                            args);
29568                            }
29569    
29570                            if ((journalArticleModelImpl.getColumnBitmask() &
29571                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST.getColumnBitmask()) != 0) {
29572                                    Object[] args = new Object[] {
29573                                                    journalArticleModelImpl.getOriginalGroupId(),
29574                                                    journalArticleModelImpl.getOriginalFolderId(),
29575                                                    journalArticleModelImpl.getOriginalStatus()
29576                                            };
29577    
29578                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_ST, args);
29579                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST,
29580                                            args);
29581    
29582                                    args = new Object[] {
29583                                                    journalArticleModelImpl.getGroupId(),
29584                                                    journalArticleModelImpl.getFolderId(),
29585                                                    journalArticleModelImpl.getStatus()
29586                                            };
29587    
29588                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_ST, args);
29589                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST,
29590                                            args);
29591                            }
29592    
29593                            if ((journalArticleModelImpl.getColumnBitmask() &
29594                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C.getColumnBitmask()) != 0) {
29595                                    Object[] args = new Object[] {
29596                                                    journalArticleModelImpl.getOriginalGroupId(),
29597                                                    journalArticleModelImpl.getOriginalClassNameId(),
29598                                                    journalArticleModelImpl.getOriginalClassPK()
29599                                            };
29600    
29601                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
29602                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
29603                                            args);
29604    
29605                                    args = new Object[] {
29606                                                    journalArticleModelImpl.getGroupId(),
29607                                                    journalArticleModelImpl.getClassNameId(),
29608                                                    journalArticleModelImpl.getClassPK()
29609                                            };
29610    
29611                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
29612                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
29613                                            args);
29614                            }
29615    
29616                            if ((journalArticleModelImpl.getColumnBitmask() &
29617                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T.getColumnBitmask()) != 0) {
29618                                    Object[] args = new Object[] {
29619                                                    journalArticleModelImpl.getOriginalGroupId(),
29620                                                    journalArticleModelImpl.getOriginalClassNameId(),
29621                                                    journalArticleModelImpl.getOriginalTemplateId()
29622                                            };
29623    
29624                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
29625                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
29626                                            args);
29627    
29628                                    args = new Object[] {
29629                                                    journalArticleModelImpl.getGroupId(),
29630                                                    journalArticleModelImpl.getClassNameId(),
29631                                                    journalArticleModelImpl.getTemplateId()
29632                                            };
29633    
29634                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
29635                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
29636                                            args);
29637                            }
29638    
29639                            if ((journalArticleModelImpl.getColumnBitmask() &
29640                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L.getColumnBitmask()) != 0) {
29641                                    Object[] args = new Object[] {
29642                                                    journalArticleModelImpl.getOriginalGroupId(),
29643                                                    journalArticleModelImpl.getOriginalClassNameId(),
29644                                                    journalArticleModelImpl.getOriginalLayoutUuid()
29645                                            };
29646    
29647                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
29648                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
29649                                            args);
29650    
29651                                    args = new Object[] {
29652                                                    journalArticleModelImpl.getGroupId(),
29653                                                    journalArticleModelImpl.getClassNameId(),
29654                                                    journalArticleModelImpl.getLayoutUuid()
29655                                            };
29656    
29657                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
29658                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
29659                                            args);
29660                            }
29661    
29662                            if ((journalArticleModelImpl.getColumnBitmask() &
29663                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST.getColumnBitmask()) != 0) {
29664                                    Object[] args = new Object[] {
29665                                                    journalArticleModelImpl.getOriginalGroupId(),
29666                                                    journalArticleModelImpl.getOriginalArticleId(),
29667                                                    journalArticleModelImpl.getOriginalStatus()
29668                                            };
29669    
29670                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
29671                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
29672                                            args);
29673    
29674                                    args = new Object[] {
29675                                                    journalArticleModelImpl.getGroupId(),
29676                                                    journalArticleModelImpl.getArticleId(),
29677                                                    journalArticleModelImpl.getStatus()
29678                                            };
29679    
29680                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
29681                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
29682                                            args);
29683                            }
29684    
29685                            if ((journalArticleModelImpl.getColumnBitmask() &
29686                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST.getColumnBitmask()) != 0) {
29687                                    Object[] args = new Object[] {
29688                                                    journalArticleModelImpl.getOriginalGroupId(),
29689                                                    journalArticleModelImpl.getOriginalUrlTitle(),
29690                                                    journalArticleModelImpl.getOriginalStatus()
29691                                            };
29692    
29693                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
29694                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
29695                                            args);
29696    
29697                                    args = new Object[] {
29698                                                    journalArticleModelImpl.getGroupId(),
29699                                                    journalArticleModelImpl.getUrlTitle(),
29700                                                    journalArticleModelImpl.getStatus()
29701                                            };
29702    
29703                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
29704                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
29705                                            args);
29706                            }
29707    
29708                            if ((journalArticleModelImpl.getColumnBitmask() &
29709                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST.getColumnBitmask()) != 0) {
29710                                    Object[] args = new Object[] {
29711                                                    journalArticleModelImpl.getOriginalCompanyId(),
29712                                                    journalArticleModelImpl.getOriginalVersion(),
29713                                                    journalArticleModelImpl.getOriginalStatus()
29714                                            };
29715    
29716                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
29717                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
29718                                            args);
29719    
29720                                    args = new Object[] {
29721                                                    journalArticleModelImpl.getCompanyId(),
29722                                                    journalArticleModelImpl.getVersion(),
29723                                                    journalArticleModelImpl.getStatus()
29724                                            };
29725    
29726                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
29727                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
29728                                            args);
29729                            }
29730                    }
29731    
29732                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
29733                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
29734                            journalArticle, false);
29735    
29736                    clearUniqueFindersCache(journalArticle);
29737                    cacheUniqueFindersCache(journalArticle);
29738    
29739                    journalArticle.resetOriginalValues();
29740    
29741                    return journalArticle;
29742            }
29743    
29744            protected JournalArticle toUnwrappedModel(JournalArticle journalArticle) {
29745                    if (journalArticle instanceof JournalArticleImpl) {
29746                            return journalArticle;
29747                    }
29748    
29749                    JournalArticleImpl journalArticleImpl = new JournalArticleImpl();
29750    
29751                    journalArticleImpl.setNew(journalArticle.isNew());
29752                    journalArticleImpl.setPrimaryKey(journalArticle.getPrimaryKey());
29753    
29754                    journalArticleImpl.setUuid(journalArticle.getUuid());
29755                    journalArticleImpl.setId(journalArticle.getId());
29756                    journalArticleImpl.setResourcePrimKey(journalArticle.getResourcePrimKey());
29757                    journalArticleImpl.setGroupId(journalArticle.getGroupId());
29758                    journalArticleImpl.setCompanyId(journalArticle.getCompanyId());
29759                    journalArticleImpl.setUserId(journalArticle.getUserId());
29760                    journalArticleImpl.setUserName(journalArticle.getUserName());
29761                    journalArticleImpl.setCreateDate(journalArticle.getCreateDate());
29762                    journalArticleImpl.setModifiedDate(journalArticle.getModifiedDate());
29763                    journalArticleImpl.setFolderId(journalArticle.getFolderId());
29764                    journalArticleImpl.setClassNameId(journalArticle.getClassNameId());
29765                    journalArticleImpl.setClassPK(journalArticle.getClassPK());
29766                    journalArticleImpl.setTreePath(journalArticle.getTreePath());
29767                    journalArticleImpl.setArticleId(journalArticle.getArticleId());
29768                    journalArticleImpl.setVersion(journalArticle.getVersion());
29769                    journalArticleImpl.setTitle(journalArticle.getTitle());
29770                    journalArticleImpl.setUrlTitle(journalArticle.getUrlTitle());
29771                    journalArticleImpl.setDescription(journalArticle.getDescription());
29772                    journalArticleImpl.setContent(journalArticle.getContent());
29773                    journalArticleImpl.setType(journalArticle.getType());
29774                    journalArticleImpl.setStructureId(journalArticle.getStructureId());
29775                    journalArticleImpl.setTemplateId(journalArticle.getTemplateId());
29776                    journalArticleImpl.setLayoutUuid(journalArticle.getLayoutUuid());
29777                    journalArticleImpl.setDisplayDate(journalArticle.getDisplayDate());
29778                    journalArticleImpl.setExpirationDate(journalArticle.getExpirationDate());
29779                    journalArticleImpl.setReviewDate(journalArticle.getReviewDate());
29780                    journalArticleImpl.setIndexable(journalArticle.isIndexable());
29781                    journalArticleImpl.setSmallImage(journalArticle.isSmallImage());
29782                    journalArticleImpl.setSmallImageId(journalArticle.getSmallImageId());
29783                    journalArticleImpl.setSmallImageURL(journalArticle.getSmallImageURL());
29784                    journalArticleImpl.setStatus(journalArticle.getStatus());
29785                    journalArticleImpl.setStatusByUserId(journalArticle.getStatusByUserId());
29786                    journalArticleImpl.setStatusByUserName(journalArticle.getStatusByUserName());
29787                    journalArticleImpl.setStatusDate(journalArticle.getStatusDate());
29788    
29789                    return journalArticleImpl;
29790            }
29791    
29792            /**
29793             * Returns the journal article with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
29794             *
29795             * @param primaryKey the primary key of the journal article
29796             * @return the journal article
29797             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
29798             */
29799            @Override
29800            public JournalArticle findByPrimaryKey(Serializable primaryKey)
29801                    throws NoSuchArticleException {
29802                    JournalArticle journalArticle = fetchByPrimaryKey(primaryKey);
29803    
29804                    if (journalArticle == null) {
29805                            if (_log.isWarnEnabled()) {
29806                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
29807                            }
29808    
29809                            throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
29810                                    primaryKey);
29811                    }
29812    
29813                    return journalArticle;
29814            }
29815    
29816            /**
29817             * Returns the journal article with the primary key or throws a {@link com.liferay.portlet.journal.NoSuchArticleException} if it could not be found.
29818             *
29819             * @param id the primary key of the journal article
29820             * @return the journal article
29821             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
29822             */
29823            @Override
29824            public JournalArticle findByPrimaryKey(long id)
29825                    throws NoSuchArticleException {
29826                    return findByPrimaryKey((Serializable)id);
29827            }
29828    
29829            /**
29830             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
29831             *
29832             * @param primaryKey the primary key of the journal article
29833             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
29834             */
29835            @Override
29836            public JournalArticle fetchByPrimaryKey(Serializable primaryKey) {
29837                    JournalArticle journalArticle = (JournalArticle)EntityCacheUtil.getResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
29838                                    JournalArticleImpl.class, primaryKey);
29839    
29840                    if (journalArticle == _nullJournalArticle) {
29841                            return null;
29842                    }
29843    
29844                    if (journalArticle == null) {
29845                            Session session = null;
29846    
29847                            try {
29848                                    session = openSession();
29849    
29850                                    journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
29851                                                    primaryKey);
29852    
29853                                    if (journalArticle != null) {
29854                                            cacheResult(journalArticle);
29855                                    }
29856                                    else {
29857                                            EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
29858                                                    JournalArticleImpl.class, primaryKey,
29859                                                    _nullJournalArticle);
29860                                    }
29861                            }
29862                            catch (Exception e) {
29863                                    EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
29864                                            JournalArticleImpl.class, primaryKey);
29865    
29866                                    throw processException(e);
29867                            }
29868                            finally {
29869                                    closeSession(session);
29870                            }
29871                    }
29872    
29873                    return journalArticle;
29874            }
29875    
29876            /**
29877             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
29878             *
29879             * @param id the primary key of the journal article
29880             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
29881             */
29882            @Override
29883            public JournalArticle fetchByPrimaryKey(long id) {
29884                    return fetchByPrimaryKey((Serializable)id);
29885            }
29886    
29887            @Override
29888            public Map<Serializable, JournalArticle> fetchByPrimaryKeys(
29889                    Set<Serializable> primaryKeys) {
29890                    if (primaryKeys.isEmpty()) {
29891                            return Collections.emptyMap();
29892                    }
29893    
29894                    Map<Serializable, JournalArticle> map = new HashMap<Serializable, JournalArticle>();
29895    
29896                    if (primaryKeys.size() == 1) {
29897                            Iterator<Serializable> iterator = primaryKeys.iterator();
29898    
29899                            Serializable primaryKey = iterator.next();
29900    
29901                            JournalArticle journalArticle = fetchByPrimaryKey(primaryKey);
29902    
29903                            if (journalArticle != null) {
29904                                    map.put(primaryKey, journalArticle);
29905                            }
29906    
29907                            return map;
29908                    }
29909    
29910                    Set<Serializable> uncachedPrimaryKeys = null;
29911    
29912                    for (Serializable primaryKey : primaryKeys) {
29913                            JournalArticle journalArticle = (JournalArticle)EntityCacheUtil.getResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
29914                                            JournalArticleImpl.class, primaryKey);
29915    
29916                            if (journalArticle == null) {
29917                                    if (uncachedPrimaryKeys == null) {
29918                                            uncachedPrimaryKeys = new HashSet<Serializable>();
29919                                    }
29920    
29921                                    uncachedPrimaryKeys.add(primaryKey);
29922                            }
29923                            else {
29924                                    map.put(primaryKey, journalArticle);
29925                            }
29926                    }
29927    
29928                    if (uncachedPrimaryKeys == null) {
29929                            return map;
29930                    }
29931    
29932                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
29933                                    1);
29934    
29935                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE_PKS_IN);
29936    
29937                    for (Serializable primaryKey : uncachedPrimaryKeys) {
29938                            query.append(String.valueOf(primaryKey));
29939    
29940                            query.append(StringPool.COMMA);
29941                    }
29942    
29943                    query.setIndex(query.index() - 1);
29944    
29945                    query.append(StringPool.CLOSE_PARENTHESIS);
29946    
29947                    String sql = query.toString();
29948    
29949                    Session session = null;
29950    
29951                    try {
29952                            session = openSession();
29953    
29954                            Query q = session.createQuery(sql);
29955    
29956                            for (JournalArticle journalArticle : (List<JournalArticle>)q.list()) {
29957                                    map.put(journalArticle.getPrimaryKeyObj(), journalArticle);
29958    
29959                                    cacheResult(journalArticle);
29960    
29961                                    uncachedPrimaryKeys.remove(journalArticle.getPrimaryKeyObj());
29962                            }
29963    
29964                            for (Serializable primaryKey : uncachedPrimaryKeys) {
29965                                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
29966                                            JournalArticleImpl.class, primaryKey, _nullJournalArticle);
29967                            }
29968                    }
29969                    catch (Exception e) {
29970                            throw processException(e);
29971                    }
29972                    finally {
29973                            closeSession(session);
29974                    }
29975    
29976                    return map;
29977            }
29978    
29979            /**
29980             * Returns all the journal articles.
29981             *
29982             * @return the journal articles
29983             */
29984            @Override
29985            public List<JournalArticle> findAll() {
29986                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
29987            }
29988    
29989            /**
29990             * Returns a range of all the journal articles.
29991             *
29992             * <p>
29993             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
29994             * </p>
29995             *
29996             * @param start the lower bound of the range of journal articles
29997             * @param end the upper bound of the range of journal articles (not inclusive)
29998             * @return the range of journal articles
29999             */
30000            @Override
30001            public List<JournalArticle> findAll(int start, int end) {
30002                    return findAll(start, end, null);
30003            }
30004    
30005            /**
30006             * Returns an ordered range of all the journal articles.
30007             *
30008             * <p>
30009             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.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.
30010             * </p>
30011             *
30012             * @param start the lower bound of the range of journal articles
30013             * @param end the upper bound of the range of journal articles (not inclusive)
30014             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
30015             * @return the ordered range of journal articles
30016             */
30017            @Override
30018            public List<JournalArticle> findAll(int start, int end,
30019                    OrderByComparator<JournalArticle> orderByComparator) {
30020                    boolean pagination = true;
30021                    FinderPath finderPath = null;
30022                    Object[] finderArgs = null;
30023    
30024                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
30025                                    (orderByComparator == null)) {
30026                            pagination = false;
30027                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
30028                            finderArgs = FINDER_ARGS_EMPTY;
30029                    }
30030                    else {
30031                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
30032                            finderArgs = new Object[] { start, end, orderByComparator };
30033                    }
30034    
30035                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
30036                                    finderArgs, this);
30037    
30038                    if (list == null) {
30039                            StringBundler query = null;
30040                            String sql = null;
30041    
30042                            if (orderByComparator != null) {
30043                                    query = new StringBundler(2 +
30044                                                    (orderByComparator.getOrderByFields().length * 3));
30045    
30046                                    query.append(_SQL_SELECT_JOURNALARTICLE);
30047    
30048                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
30049                                            orderByComparator);
30050    
30051                                    sql = query.toString();
30052                            }
30053                            else {
30054                                    sql = _SQL_SELECT_JOURNALARTICLE;
30055    
30056                                    if (pagination) {
30057                                            sql = sql.concat(JournalArticleModelImpl.ORDER_BY_JPQL);
30058                                    }
30059                            }
30060    
30061                            Session session = null;
30062    
30063                            try {
30064                                    session = openSession();
30065    
30066                                    Query q = session.createQuery(sql);
30067    
30068                                    if (!pagination) {
30069                                            list = (List<JournalArticle>)QueryUtil.list(q,
30070                                                            getDialect(), start, end, false);
30071    
30072                                            Collections.sort(list);
30073    
30074                                            list = Collections.unmodifiableList(list);
30075                                    }
30076                                    else {
30077                                            list = (List<JournalArticle>)QueryUtil.list(q,
30078                                                            getDialect(), start, end);
30079                                    }
30080    
30081                                    cacheResult(list);
30082    
30083                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
30084                            }
30085                            catch (Exception e) {
30086                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
30087    
30088                                    throw processException(e);
30089                            }
30090                            finally {
30091                                    closeSession(session);
30092                            }
30093                    }
30094    
30095                    return list;
30096            }
30097    
30098            /**
30099             * Removes all the journal articles from the database.
30100             *
30101             */
30102            @Override
30103            public void removeAll() {
30104                    for (JournalArticle journalArticle : findAll()) {
30105                            remove(journalArticle);
30106                    }
30107            }
30108    
30109            /**
30110             * Returns the number of journal articles.
30111             *
30112             * @return the number of journal articles
30113             */
30114            @Override
30115            public int countAll() {
30116                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
30117                                    FINDER_ARGS_EMPTY, this);
30118    
30119                    if (count == null) {
30120                            Session session = null;
30121    
30122                            try {
30123                                    session = openSession();
30124    
30125                                    Query q = session.createQuery(_SQL_COUNT_JOURNALARTICLE);
30126    
30127                                    count = (Long)q.uniqueResult();
30128    
30129                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
30130                                            FINDER_ARGS_EMPTY, count);
30131                            }
30132                            catch (Exception e) {
30133                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
30134                                            FINDER_ARGS_EMPTY);
30135    
30136                                    throw processException(e);
30137                            }
30138                            finally {
30139                                    closeSession(session);
30140                            }
30141                    }
30142    
30143                    return count.intValue();
30144            }
30145    
30146            @Override
30147            protected Set<String> getBadColumnNames() {
30148                    return _badColumnNames;
30149            }
30150    
30151            /**
30152             * Initializes the journal article persistence.
30153             */
30154            public void afterPropertiesSet() {
30155            }
30156    
30157            public void destroy() {
30158                    EntityCacheUtil.removeCache(JournalArticleImpl.class.getName());
30159                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
30160                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
30161                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
30162            }
30163    
30164            private static final String _SQL_SELECT_JOURNALARTICLE = "SELECT journalArticle FROM JournalArticle journalArticle";
30165            private static final String _SQL_SELECT_JOURNALARTICLE_WHERE_PKS_IN = "SELECT journalArticle FROM JournalArticle journalArticle WHERE id_ IN (";
30166            private static final String _SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT journalArticle FROM JournalArticle journalArticle WHERE ";
30167            private static final String _SQL_COUNT_JOURNALARTICLE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle";
30168            private static final String _SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle WHERE ";
30169            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "journalArticle.resourcePrimKey";
30170            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT DISTINCT {journalArticle.*} FROM JournalArticle journalArticle WHERE ";
30171            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1 =
30172                    "SELECT {JournalArticle.*} FROM (SELECT DISTINCT journalArticle.id_ FROM JournalArticle journalArticle WHERE ";
30173            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2 =
30174                    ") TEMP_TABLE INNER JOIN JournalArticle ON TEMP_TABLE.id_ = JournalArticle.id_";
30175            private static final String _FILTER_SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(DISTINCT journalArticle.id_) AS COUNT_VALUE FROM JournalArticle journalArticle WHERE ";
30176            private static final String _FILTER_ENTITY_ALIAS = "journalArticle";
30177            private static final String _FILTER_ENTITY_TABLE = "JournalArticle";
30178            private static final String _ORDER_BY_ENTITY_ALIAS = "journalArticle.";
30179            private static final String _ORDER_BY_ENTITY_TABLE = "JournalArticle.";
30180            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalArticle exists with the primary key ";
30181            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalArticle exists with the key {";
30182            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
30183            private static final Log _log = LogFactoryUtil.getLog(JournalArticlePersistenceImpl.class);
30184            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
30185                                    "uuid", "id", "type"
30186                            });
30187            private static final JournalArticle _nullJournalArticle = new JournalArticleImpl() {
30188                            @Override
30189                            public Object clone() {
30190                                    return this;
30191                            }
30192    
30193                            @Override
30194                            public CacheModel<JournalArticle> toCacheModel() {
30195                                    return _nullJournalArticleCacheModel;
30196                            }
30197                    };
30198    
30199            private static final CacheModel<JournalArticle> _nullJournalArticleCacheModel =
30200                    new CacheModel<JournalArticle>() {
30201                            @Override
30202                            public JournalArticle toEntityModel() {
30203                                    return _nullJournalArticle;
30204                            }
30205                    };
30206    }