001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.journal.service.persistence;
016    
017    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
018    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
019    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
020    import com.liferay.portal.kernel.dao.orm.FinderPath;
021    import com.liferay.portal.kernel.dao.orm.Query;
022    import com.liferay.portal.kernel.dao.orm.QueryPos;
023    import com.liferay.portal.kernel.dao.orm.QueryUtil;
024    import com.liferay.portal.kernel.dao.orm.SQLQuery;
025    import com.liferay.portal.kernel.dao.orm.Session;
026    import com.liferay.portal.kernel.exception.SystemException;
027    import com.liferay.portal.kernel.log.Log;
028    import com.liferay.portal.kernel.log.LogFactoryUtil;
029    import com.liferay.portal.kernel.util.ArrayUtil;
030    import com.liferay.portal.kernel.util.CalendarUtil;
031    import com.liferay.portal.kernel.util.GetterUtil;
032    import com.liferay.portal.kernel.util.InstanceFactory;
033    import com.liferay.portal.kernel.util.OrderByComparator;
034    import com.liferay.portal.kernel.util.SetUtil;
035    import com.liferay.portal.kernel.util.StringBundler;
036    import com.liferay.portal.kernel.util.StringPool;
037    import com.liferay.portal.kernel.util.StringUtil;
038    import com.liferay.portal.kernel.util.UnmodifiableList;
039    import com.liferay.portal.kernel.util.Validator;
040    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
041    import com.liferay.portal.model.CacheModel;
042    import com.liferay.portal.model.ModelListener;
043    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
044    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
045    
046    import com.liferay.portlet.journal.NoSuchArticleException;
047    import com.liferay.portlet.journal.model.JournalArticle;
048    import com.liferay.portlet.journal.model.impl.JournalArticleImpl;
049    import com.liferay.portlet.journal.model.impl.JournalArticleModelImpl;
050    import com.liferay.portlet.journal.service.persistence.JournalArticlePersistence;
051    
052    import java.io.Serializable;
053    
054    import java.util.ArrayList;
055    import java.util.Collections;
056    import java.util.Date;
057    import java.util.List;
058    import java.util.Set;
059    
060    /**
061     * The persistence implementation for the journal article service.
062     *
063     * <p>
064     * Caching information and settings can be found in <code>portal.properties</code>
065     * </p>
066     *
067     * @author Brian Wing Shun Chan
068     * @see JournalArticlePersistence
069     * @see JournalArticleUtil
070     * @generated
071     */
072    public class JournalArticlePersistenceImpl extends BasePersistenceImpl<JournalArticle>
073            implements JournalArticlePersistence {
074            /*
075             * NOTE FOR DEVELOPERS:
076             *
077             * 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.
078             */
079            public static final String FINDER_CLASS_NAME_ENTITY = JournalArticleImpl.class.getName();
080            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
081                    ".List1";
082            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
083                    ".List2";
084            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
085                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
086                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
087                            "findAll", new String[0]);
088            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
089                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
090                            JournalArticleImpl.class,
091                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
092            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
093                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
094                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
095            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
096                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
097                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
098                            "findByUuid",
099                            new String[] {
100                                    String.class.getName(),
101                                    
102                            Integer.class.getName(), Integer.class.getName(),
103                                    OrderByComparator.class.getName()
104                            });
105            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
106                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
107                            JournalArticleImpl.class,
108                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
109                            new String[] { String.class.getName() },
110                            JournalArticleModelImpl.UUID_COLUMN_BITMASK |
111                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
112                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
113            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
114                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
115                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
116                            new String[] { String.class.getName() });
117    
118            /**
119             * Returns all the journal articles where uuid = &#63;.
120             *
121             * @param uuid the uuid
122             * @return the matching journal articles
123             * @throws SystemException if a system exception occurred
124             */
125            @Override
126            public List<JournalArticle> findByUuid(String uuid)
127                    throws SystemException {
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             * @throws SystemException if a system exception occurred
143             */
144            @Override
145            public List<JournalArticle> findByUuid(String uuid, int start, int end)
146                    throws SystemException {
147                    return findByUuid(uuid, start, end, null);
148            }
149    
150            /**
151             * Returns an ordered range of all the journal articles where uuid = &#63;.
152             *
153             * <p>
154             * 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.
155             * </p>
156             *
157             * @param uuid the uuid
158             * @param start the lower bound of the range of journal articles
159             * @param end the upper bound of the range of journal articles (not inclusive)
160             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
161             * @return the ordered range of matching journal articles
162             * @throws SystemException if a system exception occurred
163             */
164            @Override
165            public List<JournalArticle> findByUuid(String uuid, int start, int end,
166                    OrderByComparator orderByComparator) throws SystemException {
167                    boolean pagination = true;
168                    FinderPath finderPath = null;
169                    Object[] finderArgs = null;
170    
171                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
172                                    (orderByComparator == null)) {
173                            pagination = false;
174                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
175                            finderArgs = new Object[] { uuid };
176                    }
177                    else {
178                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
179                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
180                    }
181    
182                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
183                                    finderArgs, this);
184    
185                    if ((list != null) && !list.isEmpty()) {
186                            for (JournalArticle journalArticle : list) {
187                                    if (!Validator.equals(uuid, journalArticle.getUuid())) {
188                                            list = null;
189    
190                                            break;
191                                    }
192                            }
193                    }
194    
195                    if (list == null) {
196                            StringBundler query = null;
197    
198                            if (orderByComparator != null) {
199                                    query = new StringBundler(3 +
200                                                    (orderByComparator.getOrderByFields().length * 3));
201                            }
202                            else {
203                                    query = new StringBundler(3);
204                            }
205    
206                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
207    
208                            boolean bindUuid = false;
209    
210                            if (uuid == null) {
211                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
212                            }
213                            else if (uuid.equals(StringPool.BLANK)) {
214                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
215                            }
216                            else {
217                                    bindUuid = true;
218    
219                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
220                            }
221    
222                            if (orderByComparator != null) {
223                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
224                                            orderByComparator);
225                            }
226                            else
227                             if (pagination) {
228                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
229                            }
230    
231                            String sql = query.toString();
232    
233                            Session session = null;
234    
235                            try {
236                                    session = openSession();
237    
238                                    Query q = session.createQuery(sql);
239    
240                                    QueryPos qPos = QueryPos.getInstance(q);
241    
242                                    if (bindUuid) {
243                                            qPos.add(uuid);
244                                    }
245    
246                                    if (!pagination) {
247                                            list = (List<JournalArticle>)QueryUtil.list(q,
248                                                            getDialect(), start, end, false);
249    
250                                            Collections.sort(list);
251    
252                                            list = new UnmodifiableList<JournalArticle>(list);
253                                    }
254                                    else {
255                                            list = (List<JournalArticle>)QueryUtil.list(q,
256                                                            getDialect(), start, end);
257                                    }
258    
259                                    cacheResult(list);
260    
261                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
262                            }
263                            catch (Exception e) {
264                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
265    
266                                    throw processException(e);
267                            }
268                            finally {
269                                    closeSession(session);
270                            }
271                    }
272    
273                    return list;
274            }
275    
276            /**
277             * Returns the first journal article in the ordered set where uuid = &#63;.
278             *
279             * @param uuid the uuid
280             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
281             * @return the first matching journal article
282             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
283             * @throws SystemException if a system exception occurred
284             */
285            @Override
286            public JournalArticle findByUuid_First(String uuid,
287                    OrderByComparator orderByComparator)
288                    throws NoSuchArticleException, SystemException {
289                    JournalArticle journalArticle = fetchByUuid_First(uuid,
290                                    orderByComparator);
291    
292                    if (journalArticle != null) {
293                            return journalArticle;
294                    }
295    
296                    StringBundler msg = new StringBundler(4);
297    
298                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
299    
300                    msg.append("uuid=");
301                    msg.append(uuid);
302    
303                    msg.append(StringPool.CLOSE_CURLY_BRACE);
304    
305                    throw new NoSuchArticleException(msg.toString());
306            }
307    
308            /**
309             * Returns the first journal article in the ordered set where uuid = &#63;.
310             *
311             * @param uuid the uuid
312             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
313             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
314             * @throws SystemException if a system exception occurred
315             */
316            @Override
317            public JournalArticle fetchByUuid_First(String uuid,
318                    OrderByComparator orderByComparator) throws SystemException {
319                    List<JournalArticle> list = findByUuid(uuid, 0, 1, orderByComparator);
320    
321                    if (!list.isEmpty()) {
322                            return list.get(0);
323                    }
324    
325                    return null;
326            }
327    
328            /**
329             * Returns the last journal article in the ordered set where uuid = &#63;.
330             *
331             * @param uuid the uuid
332             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
333             * @return the last matching journal article
334             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
335             * @throws SystemException if a system exception occurred
336             */
337            @Override
338            public JournalArticle findByUuid_Last(String uuid,
339                    OrderByComparator orderByComparator)
340                    throws NoSuchArticleException, SystemException {
341                    JournalArticle journalArticle = fetchByUuid_Last(uuid, orderByComparator);
342    
343                    if (journalArticle != null) {
344                            return journalArticle;
345                    }
346    
347                    StringBundler msg = new StringBundler(4);
348    
349                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
350    
351                    msg.append("uuid=");
352                    msg.append(uuid);
353    
354                    msg.append(StringPool.CLOSE_CURLY_BRACE);
355    
356                    throw new NoSuchArticleException(msg.toString());
357            }
358    
359            /**
360             * Returns the last journal article in the ordered set where uuid = &#63;.
361             *
362             * @param uuid the uuid
363             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
364             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
365             * @throws SystemException if a system exception occurred
366             */
367            @Override
368            public JournalArticle fetchByUuid_Last(String uuid,
369                    OrderByComparator orderByComparator) throws SystemException {
370                    int count = countByUuid(uuid);
371    
372                    if (count == 0) {
373                            return null;
374                    }
375    
376                    List<JournalArticle> list = findByUuid(uuid, count - 1, count,
377                                    orderByComparator);
378    
379                    if (!list.isEmpty()) {
380                            return list.get(0);
381                    }
382    
383                    return null;
384            }
385    
386            /**
387             * Returns the journal articles before and after the current journal article in the ordered set where uuid = &#63;.
388             *
389             * @param id the primary key of the current journal article
390             * @param uuid the uuid
391             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
392             * @return the previous, current, and next journal article
393             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
394             * @throws SystemException if a system exception occurred
395             */
396            @Override
397            public JournalArticle[] findByUuid_PrevAndNext(long id, String uuid,
398                    OrderByComparator orderByComparator)
399                    throws NoSuchArticleException, SystemException {
400                    JournalArticle journalArticle = findByPrimaryKey(id);
401    
402                    Session session = null;
403    
404                    try {
405                            session = openSession();
406    
407                            JournalArticle[] array = new JournalArticleImpl[3];
408    
409                            array[0] = getByUuid_PrevAndNext(session, journalArticle, uuid,
410                                            orderByComparator, true);
411    
412                            array[1] = journalArticle;
413    
414                            array[2] = getByUuid_PrevAndNext(session, journalArticle, uuid,
415                                            orderByComparator, false);
416    
417                            return array;
418                    }
419                    catch (Exception e) {
420                            throw processException(e);
421                    }
422                    finally {
423                            closeSession(session);
424                    }
425            }
426    
427            protected JournalArticle getByUuid_PrevAndNext(Session session,
428                    JournalArticle journalArticle, String uuid,
429                    OrderByComparator orderByComparator, boolean previous) {
430                    StringBundler query = null;
431    
432                    if (orderByComparator != null) {
433                            query = new StringBundler(6 +
434                                            (orderByComparator.getOrderByFields().length * 6));
435                    }
436                    else {
437                            query = new StringBundler(3);
438                    }
439    
440                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
441    
442                    boolean bindUuid = false;
443    
444                    if (uuid == null) {
445                            query.append(_FINDER_COLUMN_UUID_UUID_1);
446                    }
447                    else if (uuid.equals(StringPool.BLANK)) {
448                            query.append(_FINDER_COLUMN_UUID_UUID_3);
449                    }
450                    else {
451                            bindUuid = true;
452    
453                            query.append(_FINDER_COLUMN_UUID_UUID_2);
454                    }
455    
456                    if (orderByComparator != null) {
457                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
458    
459                            if (orderByConditionFields.length > 0) {
460                                    query.append(WHERE_AND);
461                            }
462    
463                            for (int i = 0; i < orderByConditionFields.length; i++) {
464                                    query.append(_ORDER_BY_ENTITY_ALIAS);
465                                    query.append(orderByConditionFields[i]);
466    
467                                    if ((i + 1) < orderByConditionFields.length) {
468                                            if (orderByComparator.isAscending() ^ previous) {
469                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
470                                            }
471                                            else {
472                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
473                                            }
474                                    }
475                                    else {
476                                            if (orderByComparator.isAscending() ^ previous) {
477                                                    query.append(WHERE_GREATER_THAN);
478                                            }
479                                            else {
480                                                    query.append(WHERE_LESSER_THAN);
481                                            }
482                                    }
483                            }
484    
485                            query.append(ORDER_BY_CLAUSE);
486    
487                            String[] orderByFields = orderByComparator.getOrderByFields();
488    
489                            for (int i = 0; i < orderByFields.length; i++) {
490                                    query.append(_ORDER_BY_ENTITY_ALIAS);
491                                    query.append(orderByFields[i]);
492    
493                                    if ((i + 1) < orderByFields.length) {
494                                            if (orderByComparator.isAscending() ^ previous) {
495                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
496                                            }
497                                            else {
498                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
499                                            }
500                                    }
501                                    else {
502                                            if (orderByComparator.isAscending() ^ previous) {
503                                                    query.append(ORDER_BY_ASC);
504                                            }
505                                            else {
506                                                    query.append(ORDER_BY_DESC);
507                                            }
508                                    }
509                            }
510                    }
511                    else {
512                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
513                    }
514    
515                    String sql = query.toString();
516    
517                    Query q = session.createQuery(sql);
518    
519                    q.setFirstResult(0);
520                    q.setMaxResults(2);
521    
522                    QueryPos qPos = QueryPos.getInstance(q);
523    
524                    if (bindUuid) {
525                            qPos.add(uuid);
526                    }
527    
528                    if (orderByComparator != null) {
529                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
530    
531                            for (Object value : values) {
532                                    qPos.add(value);
533                            }
534                    }
535    
536                    List<JournalArticle> list = q.list();
537    
538                    if (list.size() == 2) {
539                            return list.get(1);
540                    }
541                    else {
542                            return null;
543                    }
544            }
545    
546            /**
547             * Removes all the journal articles where uuid = &#63; from the database.
548             *
549             * @param uuid the uuid
550             * @throws SystemException if a system exception occurred
551             */
552            @Override
553            public void removeByUuid(String uuid) throws SystemException {
554                    for (JournalArticle journalArticle : findByUuid(uuid,
555                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
556                            remove(journalArticle);
557                    }
558            }
559    
560            /**
561             * Returns the number of journal articles where uuid = &#63;.
562             *
563             * @param uuid the uuid
564             * @return the number of matching journal articles
565             * @throws SystemException if a system exception occurred
566             */
567            @Override
568            public int countByUuid(String uuid) throws SystemException {
569                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
570    
571                    Object[] finderArgs = new Object[] { uuid };
572    
573                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
574                                    this);
575    
576                    if (count == null) {
577                            StringBundler query = new StringBundler(2);
578    
579                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
580    
581                            boolean bindUuid = false;
582    
583                            if (uuid == null) {
584                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
585                            }
586                            else if (uuid.equals(StringPool.BLANK)) {
587                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
588                            }
589                            else {
590                                    bindUuid = true;
591    
592                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
593                            }
594    
595                            String sql = query.toString();
596    
597                            Session session = null;
598    
599                            try {
600                                    session = openSession();
601    
602                                    Query q = session.createQuery(sql);
603    
604                                    QueryPos qPos = QueryPos.getInstance(q);
605    
606                                    if (bindUuid) {
607                                            qPos.add(uuid);
608                                    }
609    
610                                    count = (Long)q.uniqueResult();
611    
612                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
613                            }
614                            catch (Exception e) {
615                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
616    
617                                    throw processException(e);
618                            }
619                            finally {
620                                    closeSession(session);
621                            }
622                    }
623    
624                    return count.intValue();
625            }
626    
627            private static final String _FINDER_COLUMN_UUID_UUID_1 = "journalArticle.uuid IS NULL";
628            private static final String _FINDER_COLUMN_UUID_UUID_2 = "journalArticle.uuid = ?";
629            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = '')";
630            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
631                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
632                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY,
633                            "fetchByUUID_G",
634                            new String[] { String.class.getName(), Long.class.getName() },
635                            JournalArticleModelImpl.UUID_COLUMN_BITMASK |
636                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK);
637            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
638                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
639                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
640                            new String[] { String.class.getName(), Long.class.getName() });
641    
642            /**
643             * 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.
644             *
645             * @param uuid the uuid
646             * @param groupId the group ID
647             * @return the matching journal article
648             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
649             * @throws SystemException if a system exception occurred
650             */
651            @Override
652            public JournalArticle findByUUID_G(String uuid, long groupId)
653                    throws NoSuchArticleException, SystemException {
654                    JournalArticle journalArticle = fetchByUUID_G(uuid, groupId);
655    
656                    if (journalArticle == null) {
657                            StringBundler msg = new StringBundler(6);
658    
659                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
660    
661                            msg.append("uuid=");
662                            msg.append(uuid);
663    
664                            msg.append(", groupId=");
665                            msg.append(groupId);
666    
667                            msg.append(StringPool.CLOSE_CURLY_BRACE);
668    
669                            if (_log.isWarnEnabled()) {
670                                    _log.warn(msg.toString());
671                            }
672    
673                            throw new NoSuchArticleException(msg.toString());
674                    }
675    
676                    return journalArticle;
677            }
678    
679            /**
680             * 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.
681             *
682             * @param uuid the uuid
683             * @param groupId the group ID
684             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
685             * @throws SystemException if a system exception occurred
686             */
687            @Override
688            public JournalArticle fetchByUUID_G(String uuid, long groupId)
689                    throws SystemException {
690                    return fetchByUUID_G(uuid, groupId, true);
691            }
692    
693            /**
694             * 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.
695             *
696             * @param uuid the uuid
697             * @param groupId the group ID
698             * @param retrieveFromCache whether to use the finder cache
699             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
700             * @throws SystemException if a system exception occurred
701             */
702            @Override
703            public JournalArticle fetchByUUID_G(String uuid, long groupId,
704                    boolean retrieveFromCache) throws SystemException {
705                    Object[] finderArgs = new Object[] { uuid, groupId };
706    
707                    Object result = null;
708    
709                    if (retrieveFromCache) {
710                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
711                                            finderArgs, this);
712                    }
713    
714                    if (result instanceof JournalArticle) {
715                            JournalArticle journalArticle = (JournalArticle)result;
716    
717                            if (!Validator.equals(uuid, journalArticle.getUuid()) ||
718                                            (groupId != journalArticle.getGroupId())) {
719                                    result = null;
720                            }
721                    }
722    
723                    if (result == null) {
724                            StringBundler query = new StringBundler(4);
725    
726                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
727    
728                            boolean bindUuid = false;
729    
730                            if (uuid == null) {
731                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
732                            }
733                            else if (uuid.equals(StringPool.BLANK)) {
734                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
735                            }
736                            else {
737                                    bindUuid = true;
738    
739                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
740                            }
741    
742                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
743    
744                            String sql = query.toString();
745    
746                            Session session = null;
747    
748                            try {
749                                    session = openSession();
750    
751                                    Query q = session.createQuery(sql);
752    
753                                    QueryPos qPos = QueryPos.getInstance(q);
754    
755                                    if (bindUuid) {
756                                            qPos.add(uuid);
757                                    }
758    
759                                    qPos.add(groupId);
760    
761                                    List<JournalArticle> list = q.list();
762    
763                                    if (list.isEmpty()) {
764                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
765                                                    finderArgs, list);
766                                    }
767                                    else {
768                                            JournalArticle journalArticle = list.get(0);
769    
770                                            result = journalArticle;
771    
772                                            cacheResult(journalArticle);
773    
774                                            if ((journalArticle.getUuid() == null) ||
775                                                            !journalArticle.getUuid().equals(uuid) ||
776                                                            (journalArticle.getGroupId() != groupId)) {
777                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
778                                                            finderArgs, journalArticle);
779                                            }
780                                    }
781                            }
782                            catch (Exception e) {
783                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
784                                            finderArgs);
785    
786                                    throw processException(e);
787                            }
788                            finally {
789                                    closeSession(session);
790                            }
791                    }
792    
793                    if (result instanceof List<?>) {
794                            return null;
795                    }
796                    else {
797                            return (JournalArticle)result;
798                    }
799            }
800    
801            /**
802             * Removes the journal article where uuid = &#63; and groupId = &#63; from the database.
803             *
804             * @param uuid the uuid
805             * @param groupId the group ID
806             * @return the journal article that was removed
807             * @throws SystemException if a system exception occurred
808             */
809            @Override
810            public JournalArticle removeByUUID_G(String uuid, long groupId)
811                    throws NoSuchArticleException, SystemException {
812                    JournalArticle journalArticle = findByUUID_G(uuid, groupId);
813    
814                    return remove(journalArticle);
815            }
816    
817            /**
818             * Returns the number of journal articles where uuid = &#63; and groupId = &#63;.
819             *
820             * @param uuid the uuid
821             * @param groupId the group ID
822             * @return the number of matching journal articles
823             * @throws SystemException if a system exception occurred
824             */
825            @Override
826            public int countByUUID_G(String uuid, long groupId)
827                    throws SystemException {
828                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
829    
830                    Object[] finderArgs = new Object[] { uuid, groupId };
831    
832                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
833                                    this);
834    
835                    if (count == null) {
836                            StringBundler query = new StringBundler(3);
837    
838                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
839    
840                            boolean bindUuid = false;
841    
842                            if (uuid == null) {
843                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
844                            }
845                            else if (uuid.equals(StringPool.BLANK)) {
846                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
847                            }
848                            else {
849                                    bindUuid = true;
850    
851                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
852                            }
853    
854                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
855    
856                            String sql = query.toString();
857    
858                            Session session = null;
859    
860                            try {
861                                    session = openSession();
862    
863                                    Query q = session.createQuery(sql);
864    
865                                    QueryPos qPos = QueryPos.getInstance(q);
866    
867                                    if (bindUuid) {
868                                            qPos.add(uuid);
869                                    }
870    
871                                    qPos.add(groupId);
872    
873                                    count = (Long)q.uniqueResult();
874    
875                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
876                            }
877                            catch (Exception e) {
878                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
879    
880                                    throw processException(e);
881                            }
882                            finally {
883                                    closeSession(session);
884                            }
885                    }
886    
887                    return count.intValue();
888            }
889    
890            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "journalArticle.uuid IS NULL AND ";
891            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "journalArticle.uuid = ? AND ";
892            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = '') AND ";
893            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "journalArticle.groupId = ?";
894            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
895                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
896                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
897                            "findByUuid_C",
898                            new String[] {
899                                    String.class.getName(), Long.class.getName(),
900                                    
901                            Integer.class.getName(), Integer.class.getName(),
902                                    OrderByComparator.class.getName()
903                            });
904            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
905                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
906                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
907                            JournalArticleImpl.class,
908                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
909                            new String[] { String.class.getName(), Long.class.getName() },
910                            JournalArticleModelImpl.UUID_COLUMN_BITMASK |
911                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
912                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
913                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
914            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
915                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
916                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
917                            new String[] { String.class.getName(), Long.class.getName() });
918    
919            /**
920             * Returns all the journal articles where uuid = &#63; and companyId = &#63;.
921             *
922             * @param uuid the uuid
923             * @param companyId the company ID
924             * @return the matching journal articles
925             * @throws SystemException if a system exception occurred
926             */
927            @Override
928            public List<JournalArticle> findByUuid_C(String uuid, long companyId)
929                    throws SystemException {
930                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
931                            QueryUtil.ALL_POS, null);
932            }
933    
934            /**
935             * Returns a 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             * @return the range of matching journal articles
946             * @throws SystemException if a system exception occurred
947             */
948            @Override
949            public List<JournalArticle> findByUuid_C(String uuid, long companyId,
950                    int start, int end) throws SystemException {
951                    return findByUuid_C(uuid, companyId, start, end, null);
952            }
953    
954            /**
955             * Returns an ordered range of all the journal articles where uuid = &#63; and companyId = &#63;.
956             *
957             * <p>
958             * 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.
959             * </p>
960             *
961             * @param uuid the uuid
962             * @param companyId the company ID
963             * @param start the lower bound of the range of journal articles
964             * @param end the upper bound of the range of journal articles (not inclusive)
965             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
966             * @return the ordered range of matching journal articles
967             * @throws SystemException if a system exception occurred
968             */
969            @Override
970            public List<JournalArticle> findByUuid_C(String uuid, long companyId,
971                    int start, int end, OrderByComparator orderByComparator)
972                    throws SystemException {
973                    boolean pagination = true;
974                    FinderPath finderPath = null;
975                    Object[] finderArgs = null;
976    
977                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
978                                    (orderByComparator == null)) {
979                            pagination = false;
980                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
981                            finderArgs = new Object[] { uuid, companyId };
982                    }
983                    else {
984                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
985                            finderArgs = new Object[] {
986                                            uuid, companyId,
987                                            
988                                            start, end, orderByComparator
989                                    };
990                    }
991    
992                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
993                                    finderArgs, this);
994    
995                    if ((list != null) && !list.isEmpty()) {
996                            for (JournalArticle journalArticle : list) {
997                                    if (!Validator.equals(uuid, journalArticle.getUuid()) ||
998                                                    (companyId != journalArticle.getCompanyId())) {
999                                            list = null;
1000    
1001                                            break;
1002                                    }
1003                            }
1004                    }
1005    
1006                    if (list == null) {
1007                            StringBundler query = null;
1008    
1009                            if (orderByComparator != null) {
1010                                    query = new StringBundler(4 +
1011                                                    (orderByComparator.getOrderByFields().length * 3));
1012                            }
1013                            else {
1014                                    query = new StringBundler(4);
1015                            }
1016    
1017                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1018    
1019                            boolean bindUuid = false;
1020    
1021                            if (uuid == null) {
1022                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1023                            }
1024                            else if (uuid.equals(StringPool.BLANK)) {
1025                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1026                            }
1027                            else {
1028                                    bindUuid = true;
1029    
1030                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1031                            }
1032    
1033                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1034    
1035                            if (orderByComparator != null) {
1036                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1037                                            orderByComparator);
1038                            }
1039                            else
1040                             if (pagination) {
1041                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1042                            }
1043    
1044                            String sql = query.toString();
1045    
1046                            Session session = null;
1047    
1048                            try {
1049                                    session = openSession();
1050    
1051                                    Query q = session.createQuery(sql);
1052    
1053                                    QueryPos qPos = QueryPos.getInstance(q);
1054    
1055                                    if (bindUuid) {
1056                                            qPos.add(uuid);
1057                                    }
1058    
1059                                    qPos.add(companyId);
1060    
1061                                    if (!pagination) {
1062                                            list = (List<JournalArticle>)QueryUtil.list(q,
1063                                                            getDialect(), start, end, false);
1064    
1065                                            Collections.sort(list);
1066    
1067                                            list = new UnmodifiableList<JournalArticle>(list);
1068                                    }
1069                                    else {
1070                                            list = (List<JournalArticle>)QueryUtil.list(q,
1071                                                            getDialect(), start, end);
1072                                    }
1073    
1074                                    cacheResult(list);
1075    
1076                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1077                            }
1078                            catch (Exception e) {
1079                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1080    
1081                                    throw processException(e);
1082                            }
1083                            finally {
1084                                    closeSession(session);
1085                            }
1086                    }
1087    
1088                    return list;
1089            }
1090    
1091            /**
1092             * Returns the first journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1093             *
1094             * @param uuid the uuid
1095             * @param companyId the company ID
1096             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1097             * @return the first matching journal article
1098             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1099             * @throws SystemException if a system exception occurred
1100             */
1101            @Override
1102            public JournalArticle findByUuid_C_First(String uuid, long companyId,
1103                    OrderByComparator orderByComparator)
1104                    throws NoSuchArticleException, SystemException {
1105                    JournalArticle journalArticle = fetchByUuid_C_First(uuid, companyId,
1106                                    orderByComparator);
1107    
1108                    if (journalArticle != null) {
1109                            return journalArticle;
1110                    }
1111    
1112                    StringBundler msg = new StringBundler(6);
1113    
1114                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1115    
1116                    msg.append("uuid=");
1117                    msg.append(uuid);
1118    
1119                    msg.append(", companyId=");
1120                    msg.append(companyId);
1121    
1122                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1123    
1124                    throw new NoSuchArticleException(msg.toString());
1125            }
1126    
1127            /**
1128             * Returns the first journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1129             *
1130             * @param uuid the uuid
1131             * @param companyId the company ID
1132             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1133             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
1134             * @throws SystemException if a system exception occurred
1135             */
1136            @Override
1137            public JournalArticle fetchByUuid_C_First(String uuid, long companyId,
1138                    OrderByComparator orderByComparator) throws SystemException {
1139                    List<JournalArticle> list = findByUuid_C(uuid, companyId, 0, 1,
1140                                    orderByComparator);
1141    
1142                    if (!list.isEmpty()) {
1143                            return list.get(0);
1144                    }
1145    
1146                    return null;
1147            }
1148    
1149            /**
1150             * Returns the last journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1151             *
1152             * @param uuid the uuid
1153             * @param companyId the company ID
1154             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1155             * @return the last matching journal article
1156             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1157             * @throws SystemException if a system exception occurred
1158             */
1159            @Override
1160            public JournalArticle findByUuid_C_Last(String uuid, long companyId,
1161                    OrderByComparator orderByComparator)
1162                    throws NoSuchArticleException, SystemException {
1163                    JournalArticle journalArticle = fetchByUuid_C_Last(uuid, companyId,
1164                                    orderByComparator);
1165    
1166                    if (journalArticle != null) {
1167                            return journalArticle;
1168                    }
1169    
1170                    StringBundler msg = new StringBundler(6);
1171    
1172                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1173    
1174                    msg.append("uuid=");
1175                    msg.append(uuid);
1176    
1177                    msg.append(", companyId=");
1178                    msg.append(companyId);
1179    
1180                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1181    
1182                    throw new NoSuchArticleException(msg.toString());
1183            }
1184    
1185            /**
1186             * Returns the last journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1187             *
1188             * @param uuid the uuid
1189             * @param companyId the company ID
1190             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1191             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
1192             * @throws SystemException if a system exception occurred
1193             */
1194            @Override
1195            public JournalArticle fetchByUuid_C_Last(String uuid, long companyId,
1196                    OrderByComparator orderByComparator) throws SystemException {
1197                    int count = countByUuid_C(uuid, companyId);
1198    
1199                    if (count == 0) {
1200                            return null;
1201                    }
1202    
1203                    List<JournalArticle> list = findByUuid_C(uuid, companyId, count - 1,
1204                                    count, orderByComparator);
1205    
1206                    if (!list.isEmpty()) {
1207                            return list.get(0);
1208                    }
1209    
1210                    return null;
1211            }
1212    
1213            /**
1214             * Returns the journal articles before and after the current journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1215             *
1216             * @param id the primary key of the current journal article
1217             * @param uuid the uuid
1218             * @param companyId the company ID
1219             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1220             * @return the previous, current, and next journal article
1221             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
1222             * @throws SystemException if a system exception occurred
1223             */
1224            @Override
1225            public JournalArticle[] findByUuid_C_PrevAndNext(long id, String uuid,
1226                    long companyId, OrderByComparator orderByComparator)
1227                    throws NoSuchArticleException, SystemException {
1228                    JournalArticle journalArticle = findByPrimaryKey(id);
1229    
1230                    Session session = null;
1231    
1232                    try {
1233                            session = openSession();
1234    
1235                            JournalArticle[] array = new JournalArticleImpl[3];
1236    
1237                            array[0] = getByUuid_C_PrevAndNext(session, journalArticle, uuid,
1238                                            companyId, orderByComparator, true);
1239    
1240                            array[1] = journalArticle;
1241    
1242                            array[2] = getByUuid_C_PrevAndNext(session, journalArticle, uuid,
1243                                            companyId, orderByComparator, false);
1244    
1245                            return array;
1246                    }
1247                    catch (Exception e) {
1248                            throw processException(e);
1249                    }
1250                    finally {
1251                            closeSession(session);
1252                    }
1253            }
1254    
1255            protected JournalArticle getByUuid_C_PrevAndNext(Session session,
1256                    JournalArticle journalArticle, String uuid, long companyId,
1257                    OrderByComparator orderByComparator, boolean previous) {
1258                    StringBundler query = null;
1259    
1260                    if (orderByComparator != null) {
1261                            query = new StringBundler(6 +
1262                                            (orderByComparator.getOrderByFields().length * 6));
1263                    }
1264                    else {
1265                            query = new StringBundler(3);
1266                    }
1267    
1268                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1269    
1270                    boolean bindUuid = false;
1271    
1272                    if (uuid == null) {
1273                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1274                    }
1275                    else if (uuid.equals(StringPool.BLANK)) {
1276                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1277                    }
1278                    else {
1279                            bindUuid = true;
1280    
1281                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1282                    }
1283    
1284                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1285    
1286                    if (orderByComparator != null) {
1287                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1288    
1289                            if (orderByConditionFields.length > 0) {
1290                                    query.append(WHERE_AND);
1291                            }
1292    
1293                            for (int i = 0; i < orderByConditionFields.length; i++) {
1294                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1295                                    query.append(orderByConditionFields[i]);
1296    
1297                                    if ((i + 1) < orderByConditionFields.length) {
1298                                            if (orderByComparator.isAscending() ^ previous) {
1299                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1300                                            }
1301                                            else {
1302                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1303                                            }
1304                                    }
1305                                    else {
1306                                            if (orderByComparator.isAscending() ^ previous) {
1307                                                    query.append(WHERE_GREATER_THAN);
1308                                            }
1309                                            else {
1310                                                    query.append(WHERE_LESSER_THAN);
1311                                            }
1312                                    }
1313                            }
1314    
1315                            query.append(ORDER_BY_CLAUSE);
1316    
1317                            String[] orderByFields = orderByComparator.getOrderByFields();
1318    
1319                            for (int i = 0; i < orderByFields.length; i++) {
1320                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1321                                    query.append(orderByFields[i]);
1322    
1323                                    if ((i + 1) < orderByFields.length) {
1324                                            if (orderByComparator.isAscending() ^ previous) {
1325                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1326                                            }
1327                                            else {
1328                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1329                                            }
1330                                    }
1331                                    else {
1332                                            if (orderByComparator.isAscending() ^ previous) {
1333                                                    query.append(ORDER_BY_ASC);
1334                                            }
1335                                            else {
1336                                                    query.append(ORDER_BY_DESC);
1337                                            }
1338                                    }
1339                            }
1340                    }
1341                    else {
1342                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1343                    }
1344    
1345                    String sql = query.toString();
1346    
1347                    Query q = session.createQuery(sql);
1348    
1349                    q.setFirstResult(0);
1350                    q.setMaxResults(2);
1351    
1352                    QueryPos qPos = QueryPos.getInstance(q);
1353    
1354                    if (bindUuid) {
1355                            qPos.add(uuid);
1356                    }
1357    
1358                    qPos.add(companyId);
1359    
1360                    if (orderByComparator != null) {
1361                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
1362    
1363                            for (Object value : values) {
1364                                    qPos.add(value);
1365                            }
1366                    }
1367    
1368                    List<JournalArticle> list = q.list();
1369    
1370                    if (list.size() == 2) {
1371                            return list.get(1);
1372                    }
1373                    else {
1374                            return null;
1375                    }
1376            }
1377    
1378            /**
1379             * Removes all the journal articles where uuid = &#63; and companyId = &#63; from the database.
1380             *
1381             * @param uuid the uuid
1382             * @param companyId the company ID
1383             * @throws SystemException if a system exception occurred
1384             */
1385            @Override
1386            public void removeByUuid_C(String uuid, long companyId)
1387                    throws SystemException {
1388                    for (JournalArticle journalArticle : findByUuid_C(uuid, companyId,
1389                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1390                            remove(journalArticle);
1391                    }
1392            }
1393    
1394            /**
1395             * Returns the number of journal articles where uuid = &#63; and companyId = &#63;.
1396             *
1397             * @param uuid the uuid
1398             * @param companyId the company ID
1399             * @return the number of matching journal articles
1400             * @throws SystemException if a system exception occurred
1401             */
1402            @Override
1403            public int countByUuid_C(String uuid, long companyId)
1404                    throws SystemException {
1405                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1406    
1407                    Object[] finderArgs = new Object[] { uuid, companyId };
1408    
1409                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1410                                    this);
1411    
1412                    if (count == null) {
1413                            StringBundler query = new StringBundler(3);
1414    
1415                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
1416    
1417                            boolean bindUuid = false;
1418    
1419                            if (uuid == null) {
1420                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1421                            }
1422                            else if (uuid.equals(StringPool.BLANK)) {
1423                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1424                            }
1425                            else {
1426                                    bindUuid = true;
1427    
1428                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1429                            }
1430    
1431                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1432    
1433                            String sql = query.toString();
1434    
1435                            Session session = null;
1436    
1437                            try {
1438                                    session = openSession();
1439    
1440                                    Query q = session.createQuery(sql);
1441    
1442                                    QueryPos qPos = QueryPos.getInstance(q);
1443    
1444                                    if (bindUuid) {
1445                                            qPos.add(uuid);
1446                                    }
1447    
1448                                    qPos.add(companyId);
1449    
1450                                    count = (Long)q.uniqueResult();
1451    
1452                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1453                            }
1454                            catch (Exception e) {
1455                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1456    
1457                                    throw processException(e);
1458                            }
1459                            finally {
1460                                    closeSession(session);
1461                            }
1462                    }
1463    
1464                    return count.intValue();
1465            }
1466    
1467            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "journalArticle.uuid IS NULL AND ";
1468            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "journalArticle.uuid = ? AND ";
1469            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = '') AND ";
1470            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "journalArticle.companyId = ?";
1471            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEPRIMKEY =
1472                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1473                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1474                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1475                            "findByResourcePrimKey",
1476                            new String[] {
1477                                    Long.class.getName(),
1478                                    
1479                            Integer.class.getName(), Integer.class.getName(),
1480                                    OrderByComparator.class.getName()
1481                            });
1482            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY =
1483                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1484                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1485                            JournalArticleImpl.class,
1486                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByResourcePrimKey",
1487                            new String[] { Long.class.getName() },
1488                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
1489                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
1490                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
1491            public static final FinderPath FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1492                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
1493                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1494                            "countByResourcePrimKey", new String[] { Long.class.getName() });
1495    
1496            /**
1497             * Returns all the journal articles where resourcePrimKey = &#63;.
1498             *
1499             * @param resourcePrimKey the resource prim key
1500             * @return the matching journal articles
1501             * @throws SystemException if a system exception occurred
1502             */
1503            @Override
1504            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey)
1505                    throws SystemException {
1506                    return findByResourcePrimKey(resourcePrimKey, QueryUtil.ALL_POS,
1507                            QueryUtil.ALL_POS, null);
1508            }
1509    
1510            /**
1511             * Returns a range of all the journal articles where resourcePrimKey = &#63;.
1512             *
1513             * <p>
1514             * 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.
1515             * </p>
1516             *
1517             * @param resourcePrimKey the resource prim key
1518             * @param start the lower bound of the range of journal articles
1519             * @param end the upper bound of the range of journal articles (not inclusive)
1520             * @return the range of matching journal articles
1521             * @throws SystemException if a system exception occurred
1522             */
1523            @Override
1524            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey,
1525                    int start, int end) throws SystemException {
1526                    return findByResourcePrimKey(resourcePrimKey, start, end, null);
1527            }
1528    
1529            /**
1530             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63;.
1531             *
1532             * <p>
1533             * 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.
1534             * </p>
1535             *
1536             * @param resourcePrimKey the resource prim key
1537             * @param start the lower bound of the range of journal articles
1538             * @param end the upper bound of the range of journal articles (not inclusive)
1539             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1540             * @return the ordered range of matching journal articles
1541             * @throws SystemException if a system exception occurred
1542             */
1543            @Override
1544            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey,
1545                    int start, int end, OrderByComparator orderByComparator)
1546                    throws SystemException {
1547                    boolean pagination = true;
1548                    FinderPath finderPath = null;
1549                    Object[] finderArgs = null;
1550    
1551                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1552                                    (orderByComparator == null)) {
1553                            pagination = false;
1554                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
1555                            finderArgs = new Object[] { resourcePrimKey };
1556                    }
1557                    else {
1558                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
1559                            finderArgs = new Object[] {
1560                                            resourcePrimKey,
1561                                            
1562                                            start, end, orderByComparator
1563                                    };
1564                    }
1565    
1566                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
1567                                    finderArgs, this);
1568    
1569                    if ((list != null) && !list.isEmpty()) {
1570                            for (JournalArticle journalArticle : list) {
1571                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey())) {
1572                                            list = null;
1573    
1574                                            break;
1575                                    }
1576                            }
1577                    }
1578    
1579                    if (list == null) {
1580                            StringBundler query = null;
1581    
1582                            if (orderByComparator != null) {
1583                                    query = new StringBundler(3 +
1584                                                    (orderByComparator.getOrderByFields().length * 3));
1585                            }
1586                            else {
1587                                    query = new StringBundler(3);
1588                            }
1589    
1590                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1591    
1592                            query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
1593    
1594                            if (orderByComparator != null) {
1595                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1596                                            orderByComparator);
1597                            }
1598                            else
1599                             if (pagination) {
1600                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1601                            }
1602    
1603                            String sql = query.toString();
1604    
1605                            Session session = null;
1606    
1607                            try {
1608                                    session = openSession();
1609    
1610                                    Query q = session.createQuery(sql);
1611    
1612                                    QueryPos qPos = QueryPos.getInstance(q);
1613    
1614                                    qPos.add(resourcePrimKey);
1615    
1616                                    if (!pagination) {
1617                                            list = (List<JournalArticle>)QueryUtil.list(q,
1618                                                            getDialect(), start, end, false);
1619    
1620                                            Collections.sort(list);
1621    
1622                                            list = new UnmodifiableList<JournalArticle>(list);
1623                                    }
1624                                    else {
1625                                            list = (List<JournalArticle>)QueryUtil.list(q,
1626                                                            getDialect(), start, end);
1627                                    }
1628    
1629                                    cacheResult(list);
1630    
1631                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1632                            }
1633                            catch (Exception e) {
1634                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1635    
1636                                    throw processException(e);
1637                            }
1638                            finally {
1639                                    closeSession(session);
1640                            }
1641                    }
1642    
1643                    return list;
1644            }
1645    
1646            /**
1647             * Returns the first journal article in the ordered set where resourcePrimKey = &#63;.
1648             *
1649             * @param resourcePrimKey the resource prim key
1650             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1651             * @return the first matching journal article
1652             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1653             * @throws SystemException if a system exception occurred
1654             */
1655            @Override
1656            public JournalArticle findByResourcePrimKey_First(long resourcePrimKey,
1657                    OrderByComparator orderByComparator)
1658                    throws NoSuchArticleException, SystemException {
1659                    JournalArticle journalArticle = fetchByResourcePrimKey_First(resourcePrimKey,
1660                                    orderByComparator);
1661    
1662                    if (journalArticle != null) {
1663                            return journalArticle;
1664                    }
1665    
1666                    StringBundler msg = new StringBundler(4);
1667    
1668                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1669    
1670                    msg.append("resourcePrimKey=");
1671                    msg.append(resourcePrimKey);
1672    
1673                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1674    
1675                    throw new NoSuchArticleException(msg.toString());
1676            }
1677    
1678            /**
1679             * Returns the first journal article in the ordered set where resourcePrimKey = &#63;.
1680             *
1681             * @param resourcePrimKey the resource prim key
1682             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1683             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
1684             * @throws SystemException if a system exception occurred
1685             */
1686            @Override
1687            public JournalArticle fetchByResourcePrimKey_First(long resourcePrimKey,
1688                    OrderByComparator orderByComparator) throws SystemException {
1689                    List<JournalArticle> list = findByResourcePrimKey(resourcePrimKey, 0,
1690                                    1, orderByComparator);
1691    
1692                    if (!list.isEmpty()) {
1693                            return list.get(0);
1694                    }
1695    
1696                    return null;
1697            }
1698    
1699            /**
1700             * Returns the last journal article in the ordered set where resourcePrimKey = &#63;.
1701             *
1702             * @param resourcePrimKey the resource prim key
1703             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1704             * @return the last matching journal article
1705             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1706             * @throws SystemException if a system exception occurred
1707             */
1708            @Override
1709            public JournalArticle findByResourcePrimKey_Last(long resourcePrimKey,
1710                    OrderByComparator orderByComparator)
1711                    throws NoSuchArticleException, SystemException {
1712                    JournalArticle journalArticle = fetchByResourcePrimKey_Last(resourcePrimKey,
1713                                    orderByComparator);
1714    
1715                    if (journalArticle != null) {
1716                            return journalArticle;
1717                    }
1718    
1719                    StringBundler msg = new StringBundler(4);
1720    
1721                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1722    
1723                    msg.append("resourcePrimKey=");
1724                    msg.append(resourcePrimKey);
1725    
1726                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1727    
1728                    throw new NoSuchArticleException(msg.toString());
1729            }
1730    
1731            /**
1732             * Returns the last journal article in the ordered set where resourcePrimKey = &#63;.
1733             *
1734             * @param resourcePrimKey the resource prim key
1735             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1736             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
1737             * @throws SystemException if a system exception occurred
1738             */
1739            @Override
1740            public JournalArticle fetchByResourcePrimKey_Last(long resourcePrimKey,
1741                    OrderByComparator orderByComparator) throws SystemException {
1742                    int count = countByResourcePrimKey(resourcePrimKey);
1743    
1744                    if (count == 0) {
1745                            return null;
1746                    }
1747    
1748                    List<JournalArticle> list = findByResourcePrimKey(resourcePrimKey,
1749                                    count - 1, count, orderByComparator);
1750    
1751                    if (!list.isEmpty()) {
1752                            return list.get(0);
1753                    }
1754    
1755                    return null;
1756            }
1757    
1758            /**
1759             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63;.
1760             *
1761             * @param id the primary key of the current journal article
1762             * @param resourcePrimKey the resource prim key
1763             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1764             * @return the previous, current, and next journal article
1765             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
1766             * @throws SystemException if a system exception occurred
1767             */
1768            @Override
1769            public JournalArticle[] findByResourcePrimKey_PrevAndNext(long id,
1770                    long resourcePrimKey, OrderByComparator orderByComparator)
1771                    throws NoSuchArticleException, SystemException {
1772                    JournalArticle journalArticle = findByPrimaryKey(id);
1773    
1774                    Session session = null;
1775    
1776                    try {
1777                            session = openSession();
1778    
1779                            JournalArticle[] array = new JournalArticleImpl[3];
1780    
1781                            array[0] = getByResourcePrimKey_PrevAndNext(session,
1782                                            journalArticle, resourcePrimKey, orderByComparator, true);
1783    
1784                            array[1] = journalArticle;
1785    
1786                            array[2] = getByResourcePrimKey_PrevAndNext(session,
1787                                            journalArticle, resourcePrimKey, orderByComparator, false);
1788    
1789                            return array;
1790                    }
1791                    catch (Exception e) {
1792                            throw processException(e);
1793                    }
1794                    finally {
1795                            closeSession(session);
1796                    }
1797            }
1798    
1799            protected JournalArticle getByResourcePrimKey_PrevAndNext(Session session,
1800                    JournalArticle journalArticle, long resourcePrimKey,
1801                    OrderByComparator orderByComparator, boolean previous) {
1802                    StringBundler query = null;
1803    
1804                    if (orderByComparator != null) {
1805                            query = new StringBundler(6 +
1806                                            (orderByComparator.getOrderByFields().length * 6));
1807                    }
1808                    else {
1809                            query = new StringBundler(3);
1810                    }
1811    
1812                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1813    
1814                    query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
1815    
1816                    if (orderByComparator != null) {
1817                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1818    
1819                            if (orderByConditionFields.length > 0) {
1820                                    query.append(WHERE_AND);
1821                            }
1822    
1823                            for (int i = 0; i < orderByConditionFields.length; i++) {
1824                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1825                                    query.append(orderByConditionFields[i]);
1826    
1827                                    if ((i + 1) < orderByConditionFields.length) {
1828                                            if (orderByComparator.isAscending() ^ previous) {
1829                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1830                                            }
1831                                            else {
1832                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1833                                            }
1834                                    }
1835                                    else {
1836                                            if (orderByComparator.isAscending() ^ previous) {
1837                                                    query.append(WHERE_GREATER_THAN);
1838                                            }
1839                                            else {
1840                                                    query.append(WHERE_LESSER_THAN);
1841                                            }
1842                                    }
1843                            }
1844    
1845                            query.append(ORDER_BY_CLAUSE);
1846    
1847                            String[] orderByFields = orderByComparator.getOrderByFields();
1848    
1849                            for (int i = 0; i < orderByFields.length; i++) {
1850                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1851                                    query.append(orderByFields[i]);
1852    
1853                                    if ((i + 1) < orderByFields.length) {
1854                                            if (orderByComparator.isAscending() ^ previous) {
1855                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1856                                            }
1857                                            else {
1858                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1859                                            }
1860                                    }
1861                                    else {
1862                                            if (orderByComparator.isAscending() ^ previous) {
1863                                                    query.append(ORDER_BY_ASC);
1864                                            }
1865                                            else {
1866                                                    query.append(ORDER_BY_DESC);
1867                                            }
1868                                    }
1869                            }
1870                    }
1871                    else {
1872                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1873                    }
1874    
1875                    String sql = query.toString();
1876    
1877                    Query q = session.createQuery(sql);
1878    
1879                    q.setFirstResult(0);
1880                    q.setMaxResults(2);
1881    
1882                    QueryPos qPos = QueryPos.getInstance(q);
1883    
1884                    qPos.add(resourcePrimKey);
1885    
1886                    if (orderByComparator != null) {
1887                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
1888    
1889                            for (Object value : values) {
1890                                    qPos.add(value);
1891                            }
1892                    }
1893    
1894                    List<JournalArticle> list = q.list();
1895    
1896                    if (list.size() == 2) {
1897                            return list.get(1);
1898                    }
1899                    else {
1900                            return null;
1901                    }
1902            }
1903    
1904            /**
1905             * Removes all the journal articles where resourcePrimKey = &#63; from the database.
1906             *
1907             * @param resourcePrimKey the resource prim key
1908             * @throws SystemException if a system exception occurred
1909             */
1910            @Override
1911            public void removeByResourcePrimKey(long resourcePrimKey)
1912                    throws SystemException {
1913                    for (JournalArticle journalArticle : findByResourcePrimKey(
1914                                    resourcePrimKey, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1915                            remove(journalArticle);
1916                    }
1917            }
1918    
1919            /**
1920             * Returns the number of journal articles where resourcePrimKey = &#63;.
1921             *
1922             * @param resourcePrimKey the resource prim key
1923             * @return the number of matching journal articles
1924             * @throws SystemException if a system exception occurred
1925             */
1926            @Override
1927            public int countByResourcePrimKey(long resourcePrimKey)
1928                    throws SystemException {
1929                    FinderPath finderPath = FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY;
1930    
1931                    Object[] finderArgs = new Object[] { resourcePrimKey };
1932    
1933                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1934                                    this);
1935    
1936                    if (count == null) {
1937                            StringBundler query = new StringBundler(2);
1938    
1939                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
1940    
1941                            query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
1942    
1943                            String sql = query.toString();
1944    
1945                            Session session = null;
1946    
1947                            try {
1948                                    session = openSession();
1949    
1950                                    Query q = session.createQuery(sql);
1951    
1952                                    QueryPos qPos = QueryPos.getInstance(q);
1953    
1954                                    qPos.add(resourcePrimKey);
1955    
1956                                    count = (Long)q.uniqueResult();
1957    
1958                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1959                            }
1960                            catch (Exception e) {
1961                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1962    
1963                                    throw processException(e);
1964                            }
1965                            finally {
1966                                    closeSession(session);
1967                            }
1968                    }
1969    
1970                    return count.intValue();
1971            }
1972    
1973            private static final String _FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2 =
1974                    "journalArticle.resourcePrimKey = ?";
1975            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1976                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1977                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1978                            "findByGroupId",
1979                            new String[] {
1980                                    Long.class.getName(),
1981                                    
1982                            Integer.class.getName(), Integer.class.getName(),
1983                                    OrderByComparator.class.getName()
1984                            });
1985            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1986                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1987                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1988                            JournalArticleImpl.class,
1989                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1990                            new String[] { Long.class.getName() },
1991                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
1992                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
1993                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
1994            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1995                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
1996                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1997                            new String[] { Long.class.getName() });
1998    
1999            /**
2000             * Returns all the journal articles where groupId = &#63;.
2001             *
2002             * @param groupId the group ID
2003             * @return the matching journal articles
2004             * @throws SystemException if a system exception occurred
2005             */
2006            @Override
2007            public List<JournalArticle> findByGroupId(long groupId)
2008                    throws SystemException {
2009                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2010            }
2011    
2012            /**
2013             * Returns a range of all the journal articles where groupId = &#63;.
2014             *
2015             * <p>
2016             * 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.
2017             * </p>
2018             *
2019             * @param groupId the group ID
2020             * @param start the lower bound of the range of journal articles
2021             * @param end the upper bound of the range of journal articles (not inclusive)
2022             * @return the range of matching journal articles
2023             * @throws SystemException if a system exception occurred
2024             */
2025            @Override
2026            public List<JournalArticle> findByGroupId(long groupId, int start, int end)
2027                    throws SystemException {
2028                    return findByGroupId(groupId, start, end, null);
2029            }
2030    
2031            /**
2032             * Returns an ordered range of all the journal articles where groupId = &#63;.
2033             *
2034             * <p>
2035             * 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.
2036             * </p>
2037             *
2038             * @param groupId the group ID
2039             * @param start the lower bound of the range of journal articles
2040             * @param end the upper bound of the range of journal articles (not inclusive)
2041             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2042             * @return the ordered range of matching journal articles
2043             * @throws SystemException if a system exception occurred
2044             */
2045            @Override
2046            public List<JournalArticle> findByGroupId(long groupId, int start, int end,
2047                    OrderByComparator orderByComparator) throws SystemException {
2048                    boolean pagination = true;
2049                    FinderPath finderPath = null;
2050                    Object[] finderArgs = null;
2051    
2052                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2053                                    (orderByComparator == null)) {
2054                            pagination = false;
2055                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
2056                            finderArgs = new Object[] { groupId };
2057                    }
2058                    else {
2059                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
2060                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
2061                    }
2062    
2063                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
2064                                    finderArgs, this);
2065    
2066                    if ((list != null) && !list.isEmpty()) {
2067                            for (JournalArticle journalArticle : list) {
2068                                    if ((groupId != journalArticle.getGroupId())) {
2069                                            list = null;
2070    
2071                                            break;
2072                                    }
2073                            }
2074                    }
2075    
2076                    if (list == null) {
2077                            StringBundler query = null;
2078    
2079                            if (orderByComparator != null) {
2080                                    query = new StringBundler(3 +
2081                                                    (orderByComparator.getOrderByFields().length * 3));
2082                            }
2083                            else {
2084                                    query = new StringBundler(3);
2085                            }
2086    
2087                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2088    
2089                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2090    
2091                            if (orderByComparator != null) {
2092                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2093                                            orderByComparator);
2094                            }
2095                            else
2096                             if (pagination) {
2097                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2098                            }
2099    
2100                            String sql = query.toString();
2101    
2102                            Session session = null;
2103    
2104                            try {
2105                                    session = openSession();
2106    
2107                                    Query q = session.createQuery(sql);
2108    
2109                                    QueryPos qPos = QueryPos.getInstance(q);
2110    
2111                                    qPos.add(groupId);
2112    
2113                                    if (!pagination) {
2114                                            list = (List<JournalArticle>)QueryUtil.list(q,
2115                                                            getDialect(), start, end, false);
2116    
2117                                            Collections.sort(list);
2118    
2119                                            list = new UnmodifiableList<JournalArticle>(list);
2120                                    }
2121                                    else {
2122                                            list = (List<JournalArticle>)QueryUtil.list(q,
2123                                                            getDialect(), start, end);
2124                                    }
2125    
2126                                    cacheResult(list);
2127    
2128                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2129                            }
2130                            catch (Exception e) {
2131                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2132    
2133                                    throw processException(e);
2134                            }
2135                            finally {
2136                                    closeSession(session);
2137                            }
2138                    }
2139    
2140                    return list;
2141            }
2142    
2143            /**
2144             * Returns the first journal article in the ordered set where groupId = &#63;.
2145             *
2146             * @param groupId the group ID
2147             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2148             * @return the first matching journal article
2149             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2150             * @throws SystemException if a system exception occurred
2151             */
2152            @Override
2153            public JournalArticle findByGroupId_First(long groupId,
2154                    OrderByComparator orderByComparator)
2155                    throws NoSuchArticleException, SystemException {
2156                    JournalArticle journalArticle = fetchByGroupId_First(groupId,
2157                                    orderByComparator);
2158    
2159                    if (journalArticle != null) {
2160                            return journalArticle;
2161                    }
2162    
2163                    StringBundler msg = new StringBundler(4);
2164    
2165                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2166    
2167                    msg.append("groupId=");
2168                    msg.append(groupId);
2169    
2170                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2171    
2172                    throw new NoSuchArticleException(msg.toString());
2173            }
2174    
2175            /**
2176             * Returns the first journal article in the ordered set where groupId = &#63;.
2177             *
2178             * @param groupId the group ID
2179             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2180             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
2181             * @throws SystemException if a system exception occurred
2182             */
2183            @Override
2184            public JournalArticle fetchByGroupId_First(long groupId,
2185                    OrderByComparator orderByComparator) throws SystemException {
2186                    List<JournalArticle> list = findByGroupId(groupId, 0, 1,
2187                                    orderByComparator);
2188    
2189                    if (!list.isEmpty()) {
2190                            return list.get(0);
2191                    }
2192    
2193                    return null;
2194            }
2195    
2196            /**
2197             * Returns the last journal article in the ordered set where groupId = &#63;.
2198             *
2199             * @param groupId the group ID
2200             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2201             * @return the last matching journal article
2202             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2203             * @throws SystemException if a system exception occurred
2204             */
2205            @Override
2206            public JournalArticle findByGroupId_Last(long groupId,
2207                    OrderByComparator orderByComparator)
2208                    throws NoSuchArticleException, SystemException {
2209                    JournalArticle journalArticle = fetchByGroupId_Last(groupId,
2210                                    orderByComparator);
2211    
2212                    if (journalArticle != null) {
2213                            return journalArticle;
2214                    }
2215    
2216                    StringBundler msg = new StringBundler(4);
2217    
2218                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2219    
2220                    msg.append("groupId=");
2221                    msg.append(groupId);
2222    
2223                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2224    
2225                    throw new NoSuchArticleException(msg.toString());
2226            }
2227    
2228            /**
2229             * Returns the last journal article in the ordered set where groupId = &#63;.
2230             *
2231             * @param groupId the group ID
2232             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2233             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
2234             * @throws SystemException if a system exception occurred
2235             */
2236            @Override
2237            public JournalArticle fetchByGroupId_Last(long groupId,
2238                    OrderByComparator orderByComparator) throws SystemException {
2239                    int count = countByGroupId(groupId);
2240    
2241                    if (count == 0) {
2242                            return null;
2243                    }
2244    
2245                    List<JournalArticle> list = findByGroupId(groupId, count - 1, count,
2246                                    orderByComparator);
2247    
2248                    if (!list.isEmpty()) {
2249                            return list.get(0);
2250                    }
2251    
2252                    return null;
2253            }
2254    
2255            /**
2256             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63;.
2257             *
2258             * @param id the primary key of the current journal article
2259             * @param groupId the group ID
2260             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2261             * @return the previous, current, and next journal article
2262             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
2263             * @throws SystemException if a system exception occurred
2264             */
2265            @Override
2266            public JournalArticle[] findByGroupId_PrevAndNext(long id, long groupId,
2267                    OrderByComparator orderByComparator)
2268                    throws NoSuchArticleException, SystemException {
2269                    JournalArticle journalArticle = findByPrimaryKey(id);
2270    
2271                    Session session = null;
2272    
2273                    try {
2274                            session = openSession();
2275    
2276                            JournalArticle[] array = new JournalArticleImpl[3];
2277    
2278                            array[0] = getByGroupId_PrevAndNext(session, journalArticle,
2279                                            groupId, orderByComparator, true);
2280    
2281                            array[1] = journalArticle;
2282    
2283                            array[2] = getByGroupId_PrevAndNext(session, journalArticle,
2284                                            groupId, orderByComparator, false);
2285    
2286                            return array;
2287                    }
2288                    catch (Exception e) {
2289                            throw processException(e);
2290                    }
2291                    finally {
2292                            closeSession(session);
2293                    }
2294            }
2295    
2296            protected JournalArticle getByGroupId_PrevAndNext(Session session,
2297                    JournalArticle journalArticle, long groupId,
2298                    OrderByComparator orderByComparator, boolean previous) {
2299                    StringBundler query = null;
2300    
2301                    if (orderByComparator != null) {
2302                            query = new StringBundler(6 +
2303                                            (orderByComparator.getOrderByFields().length * 6));
2304                    }
2305                    else {
2306                            query = new StringBundler(3);
2307                    }
2308    
2309                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2310    
2311                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2312    
2313                    if (orderByComparator != null) {
2314                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2315    
2316                            if (orderByConditionFields.length > 0) {
2317                                    query.append(WHERE_AND);
2318                            }
2319    
2320                            for (int i = 0; i < orderByConditionFields.length; i++) {
2321                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2322                                    query.append(orderByConditionFields[i]);
2323    
2324                                    if ((i + 1) < orderByConditionFields.length) {
2325                                            if (orderByComparator.isAscending() ^ previous) {
2326                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2327                                            }
2328                                            else {
2329                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2330                                            }
2331                                    }
2332                                    else {
2333                                            if (orderByComparator.isAscending() ^ previous) {
2334                                                    query.append(WHERE_GREATER_THAN);
2335                                            }
2336                                            else {
2337                                                    query.append(WHERE_LESSER_THAN);
2338                                            }
2339                                    }
2340                            }
2341    
2342                            query.append(ORDER_BY_CLAUSE);
2343    
2344                            String[] orderByFields = orderByComparator.getOrderByFields();
2345    
2346                            for (int i = 0; i < orderByFields.length; i++) {
2347                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2348                                    query.append(orderByFields[i]);
2349    
2350                                    if ((i + 1) < orderByFields.length) {
2351                                            if (orderByComparator.isAscending() ^ previous) {
2352                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2353                                            }
2354                                            else {
2355                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2356                                            }
2357                                    }
2358                                    else {
2359                                            if (orderByComparator.isAscending() ^ previous) {
2360                                                    query.append(ORDER_BY_ASC);
2361                                            }
2362                                            else {
2363                                                    query.append(ORDER_BY_DESC);
2364                                            }
2365                                    }
2366                            }
2367                    }
2368                    else {
2369                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2370                    }
2371    
2372                    String sql = query.toString();
2373    
2374                    Query q = session.createQuery(sql);
2375    
2376                    q.setFirstResult(0);
2377                    q.setMaxResults(2);
2378    
2379                    QueryPos qPos = QueryPos.getInstance(q);
2380    
2381                    qPos.add(groupId);
2382    
2383                    if (orderByComparator != null) {
2384                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
2385    
2386                            for (Object value : values) {
2387                                    qPos.add(value);
2388                            }
2389                    }
2390    
2391                    List<JournalArticle> list = q.list();
2392    
2393                    if (list.size() == 2) {
2394                            return list.get(1);
2395                    }
2396                    else {
2397                            return null;
2398                    }
2399            }
2400    
2401            /**
2402             * Returns all the journal articles that the user has permission to view where groupId = &#63;.
2403             *
2404             * @param groupId the group ID
2405             * @return the matching journal articles that the user has permission to view
2406             * @throws SystemException if a system exception occurred
2407             */
2408            @Override
2409            public List<JournalArticle> filterFindByGroupId(long groupId)
2410                    throws SystemException {
2411                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
2412                            QueryUtil.ALL_POS, null);
2413            }
2414    
2415            /**
2416             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63;.
2417             *
2418             * <p>
2419             * 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.
2420             * </p>
2421             *
2422             * @param groupId the group ID
2423             * @param start the lower bound of the range of journal articles
2424             * @param end the upper bound of the range of journal articles (not inclusive)
2425             * @return the range of matching journal articles that the user has permission to view
2426             * @throws SystemException if a system exception occurred
2427             */
2428            @Override
2429            public List<JournalArticle> filterFindByGroupId(long groupId, int start,
2430                    int end) throws SystemException {
2431                    return filterFindByGroupId(groupId, start, end, null);
2432            }
2433    
2434            /**
2435             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63;.
2436             *
2437             * <p>
2438             * 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.
2439             * </p>
2440             *
2441             * @param groupId the group ID
2442             * @param start the lower bound of the range of journal articles
2443             * @param end the upper bound of the range of journal articles (not inclusive)
2444             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2445             * @return the ordered range of matching journal articles that the user has permission to view
2446             * @throws SystemException if a system exception occurred
2447             */
2448            @Override
2449            public List<JournalArticle> filterFindByGroupId(long groupId, int start,
2450                    int end, OrderByComparator orderByComparator) throws SystemException {
2451                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2452                            return findByGroupId(groupId, start, end, orderByComparator);
2453                    }
2454    
2455                    StringBundler query = null;
2456    
2457                    if (orderByComparator != null) {
2458                            query = new StringBundler(3 +
2459                                            (orderByComparator.getOrderByFields().length * 3));
2460                    }
2461                    else {
2462                            query = new StringBundler(3);
2463                    }
2464    
2465                    if (getDB().isSupportsInlineDistinct()) {
2466                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
2467                    }
2468                    else {
2469                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
2470                    }
2471    
2472                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2473    
2474                    if (!getDB().isSupportsInlineDistinct()) {
2475                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
2476                    }
2477    
2478                    if (orderByComparator != null) {
2479                            if (getDB().isSupportsInlineDistinct()) {
2480                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2481                                            orderByComparator, true);
2482                            }
2483                            else {
2484                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2485                                            orderByComparator, true);
2486                            }
2487                    }
2488                    else {
2489                            if (getDB().isSupportsInlineDistinct()) {
2490                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2491                            }
2492                            else {
2493                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
2494                            }
2495                    }
2496    
2497                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2498                                    JournalArticle.class.getName(),
2499                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2500    
2501                    Session session = null;
2502    
2503                    try {
2504                            session = openSession();
2505    
2506                            SQLQuery q = session.createSQLQuery(sql);
2507    
2508                            if (getDB().isSupportsInlineDistinct()) {
2509                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
2510                            }
2511                            else {
2512                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
2513                            }
2514    
2515                            QueryPos qPos = QueryPos.getInstance(q);
2516    
2517                            qPos.add(groupId);
2518    
2519                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
2520                                    end);
2521                    }
2522                    catch (Exception e) {
2523                            throw processException(e);
2524                    }
2525                    finally {
2526                            closeSession(session);
2527                    }
2528            }
2529    
2530            /**
2531             * 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;.
2532             *
2533             * @param id the primary key of the current journal article
2534             * @param groupId the group ID
2535             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2536             * @return the previous, current, and next journal article
2537             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
2538             * @throws SystemException if a system exception occurred
2539             */
2540            @Override
2541            public JournalArticle[] filterFindByGroupId_PrevAndNext(long id,
2542                    long groupId, OrderByComparator orderByComparator)
2543                    throws NoSuchArticleException, SystemException {
2544                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2545                            return findByGroupId_PrevAndNext(id, groupId, orderByComparator);
2546                    }
2547    
2548                    JournalArticle journalArticle = findByPrimaryKey(id);
2549    
2550                    Session session = null;
2551    
2552                    try {
2553                            session = openSession();
2554    
2555                            JournalArticle[] array = new JournalArticleImpl[3];
2556    
2557                            array[0] = filterGetByGroupId_PrevAndNext(session, journalArticle,
2558                                            groupId, orderByComparator, true);
2559    
2560                            array[1] = journalArticle;
2561    
2562                            array[2] = filterGetByGroupId_PrevAndNext(session, journalArticle,
2563                                            groupId, orderByComparator, false);
2564    
2565                            return array;
2566                    }
2567                    catch (Exception e) {
2568                            throw processException(e);
2569                    }
2570                    finally {
2571                            closeSession(session);
2572                    }
2573            }
2574    
2575            protected JournalArticle filterGetByGroupId_PrevAndNext(Session session,
2576                    JournalArticle journalArticle, long groupId,
2577                    OrderByComparator orderByComparator, boolean previous) {
2578                    StringBundler query = null;
2579    
2580                    if (orderByComparator != null) {
2581                            query = new StringBundler(6 +
2582                                            (orderByComparator.getOrderByFields().length * 6));
2583                    }
2584                    else {
2585                            query = new StringBundler(3);
2586                    }
2587    
2588                    if (getDB().isSupportsInlineDistinct()) {
2589                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
2590                    }
2591                    else {
2592                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
2593                    }
2594    
2595                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2596    
2597                    if (!getDB().isSupportsInlineDistinct()) {
2598                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
2599                    }
2600    
2601                    if (orderByComparator != null) {
2602                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2603    
2604                            if (orderByConditionFields.length > 0) {
2605                                    query.append(WHERE_AND);
2606                            }
2607    
2608                            for (int i = 0; i < orderByConditionFields.length; i++) {
2609                                    if (getDB().isSupportsInlineDistinct()) {
2610                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2611                                    }
2612                                    else {
2613                                            query.append(_ORDER_BY_ENTITY_TABLE);
2614                                    }
2615    
2616                                    query.append(orderByConditionFields[i]);
2617    
2618                                    if ((i + 1) < orderByConditionFields.length) {
2619                                            if (orderByComparator.isAscending() ^ previous) {
2620                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2621                                            }
2622                                            else {
2623                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2624                                            }
2625                                    }
2626                                    else {
2627                                            if (orderByComparator.isAscending() ^ previous) {
2628                                                    query.append(WHERE_GREATER_THAN);
2629                                            }
2630                                            else {
2631                                                    query.append(WHERE_LESSER_THAN);
2632                                            }
2633                                    }
2634                            }
2635    
2636                            query.append(ORDER_BY_CLAUSE);
2637    
2638                            String[] orderByFields = orderByComparator.getOrderByFields();
2639    
2640                            for (int i = 0; i < orderByFields.length; i++) {
2641                                    if (getDB().isSupportsInlineDistinct()) {
2642                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2643                                    }
2644                                    else {
2645                                            query.append(_ORDER_BY_ENTITY_TABLE);
2646                                    }
2647    
2648                                    query.append(orderByFields[i]);
2649    
2650                                    if ((i + 1) < orderByFields.length) {
2651                                            if (orderByComparator.isAscending() ^ previous) {
2652                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2653                                            }
2654                                            else {
2655                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2656                                            }
2657                                    }
2658                                    else {
2659                                            if (orderByComparator.isAscending() ^ previous) {
2660                                                    query.append(ORDER_BY_ASC);
2661                                            }
2662                                            else {
2663                                                    query.append(ORDER_BY_DESC);
2664                                            }
2665                                    }
2666                            }
2667                    }
2668                    else {
2669                            if (getDB().isSupportsInlineDistinct()) {
2670                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2671                            }
2672                            else {
2673                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
2674                            }
2675                    }
2676    
2677                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2678                                    JournalArticle.class.getName(),
2679                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2680    
2681                    SQLQuery q = session.createSQLQuery(sql);
2682    
2683                    q.setFirstResult(0);
2684                    q.setMaxResults(2);
2685    
2686                    if (getDB().isSupportsInlineDistinct()) {
2687                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
2688                    }
2689                    else {
2690                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
2691                    }
2692    
2693                    QueryPos qPos = QueryPos.getInstance(q);
2694    
2695                    qPos.add(groupId);
2696    
2697                    if (orderByComparator != null) {
2698                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
2699    
2700                            for (Object value : values) {
2701                                    qPos.add(value);
2702                            }
2703                    }
2704    
2705                    List<JournalArticle> list = q.list();
2706    
2707                    if (list.size() == 2) {
2708                            return list.get(1);
2709                    }
2710                    else {
2711                            return null;
2712                    }
2713            }
2714    
2715            /**
2716             * Removes all the journal articles where groupId = &#63; from the database.
2717             *
2718             * @param groupId the group ID
2719             * @throws SystemException if a system exception occurred
2720             */
2721            @Override
2722            public void removeByGroupId(long groupId) throws SystemException {
2723                    for (JournalArticle journalArticle : findByGroupId(groupId,
2724                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2725                            remove(journalArticle);
2726                    }
2727            }
2728    
2729            /**
2730             * Returns the number of journal articles where groupId = &#63;.
2731             *
2732             * @param groupId the group ID
2733             * @return the number of matching journal articles
2734             * @throws SystemException if a system exception occurred
2735             */
2736            @Override
2737            public int countByGroupId(long groupId) throws SystemException {
2738                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2739    
2740                    Object[] finderArgs = new Object[] { groupId };
2741    
2742                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2743                                    this);
2744    
2745                    if (count == null) {
2746                            StringBundler query = new StringBundler(2);
2747    
2748                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
2749    
2750                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2751    
2752                            String sql = query.toString();
2753    
2754                            Session session = null;
2755    
2756                            try {
2757                                    session = openSession();
2758    
2759                                    Query q = session.createQuery(sql);
2760    
2761                                    QueryPos qPos = QueryPos.getInstance(q);
2762    
2763                                    qPos.add(groupId);
2764    
2765                                    count = (Long)q.uniqueResult();
2766    
2767                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2768                            }
2769                            catch (Exception e) {
2770                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2771    
2772                                    throw processException(e);
2773                            }
2774                            finally {
2775                                    closeSession(session);
2776                            }
2777                    }
2778    
2779                    return count.intValue();
2780            }
2781    
2782            /**
2783             * Returns the number of journal articles that the user has permission to view where groupId = &#63;.
2784             *
2785             * @param groupId the group ID
2786             * @return the number of matching journal articles that the user has permission to view
2787             * @throws SystemException if a system exception occurred
2788             */
2789            @Override
2790            public int filterCountByGroupId(long groupId) throws SystemException {
2791                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2792                            return countByGroupId(groupId);
2793                    }
2794    
2795                    StringBundler query = new StringBundler(2);
2796    
2797                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
2798    
2799                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2800    
2801                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2802                                    JournalArticle.class.getName(),
2803                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2804    
2805                    Session session = null;
2806    
2807                    try {
2808                            session = openSession();
2809    
2810                            SQLQuery q = session.createSQLQuery(sql);
2811    
2812                            q.addScalar(COUNT_COLUMN_NAME,
2813                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2814    
2815                            QueryPos qPos = QueryPos.getInstance(q);
2816    
2817                            qPos.add(groupId);
2818    
2819                            Long count = (Long)q.uniqueResult();
2820    
2821                            return count.intValue();
2822                    }
2823                    catch (Exception e) {
2824                            throw processException(e);
2825                    }
2826                    finally {
2827                            closeSession(session);
2828                    }
2829            }
2830    
2831            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "journalArticle.groupId = ?";
2832            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2833                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
2834                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
2835                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2836                            "findByCompanyId",
2837                            new String[] {
2838                                    Long.class.getName(),
2839                                    
2840                            Integer.class.getName(), Integer.class.getName(),
2841                                    OrderByComparator.class.getName()
2842                            });
2843            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2844                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
2845                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
2846                            JournalArticleImpl.class,
2847                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2848                            new String[] { Long.class.getName() },
2849                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
2850                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
2851                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
2852            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
2853                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
2854                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2855                            new String[] { Long.class.getName() });
2856    
2857            /**
2858             * Returns all the journal articles where companyId = &#63;.
2859             *
2860             * @param companyId the company ID
2861             * @return the matching journal articles
2862             * @throws SystemException if a system exception occurred
2863             */
2864            @Override
2865            public List<JournalArticle> findByCompanyId(long companyId)
2866                    throws SystemException {
2867                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2868                            null);
2869            }
2870    
2871            /**
2872             * Returns a range of all the journal articles where companyId = &#63;.
2873             *
2874             * <p>
2875             * 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.
2876             * </p>
2877             *
2878             * @param companyId the company ID
2879             * @param start the lower bound of the range of journal articles
2880             * @param end the upper bound of the range of journal articles (not inclusive)
2881             * @return the range of matching journal articles
2882             * @throws SystemException if a system exception occurred
2883             */
2884            @Override
2885            public List<JournalArticle> findByCompanyId(long companyId, int start,
2886                    int end) throws SystemException {
2887                    return findByCompanyId(companyId, start, end, null);
2888            }
2889    
2890            /**
2891             * Returns an ordered range of all the journal articles where companyId = &#63;.
2892             *
2893             * <p>
2894             * 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.
2895             * </p>
2896             *
2897             * @param companyId the company ID
2898             * @param start the lower bound of the range of journal articles
2899             * @param end the upper bound of the range of journal articles (not inclusive)
2900             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2901             * @return the ordered range of matching journal articles
2902             * @throws SystemException if a system exception occurred
2903             */
2904            @Override
2905            public List<JournalArticle> findByCompanyId(long companyId, int start,
2906                    int end, OrderByComparator orderByComparator) throws SystemException {
2907                    boolean pagination = true;
2908                    FinderPath finderPath = null;
2909                    Object[] finderArgs = null;
2910    
2911                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2912                                    (orderByComparator == null)) {
2913                            pagination = false;
2914                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2915                            finderArgs = new Object[] { companyId };
2916                    }
2917                    else {
2918                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2919                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2920                    }
2921    
2922                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
2923                                    finderArgs, this);
2924    
2925                    if ((list != null) && !list.isEmpty()) {
2926                            for (JournalArticle journalArticle : list) {
2927                                    if ((companyId != journalArticle.getCompanyId())) {
2928                                            list = null;
2929    
2930                                            break;
2931                                    }
2932                            }
2933                    }
2934    
2935                    if (list == null) {
2936                            StringBundler query = null;
2937    
2938                            if (orderByComparator != null) {
2939                                    query = new StringBundler(3 +
2940                                                    (orderByComparator.getOrderByFields().length * 3));
2941                            }
2942                            else {
2943                                    query = new StringBundler(3);
2944                            }
2945    
2946                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2947    
2948                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2949    
2950                            if (orderByComparator != null) {
2951                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2952                                            orderByComparator);
2953                            }
2954                            else
2955                             if (pagination) {
2956                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2957                            }
2958    
2959                            String sql = query.toString();
2960    
2961                            Session session = null;
2962    
2963                            try {
2964                                    session = openSession();
2965    
2966                                    Query q = session.createQuery(sql);
2967    
2968                                    QueryPos qPos = QueryPos.getInstance(q);
2969    
2970                                    qPos.add(companyId);
2971    
2972                                    if (!pagination) {
2973                                            list = (List<JournalArticle>)QueryUtil.list(q,
2974                                                            getDialect(), start, end, false);
2975    
2976                                            Collections.sort(list);
2977    
2978                                            list = new UnmodifiableList<JournalArticle>(list);
2979                                    }
2980                                    else {
2981                                            list = (List<JournalArticle>)QueryUtil.list(q,
2982                                                            getDialect(), start, end);
2983                                    }
2984    
2985                                    cacheResult(list);
2986    
2987                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2988                            }
2989                            catch (Exception e) {
2990                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2991    
2992                                    throw processException(e);
2993                            }
2994                            finally {
2995                                    closeSession(session);
2996                            }
2997                    }
2998    
2999                    return list;
3000            }
3001    
3002            /**
3003             * Returns the first journal article in the ordered set where companyId = &#63;.
3004             *
3005             * @param companyId the company ID
3006             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3007             * @return the first matching journal article
3008             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3009             * @throws SystemException if a system exception occurred
3010             */
3011            @Override
3012            public JournalArticle findByCompanyId_First(long companyId,
3013                    OrderByComparator orderByComparator)
3014                    throws NoSuchArticleException, SystemException {
3015                    JournalArticle journalArticle = fetchByCompanyId_First(companyId,
3016                                    orderByComparator);
3017    
3018                    if (journalArticle != null) {
3019                            return journalArticle;
3020                    }
3021    
3022                    StringBundler msg = new StringBundler(4);
3023    
3024                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3025    
3026                    msg.append("companyId=");
3027                    msg.append(companyId);
3028    
3029                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3030    
3031                    throw new NoSuchArticleException(msg.toString());
3032            }
3033    
3034            /**
3035             * Returns the first journal article in the ordered set where companyId = &#63;.
3036             *
3037             * @param companyId the company ID
3038             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3039             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
3040             * @throws SystemException if a system exception occurred
3041             */
3042            @Override
3043            public JournalArticle fetchByCompanyId_First(long companyId,
3044                    OrderByComparator orderByComparator) throws SystemException {
3045                    List<JournalArticle> list = findByCompanyId(companyId, 0, 1,
3046                                    orderByComparator);
3047    
3048                    if (!list.isEmpty()) {
3049                            return list.get(0);
3050                    }
3051    
3052                    return null;
3053            }
3054    
3055            /**
3056             * Returns the last journal article in the ordered set where companyId = &#63;.
3057             *
3058             * @param companyId the company ID
3059             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3060             * @return the last matching journal article
3061             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3062             * @throws SystemException if a system exception occurred
3063             */
3064            @Override
3065            public JournalArticle findByCompanyId_Last(long companyId,
3066                    OrderByComparator orderByComparator)
3067                    throws NoSuchArticleException, SystemException {
3068                    JournalArticle journalArticle = fetchByCompanyId_Last(companyId,
3069                                    orderByComparator);
3070    
3071                    if (journalArticle != null) {
3072                            return journalArticle;
3073                    }
3074    
3075                    StringBundler msg = new StringBundler(4);
3076    
3077                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3078    
3079                    msg.append("companyId=");
3080                    msg.append(companyId);
3081    
3082                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3083    
3084                    throw new NoSuchArticleException(msg.toString());
3085            }
3086    
3087            /**
3088             * Returns the last journal article in the ordered set where companyId = &#63;.
3089             *
3090             * @param companyId the company ID
3091             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3092             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
3093             * @throws SystemException if a system exception occurred
3094             */
3095            @Override
3096            public JournalArticle fetchByCompanyId_Last(long companyId,
3097                    OrderByComparator orderByComparator) throws SystemException {
3098                    int count = countByCompanyId(companyId);
3099    
3100                    if (count == 0) {
3101                            return null;
3102                    }
3103    
3104                    List<JournalArticle> list = findByCompanyId(companyId, count - 1,
3105                                    count, orderByComparator);
3106    
3107                    if (!list.isEmpty()) {
3108                            return list.get(0);
3109                    }
3110    
3111                    return null;
3112            }
3113    
3114            /**
3115             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63;.
3116             *
3117             * @param id the primary key of the current journal article
3118             * @param companyId the company ID
3119             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3120             * @return the previous, current, and next journal article
3121             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
3122             * @throws SystemException if a system exception occurred
3123             */
3124            @Override
3125            public JournalArticle[] findByCompanyId_PrevAndNext(long id,
3126                    long companyId, OrderByComparator orderByComparator)
3127                    throws NoSuchArticleException, SystemException {
3128                    JournalArticle journalArticle = findByPrimaryKey(id);
3129    
3130                    Session session = null;
3131    
3132                    try {
3133                            session = openSession();
3134    
3135                            JournalArticle[] array = new JournalArticleImpl[3];
3136    
3137                            array[0] = getByCompanyId_PrevAndNext(session, journalArticle,
3138                                            companyId, orderByComparator, true);
3139    
3140                            array[1] = journalArticle;
3141    
3142                            array[2] = getByCompanyId_PrevAndNext(session, journalArticle,
3143                                            companyId, orderByComparator, false);
3144    
3145                            return array;
3146                    }
3147                    catch (Exception e) {
3148                            throw processException(e);
3149                    }
3150                    finally {
3151                            closeSession(session);
3152                    }
3153            }
3154    
3155            protected JournalArticle getByCompanyId_PrevAndNext(Session session,
3156                    JournalArticle journalArticle, long companyId,
3157                    OrderByComparator orderByComparator, boolean previous) {
3158                    StringBundler query = null;
3159    
3160                    if (orderByComparator != null) {
3161                            query = new StringBundler(6 +
3162                                            (orderByComparator.getOrderByFields().length * 6));
3163                    }
3164                    else {
3165                            query = new StringBundler(3);
3166                    }
3167    
3168                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3169    
3170                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3171    
3172                    if (orderByComparator != null) {
3173                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3174    
3175                            if (orderByConditionFields.length > 0) {
3176                                    query.append(WHERE_AND);
3177                            }
3178    
3179                            for (int i = 0; i < orderByConditionFields.length; i++) {
3180                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3181                                    query.append(orderByConditionFields[i]);
3182    
3183                                    if ((i + 1) < orderByConditionFields.length) {
3184                                            if (orderByComparator.isAscending() ^ previous) {
3185                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3186                                            }
3187                                            else {
3188                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3189                                            }
3190                                    }
3191                                    else {
3192                                            if (orderByComparator.isAscending() ^ previous) {
3193                                                    query.append(WHERE_GREATER_THAN);
3194                                            }
3195                                            else {
3196                                                    query.append(WHERE_LESSER_THAN);
3197                                            }
3198                                    }
3199                            }
3200    
3201                            query.append(ORDER_BY_CLAUSE);
3202    
3203                            String[] orderByFields = orderByComparator.getOrderByFields();
3204    
3205                            for (int i = 0; i < orderByFields.length; i++) {
3206                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3207                                    query.append(orderByFields[i]);
3208    
3209                                    if ((i + 1) < orderByFields.length) {
3210                                            if (orderByComparator.isAscending() ^ previous) {
3211                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3212                                            }
3213                                            else {
3214                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3215                                            }
3216                                    }
3217                                    else {
3218                                            if (orderByComparator.isAscending() ^ previous) {
3219                                                    query.append(ORDER_BY_ASC);
3220                                            }
3221                                            else {
3222                                                    query.append(ORDER_BY_DESC);
3223                                            }
3224                                    }
3225                            }
3226                    }
3227                    else {
3228                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3229                    }
3230    
3231                    String sql = query.toString();
3232    
3233                    Query q = session.createQuery(sql);
3234    
3235                    q.setFirstResult(0);
3236                    q.setMaxResults(2);
3237    
3238                    QueryPos qPos = QueryPos.getInstance(q);
3239    
3240                    qPos.add(companyId);
3241    
3242                    if (orderByComparator != null) {
3243                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3244    
3245                            for (Object value : values) {
3246                                    qPos.add(value);
3247                            }
3248                    }
3249    
3250                    List<JournalArticle> list = q.list();
3251    
3252                    if (list.size() == 2) {
3253                            return list.get(1);
3254                    }
3255                    else {
3256                            return null;
3257                    }
3258            }
3259    
3260            /**
3261             * Removes all the journal articles where companyId = &#63; from the database.
3262             *
3263             * @param companyId the company ID
3264             * @throws SystemException if a system exception occurred
3265             */
3266            @Override
3267            public void removeByCompanyId(long companyId) throws SystemException {
3268                    for (JournalArticle journalArticle : findByCompanyId(companyId,
3269                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3270                            remove(journalArticle);
3271                    }
3272            }
3273    
3274            /**
3275             * Returns the number of journal articles where companyId = &#63;.
3276             *
3277             * @param companyId the company ID
3278             * @return the number of matching journal articles
3279             * @throws SystemException if a system exception occurred
3280             */
3281            @Override
3282            public int countByCompanyId(long companyId) throws SystemException {
3283                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
3284    
3285                    Object[] finderArgs = new Object[] { companyId };
3286    
3287                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3288                                    this);
3289    
3290                    if (count == null) {
3291                            StringBundler query = new StringBundler(2);
3292    
3293                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
3294    
3295                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3296    
3297                            String sql = query.toString();
3298    
3299                            Session session = null;
3300    
3301                            try {
3302                                    session = openSession();
3303    
3304                                    Query q = session.createQuery(sql);
3305    
3306                                    QueryPos qPos = QueryPos.getInstance(q);
3307    
3308                                    qPos.add(companyId);
3309    
3310                                    count = (Long)q.uniqueResult();
3311    
3312                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3313                            }
3314                            catch (Exception e) {
3315                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3316    
3317                                    throw processException(e);
3318                            }
3319                            finally {
3320                                    closeSession(session);
3321                            }
3322                    }
3323    
3324                    return count.intValue();
3325            }
3326    
3327            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "journalArticle.companyId = ?";
3328            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID =
3329                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3330                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
3331                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
3332                            "findByStructureId",
3333                            new String[] {
3334                                    String.class.getName(),
3335                                    
3336                            Integer.class.getName(), Integer.class.getName(),
3337                                    OrderByComparator.class.getName()
3338                            });
3339            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID =
3340                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3341                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
3342                            JournalArticleImpl.class,
3343                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByStructureId",
3344                            new String[] { String.class.getName() },
3345                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK |
3346                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
3347                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
3348            public static final FinderPath FINDER_PATH_COUNT_BY_STRUCTUREID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3349                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
3350                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByStructureId",
3351                            new String[] { String.class.getName() });
3352            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_STRUCTUREID =
3353                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3354                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
3355                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByStructureId",
3356                            new String[] { String.class.getName() });
3357    
3358            /**
3359             * Returns all the journal articles where structureId = &#63;.
3360             *
3361             * @param structureId the structure ID
3362             * @return the matching journal articles
3363             * @throws SystemException if a system exception occurred
3364             */
3365            @Override
3366            public List<JournalArticle> findByStructureId(String structureId)
3367                    throws SystemException {
3368                    return findByStructureId(structureId, QueryUtil.ALL_POS,
3369                            QueryUtil.ALL_POS, null);
3370            }
3371    
3372            /**
3373             * Returns a range of all the journal articles where structureId = &#63;.
3374             *
3375             * <p>
3376             * 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.
3377             * </p>
3378             *
3379             * @param structureId the structure ID
3380             * @param start the lower bound of the range of journal articles
3381             * @param end the upper bound of the range of journal articles (not inclusive)
3382             * @return the range of matching journal articles
3383             * @throws SystemException if a system exception occurred
3384             */
3385            @Override
3386            public List<JournalArticle> findByStructureId(String structureId,
3387                    int start, int end) throws SystemException {
3388                    return findByStructureId(structureId, start, end, null);
3389            }
3390    
3391            /**
3392             * Returns an ordered range of all the journal articles where structureId = &#63;.
3393             *
3394             * <p>
3395             * 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.
3396             * </p>
3397             *
3398             * @param structureId the structure ID
3399             * @param start the lower bound of the range of journal articles
3400             * @param end the upper bound of the range of journal articles (not inclusive)
3401             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3402             * @return the ordered range of matching journal articles
3403             * @throws SystemException if a system exception occurred
3404             */
3405            @Override
3406            public List<JournalArticle> findByStructureId(String structureId,
3407                    int start, int end, OrderByComparator orderByComparator)
3408                    throws SystemException {
3409                    boolean pagination = true;
3410                    FinderPath finderPath = null;
3411                    Object[] finderArgs = null;
3412    
3413                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3414                                    (orderByComparator == null)) {
3415                            pagination = false;
3416                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID;
3417                            finderArgs = new Object[] { structureId };
3418                    }
3419                    else {
3420                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID;
3421                            finderArgs = new Object[] { structureId, start, end, orderByComparator };
3422                    }
3423    
3424                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
3425                                    finderArgs, this);
3426    
3427                    if ((list != null) && !list.isEmpty()) {
3428                            for (JournalArticle journalArticle : list) {
3429                                    if (!Validator.equals(structureId,
3430                                                            journalArticle.getStructureId())) {
3431                                            list = null;
3432    
3433                                            break;
3434                                    }
3435                            }
3436                    }
3437    
3438                    if (list == null) {
3439                            StringBundler query = null;
3440    
3441                            if (orderByComparator != null) {
3442                                    query = new StringBundler(3 +
3443                                                    (orderByComparator.getOrderByFields().length * 3));
3444                            }
3445                            else {
3446                                    query = new StringBundler(3);
3447                            }
3448    
3449                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3450    
3451                            boolean bindStructureId = false;
3452    
3453                            if (structureId == null) {
3454                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
3455                            }
3456                            else if (structureId.equals(StringPool.BLANK)) {
3457                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
3458                            }
3459                            else {
3460                                    bindStructureId = true;
3461    
3462                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
3463                            }
3464    
3465                            if (orderByComparator != null) {
3466                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3467                                            orderByComparator);
3468                            }
3469                            else
3470                             if (pagination) {
3471                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3472                            }
3473    
3474                            String sql = query.toString();
3475    
3476                            Session session = null;
3477    
3478                            try {
3479                                    session = openSession();
3480    
3481                                    Query q = session.createQuery(sql);
3482    
3483                                    QueryPos qPos = QueryPos.getInstance(q);
3484    
3485                                    if (bindStructureId) {
3486                                            qPos.add(structureId);
3487                                    }
3488    
3489                                    if (!pagination) {
3490                                            list = (List<JournalArticle>)QueryUtil.list(q,
3491                                                            getDialect(), start, end, false);
3492    
3493                                            Collections.sort(list);
3494    
3495                                            list = new UnmodifiableList<JournalArticle>(list);
3496                                    }
3497                                    else {
3498                                            list = (List<JournalArticle>)QueryUtil.list(q,
3499                                                            getDialect(), start, end);
3500                                    }
3501    
3502                                    cacheResult(list);
3503    
3504                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3505                            }
3506                            catch (Exception e) {
3507                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3508    
3509                                    throw processException(e);
3510                            }
3511                            finally {
3512                                    closeSession(session);
3513                            }
3514                    }
3515    
3516                    return list;
3517            }
3518    
3519            /**
3520             * Returns the first journal article in the ordered set where structureId = &#63;.
3521             *
3522             * @param structureId the structure ID
3523             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3524             * @return the first matching journal article
3525             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3526             * @throws SystemException if a system exception occurred
3527             */
3528            @Override
3529            public JournalArticle findByStructureId_First(String structureId,
3530                    OrderByComparator orderByComparator)
3531                    throws NoSuchArticleException, SystemException {
3532                    JournalArticle journalArticle = fetchByStructureId_First(structureId,
3533                                    orderByComparator);
3534    
3535                    if (journalArticle != null) {
3536                            return journalArticle;
3537                    }
3538    
3539                    StringBundler msg = new StringBundler(4);
3540    
3541                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3542    
3543                    msg.append("structureId=");
3544                    msg.append(structureId);
3545    
3546                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3547    
3548                    throw new NoSuchArticleException(msg.toString());
3549            }
3550    
3551            /**
3552             * Returns the first journal article in the ordered set where structureId = &#63;.
3553             *
3554             * @param structureId the structure ID
3555             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3556             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
3557             * @throws SystemException if a system exception occurred
3558             */
3559            @Override
3560            public JournalArticle fetchByStructureId_First(String structureId,
3561                    OrderByComparator orderByComparator) throws SystemException {
3562                    List<JournalArticle> list = findByStructureId(structureId, 0, 1,
3563                                    orderByComparator);
3564    
3565                    if (!list.isEmpty()) {
3566                            return list.get(0);
3567                    }
3568    
3569                    return null;
3570            }
3571    
3572            /**
3573             * Returns the last journal article in the ordered set where structureId = &#63;.
3574             *
3575             * @param structureId the structure ID
3576             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3577             * @return the last matching journal article
3578             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3579             * @throws SystemException if a system exception occurred
3580             */
3581            @Override
3582            public JournalArticle findByStructureId_Last(String structureId,
3583                    OrderByComparator orderByComparator)
3584                    throws NoSuchArticleException, SystemException {
3585                    JournalArticle journalArticle = fetchByStructureId_Last(structureId,
3586                                    orderByComparator);
3587    
3588                    if (journalArticle != null) {
3589                            return journalArticle;
3590                    }
3591    
3592                    StringBundler msg = new StringBundler(4);
3593    
3594                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3595    
3596                    msg.append("structureId=");
3597                    msg.append(structureId);
3598    
3599                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3600    
3601                    throw new NoSuchArticleException(msg.toString());
3602            }
3603    
3604            /**
3605             * Returns the last journal article in the ordered set where structureId = &#63;.
3606             *
3607             * @param structureId the structure ID
3608             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3609             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
3610             * @throws SystemException if a system exception occurred
3611             */
3612            @Override
3613            public JournalArticle fetchByStructureId_Last(String structureId,
3614                    OrderByComparator orderByComparator) throws SystemException {
3615                    int count = countByStructureId(structureId);
3616    
3617                    if (count == 0) {
3618                            return null;
3619                    }
3620    
3621                    List<JournalArticle> list = findByStructureId(structureId, count - 1,
3622                                    count, orderByComparator);
3623    
3624                    if (!list.isEmpty()) {
3625                            return list.get(0);
3626                    }
3627    
3628                    return null;
3629            }
3630    
3631            /**
3632             * Returns the journal articles before and after the current journal article in the ordered set where structureId = &#63;.
3633             *
3634             * @param id the primary key of the current journal article
3635             * @param structureId the structure ID
3636             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3637             * @return the previous, current, and next journal article
3638             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
3639             * @throws SystemException if a system exception occurred
3640             */
3641            @Override
3642            public JournalArticle[] findByStructureId_PrevAndNext(long id,
3643                    String structureId, OrderByComparator orderByComparator)
3644                    throws NoSuchArticleException, SystemException {
3645                    JournalArticle journalArticle = findByPrimaryKey(id);
3646    
3647                    Session session = null;
3648    
3649                    try {
3650                            session = openSession();
3651    
3652                            JournalArticle[] array = new JournalArticleImpl[3];
3653    
3654                            array[0] = getByStructureId_PrevAndNext(session, journalArticle,
3655                                            structureId, orderByComparator, true);
3656    
3657                            array[1] = journalArticle;
3658    
3659                            array[2] = getByStructureId_PrevAndNext(session, journalArticle,
3660                                            structureId, orderByComparator, false);
3661    
3662                            return array;
3663                    }
3664                    catch (Exception e) {
3665                            throw processException(e);
3666                    }
3667                    finally {
3668                            closeSession(session);
3669                    }
3670            }
3671    
3672            protected JournalArticle getByStructureId_PrevAndNext(Session session,
3673                    JournalArticle journalArticle, String structureId,
3674                    OrderByComparator orderByComparator, boolean previous) {
3675                    StringBundler query = null;
3676    
3677                    if (orderByComparator != null) {
3678                            query = new StringBundler(6 +
3679                                            (orderByComparator.getOrderByFields().length * 6));
3680                    }
3681                    else {
3682                            query = new StringBundler(3);
3683                    }
3684    
3685                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3686    
3687                    boolean bindStructureId = false;
3688    
3689                    if (structureId == null) {
3690                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
3691                    }
3692                    else if (structureId.equals(StringPool.BLANK)) {
3693                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
3694                    }
3695                    else {
3696                            bindStructureId = true;
3697    
3698                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
3699                    }
3700    
3701                    if (orderByComparator != null) {
3702                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3703    
3704                            if (orderByConditionFields.length > 0) {
3705                                    query.append(WHERE_AND);
3706                            }
3707    
3708                            for (int i = 0; i < orderByConditionFields.length; i++) {
3709                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3710                                    query.append(orderByConditionFields[i]);
3711    
3712                                    if ((i + 1) < orderByConditionFields.length) {
3713                                            if (orderByComparator.isAscending() ^ previous) {
3714                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3715                                            }
3716                                            else {
3717                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3718                                            }
3719                                    }
3720                                    else {
3721                                            if (orderByComparator.isAscending() ^ previous) {
3722                                                    query.append(WHERE_GREATER_THAN);
3723                                            }
3724                                            else {
3725                                                    query.append(WHERE_LESSER_THAN);
3726                                            }
3727                                    }
3728                            }
3729    
3730                            query.append(ORDER_BY_CLAUSE);
3731    
3732                            String[] orderByFields = orderByComparator.getOrderByFields();
3733    
3734                            for (int i = 0; i < orderByFields.length; i++) {
3735                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3736                                    query.append(orderByFields[i]);
3737    
3738                                    if ((i + 1) < orderByFields.length) {
3739                                            if (orderByComparator.isAscending() ^ previous) {
3740                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3741                                            }
3742                                            else {
3743                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3744                                            }
3745                                    }
3746                                    else {
3747                                            if (orderByComparator.isAscending() ^ previous) {
3748                                                    query.append(ORDER_BY_ASC);
3749                                            }
3750                                            else {
3751                                                    query.append(ORDER_BY_DESC);
3752                                            }
3753                                    }
3754                            }
3755                    }
3756                    else {
3757                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3758                    }
3759    
3760                    String sql = query.toString();
3761    
3762                    Query q = session.createQuery(sql);
3763    
3764                    q.setFirstResult(0);
3765                    q.setMaxResults(2);
3766    
3767                    QueryPos qPos = QueryPos.getInstance(q);
3768    
3769                    if (bindStructureId) {
3770                            qPos.add(structureId);
3771                    }
3772    
3773                    if (orderByComparator != null) {
3774                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3775    
3776                            for (Object value : values) {
3777                                    qPos.add(value);
3778                            }
3779                    }
3780    
3781                    List<JournalArticle> list = q.list();
3782    
3783                    if (list.size() == 2) {
3784                            return list.get(1);
3785                    }
3786                    else {
3787                            return null;
3788                    }
3789            }
3790    
3791            /**
3792             * Returns all the journal articles where structureId = any &#63;.
3793             *
3794             * <p>
3795             * 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.
3796             * </p>
3797             *
3798             * @param structureIds the structure IDs
3799             * @return the matching journal articles
3800             * @throws SystemException if a system exception occurred
3801             */
3802            @Override
3803            public List<JournalArticle> findByStructureId(String[] structureIds)
3804                    throws SystemException {
3805                    return findByStructureId(structureIds, QueryUtil.ALL_POS,
3806                            QueryUtil.ALL_POS, null);
3807            }
3808    
3809            /**
3810             * Returns a range of all the journal articles where structureId = any &#63;.
3811             *
3812             * <p>
3813             * 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.
3814             * </p>
3815             *
3816             * @param structureIds the structure IDs
3817             * @param start the lower bound of the range of journal articles
3818             * @param end the upper bound of the range of journal articles (not inclusive)
3819             * @return the range of matching journal articles
3820             * @throws SystemException if a system exception occurred
3821             */
3822            @Override
3823            public List<JournalArticle> findByStructureId(String[] structureIds,
3824                    int start, int end) throws SystemException {
3825                    return findByStructureId(structureIds, start, end, null);
3826            }
3827    
3828            /**
3829             * Returns an ordered range of all the journal articles where structureId = any &#63;.
3830             *
3831             * <p>
3832             * 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.
3833             * </p>
3834             *
3835             * @param structureIds the structure IDs
3836             * @param start the lower bound of the range of journal articles
3837             * @param end the upper bound of the range of journal articles (not inclusive)
3838             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3839             * @return the ordered range of matching journal articles
3840             * @throws SystemException if a system exception occurred
3841             */
3842            @Override
3843            public List<JournalArticle> findByStructureId(String[] structureIds,
3844                    int start, int end, OrderByComparator orderByComparator)
3845                    throws SystemException {
3846                    if ((structureIds != null) && (structureIds.length == 1)) {
3847                            return findByStructureId(structureIds[0], start, end,
3848                                    orderByComparator);
3849                    }
3850    
3851                    boolean pagination = true;
3852                    Object[] finderArgs = null;
3853    
3854                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3855                                    (orderByComparator == null)) {
3856                            pagination = false;
3857                            finderArgs = new Object[] { StringUtil.merge(structureIds) };
3858                    }
3859                    else {
3860                            finderArgs = new Object[] {
3861                                            StringUtil.merge(structureIds),
3862                                            
3863                                            start, end, orderByComparator
3864                                    };
3865                    }
3866    
3867                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID,
3868                                    finderArgs, this);
3869    
3870                    if ((list != null) && !list.isEmpty()) {
3871                            for (JournalArticle journalArticle : list) {
3872                                    if (!ArrayUtil.contains(structureIds,
3873                                                            journalArticle.getStructureId())) {
3874                                            list = null;
3875    
3876                                            break;
3877                                    }
3878                            }
3879                    }
3880    
3881                    if (list == null) {
3882                            StringBundler query = new StringBundler();
3883    
3884                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3885    
3886                            boolean conjunctionable = false;
3887    
3888                            if ((structureIds == null) || (structureIds.length > 0)) {
3889                                    if (conjunctionable) {
3890                                            query.append(WHERE_AND);
3891                                    }
3892    
3893                                    query.append(StringPool.OPEN_PARENTHESIS);
3894    
3895                                    for (int i = 0; i < structureIds.length; i++) {
3896                                            String structureId = structureIds[i];
3897    
3898                                            if (structureId == null) {
3899                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_4);
3900                                            }
3901                                            else if (structureId.equals(StringPool.BLANK)) {
3902                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_6);
3903                                            }
3904                                            else {
3905                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_5);
3906                                            }
3907    
3908                                            if ((i + 1) < structureIds.length) {
3909                                                    query.append(WHERE_OR);
3910                                            }
3911                                    }
3912    
3913                                    query.append(StringPool.CLOSE_PARENTHESIS);
3914    
3915                                    conjunctionable = true;
3916                            }
3917    
3918                            if (orderByComparator != null) {
3919                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3920                                            orderByComparator);
3921                            }
3922                            else
3923                             if (pagination) {
3924                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3925                            }
3926    
3927                            String sql = query.toString();
3928    
3929                            Session session = null;
3930    
3931                            try {
3932                                    session = openSession();
3933    
3934                                    Query q = session.createQuery(sql);
3935    
3936                                    QueryPos qPos = QueryPos.getInstance(q);
3937    
3938                                    if (structureIds != null) {
3939                                            for (String structureId : structureIds) {
3940                                                    if ((structureId != null) && !structureId.isEmpty()) {
3941                                                            qPos.add(structureId);
3942                                                    }
3943                                            }
3944                                    }
3945    
3946                                    if (!pagination) {
3947                                            list = (List<JournalArticle>)QueryUtil.list(q,
3948                                                            getDialect(), start, end, false);
3949    
3950                                            Collections.sort(list);
3951    
3952                                            list = new UnmodifiableList<JournalArticle>(list);
3953                                    }
3954                                    else {
3955                                            list = (List<JournalArticle>)QueryUtil.list(q,
3956                                                            getDialect(), start, end);
3957                                    }
3958    
3959                                    cacheResult(list);
3960    
3961                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID,
3962                                            finderArgs, list);
3963                            }
3964                            catch (Exception e) {
3965                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID,
3966                                            finderArgs);
3967    
3968                                    throw processException(e);
3969                            }
3970                            finally {
3971                                    closeSession(session);
3972                            }
3973                    }
3974    
3975                    return list;
3976            }
3977    
3978            /**
3979             * Removes all the journal articles where structureId = &#63; from the database.
3980             *
3981             * @param structureId the structure ID
3982             * @throws SystemException if a system exception occurred
3983             */
3984            @Override
3985            public void removeByStructureId(String structureId)
3986                    throws SystemException {
3987                    for (JournalArticle journalArticle : findByStructureId(structureId,
3988                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3989                            remove(journalArticle);
3990                    }
3991            }
3992    
3993            /**
3994             * Returns the number of journal articles where structureId = &#63;.
3995             *
3996             * @param structureId the structure ID
3997             * @return the number of matching journal articles
3998             * @throws SystemException if a system exception occurred
3999             */
4000            @Override
4001            public int countByStructureId(String structureId) throws SystemException {
4002                    FinderPath finderPath = FINDER_PATH_COUNT_BY_STRUCTUREID;
4003    
4004                    Object[] finderArgs = new Object[] { structureId };
4005    
4006                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4007                                    this);
4008    
4009                    if (count == null) {
4010                            StringBundler query = new StringBundler(2);
4011    
4012                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
4013    
4014                            boolean bindStructureId = false;
4015    
4016                            if (structureId == null) {
4017                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
4018                            }
4019                            else if (structureId.equals(StringPool.BLANK)) {
4020                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
4021                            }
4022                            else {
4023                                    bindStructureId = true;
4024    
4025                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
4026                            }
4027    
4028                            String sql = query.toString();
4029    
4030                            Session session = null;
4031    
4032                            try {
4033                                    session = openSession();
4034    
4035                                    Query q = session.createQuery(sql);
4036    
4037                                    QueryPos qPos = QueryPos.getInstance(q);
4038    
4039                                    if (bindStructureId) {
4040                                            qPos.add(structureId);
4041                                    }
4042    
4043                                    count = (Long)q.uniqueResult();
4044    
4045                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4046                            }
4047                            catch (Exception e) {
4048                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4049    
4050                                    throw processException(e);
4051                            }
4052                            finally {
4053                                    closeSession(session);
4054                            }
4055                    }
4056    
4057                    return count.intValue();
4058            }
4059    
4060            /**
4061             * Returns the number of journal articles where structureId = any &#63;.
4062             *
4063             * @param structureIds the structure IDs
4064             * @return the number of matching journal articles
4065             * @throws SystemException if a system exception occurred
4066             */
4067            @Override
4068            public int countByStructureId(String[] structureIds)
4069                    throws SystemException {
4070                    Object[] finderArgs = new Object[] { StringUtil.merge(structureIds) };
4071    
4072                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_STRUCTUREID,
4073                                    finderArgs, this);
4074    
4075                    if (count == null) {
4076                            StringBundler query = new StringBundler();
4077    
4078                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
4079    
4080                            boolean conjunctionable = false;
4081    
4082                            if ((structureIds == null) || (structureIds.length > 0)) {
4083                                    if (conjunctionable) {
4084                                            query.append(WHERE_AND);
4085                                    }
4086    
4087                                    query.append(StringPool.OPEN_PARENTHESIS);
4088    
4089                                    for (int i = 0; i < structureIds.length; i++) {
4090                                            String structureId = structureIds[i];
4091    
4092                                            if (structureId == null) {
4093                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_4);
4094                                            }
4095                                            else if (structureId.equals(StringPool.BLANK)) {
4096                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_6);
4097                                            }
4098                                            else {
4099                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_5);
4100                                            }
4101    
4102                                            if ((i + 1) < structureIds.length) {
4103                                                    query.append(WHERE_OR);
4104                                            }
4105                                    }
4106    
4107                                    query.append(StringPool.CLOSE_PARENTHESIS);
4108    
4109                                    conjunctionable = true;
4110                            }
4111    
4112                            String sql = query.toString();
4113    
4114                            Session session = null;
4115    
4116                            try {
4117                                    session = openSession();
4118    
4119                                    Query q = session.createQuery(sql);
4120    
4121                                    QueryPos qPos = QueryPos.getInstance(q);
4122    
4123                                    if (structureIds != null) {
4124                                            for (String structureId : structureIds) {
4125                                                    if ((structureId != null) && !structureId.isEmpty()) {
4126                                                            qPos.add(structureId);
4127                                                    }
4128                                            }
4129                                    }
4130    
4131                                    count = (Long)q.uniqueResult();
4132    
4133                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_STRUCTUREID,
4134                                            finderArgs, count);
4135                            }
4136                            catch (Exception e) {
4137                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_STRUCTUREID,
4138                                            finderArgs);
4139    
4140                                    throw processException(e);
4141                            }
4142                            finally {
4143                                    closeSession(session);
4144                            }
4145                    }
4146    
4147                    return count.intValue();
4148            }
4149    
4150            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
4151            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2 = "journalArticle.structureId = ?";
4152            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = '')";
4153            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_4 = "(" +
4154                    removeConjunction(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1) + ")";
4155            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_5 = "(" +
4156                    removeConjunction(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2) + ")";
4157            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_6 = "(" +
4158                    removeConjunction(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3) + ")";
4159            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_TEMPLATEID =
4160                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4161                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4162                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4163                            "findByTemplateId",
4164                            new String[] {
4165                                    String.class.getName(),
4166                                    
4167                            Integer.class.getName(), Integer.class.getName(),
4168                                    OrderByComparator.class.getName()
4169                            });
4170            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID =
4171                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4172                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4173                            JournalArticleImpl.class,
4174                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByTemplateId",
4175                            new String[] { String.class.getName() },
4176                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
4177                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
4178                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
4179            public static final FinderPath FINDER_PATH_COUNT_BY_TEMPLATEID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4180                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
4181                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByTemplateId",
4182                            new String[] { String.class.getName() });
4183    
4184            /**
4185             * Returns all the journal articles where templateId = &#63;.
4186             *
4187             * @param templateId the template ID
4188             * @return the matching journal articles
4189             * @throws SystemException if a system exception occurred
4190             */
4191            @Override
4192            public List<JournalArticle> findByTemplateId(String templateId)
4193                    throws SystemException {
4194                    return findByTemplateId(templateId, QueryUtil.ALL_POS,
4195                            QueryUtil.ALL_POS, null);
4196            }
4197    
4198            /**
4199             * Returns a range of all the journal articles where templateId = &#63;.
4200             *
4201             * <p>
4202             * 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.
4203             * </p>
4204             *
4205             * @param templateId the template ID
4206             * @param start the lower bound of the range of journal articles
4207             * @param end the upper bound of the range of journal articles (not inclusive)
4208             * @return the range of matching journal articles
4209             * @throws SystemException if a system exception occurred
4210             */
4211            @Override
4212            public List<JournalArticle> findByTemplateId(String templateId, int start,
4213                    int end) throws SystemException {
4214                    return findByTemplateId(templateId, start, end, null);
4215            }
4216    
4217            /**
4218             * Returns an ordered range of all the journal articles where templateId = &#63;.
4219             *
4220             * <p>
4221             * 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.
4222             * </p>
4223             *
4224             * @param templateId the template ID
4225             * @param start the lower bound of the range of journal articles
4226             * @param end the upper bound of the range of journal articles (not inclusive)
4227             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4228             * @return the ordered range of matching journal articles
4229             * @throws SystemException if a system exception occurred
4230             */
4231            @Override
4232            public List<JournalArticle> findByTemplateId(String templateId, int start,
4233                    int end, OrderByComparator orderByComparator) throws SystemException {
4234                    boolean pagination = true;
4235                    FinderPath finderPath = null;
4236                    Object[] finderArgs = null;
4237    
4238                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4239                                    (orderByComparator == null)) {
4240                            pagination = false;
4241                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID;
4242                            finderArgs = new Object[] { templateId };
4243                    }
4244                    else {
4245                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_TEMPLATEID;
4246                            finderArgs = new Object[] { templateId, start, end, orderByComparator };
4247                    }
4248    
4249                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4250                                    finderArgs, this);
4251    
4252                    if ((list != null) && !list.isEmpty()) {
4253                            for (JournalArticle journalArticle : list) {
4254                                    if (!Validator.equals(templateId, journalArticle.getTemplateId())) {
4255                                            list = null;
4256    
4257                                            break;
4258                                    }
4259                            }
4260                    }
4261    
4262                    if (list == null) {
4263                            StringBundler query = null;
4264    
4265                            if (orderByComparator != null) {
4266                                    query = new StringBundler(3 +
4267                                                    (orderByComparator.getOrderByFields().length * 3));
4268                            }
4269                            else {
4270                                    query = new StringBundler(3);
4271                            }
4272    
4273                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4274    
4275                            boolean bindTemplateId = false;
4276    
4277                            if (templateId == null) {
4278                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
4279                            }
4280                            else if (templateId.equals(StringPool.BLANK)) {
4281                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
4282                            }
4283                            else {
4284                                    bindTemplateId = true;
4285    
4286                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
4287                            }
4288    
4289                            if (orderByComparator != null) {
4290                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4291                                            orderByComparator);
4292                            }
4293                            else
4294                             if (pagination) {
4295                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4296                            }
4297    
4298                            String sql = query.toString();
4299    
4300                            Session session = null;
4301    
4302                            try {
4303                                    session = openSession();
4304    
4305                                    Query q = session.createQuery(sql);
4306    
4307                                    QueryPos qPos = QueryPos.getInstance(q);
4308    
4309                                    if (bindTemplateId) {
4310                                            qPos.add(templateId);
4311                                    }
4312    
4313                                    if (!pagination) {
4314                                            list = (List<JournalArticle>)QueryUtil.list(q,
4315                                                            getDialect(), start, end, false);
4316    
4317                                            Collections.sort(list);
4318    
4319                                            list = new UnmodifiableList<JournalArticle>(list);
4320                                    }
4321                                    else {
4322                                            list = (List<JournalArticle>)QueryUtil.list(q,
4323                                                            getDialect(), start, end);
4324                                    }
4325    
4326                                    cacheResult(list);
4327    
4328                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4329                            }
4330                            catch (Exception e) {
4331                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4332    
4333                                    throw processException(e);
4334                            }
4335                            finally {
4336                                    closeSession(session);
4337                            }
4338                    }
4339    
4340                    return list;
4341            }
4342    
4343            /**
4344             * Returns the first journal article in the ordered set where templateId = &#63;.
4345             *
4346             * @param templateId the template ID
4347             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4348             * @return the first matching journal article
4349             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4350             * @throws SystemException if a system exception occurred
4351             */
4352            @Override
4353            public JournalArticle findByTemplateId_First(String templateId,
4354                    OrderByComparator orderByComparator)
4355                    throws NoSuchArticleException, SystemException {
4356                    JournalArticle journalArticle = fetchByTemplateId_First(templateId,
4357                                    orderByComparator);
4358    
4359                    if (journalArticle != null) {
4360                            return journalArticle;
4361                    }
4362    
4363                    StringBundler msg = new StringBundler(4);
4364    
4365                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4366    
4367                    msg.append("templateId=");
4368                    msg.append(templateId);
4369    
4370                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4371    
4372                    throw new NoSuchArticleException(msg.toString());
4373            }
4374    
4375            /**
4376             * Returns the first journal article in the ordered set where templateId = &#63;.
4377             *
4378             * @param templateId the template ID
4379             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4380             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
4381             * @throws SystemException if a system exception occurred
4382             */
4383            @Override
4384            public JournalArticle fetchByTemplateId_First(String templateId,
4385                    OrderByComparator orderByComparator) throws SystemException {
4386                    List<JournalArticle> list = findByTemplateId(templateId, 0, 1,
4387                                    orderByComparator);
4388    
4389                    if (!list.isEmpty()) {
4390                            return list.get(0);
4391                    }
4392    
4393                    return null;
4394            }
4395    
4396            /**
4397             * Returns the last journal article in the ordered set where templateId = &#63;.
4398             *
4399             * @param templateId the template ID
4400             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4401             * @return the last matching journal article
4402             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4403             * @throws SystemException if a system exception occurred
4404             */
4405            @Override
4406            public JournalArticle findByTemplateId_Last(String templateId,
4407                    OrderByComparator orderByComparator)
4408                    throws NoSuchArticleException, SystemException {
4409                    JournalArticle journalArticle = fetchByTemplateId_Last(templateId,
4410                                    orderByComparator);
4411    
4412                    if (journalArticle != null) {
4413                            return journalArticle;
4414                    }
4415    
4416                    StringBundler msg = new StringBundler(4);
4417    
4418                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4419    
4420                    msg.append("templateId=");
4421                    msg.append(templateId);
4422    
4423                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4424    
4425                    throw new NoSuchArticleException(msg.toString());
4426            }
4427    
4428            /**
4429             * Returns the last journal article in the ordered set where templateId = &#63;.
4430             *
4431             * @param templateId the template ID
4432             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4433             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
4434             * @throws SystemException if a system exception occurred
4435             */
4436            @Override
4437            public JournalArticle fetchByTemplateId_Last(String templateId,
4438                    OrderByComparator orderByComparator) throws SystemException {
4439                    int count = countByTemplateId(templateId);
4440    
4441                    if (count == 0) {
4442                            return null;
4443                    }
4444    
4445                    List<JournalArticle> list = findByTemplateId(templateId, count - 1,
4446                                    count, orderByComparator);
4447    
4448                    if (!list.isEmpty()) {
4449                            return list.get(0);
4450                    }
4451    
4452                    return null;
4453            }
4454    
4455            /**
4456             * Returns the journal articles before and after the current journal article in the ordered set where templateId = &#63;.
4457             *
4458             * @param id the primary key of the current journal article
4459             * @param templateId the template ID
4460             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4461             * @return the previous, current, and next journal article
4462             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4463             * @throws SystemException if a system exception occurred
4464             */
4465            @Override
4466            public JournalArticle[] findByTemplateId_PrevAndNext(long id,
4467                    String templateId, OrderByComparator orderByComparator)
4468                    throws NoSuchArticleException, SystemException {
4469                    JournalArticle journalArticle = findByPrimaryKey(id);
4470    
4471                    Session session = null;
4472    
4473                    try {
4474                            session = openSession();
4475    
4476                            JournalArticle[] array = new JournalArticleImpl[3];
4477    
4478                            array[0] = getByTemplateId_PrevAndNext(session, journalArticle,
4479                                            templateId, orderByComparator, true);
4480    
4481                            array[1] = journalArticle;
4482    
4483                            array[2] = getByTemplateId_PrevAndNext(session, journalArticle,
4484                                            templateId, orderByComparator, false);
4485    
4486                            return array;
4487                    }
4488                    catch (Exception e) {
4489                            throw processException(e);
4490                    }
4491                    finally {
4492                            closeSession(session);
4493                    }
4494            }
4495    
4496            protected JournalArticle getByTemplateId_PrevAndNext(Session session,
4497                    JournalArticle journalArticle, String templateId,
4498                    OrderByComparator orderByComparator, boolean previous) {
4499                    StringBundler query = null;
4500    
4501                    if (orderByComparator != null) {
4502                            query = new StringBundler(6 +
4503                                            (orderByComparator.getOrderByFields().length * 6));
4504                    }
4505                    else {
4506                            query = new StringBundler(3);
4507                    }
4508    
4509                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4510    
4511                    boolean bindTemplateId = false;
4512    
4513                    if (templateId == null) {
4514                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
4515                    }
4516                    else if (templateId.equals(StringPool.BLANK)) {
4517                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
4518                    }
4519                    else {
4520                            bindTemplateId = true;
4521    
4522                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
4523                    }
4524    
4525                    if (orderByComparator != null) {
4526                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4527    
4528                            if (orderByConditionFields.length > 0) {
4529                                    query.append(WHERE_AND);
4530                            }
4531    
4532                            for (int i = 0; i < orderByConditionFields.length; i++) {
4533                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4534                                    query.append(orderByConditionFields[i]);
4535    
4536                                    if ((i + 1) < orderByConditionFields.length) {
4537                                            if (orderByComparator.isAscending() ^ previous) {
4538                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4539                                            }
4540                                            else {
4541                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4542                                            }
4543                                    }
4544                                    else {
4545                                            if (orderByComparator.isAscending() ^ previous) {
4546                                                    query.append(WHERE_GREATER_THAN);
4547                                            }
4548                                            else {
4549                                                    query.append(WHERE_LESSER_THAN);
4550                                            }
4551                                    }
4552                            }
4553    
4554                            query.append(ORDER_BY_CLAUSE);
4555    
4556                            String[] orderByFields = orderByComparator.getOrderByFields();
4557    
4558                            for (int i = 0; i < orderByFields.length; i++) {
4559                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4560                                    query.append(orderByFields[i]);
4561    
4562                                    if ((i + 1) < orderByFields.length) {
4563                                            if (orderByComparator.isAscending() ^ previous) {
4564                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4565                                            }
4566                                            else {
4567                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4568                                            }
4569                                    }
4570                                    else {
4571                                            if (orderByComparator.isAscending() ^ previous) {
4572                                                    query.append(ORDER_BY_ASC);
4573                                            }
4574                                            else {
4575                                                    query.append(ORDER_BY_DESC);
4576                                            }
4577                                    }
4578                            }
4579                    }
4580                    else {
4581                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4582                    }
4583    
4584                    String sql = query.toString();
4585    
4586                    Query q = session.createQuery(sql);
4587    
4588                    q.setFirstResult(0);
4589                    q.setMaxResults(2);
4590    
4591                    QueryPos qPos = QueryPos.getInstance(q);
4592    
4593                    if (bindTemplateId) {
4594                            qPos.add(templateId);
4595                    }
4596    
4597                    if (orderByComparator != null) {
4598                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
4599    
4600                            for (Object value : values) {
4601                                    qPos.add(value);
4602                            }
4603                    }
4604    
4605                    List<JournalArticle> list = q.list();
4606    
4607                    if (list.size() == 2) {
4608                            return list.get(1);
4609                    }
4610                    else {
4611                            return null;
4612                    }
4613            }
4614    
4615            /**
4616             * Removes all the journal articles where templateId = &#63; from the database.
4617             *
4618             * @param templateId the template ID
4619             * @throws SystemException if a system exception occurred
4620             */
4621            @Override
4622            public void removeByTemplateId(String templateId) throws SystemException {
4623                    for (JournalArticle journalArticle : findByTemplateId(templateId,
4624                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4625                            remove(journalArticle);
4626                    }
4627            }
4628    
4629            /**
4630             * Returns the number of journal articles where templateId = &#63;.
4631             *
4632             * @param templateId the template ID
4633             * @return the number of matching journal articles
4634             * @throws SystemException if a system exception occurred
4635             */
4636            @Override
4637            public int countByTemplateId(String templateId) throws SystemException {
4638                    FinderPath finderPath = FINDER_PATH_COUNT_BY_TEMPLATEID;
4639    
4640                    Object[] finderArgs = new Object[] { templateId };
4641    
4642                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4643                                    this);
4644    
4645                    if (count == null) {
4646                            StringBundler query = new StringBundler(2);
4647    
4648                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
4649    
4650                            boolean bindTemplateId = false;
4651    
4652                            if (templateId == null) {
4653                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
4654                            }
4655                            else if (templateId.equals(StringPool.BLANK)) {
4656                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
4657                            }
4658                            else {
4659                                    bindTemplateId = true;
4660    
4661                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
4662                            }
4663    
4664                            String sql = query.toString();
4665    
4666                            Session session = null;
4667    
4668                            try {
4669                                    session = openSession();
4670    
4671                                    Query q = session.createQuery(sql);
4672    
4673                                    QueryPos qPos = QueryPos.getInstance(q);
4674    
4675                                    if (bindTemplateId) {
4676                                            qPos.add(templateId);
4677                                    }
4678    
4679                                    count = (Long)q.uniqueResult();
4680    
4681                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4682                            }
4683                            catch (Exception e) {
4684                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4685    
4686                                    throw processException(e);
4687                            }
4688                            finally {
4689                                    closeSession(session);
4690                            }
4691                    }
4692    
4693                    return count.intValue();
4694            }
4695    
4696            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
4697            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2 = "journalArticle.templateId = ?";
4698            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = '')";
4699            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTUUID =
4700                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4701                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4702                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4703                            "findByLayoutUuid",
4704                            new String[] {
4705                                    String.class.getName(),
4706                                    
4707                            Integer.class.getName(), Integer.class.getName(),
4708                                    OrderByComparator.class.getName()
4709                            });
4710            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID =
4711                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4712                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4713                            JournalArticleImpl.class,
4714                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByLayoutUuid",
4715                            new String[] { String.class.getName() },
4716                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
4717                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
4718                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
4719            public static final FinderPath FINDER_PATH_COUNT_BY_LAYOUTUUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4720                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
4721                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByLayoutUuid",
4722                            new String[] { String.class.getName() });
4723    
4724            /**
4725             * Returns all the journal articles where layoutUuid = &#63;.
4726             *
4727             * @param layoutUuid the layout uuid
4728             * @return the matching journal articles
4729             * @throws SystemException if a system exception occurred
4730             */
4731            @Override
4732            public List<JournalArticle> findByLayoutUuid(String layoutUuid)
4733                    throws SystemException {
4734                    return findByLayoutUuid(layoutUuid, QueryUtil.ALL_POS,
4735                            QueryUtil.ALL_POS, null);
4736            }
4737    
4738            /**
4739             * Returns a range of all the journal articles where layoutUuid = &#63;.
4740             *
4741             * <p>
4742             * 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.
4743             * </p>
4744             *
4745             * @param layoutUuid the layout uuid
4746             * @param start the lower bound of the range of journal articles
4747             * @param end the upper bound of the range of journal articles (not inclusive)
4748             * @return the range of matching journal articles
4749             * @throws SystemException if a system exception occurred
4750             */
4751            @Override
4752            public List<JournalArticle> findByLayoutUuid(String layoutUuid, int start,
4753                    int end) throws SystemException {
4754                    return findByLayoutUuid(layoutUuid, start, end, null);
4755            }
4756    
4757            /**
4758             * Returns an ordered range of all the journal articles where layoutUuid = &#63;.
4759             *
4760             * <p>
4761             * 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.
4762             * </p>
4763             *
4764             * @param layoutUuid the layout uuid
4765             * @param start the lower bound of the range of journal articles
4766             * @param end the upper bound of the range of journal articles (not inclusive)
4767             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4768             * @return the ordered range of matching journal articles
4769             * @throws SystemException if a system exception occurred
4770             */
4771            @Override
4772            public List<JournalArticle> findByLayoutUuid(String layoutUuid, int start,
4773                    int end, OrderByComparator orderByComparator) throws SystemException {
4774                    boolean pagination = true;
4775                    FinderPath finderPath = null;
4776                    Object[] finderArgs = null;
4777    
4778                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4779                                    (orderByComparator == null)) {
4780                            pagination = false;
4781                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID;
4782                            finderArgs = new Object[] { layoutUuid };
4783                    }
4784                    else {
4785                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTUUID;
4786                            finderArgs = new Object[] { layoutUuid, start, end, orderByComparator };
4787                    }
4788    
4789                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4790                                    finderArgs, this);
4791    
4792                    if ((list != null) && !list.isEmpty()) {
4793                            for (JournalArticle journalArticle : list) {
4794                                    if (!Validator.equals(layoutUuid, journalArticle.getLayoutUuid())) {
4795                                            list = null;
4796    
4797                                            break;
4798                                    }
4799                            }
4800                    }
4801    
4802                    if (list == null) {
4803                            StringBundler query = null;
4804    
4805                            if (orderByComparator != null) {
4806                                    query = new StringBundler(3 +
4807                                                    (orderByComparator.getOrderByFields().length * 3));
4808                            }
4809                            else {
4810                                    query = new StringBundler(3);
4811                            }
4812    
4813                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4814    
4815                            boolean bindLayoutUuid = false;
4816    
4817                            if (layoutUuid == null) {
4818                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
4819                            }
4820                            else if (layoutUuid.equals(StringPool.BLANK)) {
4821                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
4822                            }
4823                            else {
4824                                    bindLayoutUuid = true;
4825    
4826                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
4827                            }
4828    
4829                            if (orderByComparator != null) {
4830                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4831                                            orderByComparator);
4832                            }
4833                            else
4834                             if (pagination) {
4835                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4836                            }
4837    
4838                            String sql = query.toString();
4839    
4840                            Session session = null;
4841    
4842                            try {
4843                                    session = openSession();
4844    
4845                                    Query q = session.createQuery(sql);
4846    
4847                                    QueryPos qPos = QueryPos.getInstance(q);
4848    
4849                                    if (bindLayoutUuid) {
4850                                            qPos.add(layoutUuid);
4851                                    }
4852    
4853                                    if (!pagination) {
4854                                            list = (List<JournalArticle>)QueryUtil.list(q,
4855                                                            getDialect(), start, end, false);
4856    
4857                                            Collections.sort(list);
4858    
4859                                            list = new UnmodifiableList<JournalArticle>(list);
4860                                    }
4861                                    else {
4862                                            list = (List<JournalArticle>)QueryUtil.list(q,
4863                                                            getDialect(), start, end);
4864                                    }
4865    
4866                                    cacheResult(list);
4867    
4868                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4869                            }
4870                            catch (Exception e) {
4871                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4872    
4873                                    throw processException(e);
4874                            }
4875                            finally {
4876                                    closeSession(session);
4877                            }
4878                    }
4879    
4880                    return list;
4881            }
4882    
4883            /**
4884             * Returns the first journal article in the ordered set where layoutUuid = &#63;.
4885             *
4886             * @param layoutUuid the layout uuid
4887             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4888             * @return the first matching journal article
4889             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4890             * @throws SystemException if a system exception occurred
4891             */
4892            @Override
4893            public JournalArticle findByLayoutUuid_First(String layoutUuid,
4894                    OrderByComparator orderByComparator)
4895                    throws NoSuchArticleException, SystemException {
4896                    JournalArticle journalArticle = fetchByLayoutUuid_First(layoutUuid,
4897                                    orderByComparator);
4898    
4899                    if (journalArticle != null) {
4900                            return journalArticle;
4901                    }
4902    
4903                    StringBundler msg = new StringBundler(4);
4904    
4905                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4906    
4907                    msg.append("layoutUuid=");
4908                    msg.append(layoutUuid);
4909    
4910                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4911    
4912                    throw new NoSuchArticleException(msg.toString());
4913            }
4914    
4915            /**
4916             * Returns the first journal article in the ordered set where layoutUuid = &#63;.
4917             *
4918             * @param layoutUuid the layout uuid
4919             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4920             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
4921             * @throws SystemException if a system exception occurred
4922             */
4923            @Override
4924            public JournalArticle fetchByLayoutUuid_First(String layoutUuid,
4925                    OrderByComparator orderByComparator) throws SystemException {
4926                    List<JournalArticle> list = findByLayoutUuid(layoutUuid, 0, 1,
4927                                    orderByComparator);
4928    
4929                    if (!list.isEmpty()) {
4930                            return list.get(0);
4931                    }
4932    
4933                    return null;
4934            }
4935    
4936            /**
4937             * Returns the last journal article in the ordered set where layoutUuid = &#63;.
4938             *
4939             * @param layoutUuid the layout uuid
4940             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4941             * @return the last matching journal article
4942             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4943             * @throws SystemException if a system exception occurred
4944             */
4945            @Override
4946            public JournalArticle findByLayoutUuid_Last(String layoutUuid,
4947                    OrderByComparator orderByComparator)
4948                    throws NoSuchArticleException, SystemException {
4949                    JournalArticle journalArticle = fetchByLayoutUuid_Last(layoutUuid,
4950                                    orderByComparator);
4951    
4952                    if (journalArticle != null) {
4953                            return journalArticle;
4954                    }
4955    
4956                    StringBundler msg = new StringBundler(4);
4957    
4958                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4959    
4960                    msg.append("layoutUuid=");
4961                    msg.append(layoutUuid);
4962    
4963                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4964    
4965                    throw new NoSuchArticleException(msg.toString());
4966            }
4967    
4968            /**
4969             * Returns the last journal article in the ordered set where layoutUuid = &#63;.
4970             *
4971             * @param layoutUuid the layout uuid
4972             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4973             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
4974             * @throws SystemException if a system exception occurred
4975             */
4976            @Override
4977            public JournalArticle fetchByLayoutUuid_Last(String layoutUuid,
4978                    OrderByComparator orderByComparator) throws SystemException {
4979                    int count = countByLayoutUuid(layoutUuid);
4980    
4981                    if (count == 0) {
4982                            return null;
4983                    }
4984    
4985                    List<JournalArticle> list = findByLayoutUuid(layoutUuid, count - 1,
4986                                    count, orderByComparator);
4987    
4988                    if (!list.isEmpty()) {
4989                            return list.get(0);
4990                    }
4991    
4992                    return null;
4993            }
4994    
4995            /**
4996             * Returns the journal articles before and after the current journal article in the ordered set where layoutUuid = &#63;.
4997             *
4998             * @param id the primary key of the current journal article
4999             * @param layoutUuid the layout uuid
5000             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5001             * @return the previous, current, and next journal article
5002             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
5003             * @throws SystemException if a system exception occurred
5004             */
5005            @Override
5006            public JournalArticle[] findByLayoutUuid_PrevAndNext(long id,
5007                    String layoutUuid, OrderByComparator orderByComparator)
5008                    throws NoSuchArticleException, SystemException {
5009                    JournalArticle journalArticle = findByPrimaryKey(id);
5010    
5011                    Session session = null;
5012    
5013                    try {
5014                            session = openSession();
5015    
5016                            JournalArticle[] array = new JournalArticleImpl[3];
5017    
5018                            array[0] = getByLayoutUuid_PrevAndNext(session, journalArticle,
5019                                            layoutUuid, orderByComparator, true);
5020    
5021                            array[1] = journalArticle;
5022    
5023                            array[2] = getByLayoutUuid_PrevAndNext(session, journalArticle,
5024                                            layoutUuid, orderByComparator, false);
5025    
5026                            return array;
5027                    }
5028                    catch (Exception e) {
5029                            throw processException(e);
5030                    }
5031                    finally {
5032                            closeSession(session);
5033                    }
5034            }
5035    
5036            protected JournalArticle getByLayoutUuid_PrevAndNext(Session session,
5037                    JournalArticle journalArticle, String layoutUuid,
5038                    OrderByComparator orderByComparator, boolean previous) {
5039                    StringBundler query = null;
5040    
5041                    if (orderByComparator != null) {
5042                            query = new StringBundler(6 +
5043                                            (orderByComparator.getOrderByFields().length * 6));
5044                    }
5045                    else {
5046                            query = new StringBundler(3);
5047                    }
5048    
5049                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5050    
5051                    boolean bindLayoutUuid = false;
5052    
5053                    if (layoutUuid == null) {
5054                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
5055                    }
5056                    else if (layoutUuid.equals(StringPool.BLANK)) {
5057                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
5058                    }
5059                    else {
5060                            bindLayoutUuid = true;
5061    
5062                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
5063                    }
5064    
5065                    if (orderByComparator != null) {
5066                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5067    
5068                            if (orderByConditionFields.length > 0) {
5069                                    query.append(WHERE_AND);
5070                            }
5071    
5072                            for (int i = 0; i < orderByConditionFields.length; i++) {
5073                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5074                                    query.append(orderByConditionFields[i]);
5075    
5076                                    if ((i + 1) < orderByConditionFields.length) {
5077                                            if (orderByComparator.isAscending() ^ previous) {
5078                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5079                                            }
5080                                            else {
5081                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5082                                            }
5083                                    }
5084                                    else {
5085                                            if (orderByComparator.isAscending() ^ previous) {
5086                                                    query.append(WHERE_GREATER_THAN);
5087                                            }
5088                                            else {
5089                                                    query.append(WHERE_LESSER_THAN);
5090                                            }
5091                                    }
5092                            }
5093    
5094                            query.append(ORDER_BY_CLAUSE);
5095    
5096                            String[] orderByFields = orderByComparator.getOrderByFields();
5097    
5098                            for (int i = 0; i < orderByFields.length; i++) {
5099                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5100                                    query.append(orderByFields[i]);
5101    
5102                                    if ((i + 1) < orderByFields.length) {
5103                                            if (orderByComparator.isAscending() ^ previous) {
5104                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5105                                            }
5106                                            else {
5107                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5108                                            }
5109                                    }
5110                                    else {
5111                                            if (orderByComparator.isAscending() ^ previous) {
5112                                                    query.append(ORDER_BY_ASC);
5113                                            }
5114                                            else {
5115                                                    query.append(ORDER_BY_DESC);
5116                                            }
5117                                    }
5118                            }
5119                    }
5120                    else {
5121                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5122                    }
5123    
5124                    String sql = query.toString();
5125    
5126                    Query q = session.createQuery(sql);
5127    
5128                    q.setFirstResult(0);
5129                    q.setMaxResults(2);
5130    
5131                    QueryPos qPos = QueryPos.getInstance(q);
5132    
5133                    if (bindLayoutUuid) {
5134                            qPos.add(layoutUuid);
5135                    }
5136    
5137                    if (orderByComparator != null) {
5138                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5139    
5140                            for (Object value : values) {
5141                                    qPos.add(value);
5142                            }
5143                    }
5144    
5145                    List<JournalArticle> list = q.list();
5146    
5147                    if (list.size() == 2) {
5148                            return list.get(1);
5149                    }
5150                    else {
5151                            return null;
5152                    }
5153            }
5154    
5155            /**
5156             * Removes all the journal articles where layoutUuid = &#63; from the database.
5157             *
5158             * @param layoutUuid the layout uuid
5159             * @throws SystemException if a system exception occurred
5160             */
5161            @Override
5162            public void removeByLayoutUuid(String layoutUuid) throws SystemException {
5163                    for (JournalArticle journalArticle : findByLayoutUuid(layoutUuid,
5164                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5165                            remove(journalArticle);
5166                    }
5167            }
5168    
5169            /**
5170             * Returns the number of journal articles where layoutUuid = &#63;.
5171             *
5172             * @param layoutUuid the layout uuid
5173             * @return the number of matching journal articles
5174             * @throws SystemException if a system exception occurred
5175             */
5176            @Override
5177            public int countByLayoutUuid(String layoutUuid) throws SystemException {
5178                    FinderPath finderPath = FINDER_PATH_COUNT_BY_LAYOUTUUID;
5179    
5180                    Object[] finderArgs = new Object[] { layoutUuid };
5181    
5182                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5183                                    this);
5184    
5185                    if (count == null) {
5186                            StringBundler query = new StringBundler(2);
5187    
5188                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
5189    
5190                            boolean bindLayoutUuid = false;
5191    
5192                            if (layoutUuid == null) {
5193                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
5194                            }
5195                            else if (layoutUuid.equals(StringPool.BLANK)) {
5196                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
5197                            }
5198                            else {
5199                                    bindLayoutUuid = true;
5200    
5201                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
5202                            }
5203    
5204                            String sql = query.toString();
5205    
5206                            Session session = null;
5207    
5208                            try {
5209                                    session = openSession();
5210    
5211                                    Query q = session.createQuery(sql);
5212    
5213                                    QueryPos qPos = QueryPos.getInstance(q);
5214    
5215                                    if (bindLayoutUuid) {
5216                                            qPos.add(layoutUuid);
5217                                    }
5218    
5219                                    count = (Long)q.uniqueResult();
5220    
5221                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5222                            }
5223                            catch (Exception e) {
5224                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5225    
5226                                    throw processException(e);
5227                            }
5228                            finally {
5229                                    closeSession(session);
5230                            }
5231                    }
5232    
5233                    return count.intValue();
5234            }
5235    
5236            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
5237            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
5238            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = '')";
5239            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_SMALLIMAGEID =
5240                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5241                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5242                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5243                            "findBySmallImageId",
5244                            new String[] {
5245                                    Long.class.getName(),
5246                                    
5247                            Integer.class.getName(), Integer.class.getName(),
5248                                    OrderByComparator.class.getName()
5249                            });
5250            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID =
5251                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5252                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5253                            JournalArticleImpl.class,
5254                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findBySmallImageId",
5255                            new String[] { Long.class.getName() },
5256                            JournalArticleModelImpl.SMALLIMAGEID_COLUMN_BITMASK |
5257                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
5258                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
5259            public static final FinderPath FINDER_PATH_COUNT_BY_SMALLIMAGEID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5260                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
5261                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countBySmallImageId",
5262                            new String[] { Long.class.getName() });
5263    
5264            /**
5265             * Returns all the journal articles where smallImageId = &#63;.
5266             *
5267             * @param smallImageId the small image ID
5268             * @return the matching journal articles
5269             * @throws SystemException if a system exception occurred
5270             */
5271            @Override
5272            public List<JournalArticle> findBySmallImageId(long smallImageId)
5273                    throws SystemException {
5274                    return findBySmallImageId(smallImageId, QueryUtil.ALL_POS,
5275                            QueryUtil.ALL_POS, null);
5276            }
5277    
5278            /**
5279             * Returns a range of all the journal articles where smallImageId = &#63;.
5280             *
5281             * <p>
5282             * 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.
5283             * </p>
5284             *
5285             * @param smallImageId the small image ID
5286             * @param start the lower bound of the range of journal articles
5287             * @param end the upper bound of the range of journal articles (not inclusive)
5288             * @return the range of matching journal articles
5289             * @throws SystemException if a system exception occurred
5290             */
5291            @Override
5292            public List<JournalArticle> findBySmallImageId(long smallImageId,
5293                    int start, int end) throws SystemException {
5294                    return findBySmallImageId(smallImageId, start, end, null);
5295            }
5296    
5297            /**
5298             * Returns an ordered range of all the journal articles where smallImageId = &#63;.
5299             *
5300             * <p>
5301             * 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.
5302             * </p>
5303             *
5304             * @param smallImageId the small image ID
5305             * @param start the lower bound of the range of journal articles
5306             * @param end the upper bound of the range of journal articles (not inclusive)
5307             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5308             * @return the ordered range of matching journal articles
5309             * @throws SystemException if a system exception occurred
5310             */
5311            @Override
5312            public List<JournalArticle> findBySmallImageId(long smallImageId,
5313                    int start, int end, OrderByComparator orderByComparator)
5314                    throws SystemException {
5315                    boolean pagination = true;
5316                    FinderPath finderPath = null;
5317                    Object[] finderArgs = null;
5318    
5319                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5320                                    (orderByComparator == null)) {
5321                            pagination = false;
5322                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID;
5323                            finderArgs = new Object[] { smallImageId };
5324                    }
5325                    else {
5326                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SMALLIMAGEID;
5327                            finderArgs = new Object[] {
5328                                            smallImageId,
5329                                            
5330                                            start, end, orderByComparator
5331                                    };
5332                    }
5333    
5334                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
5335                                    finderArgs, this);
5336    
5337                    if ((list != null) && !list.isEmpty()) {
5338                            for (JournalArticle journalArticle : list) {
5339                                    if ((smallImageId != journalArticle.getSmallImageId())) {
5340                                            list = null;
5341    
5342                                            break;
5343                                    }
5344                            }
5345                    }
5346    
5347                    if (list == null) {
5348                            StringBundler query = null;
5349    
5350                            if (orderByComparator != null) {
5351                                    query = new StringBundler(3 +
5352                                                    (orderByComparator.getOrderByFields().length * 3));
5353                            }
5354                            else {
5355                                    query = new StringBundler(3);
5356                            }
5357    
5358                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5359    
5360                            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
5361    
5362                            if (orderByComparator != null) {
5363                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5364                                            orderByComparator);
5365                            }
5366                            else
5367                             if (pagination) {
5368                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5369                            }
5370    
5371                            String sql = query.toString();
5372    
5373                            Session session = null;
5374    
5375                            try {
5376                                    session = openSession();
5377    
5378                                    Query q = session.createQuery(sql);
5379    
5380                                    QueryPos qPos = QueryPos.getInstance(q);
5381    
5382                                    qPos.add(smallImageId);
5383    
5384                                    if (!pagination) {
5385                                            list = (List<JournalArticle>)QueryUtil.list(q,
5386                                                            getDialect(), start, end, false);
5387    
5388                                            Collections.sort(list);
5389    
5390                                            list = new UnmodifiableList<JournalArticle>(list);
5391                                    }
5392                                    else {
5393                                            list = (List<JournalArticle>)QueryUtil.list(q,
5394                                                            getDialect(), start, end);
5395                                    }
5396    
5397                                    cacheResult(list);
5398    
5399                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5400                            }
5401                            catch (Exception e) {
5402                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5403    
5404                                    throw processException(e);
5405                            }
5406                            finally {
5407                                    closeSession(session);
5408                            }
5409                    }
5410    
5411                    return list;
5412            }
5413    
5414            /**
5415             * Returns the first journal article in the ordered set where smallImageId = &#63;.
5416             *
5417             * @param smallImageId the small image ID
5418             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5419             * @return the first matching journal article
5420             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5421             * @throws SystemException if a system exception occurred
5422             */
5423            @Override
5424            public JournalArticle findBySmallImageId_First(long smallImageId,
5425                    OrderByComparator orderByComparator)
5426                    throws NoSuchArticleException, SystemException {
5427                    JournalArticle journalArticle = fetchBySmallImageId_First(smallImageId,
5428                                    orderByComparator);
5429    
5430                    if (journalArticle != null) {
5431                            return journalArticle;
5432                    }
5433    
5434                    StringBundler msg = new StringBundler(4);
5435    
5436                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5437    
5438                    msg.append("smallImageId=");
5439                    msg.append(smallImageId);
5440    
5441                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5442    
5443                    throw new NoSuchArticleException(msg.toString());
5444            }
5445    
5446            /**
5447             * Returns the first journal article in the ordered set where smallImageId = &#63;.
5448             *
5449             * @param smallImageId the small image ID
5450             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5451             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
5452             * @throws SystemException if a system exception occurred
5453             */
5454            @Override
5455            public JournalArticle fetchBySmallImageId_First(long smallImageId,
5456                    OrderByComparator orderByComparator) throws SystemException {
5457                    List<JournalArticle> list = findBySmallImageId(smallImageId, 0, 1,
5458                                    orderByComparator);
5459    
5460                    if (!list.isEmpty()) {
5461                            return list.get(0);
5462                    }
5463    
5464                    return null;
5465            }
5466    
5467            /**
5468             * Returns the last journal article in the ordered set where smallImageId = &#63;.
5469             *
5470             * @param smallImageId the small image ID
5471             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5472             * @return the last matching journal article
5473             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5474             * @throws SystemException if a system exception occurred
5475             */
5476            @Override
5477            public JournalArticle findBySmallImageId_Last(long smallImageId,
5478                    OrderByComparator orderByComparator)
5479                    throws NoSuchArticleException, SystemException {
5480                    JournalArticle journalArticle = fetchBySmallImageId_Last(smallImageId,
5481                                    orderByComparator);
5482    
5483                    if (journalArticle != null) {
5484                            return journalArticle;
5485                    }
5486    
5487                    StringBundler msg = new StringBundler(4);
5488    
5489                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5490    
5491                    msg.append("smallImageId=");
5492                    msg.append(smallImageId);
5493    
5494                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5495    
5496                    throw new NoSuchArticleException(msg.toString());
5497            }
5498    
5499            /**
5500             * Returns the last journal article in the ordered set where smallImageId = &#63;.
5501             *
5502             * @param smallImageId the small image ID
5503             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5504             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
5505             * @throws SystemException if a system exception occurred
5506             */
5507            @Override
5508            public JournalArticle fetchBySmallImageId_Last(long smallImageId,
5509                    OrderByComparator orderByComparator) throws SystemException {
5510                    int count = countBySmallImageId(smallImageId);
5511    
5512                    if (count == 0) {
5513                            return null;
5514                    }
5515    
5516                    List<JournalArticle> list = findBySmallImageId(smallImageId, count - 1,
5517                                    count, orderByComparator);
5518    
5519                    if (!list.isEmpty()) {
5520                            return list.get(0);
5521                    }
5522    
5523                    return null;
5524            }
5525    
5526            /**
5527             * Returns the journal articles before and after the current journal article in the ordered set where smallImageId = &#63;.
5528             *
5529             * @param id the primary key of the current journal article
5530             * @param smallImageId the small image ID
5531             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5532             * @return the previous, current, and next journal article
5533             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
5534             * @throws SystemException if a system exception occurred
5535             */
5536            @Override
5537            public JournalArticle[] findBySmallImageId_PrevAndNext(long id,
5538                    long smallImageId, OrderByComparator orderByComparator)
5539                    throws NoSuchArticleException, SystemException {
5540                    JournalArticle journalArticle = findByPrimaryKey(id);
5541    
5542                    Session session = null;
5543    
5544                    try {
5545                            session = openSession();
5546    
5547                            JournalArticle[] array = new JournalArticleImpl[3];
5548    
5549                            array[0] = getBySmallImageId_PrevAndNext(session, journalArticle,
5550                                            smallImageId, orderByComparator, true);
5551    
5552                            array[1] = journalArticle;
5553    
5554                            array[2] = getBySmallImageId_PrevAndNext(session, journalArticle,
5555                                            smallImageId, orderByComparator, false);
5556    
5557                            return array;
5558                    }
5559                    catch (Exception e) {
5560                            throw processException(e);
5561                    }
5562                    finally {
5563                            closeSession(session);
5564                    }
5565            }
5566    
5567            protected JournalArticle getBySmallImageId_PrevAndNext(Session session,
5568                    JournalArticle journalArticle, long smallImageId,
5569                    OrderByComparator orderByComparator, boolean previous) {
5570                    StringBundler query = null;
5571    
5572                    if (orderByComparator != null) {
5573                            query = new StringBundler(6 +
5574                                            (orderByComparator.getOrderByFields().length * 6));
5575                    }
5576                    else {
5577                            query = new StringBundler(3);
5578                    }
5579    
5580                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5581    
5582                    query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
5583    
5584                    if (orderByComparator != null) {
5585                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5586    
5587                            if (orderByConditionFields.length > 0) {
5588                                    query.append(WHERE_AND);
5589                            }
5590    
5591                            for (int i = 0; i < orderByConditionFields.length; i++) {
5592                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5593                                    query.append(orderByConditionFields[i]);
5594    
5595                                    if ((i + 1) < orderByConditionFields.length) {
5596                                            if (orderByComparator.isAscending() ^ previous) {
5597                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5598                                            }
5599                                            else {
5600                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5601                                            }
5602                                    }
5603                                    else {
5604                                            if (orderByComparator.isAscending() ^ previous) {
5605                                                    query.append(WHERE_GREATER_THAN);
5606                                            }
5607                                            else {
5608                                                    query.append(WHERE_LESSER_THAN);
5609                                            }
5610                                    }
5611                            }
5612    
5613                            query.append(ORDER_BY_CLAUSE);
5614    
5615                            String[] orderByFields = orderByComparator.getOrderByFields();
5616    
5617                            for (int i = 0; i < orderByFields.length; i++) {
5618                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5619                                    query.append(orderByFields[i]);
5620    
5621                                    if ((i + 1) < orderByFields.length) {
5622                                            if (orderByComparator.isAscending() ^ previous) {
5623                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5624                                            }
5625                                            else {
5626                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5627                                            }
5628                                    }
5629                                    else {
5630                                            if (orderByComparator.isAscending() ^ previous) {
5631                                                    query.append(ORDER_BY_ASC);
5632                                            }
5633                                            else {
5634                                                    query.append(ORDER_BY_DESC);
5635                                            }
5636                                    }
5637                            }
5638                    }
5639                    else {
5640                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5641                    }
5642    
5643                    String sql = query.toString();
5644    
5645                    Query q = session.createQuery(sql);
5646    
5647                    q.setFirstResult(0);
5648                    q.setMaxResults(2);
5649    
5650                    QueryPos qPos = QueryPos.getInstance(q);
5651    
5652                    qPos.add(smallImageId);
5653    
5654                    if (orderByComparator != null) {
5655                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5656    
5657                            for (Object value : values) {
5658                                    qPos.add(value);
5659                            }
5660                    }
5661    
5662                    List<JournalArticle> list = q.list();
5663    
5664                    if (list.size() == 2) {
5665                            return list.get(1);
5666                    }
5667                    else {
5668                            return null;
5669                    }
5670            }
5671    
5672            /**
5673             * Removes all the journal articles where smallImageId = &#63; from the database.
5674             *
5675             * @param smallImageId the small image ID
5676             * @throws SystemException if a system exception occurred
5677             */
5678            @Override
5679            public void removeBySmallImageId(long smallImageId)
5680                    throws SystemException {
5681                    for (JournalArticle journalArticle : findBySmallImageId(smallImageId,
5682                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5683                            remove(journalArticle);
5684                    }
5685            }
5686    
5687            /**
5688             * Returns the number of journal articles where smallImageId = &#63;.
5689             *
5690             * @param smallImageId the small image ID
5691             * @return the number of matching journal articles
5692             * @throws SystemException if a system exception occurred
5693             */
5694            @Override
5695            public int countBySmallImageId(long smallImageId) throws SystemException {
5696                    FinderPath finderPath = FINDER_PATH_COUNT_BY_SMALLIMAGEID;
5697    
5698                    Object[] finderArgs = new Object[] { smallImageId };
5699    
5700                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5701                                    this);
5702    
5703                    if (count == null) {
5704                            StringBundler query = new StringBundler(2);
5705    
5706                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
5707    
5708                            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
5709    
5710                            String sql = query.toString();
5711    
5712                            Session session = null;
5713    
5714                            try {
5715                                    session = openSession();
5716    
5717                                    Query q = session.createQuery(sql);
5718    
5719                                    QueryPos qPos = QueryPos.getInstance(q);
5720    
5721                                    qPos.add(smallImageId);
5722    
5723                                    count = (Long)q.uniqueResult();
5724    
5725                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5726                            }
5727                            catch (Exception e) {
5728                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5729    
5730                                    throw processException(e);
5731                            }
5732                            finally {
5733                                    closeSession(session);
5734                            }
5735                    }
5736    
5737                    return count.intValue();
5738            }
5739    
5740            private static final String _FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2 = "journalArticle.smallImageId = ?";
5741            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5742                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5743                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5744                            "findByR_I",
5745                            new String[] {
5746                                    Long.class.getName(), Boolean.class.getName(),
5747                                    
5748                            Integer.class.getName(), Integer.class.getName(),
5749                                    OrderByComparator.class.getName()
5750                            });
5751            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5752                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5753                            JournalArticleImpl.class,
5754                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_I",
5755                            new String[] { Long.class.getName(), Boolean.class.getName() },
5756                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
5757                            JournalArticleModelImpl.INDEXABLE_COLUMN_BITMASK |
5758                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
5759                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
5760            public static final FinderPath FINDER_PATH_COUNT_BY_R_I = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5761                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
5762                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_I",
5763                            new String[] { Long.class.getName(), Boolean.class.getName() });
5764    
5765            /**
5766             * Returns all the journal articles where resourcePrimKey = &#63; and indexable = &#63;.
5767             *
5768             * @param resourcePrimKey the resource prim key
5769             * @param indexable the indexable
5770             * @return the matching journal articles
5771             * @throws SystemException if a system exception occurred
5772             */
5773            @Override
5774            public List<JournalArticle> findByR_I(long resourcePrimKey,
5775                    boolean indexable) throws SystemException {
5776                    return findByR_I(resourcePrimKey, indexable, QueryUtil.ALL_POS,
5777                            QueryUtil.ALL_POS, null);
5778            }
5779    
5780            /**
5781             * Returns a range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63;.
5782             *
5783             * <p>
5784             * 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.
5785             * </p>
5786             *
5787             * @param resourcePrimKey the resource prim key
5788             * @param indexable the indexable
5789             * @param start the lower bound of the range of journal articles
5790             * @param end the upper bound of the range of journal articles (not inclusive)
5791             * @return the range of matching journal articles
5792             * @throws SystemException if a system exception occurred
5793             */
5794            @Override
5795            public List<JournalArticle> findByR_I(long resourcePrimKey,
5796                    boolean indexable, int start, int end) throws SystemException {
5797                    return findByR_I(resourcePrimKey, indexable, start, end, null);
5798            }
5799    
5800            /**
5801             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63;.
5802             *
5803             * <p>
5804             * 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.
5805             * </p>
5806             *
5807             * @param resourcePrimKey the resource prim key
5808             * @param indexable the indexable
5809             * @param start the lower bound of the range of journal articles
5810             * @param end the upper bound of the range of journal articles (not inclusive)
5811             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5812             * @return the ordered range of matching journal articles
5813             * @throws SystemException if a system exception occurred
5814             */
5815            @Override
5816            public List<JournalArticle> findByR_I(long resourcePrimKey,
5817                    boolean indexable, int start, int end,
5818                    OrderByComparator orderByComparator) throws SystemException {
5819                    boolean pagination = true;
5820                    FinderPath finderPath = null;
5821                    Object[] finderArgs = null;
5822    
5823                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5824                                    (orderByComparator == null)) {
5825                            pagination = false;
5826                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I;
5827                            finderArgs = new Object[] { resourcePrimKey, indexable };
5828                    }
5829                    else {
5830                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I;
5831                            finderArgs = new Object[] {
5832                                            resourcePrimKey, indexable,
5833                                            
5834                                            start, end, orderByComparator
5835                                    };
5836                    }
5837    
5838                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
5839                                    finderArgs, this);
5840    
5841                    if ((list != null) && !list.isEmpty()) {
5842                            for (JournalArticle journalArticle : list) {
5843                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
5844                                                    (indexable != journalArticle.getIndexable())) {
5845                                            list = null;
5846    
5847                                            break;
5848                                    }
5849                            }
5850                    }
5851    
5852                    if (list == null) {
5853                            StringBundler query = null;
5854    
5855                            if (orderByComparator != null) {
5856                                    query = new StringBundler(4 +
5857                                                    (orderByComparator.getOrderByFields().length * 3));
5858                            }
5859                            else {
5860                                    query = new StringBundler(4);
5861                            }
5862    
5863                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5864    
5865                            query.append(_FINDER_COLUMN_R_I_RESOURCEPRIMKEY_2);
5866    
5867                            query.append(_FINDER_COLUMN_R_I_INDEXABLE_2);
5868    
5869                            if (orderByComparator != null) {
5870                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5871                                            orderByComparator);
5872                            }
5873                            else
5874                             if (pagination) {
5875                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5876                            }
5877    
5878                            String sql = query.toString();
5879    
5880                            Session session = null;
5881    
5882                            try {
5883                                    session = openSession();
5884    
5885                                    Query q = session.createQuery(sql);
5886    
5887                                    QueryPos qPos = QueryPos.getInstance(q);
5888    
5889                                    qPos.add(resourcePrimKey);
5890    
5891                                    qPos.add(indexable);
5892    
5893                                    if (!pagination) {
5894                                            list = (List<JournalArticle>)QueryUtil.list(q,
5895                                                            getDialect(), start, end, false);
5896    
5897                                            Collections.sort(list);
5898    
5899                                            list = new UnmodifiableList<JournalArticle>(list);
5900                                    }
5901                                    else {
5902                                            list = (List<JournalArticle>)QueryUtil.list(q,
5903                                                            getDialect(), start, end);
5904                                    }
5905    
5906                                    cacheResult(list);
5907    
5908                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5909                            }
5910                            catch (Exception e) {
5911                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5912    
5913                                    throw processException(e);
5914                            }
5915                            finally {
5916                                    closeSession(session);
5917                            }
5918                    }
5919    
5920                    return list;
5921            }
5922    
5923            /**
5924             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
5925             *
5926             * @param resourcePrimKey the resource prim key
5927             * @param indexable the indexable
5928             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5929             * @return the first matching journal article
5930             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5931             * @throws SystemException if a system exception occurred
5932             */
5933            @Override
5934            public JournalArticle findByR_I_First(long resourcePrimKey,
5935                    boolean indexable, OrderByComparator orderByComparator)
5936                    throws NoSuchArticleException, SystemException {
5937                    JournalArticle journalArticle = fetchByR_I_First(resourcePrimKey,
5938                                    indexable, orderByComparator);
5939    
5940                    if (journalArticle != null) {
5941                            return journalArticle;
5942                    }
5943    
5944                    StringBundler msg = new StringBundler(6);
5945    
5946                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5947    
5948                    msg.append("resourcePrimKey=");
5949                    msg.append(resourcePrimKey);
5950    
5951                    msg.append(", indexable=");
5952                    msg.append(indexable);
5953    
5954                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5955    
5956                    throw new NoSuchArticleException(msg.toString());
5957            }
5958    
5959            /**
5960             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
5961             *
5962             * @param resourcePrimKey the resource prim key
5963             * @param indexable the indexable
5964             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5965             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
5966             * @throws SystemException if a system exception occurred
5967             */
5968            @Override
5969            public JournalArticle fetchByR_I_First(long resourcePrimKey,
5970                    boolean indexable, OrderByComparator orderByComparator)
5971                    throws SystemException {
5972                    List<JournalArticle> list = findByR_I(resourcePrimKey, indexable, 0, 1,
5973                                    orderByComparator);
5974    
5975                    if (!list.isEmpty()) {
5976                            return list.get(0);
5977                    }
5978    
5979                    return null;
5980            }
5981    
5982            /**
5983             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
5984             *
5985             * @param resourcePrimKey the resource prim key
5986             * @param indexable the indexable
5987             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5988             * @return the last matching journal article
5989             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5990             * @throws SystemException if a system exception occurred
5991             */
5992            @Override
5993            public JournalArticle findByR_I_Last(long resourcePrimKey,
5994                    boolean indexable, OrderByComparator orderByComparator)
5995                    throws NoSuchArticleException, SystemException {
5996                    JournalArticle journalArticle = fetchByR_I_Last(resourcePrimKey,
5997                                    indexable, orderByComparator);
5998    
5999                    if (journalArticle != null) {
6000                            return journalArticle;
6001                    }
6002    
6003                    StringBundler msg = new StringBundler(6);
6004    
6005                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6006    
6007                    msg.append("resourcePrimKey=");
6008                    msg.append(resourcePrimKey);
6009    
6010                    msg.append(", indexable=");
6011                    msg.append(indexable);
6012    
6013                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6014    
6015                    throw new NoSuchArticleException(msg.toString());
6016            }
6017    
6018            /**
6019             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
6020             *
6021             * @param resourcePrimKey the resource prim key
6022             * @param indexable the indexable
6023             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6024             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
6025             * @throws SystemException if a system exception occurred
6026             */
6027            @Override
6028            public JournalArticle fetchByR_I_Last(long resourcePrimKey,
6029                    boolean indexable, OrderByComparator orderByComparator)
6030                    throws SystemException {
6031                    int count = countByR_I(resourcePrimKey, indexable);
6032    
6033                    if (count == 0) {
6034                            return null;
6035                    }
6036    
6037                    List<JournalArticle> list = findByR_I(resourcePrimKey, indexable,
6038                                    count - 1, count, orderByComparator);
6039    
6040                    if (!list.isEmpty()) {
6041                            return list.get(0);
6042                    }
6043    
6044                    return null;
6045            }
6046    
6047            /**
6048             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
6049             *
6050             * @param id the primary key of the current journal article
6051             * @param resourcePrimKey the resource prim key
6052             * @param indexable the indexable
6053             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6054             * @return the previous, current, and next journal article
6055             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6056             * @throws SystemException if a system exception occurred
6057             */
6058            @Override
6059            public JournalArticle[] findByR_I_PrevAndNext(long id,
6060                    long resourcePrimKey, boolean indexable,
6061                    OrderByComparator orderByComparator)
6062                    throws NoSuchArticleException, SystemException {
6063                    JournalArticle journalArticle = findByPrimaryKey(id);
6064    
6065                    Session session = null;
6066    
6067                    try {
6068                            session = openSession();
6069    
6070                            JournalArticle[] array = new JournalArticleImpl[3];
6071    
6072                            array[0] = getByR_I_PrevAndNext(session, journalArticle,
6073                                            resourcePrimKey, indexable, orderByComparator, true);
6074    
6075                            array[1] = journalArticle;
6076    
6077                            array[2] = getByR_I_PrevAndNext(session, journalArticle,
6078                                            resourcePrimKey, indexable, orderByComparator, false);
6079    
6080                            return array;
6081                    }
6082                    catch (Exception e) {
6083                            throw processException(e);
6084                    }
6085                    finally {
6086                            closeSession(session);
6087                    }
6088            }
6089    
6090            protected JournalArticle getByR_I_PrevAndNext(Session session,
6091                    JournalArticle journalArticle, long resourcePrimKey, boolean indexable,
6092                    OrderByComparator orderByComparator, boolean previous) {
6093                    StringBundler query = null;
6094    
6095                    if (orderByComparator != null) {
6096                            query = new StringBundler(6 +
6097                                            (orderByComparator.getOrderByFields().length * 6));
6098                    }
6099                    else {
6100                            query = new StringBundler(3);
6101                    }
6102    
6103                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6104    
6105                    query.append(_FINDER_COLUMN_R_I_RESOURCEPRIMKEY_2);
6106    
6107                    query.append(_FINDER_COLUMN_R_I_INDEXABLE_2);
6108    
6109                    if (orderByComparator != null) {
6110                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6111    
6112                            if (orderByConditionFields.length > 0) {
6113                                    query.append(WHERE_AND);
6114                            }
6115    
6116                            for (int i = 0; i < orderByConditionFields.length; i++) {
6117                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6118                                    query.append(orderByConditionFields[i]);
6119    
6120                                    if ((i + 1) < orderByConditionFields.length) {
6121                                            if (orderByComparator.isAscending() ^ previous) {
6122                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6123                                            }
6124                                            else {
6125                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6126                                            }
6127                                    }
6128                                    else {
6129                                            if (orderByComparator.isAscending() ^ previous) {
6130                                                    query.append(WHERE_GREATER_THAN);
6131                                            }
6132                                            else {
6133                                                    query.append(WHERE_LESSER_THAN);
6134                                            }
6135                                    }
6136                            }
6137    
6138                            query.append(ORDER_BY_CLAUSE);
6139    
6140                            String[] orderByFields = orderByComparator.getOrderByFields();
6141    
6142                            for (int i = 0; i < orderByFields.length; i++) {
6143                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6144                                    query.append(orderByFields[i]);
6145    
6146                                    if ((i + 1) < orderByFields.length) {
6147                                            if (orderByComparator.isAscending() ^ previous) {
6148                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6149                                            }
6150                                            else {
6151                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6152                                            }
6153                                    }
6154                                    else {
6155                                            if (orderByComparator.isAscending() ^ previous) {
6156                                                    query.append(ORDER_BY_ASC);
6157                                            }
6158                                            else {
6159                                                    query.append(ORDER_BY_DESC);
6160                                            }
6161                                    }
6162                            }
6163                    }
6164                    else {
6165                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6166                    }
6167    
6168                    String sql = query.toString();
6169    
6170                    Query q = session.createQuery(sql);
6171    
6172                    q.setFirstResult(0);
6173                    q.setMaxResults(2);
6174    
6175                    QueryPos qPos = QueryPos.getInstance(q);
6176    
6177                    qPos.add(resourcePrimKey);
6178    
6179                    qPos.add(indexable);
6180    
6181                    if (orderByComparator != null) {
6182                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6183    
6184                            for (Object value : values) {
6185                                    qPos.add(value);
6186                            }
6187                    }
6188    
6189                    List<JournalArticle> list = q.list();
6190    
6191                    if (list.size() == 2) {
6192                            return list.get(1);
6193                    }
6194                    else {
6195                            return null;
6196                    }
6197            }
6198    
6199            /**
6200             * Removes all the journal articles where resourcePrimKey = &#63; and indexable = &#63; from the database.
6201             *
6202             * @param resourcePrimKey the resource prim key
6203             * @param indexable the indexable
6204             * @throws SystemException if a system exception occurred
6205             */
6206            @Override
6207            public void removeByR_I(long resourcePrimKey, boolean indexable)
6208                    throws SystemException {
6209                    for (JournalArticle journalArticle : findByR_I(resourcePrimKey,
6210                                    indexable, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6211                            remove(journalArticle);
6212                    }
6213            }
6214    
6215            /**
6216             * Returns the number of journal articles where resourcePrimKey = &#63; and indexable = &#63;.
6217             *
6218             * @param resourcePrimKey the resource prim key
6219             * @param indexable the indexable
6220             * @return the number of matching journal articles
6221             * @throws SystemException if a system exception occurred
6222             */
6223            @Override
6224            public int countByR_I(long resourcePrimKey, boolean indexable)
6225                    throws SystemException {
6226                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_I;
6227    
6228                    Object[] finderArgs = new Object[] { resourcePrimKey, indexable };
6229    
6230                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6231                                    this);
6232    
6233                    if (count == null) {
6234                            StringBundler query = new StringBundler(3);
6235    
6236                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
6237    
6238                            query.append(_FINDER_COLUMN_R_I_RESOURCEPRIMKEY_2);
6239    
6240                            query.append(_FINDER_COLUMN_R_I_INDEXABLE_2);
6241    
6242                            String sql = query.toString();
6243    
6244                            Session session = null;
6245    
6246                            try {
6247                                    session = openSession();
6248    
6249                                    Query q = session.createQuery(sql);
6250    
6251                                    QueryPos qPos = QueryPos.getInstance(q);
6252    
6253                                    qPos.add(resourcePrimKey);
6254    
6255                                    qPos.add(indexable);
6256    
6257                                    count = (Long)q.uniqueResult();
6258    
6259                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6260                            }
6261                            catch (Exception e) {
6262                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6263    
6264                                    throw processException(e);
6265                            }
6266                            finally {
6267                                    closeSession(session);
6268                            }
6269                    }
6270    
6271                    return count.intValue();
6272            }
6273    
6274            private static final String _FINDER_COLUMN_R_I_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
6275            private static final String _FINDER_COLUMN_R_I_INDEXABLE_2 = "journalArticle.indexable = ?";
6276            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6277                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
6278                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
6279                            "findByR_ST",
6280                            new String[] {
6281                                    Long.class.getName(), Integer.class.getName(),
6282                                    
6283                            Integer.class.getName(), Integer.class.getName(),
6284                                    OrderByComparator.class.getName()
6285                            });
6286            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6287                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
6288                            JournalArticleImpl.class,
6289                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_ST",
6290                            new String[] { Long.class.getName(), Integer.class.getName() },
6291                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
6292                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
6293                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
6294                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
6295            public static final FinderPath FINDER_PATH_COUNT_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6296                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
6297                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_ST",
6298                            new String[] { Long.class.getName(), Integer.class.getName() });
6299            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6300                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
6301                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByR_ST",
6302                            new String[] { Long.class.getName(), Integer.class.getName() });
6303    
6304            /**
6305             * Returns all the journal articles where resourcePrimKey = &#63; and status = &#63;.
6306             *
6307             * @param resourcePrimKey the resource prim key
6308             * @param status the status
6309             * @return the matching journal articles
6310             * @throws SystemException if a system exception occurred
6311             */
6312            @Override
6313            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status)
6314                    throws SystemException {
6315                    return findByR_ST(resourcePrimKey, status, QueryUtil.ALL_POS,
6316                            QueryUtil.ALL_POS, null);
6317            }
6318    
6319            /**
6320             * Returns a range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
6321             *
6322             * <p>
6323             * 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.
6324             * </p>
6325             *
6326             * @param resourcePrimKey the resource prim key
6327             * @param status the status
6328             * @param start the lower bound of the range of journal articles
6329             * @param end the upper bound of the range of journal articles (not inclusive)
6330             * @return the range of matching journal articles
6331             * @throws SystemException if a system exception occurred
6332             */
6333            @Override
6334            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
6335                    int start, int end) throws SystemException {
6336                    return findByR_ST(resourcePrimKey, status, start, end, null);
6337            }
6338    
6339            /**
6340             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
6341             *
6342             * <p>
6343             * 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.
6344             * </p>
6345             *
6346             * @param resourcePrimKey the resource prim key
6347             * @param status the status
6348             * @param start the lower bound of the range of journal articles
6349             * @param end the upper bound of the range of journal articles (not inclusive)
6350             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6351             * @return the ordered range of matching journal articles
6352             * @throws SystemException if a system exception occurred
6353             */
6354            @Override
6355            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
6356                    int start, int end, OrderByComparator orderByComparator)
6357                    throws SystemException {
6358                    boolean pagination = true;
6359                    FinderPath finderPath = null;
6360                    Object[] finderArgs = null;
6361    
6362                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6363                                    (orderByComparator == null)) {
6364                            pagination = false;
6365                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST;
6366                            finderArgs = new Object[] { resourcePrimKey, status };
6367                    }
6368                    else {
6369                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST;
6370                            finderArgs = new Object[] {
6371                                            resourcePrimKey, status,
6372                                            
6373                                            start, end, orderByComparator
6374                                    };
6375                    }
6376    
6377                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
6378                                    finderArgs, this);
6379    
6380                    if ((list != null) && !list.isEmpty()) {
6381                            for (JournalArticle journalArticle : list) {
6382                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
6383                                                    (status != journalArticle.getStatus())) {
6384                                            list = null;
6385    
6386                                            break;
6387                                    }
6388                            }
6389                    }
6390    
6391                    if (list == null) {
6392                            StringBundler query = null;
6393    
6394                            if (orderByComparator != null) {
6395                                    query = new StringBundler(4 +
6396                                                    (orderByComparator.getOrderByFields().length * 3));
6397                            }
6398                            else {
6399                                    query = new StringBundler(4);
6400                            }
6401    
6402                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6403    
6404                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
6405    
6406                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
6407    
6408                            if (orderByComparator != null) {
6409                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6410                                            orderByComparator);
6411                            }
6412                            else
6413                             if (pagination) {
6414                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6415                            }
6416    
6417                            String sql = query.toString();
6418    
6419                            Session session = null;
6420    
6421                            try {
6422                                    session = openSession();
6423    
6424                                    Query q = session.createQuery(sql);
6425    
6426                                    QueryPos qPos = QueryPos.getInstance(q);
6427    
6428                                    qPos.add(resourcePrimKey);
6429    
6430                                    qPos.add(status);
6431    
6432                                    if (!pagination) {
6433                                            list = (List<JournalArticle>)QueryUtil.list(q,
6434                                                            getDialect(), start, end, false);
6435    
6436                                            Collections.sort(list);
6437    
6438                                            list = new UnmodifiableList<JournalArticle>(list);
6439                                    }
6440                                    else {
6441                                            list = (List<JournalArticle>)QueryUtil.list(q,
6442                                                            getDialect(), start, end);
6443                                    }
6444    
6445                                    cacheResult(list);
6446    
6447                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6448                            }
6449                            catch (Exception e) {
6450                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6451    
6452                                    throw processException(e);
6453                            }
6454                            finally {
6455                                    closeSession(session);
6456                            }
6457                    }
6458    
6459                    return list;
6460            }
6461    
6462            /**
6463             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6464             *
6465             * @param resourcePrimKey the resource prim key
6466             * @param status the status
6467             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6468             * @return the first matching journal article
6469             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6470             * @throws SystemException if a system exception occurred
6471             */
6472            @Override
6473            public JournalArticle findByR_ST_First(long resourcePrimKey, int status,
6474                    OrderByComparator orderByComparator)
6475                    throws NoSuchArticleException, SystemException {
6476                    JournalArticle journalArticle = fetchByR_ST_First(resourcePrimKey,
6477                                    status, orderByComparator);
6478    
6479                    if (journalArticle != null) {
6480                            return journalArticle;
6481                    }
6482    
6483                    StringBundler msg = new StringBundler(6);
6484    
6485                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6486    
6487                    msg.append("resourcePrimKey=");
6488                    msg.append(resourcePrimKey);
6489    
6490                    msg.append(", status=");
6491                    msg.append(status);
6492    
6493                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6494    
6495                    throw new NoSuchArticleException(msg.toString());
6496            }
6497    
6498            /**
6499             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6500             *
6501             * @param resourcePrimKey the resource prim key
6502             * @param status the status
6503             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6504             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
6505             * @throws SystemException if a system exception occurred
6506             */
6507            @Override
6508            public JournalArticle fetchByR_ST_First(long resourcePrimKey, int status,
6509                    OrderByComparator orderByComparator) throws SystemException {
6510                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status, 0, 1,
6511                                    orderByComparator);
6512    
6513                    if (!list.isEmpty()) {
6514                            return list.get(0);
6515                    }
6516    
6517                    return null;
6518            }
6519    
6520            /**
6521             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6522             *
6523             * @param resourcePrimKey the resource prim key
6524             * @param status the status
6525             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6526             * @return the last matching journal article
6527             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6528             * @throws SystemException if a system exception occurred
6529             */
6530            @Override
6531            public JournalArticle findByR_ST_Last(long resourcePrimKey, int status,
6532                    OrderByComparator orderByComparator)
6533                    throws NoSuchArticleException, SystemException {
6534                    JournalArticle journalArticle = fetchByR_ST_Last(resourcePrimKey,
6535                                    status, orderByComparator);
6536    
6537                    if (journalArticle != null) {
6538                            return journalArticle;
6539                    }
6540    
6541                    StringBundler msg = new StringBundler(6);
6542    
6543                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6544    
6545                    msg.append("resourcePrimKey=");
6546                    msg.append(resourcePrimKey);
6547    
6548                    msg.append(", status=");
6549                    msg.append(status);
6550    
6551                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6552    
6553                    throw new NoSuchArticleException(msg.toString());
6554            }
6555    
6556            /**
6557             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6558             *
6559             * @param resourcePrimKey the resource prim key
6560             * @param status the status
6561             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6562             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
6563             * @throws SystemException if a system exception occurred
6564             */
6565            @Override
6566            public JournalArticle fetchByR_ST_Last(long resourcePrimKey, int status,
6567                    OrderByComparator orderByComparator) throws SystemException {
6568                    int count = countByR_ST(resourcePrimKey, status);
6569    
6570                    if (count == 0) {
6571                            return null;
6572                    }
6573    
6574                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status,
6575                                    count - 1, count, orderByComparator);
6576    
6577                    if (!list.isEmpty()) {
6578                            return list.get(0);
6579                    }
6580    
6581                    return null;
6582            }
6583    
6584            /**
6585             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6586             *
6587             * @param id the primary key of the current journal article
6588             * @param resourcePrimKey the resource prim key
6589             * @param status the status
6590             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6591             * @return the previous, current, and next journal article
6592             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6593             * @throws SystemException if a system exception occurred
6594             */
6595            @Override
6596            public JournalArticle[] findByR_ST_PrevAndNext(long id,
6597                    long resourcePrimKey, int status, OrderByComparator orderByComparator)
6598                    throws NoSuchArticleException, SystemException {
6599                    JournalArticle journalArticle = findByPrimaryKey(id);
6600    
6601                    Session session = null;
6602    
6603                    try {
6604                            session = openSession();
6605    
6606                            JournalArticle[] array = new JournalArticleImpl[3];
6607    
6608                            array[0] = getByR_ST_PrevAndNext(session, journalArticle,
6609                                            resourcePrimKey, status, orderByComparator, true);
6610    
6611                            array[1] = journalArticle;
6612    
6613                            array[2] = getByR_ST_PrevAndNext(session, journalArticle,
6614                                            resourcePrimKey, status, orderByComparator, false);
6615    
6616                            return array;
6617                    }
6618                    catch (Exception e) {
6619                            throw processException(e);
6620                    }
6621                    finally {
6622                            closeSession(session);
6623                    }
6624            }
6625    
6626            protected JournalArticle getByR_ST_PrevAndNext(Session session,
6627                    JournalArticle journalArticle, long resourcePrimKey, int status,
6628                    OrderByComparator orderByComparator, boolean previous) {
6629                    StringBundler query = null;
6630    
6631                    if (orderByComparator != null) {
6632                            query = new StringBundler(6 +
6633                                            (orderByComparator.getOrderByFields().length * 6));
6634                    }
6635                    else {
6636                            query = new StringBundler(3);
6637                    }
6638    
6639                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6640    
6641                    query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
6642    
6643                    query.append(_FINDER_COLUMN_R_ST_STATUS_2);
6644    
6645                    if (orderByComparator != null) {
6646                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6647    
6648                            if (orderByConditionFields.length > 0) {
6649                                    query.append(WHERE_AND);
6650                            }
6651    
6652                            for (int i = 0; i < orderByConditionFields.length; i++) {
6653                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6654                                    query.append(orderByConditionFields[i]);
6655    
6656                                    if ((i + 1) < orderByConditionFields.length) {
6657                                            if (orderByComparator.isAscending() ^ previous) {
6658                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6659                                            }
6660                                            else {
6661                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6662                                            }
6663                                    }
6664                                    else {
6665                                            if (orderByComparator.isAscending() ^ previous) {
6666                                                    query.append(WHERE_GREATER_THAN);
6667                                            }
6668                                            else {
6669                                                    query.append(WHERE_LESSER_THAN);
6670                                            }
6671                                    }
6672                            }
6673    
6674                            query.append(ORDER_BY_CLAUSE);
6675    
6676                            String[] orderByFields = orderByComparator.getOrderByFields();
6677    
6678                            for (int i = 0; i < orderByFields.length; i++) {
6679                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6680                                    query.append(orderByFields[i]);
6681    
6682                                    if ((i + 1) < orderByFields.length) {
6683                                            if (orderByComparator.isAscending() ^ previous) {
6684                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6685                                            }
6686                                            else {
6687                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6688                                            }
6689                                    }
6690                                    else {
6691                                            if (orderByComparator.isAscending() ^ previous) {
6692                                                    query.append(ORDER_BY_ASC);
6693                                            }
6694                                            else {
6695                                                    query.append(ORDER_BY_DESC);
6696                                            }
6697                                    }
6698                            }
6699                    }
6700                    else {
6701                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6702                    }
6703    
6704                    String sql = query.toString();
6705    
6706                    Query q = session.createQuery(sql);
6707    
6708                    q.setFirstResult(0);
6709                    q.setMaxResults(2);
6710    
6711                    QueryPos qPos = QueryPos.getInstance(q);
6712    
6713                    qPos.add(resourcePrimKey);
6714    
6715                    qPos.add(status);
6716    
6717                    if (orderByComparator != null) {
6718                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6719    
6720                            for (Object value : values) {
6721                                    qPos.add(value);
6722                            }
6723                    }
6724    
6725                    List<JournalArticle> list = q.list();
6726    
6727                    if (list.size() == 2) {
6728                            return list.get(1);
6729                    }
6730                    else {
6731                            return null;
6732                    }
6733            }
6734    
6735            /**
6736             * Returns all the journal articles where resourcePrimKey = &#63; and status = any &#63;.
6737             *
6738             * <p>
6739             * 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.
6740             * </p>
6741             *
6742             * @param resourcePrimKey the resource prim key
6743             * @param statuses the statuses
6744             * @return the matching journal articles
6745             * @throws SystemException if a system exception occurred
6746             */
6747            @Override
6748            public List<JournalArticle> findByR_ST(long resourcePrimKey, int[] statuses)
6749                    throws SystemException {
6750                    return findByR_ST(resourcePrimKey, statuses, QueryUtil.ALL_POS,
6751                            QueryUtil.ALL_POS, null);
6752            }
6753    
6754            /**
6755             * Returns a range of all the journal articles where resourcePrimKey = &#63; and status = any &#63;.
6756             *
6757             * <p>
6758             * 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.
6759             * </p>
6760             *
6761             * @param resourcePrimKey the resource prim key
6762             * @param statuses the statuses
6763             * @param start the lower bound of the range of journal articles
6764             * @param end the upper bound of the range of journal articles (not inclusive)
6765             * @return the range of matching journal articles
6766             * @throws SystemException if a system exception occurred
6767             */
6768            @Override
6769            public List<JournalArticle> findByR_ST(long resourcePrimKey,
6770                    int[] statuses, int start, int end) throws SystemException {
6771                    return findByR_ST(resourcePrimKey, statuses, start, end, null);
6772            }
6773    
6774            /**
6775             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and status = any &#63;.
6776             *
6777             * <p>
6778             * 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.
6779             * </p>
6780             *
6781             * @param resourcePrimKey the resource prim key
6782             * @param statuses the statuses
6783             * @param start the lower bound of the range of journal articles
6784             * @param end the upper bound of the range of journal articles (not inclusive)
6785             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6786             * @return the ordered range of matching journal articles
6787             * @throws SystemException if a system exception occurred
6788             */
6789            @Override
6790            public List<JournalArticle> findByR_ST(long resourcePrimKey,
6791                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
6792                    throws SystemException {
6793                    if ((statuses != null) && (statuses.length == 1)) {
6794                            return findByR_ST(resourcePrimKey, statuses[0], start, end,
6795                                    orderByComparator);
6796                    }
6797    
6798                    boolean pagination = true;
6799                    Object[] finderArgs = null;
6800    
6801                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6802                                    (orderByComparator == null)) {
6803                            pagination = false;
6804                            finderArgs = new Object[] {
6805                                            resourcePrimKey, StringUtil.merge(statuses)
6806                                    };
6807                    }
6808                    else {
6809                            finderArgs = new Object[] {
6810                                            resourcePrimKey, StringUtil.merge(statuses),
6811                                            
6812                                            start, end, orderByComparator
6813                                    };
6814                    }
6815    
6816                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST,
6817                                    finderArgs, this);
6818    
6819                    if ((list != null) && !list.isEmpty()) {
6820                            for (JournalArticle journalArticle : list) {
6821                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
6822                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
6823                                            list = null;
6824    
6825                                            break;
6826                                    }
6827                            }
6828                    }
6829    
6830                    if (list == null) {
6831                            StringBundler query = new StringBundler();
6832    
6833                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6834    
6835                            boolean conjunctionable = false;
6836    
6837                            if (conjunctionable) {
6838                                    query.append(WHERE_AND);
6839                            }
6840    
6841                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_5);
6842    
6843                            conjunctionable = true;
6844    
6845                            if ((statuses == null) || (statuses.length > 0)) {
6846                                    if (conjunctionable) {
6847                                            query.append(WHERE_AND);
6848                                    }
6849    
6850                                    query.append(StringPool.OPEN_PARENTHESIS);
6851    
6852                                    for (int i = 0; i < statuses.length; i++) {
6853                                            query.append(_FINDER_COLUMN_R_ST_STATUS_5);
6854    
6855                                            if ((i + 1) < statuses.length) {
6856                                                    query.append(WHERE_OR);
6857                                            }
6858                                    }
6859    
6860                                    query.append(StringPool.CLOSE_PARENTHESIS);
6861    
6862                                    conjunctionable = true;
6863                            }
6864    
6865                            if (orderByComparator != null) {
6866                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6867                                            orderByComparator);
6868                            }
6869                            else
6870                             if (pagination) {
6871                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6872                            }
6873    
6874                            String sql = query.toString();
6875    
6876                            Session session = null;
6877    
6878                            try {
6879                                    session = openSession();
6880    
6881                                    Query q = session.createQuery(sql);
6882    
6883                                    QueryPos qPos = QueryPos.getInstance(q);
6884    
6885                                    qPos.add(resourcePrimKey);
6886    
6887                                    if (statuses != null) {
6888                                            qPos.add(statuses);
6889                                    }
6890    
6891                                    if (!pagination) {
6892                                            list = (List<JournalArticle>)QueryUtil.list(q,
6893                                                            getDialect(), start, end, false);
6894    
6895                                            Collections.sort(list);
6896    
6897                                            list = new UnmodifiableList<JournalArticle>(list);
6898                                    }
6899                                    else {
6900                                            list = (List<JournalArticle>)QueryUtil.list(q,
6901                                                            getDialect(), start, end);
6902                                    }
6903    
6904                                    cacheResult(list);
6905    
6906                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST,
6907                                            finderArgs, list);
6908                            }
6909                            catch (Exception e) {
6910                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST,
6911                                            finderArgs);
6912    
6913                                    throw processException(e);
6914                            }
6915                            finally {
6916                                    closeSession(session);
6917                            }
6918                    }
6919    
6920                    return list;
6921            }
6922    
6923            /**
6924             * Removes all the journal articles where resourcePrimKey = &#63; and status = &#63; from the database.
6925             *
6926             * @param resourcePrimKey the resource prim key
6927             * @param status the status
6928             * @throws SystemException if a system exception occurred
6929             */
6930            @Override
6931            public void removeByR_ST(long resourcePrimKey, int status)
6932                    throws SystemException {
6933                    for (JournalArticle journalArticle : findByR_ST(resourcePrimKey,
6934                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6935                            remove(journalArticle);
6936                    }
6937            }
6938    
6939            /**
6940             * Returns the number of journal articles where resourcePrimKey = &#63; and status = &#63;.
6941             *
6942             * @param resourcePrimKey the resource prim key
6943             * @param status the status
6944             * @return the number of matching journal articles
6945             * @throws SystemException if a system exception occurred
6946             */
6947            @Override
6948            public int countByR_ST(long resourcePrimKey, int status)
6949                    throws SystemException {
6950                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_ST;
6951    
6952                    Object[] finderArgs = new Object[] { resourcePrimKey, status };
6953    
6954                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6955                                    this);
6956    
6957                    if (count == null) {
6958                            StringBundler query = new StringBundler(3);
6959    
6960                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
6961    
6962                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
6963    
6964                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
6965    
6966                            String sql = query.toString();
6967    
6968                            Session session = null;
6969    
6970                            try {
6971                                    session = openSession();
6972    
6973                                    Query q = session.createQuery(sql);
6974    
6975                                    QueryPos qPos = QueryPos.getInstance(q);
6976    
6977                                    qPos.add(resourcePrimKey);
6978    
6979                                    qPos.add(status);
6980    
6981                                    count = (Long)q.uniqueResult();
6982    
6983                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6984                            }
6985                            catch (Exception e) {
6986                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6987    
6988                                    throw processException(e);
6989                            }
6990                            finally {
6991                                    closeSession(session);
6992                            }
6993                    }
6994    
6995                    return count.intValue();
6996            }
6997    
6998            /**
6999             * Returns the number of journal articles where resourcePrimKey = &#63; and status = any &#63;.
7000             *
7001             * @param resourcePrimKey the resource prim key
7002             * @param statuses the statuses
7003             * @return the number of matching journal articles
7004             * @throws SystemException if a system exception occurred
7005             */
7006            @Override
7007            public int countByR_ST(long resourcePrimKey, int[] statuses)
7008                    throws SystemException {
7009                    Object[] finderArgs = new Object[] {
7010                                    resourcePrimKey, StringUtil.merge(statuses)
7011                            };
7012    
7013                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_ST,
7014                                    finderArgs, this);
7015    
7016                    if (count == null) {
7017                            StringBundler query = new StringBundler();
7018    
7019                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
7020    
7021                            boolean conjunctionable = false;
7022    
7023                            if (conjunctionable) {
7024                                    query.append(WHERE_AND);
7025                            }
7026    
7027                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_5);
7028    
7029                            conjunctionable = true;
7030    
7031                            if ((statuses == null) || (statuses.length > 0)) {
7032                                    if (conjunctionable) {
7033                                            query.append(WHERE_AND);
7034                                    }
7035    
7036                                    query.append(StringPool.OPEN_PARENTHESIS);
7037    
7038                                    for (int i = 0; i < statuses.length; i++) {
7039                                            query.append(_FINDER_COLUMN_R_ST_STATUS_5);
7040    
7041                                            if ((i + 1) < statuses.length) {
7042                                                    query.append(WHERE_OR);
7043                                            }
7044                                    }
7045    
7046                                    query.append(StringPool.CLOSE_PARENTHESIS);
7047    
7048                                    conjunctionable = true;
7049                            }
7050    
7051                            String sql = query.toString();
7052    
7053                            Session session = null;
7054    
7055                            try {
7056                                    session = openSession();
7057    
7058                                    Query q = session.createQuery(sql);
7059    
7060                                    QueryPos qPos = QueryPos.getInstance(q);
7061    
7062                                    qPos.add(resourcePrimKey);
7063    
7064                                    if (statuses != null) {
7065                                            qPos.add(statuses);
7066                                    }
7067    
7068                                    count = (Long)q.uniqueResult();
7069    
7070                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_ST,
7071                                            finderArgs, count);
7072                            }
7073                            catch (Exception e) {
7074                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_ST,
7075                                            finderArgs);
7076    
7077                                    throw processException(e);
7078                            }
7079                            finally {
7080                                    closeSession(session);
7081                            }
7082                    }
7083    
7084                    return count.intValue();
7085            }
7086    
7087            private static final String _FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
7088            private static final String _FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_5 = "(" +
7089                    removeConjunction(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2) + ")";
7090            private static final String _FINDER_COLUMN_R_ST_STATUS_2 = "journalArticle.status = ?";
7091            private static final String _FINDER_COLUMN_R_ST_STATUS_5 = "(" +
7092                    removeConjunction(_FINDER_COLUMN_R_ST_STATUS_2) + ")";
7093            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7094                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
7095                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
7096                            "findByG_U",
7097                            new String[] {
7098                                    Long.class.getName(), Long.class.getName(),
7099                                    
7100                            Integer.class.getName(), Integer.class.getName(),
7101                                    OrderByComparator.class.getName()
7102                            });
7103            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7104                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
7105                            JournalArticleImpl.class,
7106                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U",
7107                            new String[] { Long.class.getName(), Long.class.getName() },
7108                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
7109                            JournalArticleModelImpl.USERID_COLUMN_BITMASK |
7110                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
7111                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
7112            public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7113                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
7114                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U",
7115                            new String[] { Long.class.getName(), Long.class.getName() });
7116    
7117            /**
7118             * Returns all the journal articles where groupId = &#63; and userId = &#63;.
7119             *
7120             * @param groupId the group ID
7121             * @param userId the user ID
7122             * @return the matching journal articles
7123             * @throws SystemException if a system exception occurred
7124             */
7125            @Override
7126            public List<JournalArticle> findByG_U(long groupId, long userId)
7127                    throws SystemException {
7128                    return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
7129                            null);
7130            }
7131    
7132            /**
7133             * Returns a range of all the journal articles where groupId = &#63; and userId = &#63;.
7134             *
7135             * <p>
7136             * 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.
7137             * </p>
7138             *
7139             * @param groupId the group ID
7140             * @param userId the user ID
7141             * @param start the lower bound of the range of journal articles
7142             * @param end the upper bound of the range of journal articles (not inclusive)
7143             * @return the range of matching journal articles
7144             * @throws SystemException if a system exception occurred
7145             */
7146            @Override
7147            public List<JournalArticle> findByG_U(long groupId, long userId, int start,
7148                    int end) throws SystemException {
7149                    return findByG_U(groupId, userId, start, end, null);
7150            }
7151    
7152            /**
7153             * Returns an ordered range of all the journal articles where groupId = &#63; and userId = &#63;.
7154             *
7155             * <p>
7156             * 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.
7157             * </p>
7158             *
7159             * @param groupId the group ID
7160             * @param userId the user ID
7161             * @param start the lower bound of the range of journal articles
7162             * @param end the upper bound of the range of journal articles (not inclusive)
7163             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7164             * @return the ordered range of matching journal articles
7165             * @throws SystemException if a system exception occurred
7166             */
7167            @Override
7168            public List<JournalArticle> findByG_U(long groupId, long userId, int start,
7169                    int end, OrderByComparator orderByComparator) throws SystemException {
7170                    boolean pagination = true;
7171                    FinderPath finderPath = null;
7172                    Object[] finderArgs = null;
7173    
7174                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7175                                    (orderByComparator == null)) {
7176                            pagination = false;
7177                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U;
7178                            finderArgs = new Object[] { groupId, userId };
7179                    }
7180                    else {
7181                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U;
7182                            finderArgs = new Object[] {
7183                                            groupId, userId,
7184                                            
7185                                            start, end, orderByComparator
7186                                    };
7187                    }
7188    
7189                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
7190                                    finderArgs, this);
7191    
7192                    if ((list != null) && !list.isEmpty()) {
7193                            for (JournalArticle journalArticle : list) {
7194                                    if ((groupId != journalArticle.getGroupId()) ||
7195                                                    (userId != journalArticle.getUserId())) {
7196                                            list = null;
7197    
7198                                            break;
7199                                    }
7200                            }
7201                    }
7202    
7203                    if (list == null) {
7204                            StringBundler query = null;
7205    
7206                            if (orderByComparator != null) {
7207                                    query = new StringBundler(4 +
7208                                                    (orderByComparator.getOrderByFields().length * 3));
7209                            }
7210                            else {
7211                                    query = new StringBundler(4);
7212                            }
7213    
7214                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7215    
7216                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7217    
7218                            query.append(_FINDER_COLUMN_G_U_USERID_2);
7219    
7220                            if (orderByComparator != null) {
7221                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7222                                            orderByComparator);
7223                            }
7224                            else
7225                             if (pagination) {
7226                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7227                            }
7228    
7229                            String sql = query.toString();
7230    
7231                            Session session = null;
7232    
7233                            try {
7234                                    session = openSession();
7235    
7236                                    Query q = session.createQuery(sql);
7237    
7238                                    QueryPos qPos = QueryPos.getInstance(q);
7239    
7240                                    qPos.add(groupId);
7241    
7242                                    qPos.add(userId);
7243    
7244                                    if (!pagination) {
7245                                            list = (List<JournalArticle>)QueryUtil.list(q,
7246                                                            getDialect(), start, end, false);
7247    
7248                                            Collections.sort(list);
7249    
7250                                            list = new UnmodifiableList<JournalArticle>(list);
7251                                    }
7252                                    else {
7253                                            list = (List<JournalArticle>)QueryUtil.list(q,
7254                                                            getDialect(), start, end);
7255                                    }
7256    
7257                                    cacheResult(list);
7258    
7259                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
7260                            }
7261                            catch (Exception e) {
7262                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7263    
7264                                    throw processException(e);
7265                            }
7266                            finally {
7267                                    closeSession(session);
7268                            }
7269                    }
7270    
7271                    return list;
7272            }
7273    
7274            /**
7275             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63;.
7276             *
7277             * @param groupId the group ID
7278             * @param userId the user ID
7279             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7280             * @return the first matching journal article
7281             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
7282             * @throws SystemException if a system exception occurred
7283             */
7284            @Override
7285            public JournalArticle findByG_U_First(long groupId, long userId,
7286                    OrderByComparator orderByComparator)
7287                    throws NoSuchArticleException, SystemException {
7288                    JournalArticle journalArticle = fetchByG_U_First(groupId, userId,
7289                                    orderByComparator);
7290    
7291                    if (journalArticle != null) {
7292                            return journalArticle;
7293                    }
7294    
7295                    StringBundler msg = new StringBundler(6);
7296    
7297                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7298    
7299                    msg.append("groupId=");
7300                    msg.append(groupId);
7301    
7302                    msg.append(", userId=");
7303                    msg.append(userId);
7304    
7305                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7306    
7307                    throw new NoSuchArticleException(msg.toString());
7308            }
7309    
7310            /**
7311             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63;.
7312             *
7313             * @param groupId the group ID
7314             * @param userId the user ID
7315             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7316             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
7317             * @throws SystemException if a system exception occurred
7318             */
7319            @Override
7320            public JournalArticle fetchByG_U_First(long groupId, long userId,
7321                    OrderByComparator orderByComparator) throws SystemException {
7322                    List<JournalArticle> list = findByG_U(groupId, userId, 0, 1,
7323                                    orderByComparator);
7324    
7325                    if (!list.isEmpty()) {
7326                            return list.get(0);
7327                    }
7328    
7329                    return null;
7330            }
7331    
7332            /**
7333             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63;.
7334             *
7335             * @param groupId the group ID
7336             * @param userId the user ID
7337             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7338             * @return the last matching journal article
7339             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
7340             * @throws SystemException if a system exception occurred
7341             */
7342            @Override
7343            public JournalArticle findByG_U_Last(long groupId, long userId,
7344                    OrderByComparator orderByComparator)
7345                    throws NoSuchArticleException, SystemException {
7346                    JournalArticle journalArticle = fetchByG_U_Last(groupId, userId,
7347                                    orderByComparator);
7348    
7349                    if (journalArticle != null) {
7350                            return journalArticle;
7351                    }
7352    
7353                    StringBundler msg = new StringBundler(6);
7354    
7355                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7356    
7357                    msg.append("groupId=");
7358                    msg.append(groupId);
7359    
7360                    msg.append(", userId=");
7361                    msg.append(userId);
7362    
7363                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7364    
7365                    throw new NoSuchArticleException(msg.toString());
7366            }
7367    
7368            /**
7369             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63;.
7370             *
7371             * @param groupId the group ID
7372             * @param userId the user ID
7373             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7374             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
7375             * @throws SystemException if a system exception occurred
7376             */
7377            @Override
7378            public JournalArticle fetchByG_U_Last(long groupId, long userId,
7379                    OrderByComparator orderByComparator) throws SystemException {
7380                    int count = countByG_U(groupId, userId);
7381    
7382                    if (count == 0) {
7383                            return null;
7384                    }
7385    
7386                    List<JournalArticle> list = findByG_U(groupId, userId, count - 1,
7387                                    count, orderByComparator);
7388    
7389                    if (!list.isEmpty()) {
7390                            return list.get(0);
7391                    }
7392    
7393                    return null;
7394            }
7395    
7396            /**
7397             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and userId = &#63;.
7398             *
7399             * @param id the primary key of the current journal article
7400             * @param groupId the group ID
7401             * @param userId the user ID
7402             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7403             * @return the previous, current, and next journal article
7404             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
7405             * @throws SystemException if a system exception occurred
7406             */
7407            @Override
7408            public JournalArticle[] findByG_U_PrevAndNext(long id, long groupId,
7409                    long userId, OrderByComparator orderByComparator)
7410                    throws NoSuchArticleException, SystemException {
7411                    JournalArticle journalArticle = findByPrimaryKey(id);
7412    
7413                    Session session = null;
7414    
7415                    try {
7416                            session = openSession();
7417    
7418                            JournalArticle[] array = new JournalArticleImpl[3];
7419    
7420                            array[0] = getByG_U_PrevAndNext(session, journalArticle, groupId,
7421                                            userId, orderByComparator, true);
7422    
7423                            array[1] = journalArticle;
7424    
7425                            array[2] = getByG_U_PrevAndNext(session, journalArticle, groupId,
7426                                            userId, orderByComparator, false);
7427    
7428                            return array;
7429                    }
7430                    catch (Exception e) {
7431                            throw processException(e);
7432                    }
7433                    finally {
7434                            closeSession(session);
7435                    }
7436            }
7437    
7438            protected JournalArticle getByG_U_PrevAndNext(Session session,
7439                    JournalArticle journalArticle, long groupId, long userId,
7440                    OrderByComparator orderByComparator, boolean previous) {
7441                    StringBundler query = null;
7442    
7443                    if (orderByComparator != null) {
7444                            query = new StringBundler(6 +
7445                                            (orderByComparator.getOrderByFields().length * 6));
7446                    }
7447                    else {
7448                            query = new StringBundler(3);
7449                    }
7450    
7451                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7452    
7453                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7454    
7455                    query.append(_FINDER_COLUMN_G_U_USERID_2);
7456    
7457                    if (orderByComparator != null) {
7458                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7459    
7460                            if (orderByConditionFields.length > 0) {
7461                                    query.append(WHERE_AND);
7462                            }
7463    
7464                            for (int i = 0; i < orderByConditionFields.length; i++) {
7465                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7466                                    query.append(orderByConditionFields[i]);
7467    
7468                                    if ((i + 1) < orderByConditionFields.length) {
7469                                            if (orderByComparator.isAscending() ^ previous) {
7470                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7471                                            }
7472                                            else {
7473                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7474                                            }
7475                                    }
7476                                    else {
7477                                            if (orderByComparator.isAscending() ^ previous) {
7478                                                    query.append(WHERE_GREATER_THAN);
7479                                            }
7480                                            else {
7481                                                    query.append(WHERE_LESSER_THAN);
7482                                            }
7483                                    }
7484                            }
7485    
7486                            query.append(ORDER_BY_CLAUSE);
7487    
7488                            String[] orderByFields = orderByComparator.getOrderByFields();
7489    
7490                            for (int i = 0; i < orderByFields.length; i++) {
7491                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7492                                    query.append(orderByFields[i]);
7493    
7494                                    if ((i + 1) < orderByFields.length) {
7495                                            if (orderByComparator.isAscending() ^ previous) {
7496                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7497                                            }
7498                                            else {
7499                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7500                                            }
7501                                    }
7502                                    else {
7503                                            if (orderByComparator.isAscending() ^ previous) {
7504                                                    query.append(ORDER_BY_ASC);
7505                                            }
7506                                            else {
7507                                                    query.append(ORDER_BY_DESC);
7508                                            }
7509                                    }
7510                            }
7511                    }
7512                    else {
7513                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7514                    }
7515    
7516                    String sql = query.toString();
7517    
7518                    Query q = session.createQuery(sql);
7519    
7520                    q.setFirstResult(0);
7521                    q.setMaxResults(2);
7522    
7523                    QueryPos qPos = QueryPos.getInstance(q);
7524    
7525                    qPos.add(groupId);
7526    
7527                    qPos.add(userId);
7528    
7529                    if (orderByComparator != null) {
7530                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7531    
7532                            for (Object value : values) {
7533                                    qPos.add(value);
7534                            }
7535                    }
7536    
7537                    List<JournalArticle> list = q.list();
7538    
7539                    if (list.size() == 2) {
7540                            return list.get(1);
7541                    }
7542                    else {
7543                            return null;
7544                    }
7545            }
7546    
7547            /**
7548             * Returns all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
7549             *
7550             * @param groupId the group ID
7551             * @param userId the user ID
7552             * @return the matching journal articles that the user has permission to view
7553             * @throws SystemException if a system exception occurred
7554             */
7555            @Override
7556            public List<JournalArticle> filterFindByG_U(long groupId, long userId)
7557                    throws SystemException {
7558                    return filterFindByG_U(groupId, userId, QueryUtil.ALL_POS,
7559                            QueryUtil.ALL_POS, null);
7560            }
7561    
7562            /**
7563             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
7564             *
7565             * <p>
7566             * 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.
7567             * </p>
7568             *
7569             * @param groupId the group ID
7570             * @param userId the user ID
7571             * @param start the lower bound of the range of journal articles
7572             * @param end the upper bound of the range of journal articles (not inclusive)
7573             * @return the range of matching journal articles that the user has permission to view
7574             * @throws SystemException if a system exception occurred
7575             */
7576            @Override
7577            public List<JournalArticle> filterFindByG_U(long groupId, long userId,
7578                    int start, int end) throws SystemException {
7579                    return filterFindByG_U(groupId, userId, start, end, null);
7580            }
7581    
7582            /**
7583             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and userId = &#63;.
7584             *
7585             * <p>
7586             * 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.
7587             * </p>
7588             *
7589             * @param groupId the group ID
7590             * @param userId the user ID
7591             * @param start the lower bound of the range of journal articles
7592             * @param end the upper bound of the range of journal articles (not inclusive)
7593             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7594             * @return the ordered range of matching journal articles that the user has permission to view
7595             * @throws SystemException if a system exception occurred
7596             */
7597            @Override
7598            public List<JournalArticle> filterFindByG_U(long groupId, long userId,
7599                    int start, int end, OrderByComparator orderByComparator)
7600                    throws SystemException {
7601                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7602                            return findByG_U(groupId, userId, start, end, orderByComparator);
7603                    }
7604    
7605                    StringBundler query = null;
7606    
7607                    if (orderByComparator != null) {
7608                            query = new StringBundler(4 +
7609                                            (orderByComparator.getOrderByFields().length * 3));
7610                    }
7611                    else {
7612                            query = new StringBundler(4);
7613                    }
7614    
7615                    if (getDB().isSupportsInlineDistinct()) {
7616                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7617                    }
7618                    else {
7619                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7620                    }
7621    
7622                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7623    
7624                    query.append(_FINDER_COLUMN_G_U_USERID_2);
7625    
7626                    if (!getDB().isSupportsInlineDistinct()) {
7627                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7628                    }
7629    
7630                    if (orderByComparator != null) {
7631                            if (getDB().isSupportsInlineDistinct()) {
7632                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7633                                            orderByComparator, true);
7634                            }
7635                            else {
7636                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7637                                            orderByComparator, true);
7638                            }
7639                    }
7640                    else {
7641                            if (getDB().isSupportsInlineDistinct()) {
7642                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7643                            }
7644                            else {
7645                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7646                            }
7647                    }
7648    
7649                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7650                                    JournalArticle.class.getName(),
7651                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7652    
7653                    Session session = null;
7654    
7655                    try {
7656                            session = openSession();
7657    
7658                            SQLQuery q = session.createSQLQuery(sql);
7659    
7660                            if (getDB().isSupportsInlineDistinct()) {
7661                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7662                            }
7663                            else {
7664                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7665                            }
7666    
7667                            QueryPos qPos = QueryPos.getInstance(q);
7668    
7669                            qPos.add(groupId);
7670    
7671                            qPos.add(userId);
7672    
7673                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
7674                                    end);
7675                    }
7676                    catch (Exception e) {
7677                            throw processException(e);
7678                    }
7679                    finally {
7680                            closeSession(session);
7681                    }
7682            }
7683    
7684            /**
7685             * 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;.
7686             *
7687             * @param id the primary key of the current journal article
7688             * @param groupId the group ID
7689             * @param userId the user ID
7690             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7691             * @return the previous, current, and next journal article
7692             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
7693             * @throws SystemException if a system exception occurred
7694             */
7695            @Override
7696            public JournalArticle[] filterFindByG_U_PrevAndNext(long id, long groupId,
7697                    long userId, OrderByComparator orderByComparator)
7698                    throws NoSuchArticleException, SystemException {
7699                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7700                            return findByG_U_PrevAndNext(id, groupId, userId, orderByComparator);
7701                    }
7702    
7703                    JournalArticle journalArticle = findByPrimaryKey(id);
7704    
7705                    Session session = null;
7706    
7707                    try {
7708                            session = openSession();
7709    
7710                            JournalArticle[] array = new JournalArticleImpl[3];
7711    
7712                            array[0] = filterGetByG_U_PrevAndNext(session, journalArticle,
7713                                            groupId, userId, orderByComparator, true);
7714    
7715                            array[1] = journalArticle;
7716    
7717                            array[2] = filterGetByG_U_PrevAndNext(session, journalArticle,
7718                                            groupId, userId, orderByComparator, false);
7719    
7720                            return array;
7721                    }
7722                    catch (Exception e) {
7723                            throw processException(e);
7724                    }
7725                    finally {
7726                            closeSession(session);
7727                    }
7728            }
7729    
7730            protected JournalArticle filterGetByG_U_PrevAndNext(Session session,
7731                    JournalArticle journalArticle, long groupId, long userId,
7732                    OrderByComparator orderByComparator, boolean previous) {
7733                    StringBundler query = null;
7734    
7735                    if (orderByComparator != null) {
7736                            query = new StringBundler(6 +
7737                                            (orderByComparator.getOrderByFields().length * 6));
7738                    }
7739                    else {
7740                            query = new StringBundler(3);
7741                    }
7742    
7743                    if (getDB().isSupportsInlineDistinct()) {
7744                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7745                    }
7746                    else {
7747                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7748                    }
7749    
7750                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7751    
7752                    query.append(_FINDER_COLUMN_G_U_USERID_2);
7753    
7754                    if (!getDB().isSupportsInlineDistinct()) {
7755                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7756                    }
7757    
7758                    if (orderByComparator != null) {
7759                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7760    
7761                            if (orderByConditionFields.length > 0) {
7762                                    query.append(WHERE_AND);
7763                            }
7764    
7765                            for (int i = 0; i < orderByConditionFields.length; i++) {
7766                                    if (getDB().isSupportsInlineDistinct()) {
7767                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7768                                    }
7769                                    else {
7770                                            query.append(_ORDER_BY_ENTITY_TABLE);
7771                                    }
7772    
7773                                    query.append(orderByConditionFields[i]);
7774    
7775                                    if ((i + 1) < orderByConditionFields.length) {
7776                                            if (orderByComparator.isAscending() ^ previous) {
7777                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7778                                            }
7779                                            else {
7780                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7781                                            }
7782                                    }
7783                                    else {
7784                                            if (orderByComparator.isAscending() ^ previous) {
7785                                                    query.append(WHERE_GREATER_THAN);
7786                                            }
7787                                            else {
7788                                                    query.append(WHERE_LESSER_THAN);
7789                                            }
7790                                    }
7791                            }
7792    
7793                            query.append(ORDER_BY_CLAUSE);
7794    
7795                            String[] orderByFields = orderByComparator.getOrderByFields();
7796    
7797                            for (int i = 0; i < orderByFields.length; i++) {
7798                                    if (getDB().isSupportsInlineDistinct()) {
7799                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7800                                    }
7801                                    else {
7802                                            query.append(_ORDER_BY_ENTITY_TABLE);
7803                                    }
7804    
7805                                    query.append(orderByFields[i]);
7806    
7807                                    if ((i + 1) < orderByFields.length) {
7808                                            if (orderByComparator.isAscending() ^ previous) {
7809                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7810                                            }
7811                                            else {
7812                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7813                                            }
7814                                    }
7815                                    else {
7816                                            if (orderByComparator.isAscending() ^ previous) {
7817                                                    query.append(ORDER_BY_ASC);
7818                                            }
7819                                            else {
7820                                                    query.append(ORDER_BY_DESC);
7821                                            }
7822                                    }
7823                            }
7824                    }
7825                    else {
7826                            if (getDB().isSupportsInlineDistinct()) {
7827                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7828                            }
7829                            else {
7830                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7831                            }
7832                    }
7833    
7834                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7835                                    JournalArticle.class.getName(),
7836                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7837    
7838                    SQLQuery q = session.createSQLQuery(sql);
7839    
7840                    q.setFirstResult(0);
7841                    q.setMaxResults(2);
7842    
7843                    if (getDB().isSupportsInlineDistinct()) {
7844                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7845                    }
7846                    else {
7847                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7848                    }
7849    
7850                    QueryPos qPos = QueryPos.getInstance(q);
7851    
7852                    qPos.add(groupId);
7853    
7854                    qPos.add(userId);
7855    
7856                    if (orderByComparator != null) {
7857                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7858    
7859                            for (Object value : values) {
7860                                    qPos.add(value);
7861                            }
7862                    }
7863    
7864                    List<JournalArticle> list = q.list();
7865    
7866                    if (list.size() == 2) {
7867                            return list.get(1);
7868                    }
7869                    else {
7870                            return null;
7871                    }
7872            }
7873    
7874            /**
7875             * Removes all the journal articles where groupId = &#63; and userId = &#63; from the database.
7876             *
7877             * @param groupId the group ID
7878             * @param userId the user ID
7879             * @throws SystemException if a system exception occurred
7880             */
7881            @Override
7882            public void removeByG_U(long groupId, long userId)
7883                    throws SystemException {
7884                    for (JournalArticle journalArticle : findByG_U(groupId, userId,
7885                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7886                            remove(journalArticle);
7887                    }
7888            }
7889    
7890            /**
7891             * Returns the number of journal articles where groupId = &#63; and userId = &#63;.
7892             *
7893             * @param groupId the group ID
7894             * @param userId the user ID
7895             * @return the number of matching journal articles
7896             * @throws SystemException if a system exception occurred
7897             */
7898            @Override
7899            public int countByG_U(long groupId, long userId) throws SystemException {
7900                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U;
7901    
7902                    Object[] finderArgs = new Object[] { groupId, userId };
7903    
7904                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7905                                    this);
7906    
7907                    if (count == null) {
7908                            StringBundler query = new StringBundler(3);
7909    
7910                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
7911    
7912                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7913    
7914                            query.append(_FINDER_COLUMN_G_U_USERID_2);
7915    
7916                            String sql = query.toString();
7917    
7918                            Session session = null;
7919    
7920                            try {
7921                                    session = openSession();
7922    
7923                                    Query q = session.createQuery(sql);
7924    
7925                                    QueryPos qPos = QueryPos.getInstance(q);
7926    
7927                                    qPos.add(groupId);
7928    
7929                                    qPos.add(userId);
7930    
7931                                    count = (Long)q.uniqueResult();
7932    
7933                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
7934                            }
7935                            catch (Exception e) {
7936                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7937    
7938                                    throw processException(e);
7939                            }
7940                            finally {
7941                                    closeSession(session);
7942                            }
7943                    }
7944    
7945                    return count.intValue();
7946            }
7947    
7948            /**
7949             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
7950             *
7951             * @param groupId the group ID
7952             * @param userId the user ID
7953             * @return the number of matching journal articles that the user has permission to view
7954             * @throws SystemException if a system exception occurred
7955             */
7956            @Override
7957            public int filterCountByG_U(long groupId, long userId)
7958                    throws SystemException {
7959                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7960                            return countByG_U(groupId, userId);
7961                    }
7962    
7963                    StringBundler query = new StringBundler(3);
7964    
7965                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
7966    
7967                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7968    
7969                    query.append(_FINDER_COLUMN_G_U_USERID_2);
7970    
7971                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7972                                    JournalArticle.class.getName(),
7973                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7974    
7975                    Session session = null;
7976    
7977                    try {
7978                            session = openSession();
7979    
7980                            SQLQuery q = session.createSQLQuery(sql);
7981    
7982                            q.addScalar(COUNT_COLUMN_NAME,
7983                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
7984    
7985                            QueryPos qPos = QueryPos.getInstance(q);
7986    
7987                            qPos.add(groupId);
7988    
7989                            qPos.add(userId);
7990    
7991                            Long count = (Long)q.uniqueResult();
7992    
7993                            return count.intValue();
7994                    }
7995                    catch (Exception e) {
7996                            throw processException(e);
7997                    }
7998                    finally {
7999                            closeSession(session);
8000                    }
8001            }
8002    
8003            private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "journalArticle.groupId = ? AND ";
8004            private static final String _FINDER_COLUMN_G_U_USERID_2 = "journalArticle.userId = ?";
8005            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
8006                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
8007                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
8008                            "findByG_F",
8009                            new String[] {
8010                                    Long.class.getName(), Long.class.getName(),
8011                                    
8012                            Integer.class.getName(), Integer.class.getName(),
8013                                    OrderByComparator.class.getName()
8014                            });
8015            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
8016                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
8017                            JournalArticleImpl.class,
8018                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F",
8019                            new String[] { Long.class.getName(), Long.class.getName() },
8020                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
8021                            JournalArticleModelImpl.FOLDERID_COLUMN_BITMASK |
8022                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
8023                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
8024            public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
8025                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
8026                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F",
8027                            new String[] { Long.class.getName(), Long.class.getName() });
8028            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
8029                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
8030                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F",
8031                            new String[] { Long.class.getName(), Long.class.getName() });
8032    
8033            /**
8034             * Returns all the journal articles where groupId = &#63; and folderId = &#63;.
8035             *
8036             * @param groupId the group ID
8037             * @param folderId the folder ID
8038             * @return the matching journal articles
8039             * @throws SystemException if a system exception occurred
8040             */
8041            @Override
8042            public List<JournalArticle> findByG_F(long groupId, long folderId)
8043                    throws SystemException {
8044                    return findByG_F(groupId, folderId, QueryUtil.ALL_POS,
8045                            QueryUtil.ALL_POS, null);
8046            }
8047    
8048            /**
8049             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63;.
8050             *
8051             * <p>
8052             * 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.
8053             * </p>
8054             *
8055             * @param groupId the group ID
8056             * @param folderId the folder ID
8057             * @param start the lower bound of the range of journal articles
8058             * @param end the upper bound of the range of journal articles (not inclusive)
8059             * @return the range of matching journal articles
8060             * @throws SystemException if a system exception occurred
8061             */
8062            @Override
8063            public List<JournalArticle> findByG_F(long groupId, long folderId,
8064                    int start, int end) throws SystemException {
8065                    return findByG_F(groupId, folderId, start, end, null);
8066            }
8067    
8068            /**
8069             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63;.
8070             *
8071             * <p>
8072             * 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.
8073             * </p>
8074             *
8075             * @param groupId the group ID
8076             * @param folderId the folder ID
8077             * @param start the lower bound of the range of journal articles
8078             * @param end the upper bound of the range of journal articles (not inclusive)
8079             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8080             * @return the ordered range of matching journal articles
8081             * @throws SystemException if a system exception occurred
8082             */
8083            @Override
8084            public List<JournalArticle> findByG_F(long groupId, long folderId,
8085                    int start, int end, OrderByComparator orderByComparator)
8086                    throws SystemException {
8087                    boolean pagination = true;
8088                    FinderPath finderPath = null;
8089                    Object[] finderArgs = null;
8090    
8091                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8092                                    (orderByComparator == null)) {
8093                            pagination = false;
8094                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F;
8095                            finderArgs = new Object[] { groupId, folderId };
8096                    }
8097                    else {
8098                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F;
8099                            finderArgs = new Object[] {
8100                                            groupId, folderId,
8101                                            
8102                                            start, end, orderByComparator
8103                                    };
8104                    }
8105    
8106                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
8107                                    finderArgs, this);
8108    
8109                    if ((list != null) && !list.isEmpty()) {
8110                            for (JournalArticle journalArticle : list) {
8111                                    if ((groupId != journalArticle.getGroupId()) ||
8112                                                    (folderId != journalArticle.getFolderId())) {
8113                                            list = null;
8114    
8115                                            break;
8116                                    }
8117                            }
8118                    }
8119    
8120                    if (list == null) {
8121                            StringBundler query = null;
8122    
8123                            if (orderByComparator != null) {
8124                                    query = new StringBundler(4 +
8125                                                    (orderByComparator.getOrderByFields().length * 3));
8126                            }
8127                            else {
8128                                    query = new StringBundler(4);
8129                            }
8130    
8131                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8132    
8133                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8134    
8135                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
8136    
8137                            if (orderByComparator != null) {
8138                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8139                                            orderByComparator);
8140                            }
8141                            else
8142                             if (pagination) {
8143                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8144                            }
8145    
8146                            String sql = query.toString();
8147    
8148                            Session session = null;
8149    
8150                            try {
8151                                    session = openSession();
8152    
8153                                    Query q = session.createQuery(sql);
8154    
8155                                    QueryPos qPos = QueryPos.getInstance(q);
8156    
8157                                    qPos.add(groupId);
8158    
8159                                    qPos.add(folderId);
8160    
8161                                    if (!pagination) {
8162                                            list = (List<JournalArticle>)QueryUtil.list(q,
8163                                                            getDialect(), start, end, false);
8164    
8165                                            Collections.sort(list);
8166    
8167                                            list = new UnmodifiableList<JournalArticle>(list);
8168                                    }
8169                                    else {
8170                                            list = (List<JournalArticle>)QueryUtil.list(q,
8171                                                            getDialect(), start, end);
8172                                    }
8173    
8174                                    cacheResult(list);
8175    
8176                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
8177                            }
8178                            catch (Exception e) {
8179                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8180    
8181                                    throw processException(e);
8182                            }
8183                            finally {
8184                                    closeSession(session);
8185                            }
8186                    }
8187    
8188                    return list;
8189            }
8190    
8191            /**
8192             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63;.
8193             *
8194             * @param groupId the group ID
8195             * @param folderId the folder ID
8196             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8197             * @return the first matching journal article
8198             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
8199             * @throws SystemException if a system exception occurred
8200             */
8201            @Override
8202            public JournalArticle findByG_F_First(long groupId, long folderId,
8203                    OrderByComparator orderByComparator)
8204                    throws NoSuchArticleException, SystemException {
8205                    JournalArticle journalArticle = fetchByG_F_First(groupId, folderId,
8206                                    orderByComparator);
8207    
8208                    if (journalArticle != null) {
8209                            return journalArticle;
8210                    }
8211    
8212                    StringBundler msg = new StringBundler(6);
8213    
8214                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8215    
8216                    msg.append("groupId=");
8217                    msg.append(groupId);
8218    
8219                    msg.append(", folderId=");
8220                    msg.append(folderId);
8221    
8222                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8223    
8224                    throw new NoSuchArticleException(msg.toString());
8225            }
8226    
8227            /**
8228             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63;.
8229             *
8230             * @param groupId the group ID
8231             * @param folderId the folder ID
8232             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8233             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
8234             * @throws SystemException if a system exception occurred
8235             */
8236            @Override
8237            public JournalArticle fetchByG_F_First(long groupId, long folderId,
8238                    OrderByComparator orderByComparator) throws SystemException {
8239                    List<JournalArticle> list = findByG_F(groupId, folderId, 0, 1,
8240                                    orderByComparator);
8241    
8242                    if (!list.isEmpty()) {
8243                            return list.get(0);
8244                    }
8245    
8246                    return null;
8247            }
8248    
8249            /**
8250             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63;.
8251             *
8252             * @param groupId the group ID
8253             * @param folderId the folder ID
8254             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8255             * @return the last matching journal article
8256             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
8257             * @throws SystemException if a system exception occurred
8258             */
8259            @Override
8260            public JournalArticle findByG_F_Last(long groupId, long folderId,
8261                    OrderByComparator orderByComparator)
8262                    throws NoSuchArticleException, SystemException {
8263                    JournalArticle journalArticle = fetchByG_F_Last(groupId, folderId,
8264                                    orderByComparator);
8265    
8266                    if (journalArticle != null) {
8267                            return journalArticle;
8268                    }
8269    
8270                    StringBundler msg = new StringBundler(6);
8271    
8272                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8273    
8274                    msg.append("groupId=");
8275                    msg.append(groupId);
8276    
8277                    msg.append(", folderId=");
8278                    msg.append(folderId);
8279    
8280                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8281    
8282                    throw new NoSuchArticleException(msg.toString());
8283            }
8284    
8285            /**
8286             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63;.
8287             *
8288             * @param groupId the group ID
8289             * @param folderId the folder ID
8290             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8291             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
8292             * @throws SystemException if a system exception occurred
8293             */
8294            @Override
8295            public JournalArticle fetchByG_F_Last(long groupId, long folderId,
8296                    OrderByComparator orderByComparator) throws SystemException {
8297                    int count = countByG_F(groupId, folderId);
8298    
8299                    if (count == 0) {
8300                            return null;
8301                    }
8302    
8303                    List<JournalArticle> list = findByG_F(groupId, folderId, count - 1,
8304                                    count, orderByComparator);
8305    
8306                    if (!list.isEmpty()) {
8307                            return list.get(0);
8308                    }
8309    
8310                    return null;
8311            }
8312    
8313            /**
8314             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and folderId = &#63;.
8315             *
8316             * @param id the primary key of the current journal article
8317             * @param groupId the group ID
8318             * @param folderId the folder ID
8319             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8320             * @return the previous, current, and next journal article
8321             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
8322             * @throws SystemException if a system exception occurred
8323             */
8324            @Override
8325            public JournalArticle[] findByG_F_PrevAndNext(long id, long groupId,
8326                    long folderId, OrderByComparator orderByComparator)
8327                    throws NoSuchArticleException, SystemException {
8328                    JournalArticle journalArticle = findByPrimaryKey(id);
8329    
8330                    Session session = null;
8331    
8332                    try {
8333                            session = openSession();
8334    
8335                            JournalArticle[] array = new JournalArticleImpl[3];
8336    
8337                            array[0] = getByG_F_PrevAndNext(session, journalArticle, groupId,
8338                                            folderId, orderByComparator, true);
8339    
8340                            array[1] = journalArticle;
8341    
8342                            array[2] = getByG_F_PrevAndNext(session, journalArticle, groupId,
8343                                            folderId, orderByComparator, false);
8344    
8345                            return array;
8346                    }
8347                    catch (Exception e) {
8348                            throw processException(e);
8349                    }
8350                    finally {
8351                            closeSession(session);
8352                    }
8353            }
8354    
8355            protected JournalArticle getByG_F_PrevAndNext(Session session,
8356                    JournalArticle journalArticle, long groupId, long folderId,
8357                    OrderByComparator orderByComparator, boolean previous) {
8358                    StringBundler query = null;
8359    
8360                    if (orderByComparator != null) {
8361                            query = new StringBundler(6 +
8362                                            (orderByComparator.getOrderByFields().length * 6));
8363                    }
8364                    else {
8365                            query = new StringBundler(3);
8366                    }
8367    
8368                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8369    
8370                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8371    
8372                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
8373    
8374                    if (orderByComparator != null) {
8375                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8376    
8377                            if (orderByConditionFields.length > 0) {
8378                                    query.append(WHERE_AND);
8379                            }
8380    
8381                            for (int i = 0; i < orderByConditionFields.length; i++) {
8382                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8383                                    query.append(orderByConditionFields[i]);
8384    
8385                                    if ((i + 1) < orderByConditionFields.length) {
8386                                            if (orderByComparator.isAscending() ^ previous) {
8387                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8388                                            }
8389                                            else {
8390                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8391                                            }
8392                                    }
8393                                    else {
8394                                            if (orderByComparator.isAscending() ^ previous) {
8395                                                    query.append(WHERE_GREATER_THAN);
8396                                            }
8397                                            else {
8398                                                    query.append(WHERE_LESSER_THAN);
8399                                            }
8400                                    }
8401                            }
8402    
8403                            query.append(ORDER_BY_CLAUSE);
8404    
8405                            String[] orderByFields = orderByComparator.getOrderByFields();
8406    
8407                            for (int i = 0; i < orderByFields.length; i++) {
8408                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8409                                    query.append(orderByFields[i]);
8410    
8411                                    if ((i + 1) < orderByFields.length) {
8412                                            if (orderByComparator.isAscending() ^ previous) {
8413                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8414                                            }
8415                                            else {
8416                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8417                                            }
8418                                    }
8419                                    else {
8420                                            if (orderByComparator.isAscending() ^ previous) {
8421                                                    query.append(ORDER_BY_ASC);
8422                                            }
8423                                            else {
8424                                                    query.append(ORDER_BY_DESC);
8425                                            }
8426                                    }
8427                            }
8428                    }
8429                    else {
8430                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8431                    }
8432    
8433                    String sql = query.toString();
8434    
8435                    Query q = session.createQuery(sql);
8436    
8437                    q.setFirstResult(0);
8438                    q.setMaxResults(2);
8439    
8440                    QueryPos qPos = QueryPos.getInstance(q);
8441    
8442                    qPos.add(groupId);
8443    
8444                    qPos.add(folderId);
8445    
8446                    if (orderByComparator != null) {
8447                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8448    
8449                            for (Object value : values) {
8450                                    qPos.add(value);
8451                            }
8452                    }
8453    
8454                    List<JournalArticle> list = q.list();
8455    
8456                    if (list.size() == 2) {
8457                            return list.get(1);
8458                    }
8459                    else {
8460                            return null;
8461                    }
8462            }
8463    
8464            /**
8465             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
8466             *
8467             * @param groupId the group ID
8468             * @param folderId the folder ID
8469             * @return the matching journal articles that the user has permission to view
8470             * @throws SystemException if a system exception occurred
8471             */
8472            @Override
8473            public List<JournalArticle> filterFindByG_F(long groupId, long folderId)
8474                    throws SystemException {
8475                    return filterFindByG_F(groupId, folderId, QueryUtil.ALL_POS,
8476                            QueryUtil.ALL_POS, null);
8477            }
8478    
8479            /**
8480             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
8481             *
8482             * <p>
8483             * 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.
8484             * </p>
8485             *
8486             * @param groupId the group ID
8487             * @param folderId the folder ID
8488             * @param start the lower bound of the range of journal articles
8489             * @param end the upper bound of the range of journal articles (not inclusive)
8490             * @return the range of matching journal articles that the user has permission to view
8491             * @throws SystemException if a system exception occurred
8492             */
8493            @Override
8494            public List<JournalArticle> filterFindByG_F(long groupId, long folderId,
8495                    int start, int end) throws SystemException {
8496                    return filterFindByG_F(groupId, folderId, start, end, null);
8497            }
8498    
8499            /**
8500             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and folderId = &#63;.
8501             *
8502             * <p>
8503             * 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.
8504             * </p>
8505             *
8506             * @param groupId the group ID
8507             * @param folderId the folder ID
8508             * @param start the lower bound of the range of journal articles
8509             * @param end the upper bound of the range of journal articles (not inclusive)
8510             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8511             * @return the ordered range of matching journal articles that the user has permission to view
8512             * @throws SystemException if a system exception occurred
8513             */
8514            @Override
8515            public List<JournalArticle> filterFindByG_F(long groupId, long folderId,
8516                    int start, int end, OrderByComparator orderByComparator)
8517                    throws SystemException {
8518                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8519                            return findByG_F(groupId, folderId, start, end, orderByComparator);
8520                    }
8521    
8522                    StringBundler query = null;
8523    
8524                    if (orderByComparator != null) {
8525                            query = new StringBundler(4 +
8526                                            (orderByComparator.getOrderByFields().length * 3));
8527                    }
8528                    else {
8529                            query = new StringBundler(4);
8530                    }
8531    
8532                    if (getDB().isSupportsInlineDistinct()) {
8533                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8534                    }
8535                    else {
8536                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8537                    }
8538    
8539                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8540    
8541                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
8542    
8543                    if (!getDB().isSupportsInlineDistinct()) {
8544                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8545                    }
8546    
8547                    if (orderByComparator != null) {
8548                            if (getDB().isSupportsInlineDistinct()) {
8549                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8550                                            orderByComparator, true);
8551                            }
8552                            else {
8553                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8554                                            orderByComparator, true);
8555                            }
8556                    }
8557                    else {
8558                            if (getDB().isSupportsInlineDistinct()) {
8559                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8560                            }
8561                            else {
8562                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8563                            }
8564                    }
8565    
8566                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8567                                    JournalArticle.class.getName(),
8568                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8569    
8570                    Session session = null;
8571    
8572                    try {
8573                            session = openSession();
8574    
8575                            SQLQuery q = session.createSQLQuery(sql);
8576    
8577                            if (getDB().isSupportsInlineDistinct()) {
8578                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8579                            }
8580                            else {
8581                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8582                            }
8583    
8584                            QueryPos qPos = QueryPos.getInstance(q);
8585    
8586                            qPos.add(groupId);
8587    
8588                            qPos.add(folderId);
8589    
8590                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
8591                                    end);
8592                    }
8593                    catch (Exception e) {
8594                            throw processException(e);
8595                    }
8596                    finally {
8597                            closeSession(session);
8598                    }
8599            }
8600    
8601            /**
8602             * 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;.
8603             *
8604             * @param id the primary key of the current journal article
8605             * @param groupId the group ID
8606             * @param folderId the folder ID
8607             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8608             * @return the previous, current, and next journal article
8609             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
8610             * @throws SystemException if a system exception occurred
8611             */
8612            @Override
8613            public JournalArticle[] filterFindByG_F_PrevAndNext(long id, long groupId,
8614                    long folderId, OrderByComparator orderByComparator)
8615                    throws NoSuchArticleException, SystemException {
8616                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8617                            return findByG_F_PrevAndNext(id, groupId, folderId,
8618                                    orderByComparator);
8619                    }
8620    
8621                    JournalArticle journalArticle = findByPrimaryKey(id);
8622    
8623                    Session session = null;
8624    
8625                    try {
8626                            session = openSession();
8627    
8628                            JournalArticle[] array = new JournalArticleImpl[3];
8629    
8630                            array[0] = filterGetByG_F_PrevAndNext(session, journalArticle,
8631                                            groupId, folderId, orderByComparator, true);
8632    
8633                            array[1] = journalArticle;
8634    
8635                            array[2] = filterGetByG_F_PrevAndNext(session, journalArticle,
8636                                            groupId, folderId, orderByComparator, false);
8637    
8638                            return array;
8639                    }
8640                    catch (Exception e) {
8641                            throw processException(e);
8642                    }
8643                    finally {
8644                            closeSession(session);
8645                    }
8646            }
8647    
8648            protected JournalArticle filterGetByG_F_PrevAndNext(Session session,
8649                    JournalArticle journalArticle, long groupId, long folderId,
8650                    OrderByComparator orderByComparator, boolean previous) {
8651                    StringBundler query = null;
8652    
8653                    if (orderByComparator != null) {
8654                            query = new StringBundler(6 +
8655                                            (orderByComparator.getOrderByFields().length * 6));
8656                    }
8657                    else {
8658                            query = new StringBundler(3);
8659                    }
8660    
8661                    if (getDB().isSupportsInlineDistinct()) {
8662                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8663                    }
8664                    else {
8665                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8666                    }
8667    
8668                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8669    
8670                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
8671    
8672                    if (!getDB().isSupportsInlineDistinct()) {
8673                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8674                    }
8675    
8676                    if (orderByComparator != null) {
8677                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8678    
8679                            if (orderByConditionFields.length > 0) {
8680                                    query.append(WHERE_AND);
8681                            }
8682    
8683                            for (int i = 0; i < orderByConditionFields.length; i++) {
8684                                    if (getDB().isSupportsInlineDistinct()) {
8685                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8686                                    }
8687                                    else {
8688                                            query.append(_ORDER_BY_ENTITY_TABLE);
8689                                    }
8690    
8691                                    query.append(orderByConditionFields[i]);
8692    
8693                                    if ((i + 1) < orderByConditionFields.length) {
8694                                            if (orderByComparator.isAscending() ^ previous) {
8695                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8696                                            }
8697                                            else {
8698                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8699                                            }
8700                                    }
8701                                    else {
8702                                            if (orderByComparator.isAscending() ^ previous) {
8703                                                    query.append(WHERE_GREATER_THAN);
8704                                            }
8705                                            else {
8706                                                    query.append(WHERE_LESSER_THAN);
8707                                            }
8708                                    }
8709                            }
8710    
8711                            query.append(ORDER_BY_CLAUSE);
8712    
8713                            String[] orderByFields = orderByComparator.getOrderByFields();
8714    
8715                            for (int i = 0; i < orderByFields.length; i++) {
8716                                    if (getDB().isSupportsInlineDistinct()) {
8717                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8718                                    }
8719                                    else {
8720                                            query.append(_ORDER_BY_ENTITY_TABLE);
8721                                    }
8722    
8723                                    query.append(orderByFields[i]);
8724    
8725                                    if ((i + 1) < orderByFields.length) {
8726                                            if (orderByComparator.isAscending() ^ previous) {
8727                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8728                                            }
8729                                            else {
8730                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8731                                            }
8732                                    }
8733                                    else {
8734                                            if (orderByComparator.isAscending() ^ previous) {
8735                                                    query.append(ORDER_BY_ASC);
8736                                            }
8737                                            else {
8738                                                    query.append(ORDER_BY_DESC);
8739                                            }
8740                                    }
8741                            }
8742                    }
8743                    else {
8744                            if (getDB().isSupportsInlineDistinct()) {
8745                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8746                            }
8747                            else {
8748                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8749                            }
8750                    }
8751    
8752                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8753                                    JournalArticle.class.getName(),
8754                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8755    
8756                    SQLQuery q = session.createSQLQuery(sql);
8757    
8758                    q.setFirstResult(0);
8759                    q.setMaxResults(2);
8760    
8761                    if (getDB().isSupportsInlineDistinct()) {
8762                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8763                    }
8764                    else {
8765                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8766                    }
8767    
8768                    QueryPos qPos = QueryPos.getInstance(q);
8769    
8770                    qPos.add(groupId);
8771    
8772                    qPos.add(folderId);
8773    
8774                    if (orderByComparator != null) {
8775                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8776    
8777                            for (Object value : values) {
8778                                    qPos.add(value);
8779                            }
8780                    }
8781    
8782                    List<JournalArticle> list = q.list();
8783    
8784                    if (list.size() == 2) {
8785                            return list.get(1);
8786                    }
8787                    else {
8788                            return null;
8789                    }
8790            }
8791    
8792            /**
8793             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
8794             *
8795             * @param groupId the group ID
8796             * @param folderIds the folder IDs
8797             * @return the matching journal articles that the user has permission to view
8798             * @throws SystemException if a system exception occurred
8799             */
8800            @Override
8801            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds)
8802                    throws SystemException {
8803                    return filterFindByG_F(groupId, folderIds, QueryUtil.ALL_POS,
8804                            QueryUtil.ALL_POS, null);
8805            }
8806    
8807            /**
8808             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
8809             *
8810             * <p>
8811             * 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.
8812             * </p>
8813             *
8814             * @param groupId the group ID
8815             * @param folderIds the folder IDs
8816             * @param start the lower bound of the range of journal articles
8817             * @param end the upper bound of the range of journal articles (not inclusive)
8818             * @return the range of matching journal articles that the user has permission to view
8819             * @throws SystemException if a system exception occurred
8820             */
8821            @Override
8822            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds,
8823                    int start, int end) throws SystemException {
8824                    return filterFindByG_F(groupId, folderIds, start, end, null);
8825            }
8826    
8827            /**
8828             * Returns an ordered range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
8829             *
8830             * <p>
8831             * 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.
8832             * </p>
8833             *
8834             * @param groupId the group ID
8835             * @param folderIds the folder IDs
8836             * @param start the lower bound of the range of journal articles
8837             * @param end the upper bound of the range of journal articles (not inclusive)
8838             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8839             * @return the ordered range of matching journal articles that the user has permission to view
8840             * @throws SystemException if a system exception occurred
8841             */
8842            @Override
8843            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds,
8844                    int start, int end, OrderByComparator orderByComparator)
8845                    throws SystemException {
8846                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8847                            return findByG_F(groupId, folderIds, start, end, orderByComparator);
8848                    }
8849    
8850                    StringBundler query = new StringBundler();
8851    
8852                    if (getDB().isSupportsInlineDistinct()) {
8853                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8854                    }
8855                    else {
8856                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8857                    }
8858    
8859                    boolean conjunctionable = false;
8860    
8861                    if (conjunctionable) {
8862                            query.append(WHERE_AND);
8863                    }
8864    
8865                    query.append(_FINDER_COLUMN_G_F_GROUPID_5);
8866    
8867                    conjunctionable = true;
8868    
8869                    if ((folderIds == null) || (folderIds.length > 0)) {
8870                            if (conjunctionable) {
8871                                    query.append(WHERE_AND);
8872                            }
8873    
8874                            query.append(StringPool.OPEN_PARENTHESIS);
8875    
8876                            for (int i = 0; i < folderIds.length; i++) {
8877                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
8878    
8879                                    if ((i + 1) < folderIds.length) {
8880                                            query.append(WHERE_OR);
8881                                    }
8882                            }
8883    
8884                            query.append(StringPool.CLOSE_PARENTHESIS);
8885    
8886                            conjunctionable = true;
8887                    }
8888    
8889                    if (!getDB().isSupportsInlineDistinct()) {
8890                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8891                    }
8892    
8893                    if (orderByComparator != null) {
8894                            if (getDB().isSupportsInlineDistinct()) {
8895                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8896                                            orderByComparator, true);
8897                            }
8898                            else {
8899                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8900                                            orderByComparator, true);
8901                            }
8902                    }
8903                    else {
8904                            if (getDB().isSupportsInlineDistinct()) {
8905                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8906                            }
8907                            else {
8908                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8909                            }
8910                    }
8911    
8912                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8913                                    JournalArticle.class.getName(),
8914                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8915    
8916                    Session session = null;
8917    
8918                    try {
8919                            session = openSession();
8920    
8921                            SQLQuery q = session.createSQLQuery(sql);
8922    
8923                            if (getDB().isSupportsInlineDistinct()) {
8924                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8925                            }
8926                            else {
8927                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8928                            }
8929    
8930                            QueryPos qPos = QueryPos.getInstance(q);
8931    
8932                            qPos.add(groupId);
8933    
8934                            if (folderIds != null) {
8935                                    qPos.add(folderIds);
8936                            }
8937    
8938                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
8939                                    end);
8940                    }
8941                    catch (Exception e) {
8942                            throw processException(e);
8943                    }
8944                    finally {
8945                            closeSession(session);
8946                    }
8947            }
8948    
8949            /**
8950             * Returns all the journal articles where groupId = &#63; and folderId = any &#63;.
8951             *
8952             * <p>
8953             * 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.
8954             * </p>
8955             *
8956             * @param groupId the group ID
8957             * @param folderIds the folder IDs
8958             * @return the matching journal articles
8959             * @throws SystemException if a system exception occurred
8960             */
8961            @Override
8962            public List<JournalArticle> findByG_F(long groupId, long[] folderIds)
8963                    throws SystemException {
8964                    return findByG_F(groupId, folderIds, QueryUtil.ALL_POS,
8965                            QueryUtil.ALL_POS, null);
8966            }
8967    
8968            /**
8969             * Returns a range of all the journal articles where groupId = &#63; and folderId = any &#63;.
8970             *
8971             * <p>
8972             * 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.
8973             * </p>
8974             *
8975             * @param groupId the group ID
8976             * @param folderIds the folder IDs
8977             * @param start the lower bound of the range of journal articles
8978             * @param end the upper bound of the range of journal articles (not inclusive)
8979             * @return the range of matching journal articles
8980             * @throws SystemException if a system exception occurred
8981             */
8982            @Override
8983            public List<JournalArticle> findByG_F(long groupId, long[] folderIds,
8984                    int start, int end) throws SystemException {
8985                    return findByG_F(groupId, folderIds, start, end, null);
8986            }
8987    
8988            /**
8989             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = any &#63;.
8990             *
8991             * <p>
8992             * 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.
8993             * </p>
8994             *
8995             * @param groupId the group ID
8996             * @param folderIds the folder IDs
8997             * @param start the lower bound of the range of journal articles
8998             * @param end the upper bound of the range of journal articles (not inclusive)
8999             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9000             * @return the ordered range of matching journal articles
9001             * @throws SystemException if a system exception occurred
9002             */
9003            @Override
9004            public List<JournalArticle> findByG_F(long groupId, long[] folderIds,
9005                    int start, int end, OrderByComparator orderByComparator)
9006                    throws SystemException {
9007                    if ((folderIds != null) && (folderIds.length == 1)) {
9008                            return findByG_F(groupId, folderIds[0], start, end,
9009                                    orderByComparator);
9010                    }
9011    
9012                    boolean pagination = true;
9013                    Object[] finderArgs = null;
9014    
9015                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9016                                    (orderByComparator == null)) {
9017                            pagination = false;
9018                            finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
9019                    }
9020                    else {
9021                            finderArgs = new Object[] {
9022                                            groupId, StringUtil.merge(folderIds),
9023                                            
9024                                            start, end, orderByComparator
9025                                    };
9026                    }
9027    
9028                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
9029                                    finderArgs, this);
9030    
9031                    if ((list != null) && !list.isEmpty()) {
9032                            for (JournalArticle journalArticle : list) {
9033                                    if ((groupId != journalArticle.getGroupId()) ||
9034                                                    !ArrayUtil.contains(folderIds,
9035                                                            journalArticle.getFolderId())) {
9036                                            list = null;
9037    
9038                                            break;
9039                                    }
9040                            }
9041                    }
9042    
9043                    if (list == null) {
9044                            StringBundler query = new StringBundler();
9045    
9046                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9047    
9048                            boolean conjunctionable = false;
9049    
9050                            if (conjunctionable) {
9051                                    query.append(WHERE_AND);
9052                            }
9053    
9054                            query.append(_FINDER_COLUMN_G_F_GROUPID_5);
9055    
9056                            conjunctionable = true;
9057    
9058                            if ((folderIds == null) || (folderIds.length > 0)) {
9059                                    if (conjunctionable) {
9060                                            query.append(WHERE_AND);
9061                                    }
9062    
9063                                    query.append(StringPool.OPEN_PARENTHESIS);
9064    
9065                                    for (int i = 0; i < folderIds.length; i++) {
9066                                            query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
9067    
9068                                            if ((i + 1) < folderIds.length) {
9069                                                    query.append(WHERE_OR);
9070                                            }
9071                                    }
9072    
9073                                    query.append(StringPool.CLOSE_PARENTHESIS);
9074    
9075                                    conjunctionable = true;
9076                            }
9077    
9078                            if (orderByComparator != null) {
9079                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9080                                            orderByComparator);
9081                            }
9082                            else
9083                             if (pagination) {
9084                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9085                            }
9086    
9087                            String sql = query.toString();
9088    
9089                            Session session = null;
9090    
9091                            try {
9092                                    session = openSession();
9093    
9094                                    Query q = session.createQuery(sql);
9095    
9096                                    QueryPos qPos = QueryPos.getInstance(q);
9097    
9098                                    qPos.add(groupId);
9099    
9100                                    if (folderIds != null) {
9101                                            qPos.add(folderIds);
9102                                    }
9103    
9104                                    if (!pagination) {
9105                                            list = (List<JournalArticle>)QueryUtil.list(q,
9106                                                            getDialect(), start, end, false);
9107    
9108                                            Collections.sort(list);
9109    
9110                                            list = new UnmodifiableList<JournalArticle>(list);
9111                                    }
9112                                    else {
9113                                            list = (List<JournalArticle>)QueryUtil.list(q,
9114                                                            getDialect(), start, end);
9115                                    }
9116    
9117                                    cacheResult(list);
9118    
9119                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
9120                                            finderArgs, list);
9121                            }
9122                            catch (Exception e) {
9123                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
9124                                            finderArgs);
9125    
9126                                    throw processException(e);
9127                            }
9128                            finally {
9129                                    closeSession(session);
9130                            }
9131                    }
9132    
9133                    return list;
9134            }
9135    
9136            /**
9137             * Removes all the journal articles where groupId = &#63; and folderId = &#63; from the database.
9138             *
9139             * @param groupId the group ID
9140             * @param folderId the folder ID
9141             * @throws SystemException if a system exception occurred
9142             */
9143            @Override
9144            public void removeByG_F(long groupId, long folderId)
9145                    throws SystemException {
9146                    for (JournalArticle journalArticle : findByG_F(groupId, folderId,
9147                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9148                            remove(journalArticle);
9149                    }
9150            }
9151    
9152            /**
9153             * Returns the number of journal articles where groupId = &#63; and folderId = &#63;.
9154             *
9155             * @param groupId the group ID
9156             * @param folderId the folder ID
9157             * @return the number of matching journal articles
9158             * @throws SystemException if a system exception occurred
9159             */
9160            @Override
9161            public int countByG_F(long groupId, long folderId)
9162                    throws SystemException {
9163                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F;
9164    
9165                    Object[] finderArgs = new Object[] { groupId, folderId };
9166    
9167                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9168                                    this);
9169    
9170                    if (count == null) {
9171                            StringBundler query = new StringBundler(3);
9172    
9173                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
9174    
9175                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
9176    
9177                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
9178    
9179                            String sql = query.toString();
9180    
9181                            Session session = null;
9182    
9183                            try {
9184                                    session = openSession();
9185    
9186                                    Query q = session.createQuery(sql);
9187    
9188                                    QueryPos qPos = QueryPos.getInstance(q);
9189    
9190                                    qPos.add(groupId);
9191    
9192                                    qPos.add(folderId);
9193    
9194                                    count = (Long)q.uniqueResult();
9195    
9196                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
9197                            }
9198                            catch (Exception e) {
9199                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9200    
9201                                    throw processException(e);
9202                            }
9203                            finally {
9204                                    closeSession(session);
9205                            }
9206                    }
9207    
9208                    return count.intValue();
9209            }
9210    
9211            /**
9212             * Returns the number of journal articles where groupId = &#63; and folderId = any &#63;.
9213             *
9214             * @param groupId the group ID
9215             * @param folderIds the folder IDs
9216             * @return the number of matching journal articles
9217             * @throws SystemException if a system exception occurred
9218             */
9219            @Override
9220            public int countByG_F(long groupId, long[] folderIds)
9221                    throws SystemException {
9222                    Object[] finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
9223    
9224                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
9225                                    finderArgs, this);
9226    
9227                    if (count == null) {
9228                            StringBundler query = new StringBundler();
9229    
9230                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
9231    
9232                            boolean conjunctionable = false;
9233    
9234                            if (conjunctionable) {
9235                                    query.append(WHERE_AND);
9236                            }
9237    
9238                            query.append(_FINDER_COLUMN_G_F_GROUPID_5);
9239    
9240                            conjunctionable = true;
9241    
9242                            if ((folderIds == null) || (folderIds.length > 0)) {
9243                                    if (conjunctionable) {
9244                                            query.append(WHERE_AND);
9245                                    }
9246    
9247                                    query.append(StringPool.OPEN_PARENTHESIS);
9248    
9249                                    for (int i = 0; i < folderIds.length; i++) {
9250                                            query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
9251    
9252                                            if ((i + 1) < folderIds.length) {
9253                                                    query.append(WHERE_OR);
9254                                            }
9255                                    }
9256    
9257                                    query.append(StringPool.CLOSE_PARENTHESIS);
9258    
9259                                    conjunctionable = true;
9260                            }
9261    
9262                            String sql = query.toString();
9263    
9264                            Session session = null;
9265    
9266                            try {
9267                                    session = openSession();
9268    
9269                                    Query q = session.createQuery(sql);
9270    
9271                                    QueryPos qPos = QueryPos.getInstance(q);
9272    
9273                                    qPos.add(groupId);
9274    
9275                                    if (folderIds != null) {
9276                                            qPos.add(folderIds);
9277                                    }
9278    
9279                                    count = (Long)q.uniqueResult();
9280    
9281                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
9282                                            finderArgs, count);
9283                            }
9284                            catch (Exception e) {
9285                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
9286                                            finderArgs);
9287    
9288                                    throw processException(e);
9289                            }
9290                            finally {
9291                                    closeSession(session);
9292                            }
9293                    }
9294    
9295                    return count.intValue();
9296            }
9297    
9298            /**
9299             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
9300             *
9301             * @param groupId the group ID
9302             * @param folderId the folder ID
9303             * @return the number of matching journal articles that the user has permission to view
9304             * @throws SystemException if a system exception occurred
9305             */
9306            @Override
9307            public int filterCountByG_F(long groupId, long folderId)
9308                    throws SystemException {
9309                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9310                            return countByG_F(groupId, folderId);
9311                    }
9312    
9313                    StringBundler query = new StringBundler(3);
9314    
9315                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
9316    
9317                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
9318    
9319                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
9320    
9321                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9322                                    JournalArticle.class.getName(),
9323                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9324    
9325                    Session session = null;
9326    
9327                    try {
9328                            session = openSession();
9329    
9330                            SQLQuery q = session.createSQLQuery(sql);
9331    
9332                            q.addScalar(COUNT_COLUMN_NAME,
9333                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9334    
9335                            QueryPos qPos = QueryPos.getInstance(q);
9336    
9337                            qPos.add(groupId);
9338    
9339                            qPos.add(folderId);
9340    
9341                            Long count = (Long)q.uniqueResult();
9342    
9343                            return count.intValue();
9344                    }
9345                    catch (Exception e) {
9346                            throw processException(e);
9347                    }
9348                    finally {
9349                            closeSession(session);
9350                    }
9351            }
9352    
9353            /**
9354             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
9355             *
9356             * @param groupId the group ID
9357             * @param folderIds the folder IDs
9358             * @return the number of matching journal articles that the user has permission to view
9359             * @throws SystemException if a system exception occurred
9360             */
9361            @Override
9362            public int filterCountByG_F(long groupId, long[] folderIds)
9363                    throws SystemException {
9364                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9365                            return countByG_F(groupId, folderIds);
9366                    }
9367    
9368                    StringBundler query = new StringBundler();
9369    
9370                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
9371    
9372                    boolean conjunctionable = false;
9373    
9374                    if (conjunctionable) {
9375                            query.append(WHERE_AND);
9376                    }
9377    
9378                    query.append(_FINDER_COLUMN_G_F_GROUPID_5);
9379    
9380                    conjunctionable = true;
9381    
9382                    if ((folderIds == null) || (folderIds.length > 0)) {
9383                            if (conjunctionable) {
9384                                    query.append(WHERE_AND);
9385                            }
9386    
9387                            query.append(StringPool.OPEN_PARENTHESIS);
9388    
9389                            for (int i = 0; i < folderIds.length; i++) {
9390                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
9391    
9392                                    if ((i + 1) < folderIds.length) {
9393                                            query.append(WHERE_OR);
9394                                    }
9395                            }
9396    
9397                            query.append(StringPool.CLOSE_PARENTHESIS);
9398    
9399                            conjunctionable = true;
9400                    }
9401    
9402                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9403                                    JournalArticle.class.getName(),
9404                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9405    
9406                    Session session = null;
9407    
9408                    try {
9409                            session = openSession();
9410    
9411                            SQLQuery q = session.createSQLQuery(sql);
9412    
9413                            q.addScalar(COUNT_COLUMN_NAME,
9414                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9415    
9416                            QueryPos qPos = QueryPos.getInstance(q);
9417    
9418                            qPos.add(groupId);
9419    
9420                            if (folderIds != null) {
9421                                    qPos.add(folderIds);
9422                            }
9423    
9424                            Long count = (Long)q.uniqueResult();
9425    
9426                            return count.intValue();
9427                    }
9428                    catch (Exception e) {
9429                            throw processException(e);
9430                    }
9431                    finally {
9432                            closeSession(session);
9433                    }
9434            }
9435    
9436            private static final String _FINDER_COLUMN_G_F_GROUPID_2 = "journalArticle.groupId = ? AND ";
9437            private static final String _FINDER_COLUMN_G_F_GROUPID_5 = "(" +
9438                    removeConjunction(_FINDER_COLUMN_G_F_GROUPID_2) + ")";
9439            private static final String _FINDER_COLUMN_G_F_FOLDERID_2 = "journalArticle.folderId = ?";
9440            private static final String _FINDER_COLUMN_G_F_FOLDERID_5 = "(" +
9441                    removeConjunction(_FINDER_COLUMN_G_F_FOLDERID_2) + ")";
9442            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9443                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
9444                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
9445                            "findByG_A",
9446                            new String[] {
9447                                    Long.class.getName(), String.class.getName(),
9448                                    
9449                            Integer.class.getName(), Integer.class.getName(),
9450                                    OrderByComparator.class.getName()
9451                            });
9452            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9453                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
9454                            JournalArticleImpl.class,
9455                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A",
9456                            new String[] { Long.class.getName(), String.class.getName() },
9457                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
9458                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
9459                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
9460            public static final FinderPath FINDER_PATH_COUNT_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9461                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
9462                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A",
9463                            new String[] { Long.class.getName(), String.class.getName() });
9464    
9465            /**
9466             * Returns all the journal articles where groupId = &#63; and articleId = &#63;.
9467             *
9468             * @param groupId the group ID
9469             * @param articleId the article ID
9470             * @return the matching journal articles
9471             * @throws SystemException if a system exception occurred
9472             */
9473            @Override
9474            public List<JournalArticle> findByG_A(long groupId, String articleId)
9475                    throws SystemException {
9476                    return findByG_A(groupId, articleId, QueryUtil.ALL_POS,
9477                            QueryUtil.ALL_POS, null);
9478            }
9479    
9480            /**
9481             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63;.
9482             *
9483             * <p>
9484             * 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.
9485             * </p>
9486             *
9487             * @param groupId the group ID
9488             * @param articleId the article ID
9489             * @param start the lower bound of the range of journal articles
9490             * @param end the upper bound of the range of journal articles (not inclusive)
9491             * @return the range of matching journal articles
9492             * @throws SystemException if a system exception occurred
9493             */
9494            @Override
9495            public List<JournalArticle> findByG_A(long groupId, String articleId,
9496                    int start, int end) throws SystemException {
9497                    return findByG_A(groupId, articleId, start, end, null);
9498            }
9499    
9500            /**
9501             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63;.
9502             *
9503             * <p>
9504             * 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.
9505             * </p>
9506             *
9507             * @param groupId the group ID
9508             * @param articleId the article ID
9509             * @param start the lower bound of the range of journal articles
9510             * @param end the upper bound of the range of journal articles (not inclusive)
9511             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9512             * @return the ordered range of matching journal articles
9513             * @throws SystemException if a system exception occurred
9514             */
9515            @Override
9516            public List<JournalArticle> findByG_A(long groupId, String articleId,
9517                    int start, int end, OrderByComparator orderByComparator)
9518                    throws SystemException {
9519                    boolean pagination = true;
9520                    FinderPath finderPath = null;
9521                    Object[] finderArgs = null;
9522    
9523                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9524                                    (orderByComparator == null)) {
9525                            pagination = false;
9526                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A;
9527                            finderArgs = new Object[] { groupId, articleId };
9528                    }
9529                    else {
9530                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A;
9531                            finderArgs = new Object[] {
9532                                            groupId, articleId,
9533                                            
9534                                            start, end, orderByComparator
9535                                    };
9536                    }
9537    
9538                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
9539                                    finderArgs, this);
9540    
9541                    if ((list != null) && !list.isEmpty()) {
9542                            for (JournalArticle journalArticle : list) {
9543                                    if ((groupId != journalArticle.getGroupId()) ||
9544                                                    !Validator.equals(articleId,
9545                                                            journalArticle.getArticleId())) {
9546                                            list = null;
9547    
9548                                            break;
9549                                    }
9550                            }
9551                    }
9552    
9553                    if (list == null) {
9554                            StringBundler query = null;
9555    
9556                            if (orderByComparator != null) {
9557                                    query = new StringBundler(4 +
9558                                                    (orderByComparator.getOrderByFields().length * 3));
9559                            }
9560                            else {
9561                                    query = new StringBundler(4);
9562                            }
9563    
9564                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9565    
9566                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
9567    
9568                            boolean bindArticleId = false;
9569    
9570                            if (articleId == null) {
9571                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
9572                            }
9573                            else if (articleId.equals(StringPool.BLANK)) {
9574                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
9575                            }
9576                            else {
9577                                    bindArticleId = true;
9578    
9579                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
9580                            }
9581    
9582                            if (orderByComparator != null) {
9583                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9584                                            orderByComparator);
9585                            }
9586                            else
9587                             if (pagination) {
9588                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9589                            }
9590    
9591                            String sql = query.toString();
9592    
9593                            Session session = null;
9594    
9595                            try {
9596                                    session = openSession();
9597    
9598                                    Query q = session.createQuery(sql);
9599    
9600                                    QueryPos qPos = QueryPos.getInstance(q);
9601    
9602                                    qPos.add(groupId);
9603    
9604                                    if (bindArticleId) {
9605                                            qPos.add(articleId);
9606                                    }
9607    
9608                                    if (!pagination) {
9609                                            list = (List<JournalArticle>)QueryUtil.list(q,
9610                                                            getDialect(), start, end, false);
9611    
9612                                            Collections.sort(list);
9613    
9614                                            list = new UnmodifiableList<JournalArticle>(list);
9615                                    }
9616                                    else {
9617                                            list = (List<JournalArticle>)QueryUtil.list(q,
9618                                                            getDialect(), start, end);
9619                                    }
9620    
9621                                    cacheResult(list);
9622    
9623                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
9624                            }
9625                            catch (Exception e) {
9626                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9627    
9628                                    throw processException(e);
9629                            }
9630                            finally {
9631                                    closeSession(session);
9632                            }
9633                    }
9634    
9635                    return list;
9636            }
9637    
9638            /**
9639             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9640             *
9641             * @param groupId the group ID
9642             * @param articleId the article ID
9643             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9644             * @return the first matching journal article
9645             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9646             * @throws SystemException if a system exception occurred
9647             */
9648            @Override
9649            public JournalArticle findByG_A_First(long groupId, String articleId,
9650                    OrderByComparator orderByComparator)
9651                    throws NoSuchArticleException, SystemException {
9652                    JournalArticle journalArticle = fetchByG_A_First(groupId, articleId,
9653                                    orderByComparator);
9654    
9655                    if (journalArticle != null) {
9656                            return journalArticle;
9657                    }
9658    
9659                    StringBundler msg = new StringBundler(6);
9660    
9661                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9662    
9663                    msg.append("groupId=");
9664                    msg.append(groupId);
9665    
9666                    msg.append(", articleId=");
9667                    msg.append(articleId);
9668    
9669                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9670    
9671                    throw new NoSuchArticleException(msg.toString());
9672            }
9673    
9674            /**
9675             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9676             *
9677             * @param groupId the group ID
9678             * @param articleId the article ID
9679             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9680             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
9681             * @throws SystemException if a system exception occurred
9682             */
9683            @Override
9684            public JournalArticle fetchByG_A_First(long groupId, String articleId,
9685                    OrderByComparator orderByComparator) throws SystemException {
9686                    List<JournalArticle> list = findByG_A(groupId, articleId, 0, 1,
9687                                    orderByComparator);
9688    
9689                    if (!list.isEmpty()) {
9690                            return list.get(0);
9691                    }
9692    
9693                    return null;
9694            }
9695    
9696            /**
9697             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9698             *
9699             * @param groupId the group ID
9700             * @param articleId the article ID
9701             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9702             * @return the last matching journal article
9703             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9704             * @throws SystemException if a system exception occurred
9705             */
9706            @Override
9707            public JournalArticle findByG_A_Last(long groupId, String articleId,
9708                    OrderByComparator orderByComparator)
9709                    throws NoSuchArticleException, SystemException {
9710                    JournalArticle journalArticle = fetchByG_A_Last(groupId, articleId,
9711                                    orderByComparator);
9712    
9713                    if (journalArticle != null) {
9714                            return journalArticle;
9715                    }
9716    
9717                    StringBundler msg = new StringBundler(6);
9718    
9719                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9720    
9721                    msg.append("groupId=");
9722                    msg.append(groupId);
9723    
9724                    msg.append(", articleId=");
9725                    msg.append(articleId);
9726    
9727                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9728    
9729                    throw new NoSuchArticleException(msg.toString());
9730            }
9731    
9732            /**
9733             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9734             *
9735             * @param groupId the group ID
9736             * @param articleId the article ID
9737             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9738             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
9739             * @throws SystemException if a system exception occurred
9740             */
9741            @Override
9742            public JournalArticle fetchByG_A_Last(long groupId, String articleId,
9743                    OrderByComparator orderByComparator) throws SystemException {
9744                    int count = countByG_A(groupId, articleId);
9745    
9746                    if (count == 0) {
9747                            return null;
9748                    }
9749    
9750                    List<JournalArticle> list = findByG_A(groupId, articleId, count - 1,
9751                                    count, orderByComparator);
9752    
9753                    if (!list.isEmpty()) {
9754                            return list.get(0);
9755                    }
9756    
9757                    return null;
9758            }
9759    
9760            /**
9761             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9762             *
9763             * @param id the primary key of the current journal article
9764             * @param groupId the group ID
9765             * @param articleId the article ID
9766             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9767             * @return the previous, current, and next journal article
9768             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
9769             * @throws SystemException if a system exception occurred
9770             */
9771            @Override
9772            public JournalArticle[] findByG_A_PrevAndNext(long id, long groupId,
9773                    String articleId, OrderByComparator orderByComparator)
9774                    throws NoSuchArticleException, SystemException {
9775                    JournalArticle journalArticle = findByPrimaryKey(id);
9776    
9777                    Session session = null;
9778    
9779                    try {
9780                            session = openSession();
9781    
9782                            JournalArticle[] array = new JournalArticleImpl[3];
9783    
9784                            array[0] = getByG_A_PrevAndNext(session, journalArticle, groupId,
9785                                            articleId, orderByComparator, true);
9786    
9787                            array[1] = journalArticle;
9788    
9789                            array[2] = getByG_A_PrevAndNext(session, journalArticle, groupId,
9790                                            articleId, orderByComparator, false);
9791    
9792                            return array;
9793                    }
9794                    catch (Exception e) {
9795                            throw processException(e);
9796                    }
9797                    finally {
9798                            closeSession(session);
9799                    }
9800            }
9801    
9802            protected JournalArticle getByG_A_PrevAndNext(Session session,
9803                    JournalArticle journalArticle, long groupId, String articleId,
9804                    OrderByComparator orderByComparator, boolean previous) {
9805                    StringBundler query = null;
9806    
9807                    if (orderByComparator != null) {
9808                            query = new StringBundler(6 +
9809                                            (orderByComparator.getOrderByFields().length * 6));
9810                    }
9811                    else {
9812                            query = new StringBundler(3);
9813                    }
9814    
9815                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9816    
9817                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
9818    
9819                    boolean bindArticleId = false;
9820    
9821                    if (articleId == null) {
9822                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
9823                    }
9824                    else if (articleId.equals(StringPool.BLANK)) {
9825                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
9826                    }
9827                    else {
9828                            bindArticleId = true;
9829    
9830                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
9831                    }
9832    
9833                    if (orderByComparator != null) {
9834                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9835    
9836                            if (orderByConditionFields.length > 0) {
9837                                    query.append(WHERE_AND);
9838                            }
9839    
9840                            for (int i = 0; i < orderByConditionFields.length; i++) {
9841                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9842                                    query.append(orderByConditionFields[i]);
9843    
9844                                    if ((i + 1) < orderByConditionFields.length) {
9845                                            if (orderByComparator.isAscending() ^ previous) {
9846                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9847                                            }
9848                                            else {
9849                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9850                                            }
9851                                    }
9852                                    else {
9853                                            if (orderByComparator.isAscending() ^ previous) {
9854                                                    query.append(WHERE_GREATER_THAN);
9855                                            }
9856                                            else {
9857                                                    query.append(WHERE_LESSER_THAN);
9858                                            }
9859                                    }
9860                            }
9861    
9862                            query.append(ORDER_BY_CLAUSE);
9863    
9864                            String[] orderByFields = orderByComparator.getOrderByFields();
9865    
9866                            for (int i = 0; i < orderByFields.length; i++) {
9867                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9868                                    query.append(orderByFields[i]);
9869    
9870                                    if ((i + 1) < orderByFields.length) {
9871                                            if (orderByComparator.isAscending() ^ previous) {
9872                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9873                                            }
9874                                            else {
9875                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9876                                            }
9877                                    }
9878                                    else {
9879                                            if (orderByComparator.isAscending() ^ previous) {
9880                                                    query.append(ORDER_BY_ASC);
9881                                            }
9882                                            else {
9883                                                    query.append(ORDER_BY_DESC);
9884                                            }
9885                                    }
9886                            }
9887                    }
9888                    else {
9889                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9890                    }
9891    
9892                    String sql = query.toString();
9893    
9894                    Query q = session.createQuery(sql);
9895    
9896                    q.setFirstResult(0);
9897                    q.setMaxResults(2);
9898    
9899                    QueryPos qPos = QueryPos.getInstance(q);
9900    
9901                    qPos.add(groupId);
9902    
9903                    if (bindArticleId) {
9904                            qPos.add(articleId);
9905                    }
9906    
9907                    if (orderByComparator != null) {
9908                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
9909    
9910                            for (Object value : values) {
9911                                    qPos.add(value);
9912                            }
9913                    }
9914    
9915                    List<JournalArticle> list = q.list();
9916    
9917                    if (list.size() == 2) {
9918                            return list.get(1);
9919                    }
9920                    else {
9921                            return null;
9922                    }
9923            }
9924    
9925            /**
9926             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
9927             *
9928             * @param groupId the group ID
9929             * @param articleId the article ID
9930             * @return the matching journal articles that the user has permission to view
9931             * @throws SystemException if a system exception occurred
9932             */
9933            @Override
9934            public List<JournalArticle> filterFindByG_A(long groupId, String articleId)
9935                    throws SystemException {
9936                    return filterFindByG_A(groupId, articleId, QueryUtil.ALL_POS,
9937                            QueryUtil.ALL_POS, null);
9938            }
9939    
9940            /**
9941             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
9942             *
9943             * <p>
9944             * 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.
9945             * </p>
9946             *
9947             * @param groupId the group ID
9948             * @param articleId the article ID
9949             * @param start the lower bound of the range of journal articles
9950             * @param end the upper bound of the range of journal articles (not inclusive)
9951             * @return the range of matching journal articles that the user has permission to view
9952             * @throws SystemException if a system exception occurred
9953             */
9954            @Override
9955            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
9956                    int start, int end) throws SystemException {
9957                    return filterFindByG_A(groupId, articleId, start, end, null);
9958            }
9959    
9960            /**
9961             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and articleId = &#63;.
9962             *
9963             * <p>
9964             * 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.
9965             * </p>
9966             *
9967             * @param groupId the group ID
9968             * @param articleId the article ID
9969             * @param start the lower bound of the range of journal articles
9970             * @param end the upper bound of the range of journal articles (not inclusive)
9971             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9972             * @return the ordered range of matching journal articles that the user has permission to view
9973             * @throws SystemException if a system exception occurred
9974             */
9975            @Override
9976            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
9977                    int start, int end, OrderByComparator orderByComparator)
9978                    throws SystemException {
9979                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9980                            return findByG_A(groupId, articleId, start, end, orderByComparator);
9981                    }
9982    
9983                    StringBundler query = null;
9984    
9985                    if (orderByComparator != null) {
9986                            query = new StringBundler(4 +
9987                                            (orderByComparator.getOrderByFields().length * 3));
9988                    }
9989                    else {
9990                            query = new StringBundler(4);
9991                    }
9992    
9993                    if (getDB().isSupportsInlineDistinct()) {
9994                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
9995                    }
9996                    else {
9997                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
9998                    }
9999    
10000                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
10001    
10002                    boolean bindArticleId = false;
10003    
10004                    if (articleId == null) {
10005                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
10006                    }
10007                    else if (articleId.equals(StringPool.BLANK)) {
10008                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
10009                    }
10010                    else {
10011                            bindArticleId = true;
10012    
10013                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
10014                    }
10015    
10016                    if (!getDB().isSupportsInlineDistinct()) {
10017                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
10018                    }
10019    
10020                    if (orderByComparator != null) {
10021                            if (getDB().isSupportsInlineDistinct()) {
10022                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10023                                            orderByComparator, true);
10024                            }
10025                            else {
10026                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10027                                            orderByComparator, true);
10028                            }
10029                    }
10030                    else {
10031                            if (getDB().isSupportsInlineDistinct()) {
10032                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10033                            }
10034                            else {
10035                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
10036                            }
10037                    }
10038    
10039                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10040                                    JournalArticle.class.getName(),
10041                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10042    
10043                    Session session = null;
10044    
10045                    try {
10046                            session = openSession();
10047    
10048                            SQLQuery q = session.createSQLQuery(sql);
10049    
10050                            if (getDB().isSupportsInlineDistinct()) {
10051                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
10052                            }
10053                            else {
10054                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
10055                            }
10056    
10057                            QueryPos qPos = QueryPos.getInstance(q);
10058    
10059                            qPos.add(groupId);
10060    
10061                            if (bindArticleId) {
10062                                    qPos.add(articleId);
10063                            }
10064    
10065                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
10066                                    end);
10067                    }
10068                    catch (Exception e) {
10069                            throw processException(e);
10070                    }
10071                    finally {
10072                            closeSession(session);
10073                    }
10074            }
10075    
10076            /**
10077             * 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;.
10078             *
10079             * @param id the primary key of the current journal article
10080             * @param groupId the group ID
10081             * @param articleId the article ID
10082             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10083             * @return the previous, current, and next journal article
10084             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10085             * @throws SystemException if a system exception occurred
10086             */
10087            @Override
10088            public JournalArticle[] filterFindByG_A_PrevAndNext(long id, long groupId,
10089                    String articleId, OrderByComparator orderByComparator)
10090                    throws NoSuchArticleException, SystemException {
10091                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10092                            return findByG_A_PrevAndNext(id, groupId, articleId,
10093                                    orderByComparator);
10094                    }
10095    
10096                    JournalArticle journalArticle = findByPrimaryKey(id);
10097    
10098                    Session session = null;
10099    
10100                    try {
10101                            session = openSession();
10102    
10103                            JournalArticle[] array = new JournalArticleImpl[3];
10104    
10105                            array[0] = filterGetByG_A_PrevAndNext(session, journalArticle,
10106                                            groupId, articleId, orderByComparator, true);
10107    
10108                            array[1] = journalArticle;
10109    
10110                            array[2] = filterGetByG_A_PrevAndNext(session, journalArticle,
10111                                            groupId, articleId, orderByComparator, false);
10112    
10113                            return array;
10114                    }
10115                    catch (Exception e) {
10116                            throw processException(e);
10117                    }
10118                    finally {
10119                            closeSession(session);
10120                    }
10121            }
10122    
10123            protected JournalArticle filterGetByG_A_PrevAndNext(Session session,
10124                    JournalArticle journalArticle, long groupId, String articleId,
10125                    OrderByComparator orderByComparator, boolean previous) {
10126                    StringBundler query = null;
10127    
10128                    if (orderByComparator != null) {
10129                            query = new StringBundler(6 +
10130                                            (orderByComparator.getOrderByFields().length * 6));
10131                    }
10132                    else {
10133                            query = new StringBundler(3);
10134                    }
10135    
10136                    if (getDB().isSupportsInlineDistinct()) {
10137                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
10138                    }
10139                    else {
10140                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
10141                    }
10142    
10143                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
10144    
10145                    boolean bindArticleId = false;
10146    
10147                    if (articleId == null) {
10148                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
10149                    }
10150                    else if (articleId.equals(StringPool.BLANK)) {
10151                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
10152                    }
10153                    else {
10154                            bindArticleId = true;
10155    
10156                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
10157                    }
10158    
10159                    if (!getDB().isSupportsInlineDistinct()) {
10160                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
10161                    }
10162    
10163                    if (orderByComparator != null) {
10164                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10165    
10166                            if (orderByConditionFields.length > 0) {
10167                                    query.append(WHERE_AND);
10168                            }
10169    
10170                            for (int i = 0; i < orderByConditionFields.length; i++) {
10171                                    if (getDB().isSupportsInlineDistinct()) {
10172                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10173                                    }
10174                                    else {
10175                                            query.append(_ORDER_BY_ENTITY_TABLE);
10176                                    }
10177    
10178                                    query.append(orderByConditionFields[i]);
10179    
10180                                    if ((i + 1) < orderByConditionFields.length) {
10181                                            if (orderByComparator.isAscending() ^ previous) {
10182                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10183                                            }
10184                                            else {
10185                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10186                                            }
10187                                    }
10188                                    else {
10189                                            if (orderByComparator.isAscending() ^ previous) {
10190                                                    query.append(WHERE_GREATER_THAN);
10191                                            }
10192                                            else {
10193                                                    query.append(WHERE_LESSER_THAN);
10194                                            }
10195                                    }
10196                            }
10197    
10198                            query.append(ORDER_BY_CLAUSE);
10199    
10200                            String[] orderByFields = orderByComparator.getOrderByFields();
10201    
10202                            for (int i = 0; i < orderByFields.length; i++) {
10203                                    if (getDB().isSupportsInlineDistinct()) {
10204                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10205                                    }
10206                                    else {
10207                                            query.append(_ORDER_BY_ENTITY_TABLE);
10208                                    }
10209    
10210                                    query.append(orderByFields[i]);
10211    
10212                                    if ((i + 1) < orderByFields.length) {
10213                                            if (orderByComparator.isAscending() ^ previous) {
10214                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10215                                            }
10216                                            else {
10217                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10218                                            }
10219                                    }
10220                                    else {
10221                                            if (orderByComparator.isAscending() ^ previous) {
10222                                                    query.append(ORDER_BY_ASC);
10223                                            }
10224                                            else {
10225                                                    query.append(ORDER_BY_DESC);
10226                                            }
10227                                    }
10228                            }
10229                    }
10230                    else {
10231                            if (getDB().isSupportsInlineDistinct()) {
10232                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10233                            }
10234                            else {
10235                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
10236                            }
10237                    }
10238    
10239                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10240                                    JournalArticle.class.getName(),
10241                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10242    
10243                    SQLQuery q = session.createSQLQuery(sql);
10244    
10245                    q.setFirstResult(0);
10246                    q.setMaxResults(2);
10247    
10248                    if (getDB().isSupportsInlineDistinct()) {
10249                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
10250                    }
10251                    else {
10252                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
10253                    }
10254    
10255                    QueryPos qPos = QueryPos.getInstance(q);
10256    
10257                    qPos.add(groupId);
10258    
10259                    if (bindArticleId) {
10260                            qPos.add(articleId);
10261                    }
10262    
10263                    if (orderByComparator != null) {
10264                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10265    
10266                            for (Object value : values) {
10267                                    qPos.add(value);
10268                            }
10269                    }
10270    
10271                    List<JournalArticle> list = q.list();
10272    
10273                    if (list.size() == 2) {
10274                            return list.get(1);
10275                    }
10276                    else {
10277                            return null;
10278                    }
10279            }
10280    
10281            /**
10282             * Removes all the journal articles where groupId = &#63; and articleId = &#63; from the database.
10283             *
10284             * @param groupId the group ID
10285             * @param articleId the article ID
10286             * @throws SystemException if a system exception occurred
10287             */
10288            @Override
10289            public void removeByG_A(long groupId, String articleId)
10290                    throws SystemException {
10291                    for (JournalArticle journalArticle : findByG_A(groupId, articleId,
10292                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10293                            remove(journalArticle);
10294                    }
10295            }
10296    
10297            /**
10298             * Returns the number of journal articles where groupId = &#63; and articleId = &#63;.
10299             *
10300             * @param groupId the group ID
10301             * @param articleId the article ID
10302             * @return the number of matching journal articles
10303             * @throws SystemException if a system exception occurred
10304             */
10305            @Override
10306            public int countByG_A(long groupId, String articleId)
10307                    throws SystemException {
10308                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A;
10309    
10310                    Object[] finderArgs = new Object[] { groupId, articleId };
10311    
10312                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10313                                    this);
10314    
10315                    if (count == null) {
10316                            StringBundler query = new StringBundler(3);
10317    
10318                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
10319    
10320                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
10321    
10322                            boolean bindArticleId = false;
10323    
10324                            if (articleId == null) {
10325                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
10326                            }
10327                            else if (articleId.equals(StringPool.BLANK)) {
10328                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
10329                            }
10330                            else {
10331                                    bindArticleId = true;
10332    
10333                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
10334                            }
10335    
10336                            String sql = query.toString();
10337    
10338                            Session session = null;
10339    
10340                            try {
10341                                    session = openSession();
10342    
10343                                    Query q = session.createQuery(sql);
10344    
10345                                    QueryPos qPos = QueryPos.getInstance(q);
10346    
10347                                    qPos.add(groupId);
10348    
10349                                    if (bindArticleId) {
10350                                            qPos.add(articleId);
10351                                    }
10352    
10353                                    count = (Long)q.uniqueResult();
10354    
10355                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
10356                            }
10357                            catch (Exception e) {
10358                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10359    
10360                                    throw processException(e);
10361                            }
10362                            finally {
10363                                    closeSession(session);
10364                            }
10365                    }
10366    
10367                    return count.intValue();
10368            }
10369    
10370            /**
10371             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
10372             *
10373             * @param groupId the group ID
10374             * @param articleId the article ID
10375             * @return the number of matching journal articles that the user has permission to view
10376             * @throws SystemException if a system exception occurred
10377             */
10378            @Override
10379            public int filterCountByG_A(long groupId, String articleId)
10380                    throws SystemException {
10381                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10382                            return countByG_A(groupId, articleId);
10383                    }
10384    
10385                    StringBundler query = new StringBundler(3);
10386    
10387                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
10388    
10389                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
10390    
10391                    boolean bindArticleId = false;
10392    
10393                    if (articleId == null) {
10394                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
10395                    }
10396                    else if (articleId.equals(StringPool.BLANK)) {
10397                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
10398                    }
10399                    else {
10400                            bindArticleId = true;
10401    
10402                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
10403                    }
10404    
10405                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10406                                    JournalArticle.class.getName(),
10407                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10408    
10409                    Session session = null;
10410    
10411                    try {
10412                            session = openSession();
10413    
10414                            SQLQuery q = session.createSQLQuery(sql);
10415    
10416                            q.addScalar(COUNT_COLUMN_NAME,
10417                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
10418    
10419                            QueryPos qPos = QueryPos.getInstance(q);
10420    
10421                            qPos.add(groupId);
10422    
10423                            if (bindArticleId) {
10424                                    qPos.add(articleId);
10425                            }
10426    
10427                            Long count = (Long)q.uniqueResult();
10428    
10429                            return count.intValue();
10430                    }
10431                    catch (Exception e) {
10432                            throw processException(e);
10433                    }
10434                    finally {
10435                            closeSession(session);
10436                    }
10437            }
10438    
10439            private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalArticle.groupId = ? AND ";
10440            private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalArticle.articleId IS NULL";
10441            private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalArticle.articleId = ?";
10442            private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '')";
10443            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10444                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
10445                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
10446                            "findByG_UT",
10447                            new String[] {
10448                                    Long.class.getName(), String.class.getName(),
10449                                    
10450                            Integer.class.getName(), Integer.class.getName(),
10451                                    OrderByComparator.class.getName()
10452                            });
10453            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10454                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
10455                            JournalArticleImpl.class,
10456                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_UT",
10457                            new String[] { Long.class.getName(), String.class.getName() },
10458                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
10459                            JournalArticleModelImpl.URLTITLE_COLUMN_BITMASK |
10460                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
10461                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
10462            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10463                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
10464                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT",
10465                            new String[] { Long.class.getName(), String.class.getName() });
10466    
10467            /**
10468             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63;.
10469             *
10470             * @param groupId the group ID
10471             * @param urlTitle the url title
10472             * @return the matching journal articles
10473             * @throws SystemException if a system exception occurred
10474             */
10475            @Override
10476            public List<JournalArticle> findByG_UT(long groupId, String urlTitle)
10477                    throws SystemException {
10478                    return findByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
10479                            QueryUtil.ALL_POS, null);
10480            }
10481    
10482            /**
10483             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
10484             *
10485             * <p>
10486             * 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.
10487             * </p>
10488             *
10489             * @param groupId the group ID
10490             * @param urlTitle the url title
10491             * @param start the lower bound of the range of journal articles
10492             * @param end the upper bound of the range of journal articles (not inclusive)
10493             * @return the range of matching journal articles
10494             * @throws SystemException if a system exception occurred
10495             */
10496            @Override
10497            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
10498                    int start, int end) throws SystemException {
10499                    return findByG_UT(groupId, urlTitle, start, end, null);
10500            }
10501    
10502            /**
10503             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
10504             *
10505             * <p>
10506             * 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.
10507             * </p>
10508             *
10509             * @param groupId the group ID
10510             * @param urlTitle the url title
10511             * @param start the lower bound of the range of journal articles
10512             * @param end the upper bound of the range of journal articles (not inclusive)
10513             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10514             * @return the ordered range of matching journal articles
10515             * @throws SystemException if a system exception occurred
10516             */
10517            @Override
10518            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
10519                    int start, int end, OrderByComparator orderByComparator)
10520                    throws SystemException {
10521                    boolean pagination = true;
10522                    FinderPath finderPath = null;
10523                    Object[] finderArgs = null;
10524    
10525                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10526                                    (orderByComparator == null)) {
10527                            pagination = false;
10528                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT;
10529                            finderArgs = new Object[] { groupId, urlTitle };
10530                    }
10531                    else {
10532                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT;
10533                            finderArgs = new Object[] {
10534                                            groupId, urlTitle,
10535                                            
10536                                            start, end, orderByComparator
10537                                    };
10538                    }
10539    
10540                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
10541                                    finderArgs, this);
10542    
10543                    if ((list != null) && !list.isEmpty()) {
10544                            for (JournalArticle journalArticle : list) {
10545                                    if ((groupId != journalArticle.getGroupId()) ||
10546                                                    !Validator.equals(urlTitle, journalArticle.getUrlTitle())) {
10547                                            list = null;
10548    
10549                                            break;
10550                                    }
10551                            }
10552                    }
10553    
10554                    if (list == null) {
10555                            StringBundler query = null;
10556    
10557                            if (orderByComparator != null) {
10558                                    query = new StringBundler(4 +
10559                                                    (orderByComparator.getOrderByFields().length * 3));
10560                            }
10561                            else {
10562                                    query = new StringBundler(4);
10563                            }
10564    
10565                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10566    
10567                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10568    
10569                            boolean bindUrlTitle = false;
10570    
10571                            if (urlTitle == null) {
10572                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10573                            }
10574                            else if (urlTitle.equals(StringPool.BLANK)) {
10575                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
10576                            }
10577                            else {
10578                                    bindUrlTitle = true;
10579    
10580                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
10581                            }
10582    
10583                            if (orderByComparator != null) {
10584                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10585                                            orderByComparator);
10586                            }
10587                            else
10588                             if (pagination) {
10589                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10590                            }
10591    
10592                            String sql = query.toString();
10593    
10594                            Session session = null;
10595    
10596                            try {
10597                                    session = openSession();
10598    
10599                                    Query q = session.createQuery(sql);
10600    
10601                                    QueryPos qPos = QueryPos.getInstance(q);
10602    
10603                                    qPos.add(groupId);
10604    
10605                                    if (bindUrlTitle) {
10606                                            qPos.add(urlTitle);
10607                                    }
10608    
10609                                    if (!pagination) {
10610                                            list = (List<JournalArticle>)QueryUtil.list(q,
10611                                                            getDialect(), start, end, false);
10612    
10613                                            Collections.sort(list);
10614    
10615                                            list = new UnmodifiableList<JournalArticle>(list);
10616                                    }
10617                                    else {
10618                                            list = (List<JournalArticle>)QueryUtil.list(q,
10619                                                            getDialect(), start, end);
10620                                    }
10621    
10622                                    cacheResult(list);
10623    
10624                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
10625                            }
10626                            catch (Exception e) {
10627                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10628    
10629                                    throw processException(e);
10630                            }
10631                            finally {
10632                                    closeSession(session);
10633                            }
10634                    }
10635    
10636                    return list;
10637            }
10638    
10639            /**
10640             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10641             *
10642             * @param groupId the group ID
10643             * @param urlTitle the url title
10644             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10645             * @return the first matching journal article
10646             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10647             * @throws SystemException if a system exception occurred
10648             */
10649            @Override
10650            public JournalArticle findByG_UT_First(long groupId, String urlTitle,
10651                    OrderByComparator orderByComparator)
10652                    throws NoSuchArticleException, SystemException {
10653                    JournalArticle journalArticle = fetchByG_UT_First(groupId, urlTitle,
10654                                    orderByComparator);
10655    
10656                    if (journalArticle != null) {
10657                            return journalArticle;
10658                    }
10659    
10660                    StringBundler msg = new StringBundler(6);
10661    
10662                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10663    
10664                    msg.append("groupId=");
10665                    msg.append(groupId);
10666    
10667                    msg.append(", urlTitle=");
10668                    msg.append(urlTitle);
10669    
10670                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10671    
10672                    throw new NoSuchArticleException(msg.toString());
10673            }
10674    
10675            /**
10676             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10677             *
10678             * @param groupId the group ID
10679             * @param urlTitle the url title
10680             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10681             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
10682             * @throws SystemException if a system exception occurred
10683             */
10684            @Override
10685            public JournalArticle fetchByG_UT_First(long groupId, String urlTitle,
10686                    OrderByComparator orderByComparator) throws SystemException {
10687                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, 0, 1,
10688                                    orderByComparator);
10689    
10690                    if (!list.isEmpty()) {
10691                            return list.get(0);
10692                    }
10693    
10694                    return null;
10695            }
10696    
10697            /**
10698             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10699             *
10700             * @param groupId the group ID
10701             * @param urlTitle the url title
10702             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10703             * @return the last matching journal article
10704             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10705             * @throws SystemException if a system exception occurred
10706             */
10707            @Override
10708            public JournalArticle findByG_UT_Last(long groupId, String urlTitle,
10709                    OrderByComparator orderByComparator)
10710                    throws NoSuchArticleException, SystemException {
10711                    JournalArticle journalArticle = fetchByG_UT_Last(groupId, urlTitle,
10712                                    orderByComparator);
10713    
10714                    if (journalArticle != null) {
10715                            return journalArticle;
10716                    }
10717    
10718                    StringBundler msg = new StringBundler(6);
10719    
10720                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10721    
10722                    msg.append("groupId=");
10723                    msg.append(groupId);
10724    
10725                    msg.append(", urlTitle=");
10726                    msg.append(urlTitle);
10727    
10728                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10729    
10730                    throw new NoSuchArticleException(msg.toString());
10731            }
10732    
10733            /**
10734             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10735             *
10736             * @param groupId the group ID
10737             * @param urlTitle the url title
10738             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10739             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
10740             * @throws SystemException if a system exception occurred
10741             */
10742            @Override
10743            public JournalArticle fetchByG_UT_Last(long groupId, String urlTitle,
10744                    OrderByComparator orderByComparator) throws SystemException {
10745                    int count = countByG_UT(groupId, urlTitle);
10746    
10747                    if (count == 0) {
10748                            return null;
10749                    }
10750    
10751                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, count - 1,
10752                                    count, orderByComparator);
10753    
10754                    if (!list.isEmpty()) {
10755                            return list.get(0);
10756                    }
10757    
10758                    return null;
10759            }
10760    
10761            /**
10762             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10763             *
10764             * @param id the primary key of the current journal article
10765             * @param groupId the group ID
10766             * @param urlTitle the url title
10767             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10768             * @return the previous, current, and next journal article
10769             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10770             * @throws SystemException if a system exception occurred
10771             */
10772            @Override
10773            public JournalArticle[] findByG_UT_PrevAndNext(long id, long groupId,
10774                    String urlTitle, OrderByComparator orderByComparator)
10775                    throws NoSuchArticleException, SystemException {
10776                    JournalArticle journalArticle = findByPrimaryKey(id);
10777    
10778                    Session session = null;
10779    
10780                    try {
10781                            session = openSession();
10782    
10783                            JournalArticle[] array = new JournalArticleImpl[3];
10784    
10785                            array[0] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
10786                                            urlTitle, orderByComparator, true);
10787    
10788                            array[1] = journalArticle;
10789    
10790                            array[2] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
10791                                            urlTitle, orderByComparator, false);
10792    
10793                            return array;
10794                    }
10795                    catch (Exception e) {
10796                            throw processException(e);
10797                    }
10798                    finally {
10799                            closeSession(session);
10800                    }
10801            }
10802    
10803            protected JournalArticle getByG_UT_PrevAndNext(Session session,
10804                    JournalArticle journalArticle, long groupId, String urlTitle,
10805                    OrderByComparator orderByComparator, boolean previous) {
10806                    StringBundler query = null;
10807    
10808                    if (orderByComparator != null) {
10809                            query = new StringBundler(6 +
10810                                            (orderByComparator.getOrderByFields().length * 6));
10811                    }
10812                    else {
10813                            query = new StringBundler(3);
10814                    }
10815    
10816                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10817    
10818                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10819    
10820                    boolean bindUrlTitle = false;
10821    
10822                    if (urlTitle == null) {
10823                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10824                    }
10825                    else if (urlTitle.equals(StringPool.BLANK)) {
10826                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
10827                    }
10828                    else {
10829                            bindUrlTitle = true;
10830    
10831                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
10832                    }
10833    
10834                    if (orderByComparator != null) {
10835                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10836    
10837                            if (orderByConditionFields.length > 0) {
10838                                    query.append(WHERE_AND);
10839                            }
10840    
10841                            for (int i = 0; i < orderByConditionFields.length; i++) {
10842                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10843                                    query.append(orderByConditionFields[i]);
10844    
10845                                    if ((i + 1) < orderByConditionFields.length) {
10846                                            if (orderByComparator.isAscending() ^ previous) {
10847                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10848                                            }
10849                                            else {
10850                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10851                                            }
10852                                    }
10853                                    else {
10854                                            if (orderByComparator.isAscending() ^ previous) {
10855                                                    query.append(WHERE_GREATER_THAN);
10856                                            }
10857                                            else {
10858                                                    query.append(WHERE_LESSER_THAN);
10859                                            }
10860                                    }
10861                            }
10862    
10863                            query.append(ORDER_BY_CLAUSE);
10864    
10865                            String[] orderByFields = orderByComparator.getOrderByFields();
10866    
10867                            for (int i = 0; i < orderByFields.length; i++) {
10868                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10869                                    query.append(orderByFields[i]);
10870    
10871                                    if ((i + 1) < orderByFields.length) {
10872                                            if (orderByComparator.isAscending() ^ previous) {
10873                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10874                                            }
10875                                            else {
10876                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10877                                            }
10878                                    }
10879                                    else {
10880                                            if (orderByComparator.isAscending() ^ previous) {
10881                                                    query.append(ORDER_BY_ASC);
10882                                            }
10883                                            else {
10884                                                    query.append(ORDER_BY_DESC);
10885                                            }
10886                                    }
10887                            }
10888                    }
10889                    else {
10890                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10891                    }
10892    
10893                    String sql = query.toString();
10894    
10895                    Query q = session.createQuery(sql);
10896    
10897                    q.setFirstResult(0);
10898                    q.setMaxResults(2);
10899    
10900                    QueryPos qPos = QueryPos.getInstance(q);
10901    
10902                    qPos.add(groupId);
10903    
10904                    if (bindUrlTitle) {
10905                            qPos.add(urlTitle);
10906                    }
10907    
10908                    if (orderByComparator != null) {
10909                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10910    
10911                            for (Object value : values) {
10912                                    qPos.add(value);
10913                            }
10914                    }
10915    
10916                    List<JournalArticle> list = q.list();
10917    
10918                    if (list.size() == 2) {
10919                            return list.get(1);
10920                    }
10921                    else {
10922                            return null;
10923                    }
10924            }
10925    
10926            /**
10927             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
10928             *
10929             * @param groupId the group ID
10930             * @param urlTitle the url title
10931             * @return the matching journal articles that the user has permission to view
10932             * @throws SystemException if a system exception occurred
10933             */
10934            @Override
10935            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle)
10936                    throws SystemException {
10937                    return filterFindByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
10938                            QueryUtil.ALL_POS, null);
10939            }
10940    
10941            /**
10942             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
10943             *
10944             * <p>
10945             * 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.
10946             * </p>
10947             *
10948             * @param groupId the group ID
10949             * @param urlTitle the url title
10950             * @param start the lower bound of the range of journal articles
10951             * @param end the upper bound of the range of journal articles (not inclusive)
10952             * @return the range of matching journal articles that the user has permission to view
10953             * @throws SystemException if a system exception occurred
10954             */
10955            @Override
10956            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
10957                    int start, int end) throws SystemException {
10958                    return filterFindByG_UT(groupId, urlTitle, start, end, null);
10959            }
10960    
10961            /**
10962             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and urlTitle = &#63;.
10963             *
10964             * <p>
10965             * 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.
10966             * </p>
10967             *
10968             * @param groupId the group ID
10969             * @param urlTitle the url title
10970             * @param start the lower bound of the range of journal articles
10971             * @param end the upper bound of the range of journal articles (not inclusive)
10972             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10973             * @return the ordered range of matching journal articles that the user has permission to view
10974             * @throws SystemException if a system exception occurred
10975             */
10976            @Override
10977            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
10978                    int start, int end, OrderByComparator orderByComparator)
10979                    throws SystemException {
10980                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10981                            return findByG_UT(groupId, urlTitle, start, end, orderByComparator);
10982                    }
10983    
10984                    StringBundler query = null;
10985    
10986                    if (orderByComparator != null) {
10987                            query = new StringBundler(4 +
10988                                            (orderByComparator.getOrderByFields().length * 3));
10989                    }
10990                    else {
10991                            query = new StringBundler(4);
10992                    }
10993    
10994                    if (getDB().isSupportsInlineDistinct()) {
10995                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
10996                    }
10997                    else {
10998                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
10999                    }
11000    
11001                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
11002    
11003                    boolean bindUrlTitle = false;
11004    
11005                    if (urlTitle == null) {
11006                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
11007                    }
11008                    else if (urlTitle.equals(StringPool.BLANK)) {
11009                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
11010                    }
11011                    else {
11012                            bindUrlTitle = true;
11013    
11014                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
11015                    }
11016    
11017                    if (!getDB().isSupportsInlineDistinct()) {
11018                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11019                    }
11020    
11021                    if (orderByComparator != null) {
11022                            if (getDB().isSupportsInlineDistinct()) {
11023                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11024                                            orderByComparator, true);
11025                            }
11026                            else {
11027                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11028                                            orderByComparator, true);
11029                            }
11030                    }
11031                    else {
11032                            if (getDB().isSupportsInlineDistinct()) {
11033                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11034                            }
11035                            else {
11036                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11037                            }
11038                    }
11039    
11040                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11041                                    JournalArticle.class.getName(),
11042                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11043    
11044                    Session session = null;
11045    
11046                    try {
11047                            session = openSession();
11048    
11049                            SQLQuery q = session.createSQLQuery(sql);
11050    
11051                            if (getDB().isSupportsInlineDistinct()) {
11052                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11053                            }
11054                            else {
11055                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11056                            }
11057    
11058                            QueryPos qPos = QueryPos.getInstance(q);
11059    
11060                            qPos.add(groupId);
11061    
11062                            if (bindUrlTitle) {
11063                                    qPos.add(urlTitle);
11064                            }
11065    
11066                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
11067                                    end);
11068                    }
11069                    catch (Exception e) {
11070                            throw processException(e);
11071                    }
11072                    finally {
11073                            closeSession(session);
11074                    }
11075            }
11076    
11077            /**
11078             * 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;.
11079             *
11080             * @param id the primary key of the current journal article
11081             * @param groupId the group ID
11082             * @param urlTitle the url title
11083             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11084             * @return the previous, current, and next journal article
11085             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11086             * @throws SystemException if a system exception occurred
11087             */
11088            @Override
11089            public JournalArticle[] filterFindByG_UT_PrevAndNext(long id, long groupId,
11090                    String urlTitle, OrderByComparator orderByComparator)
11091                    throws NoSuchArticleException, SystemException {
11092                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11093                            return findByG_UT_PrevAndNext(id, groupId, urlTitle,
11094                                    orderByComparator);
11095                    }
11096    
11097                    JournalArticle journalArticle = findByPrimaryKey(id);
11098    
11099                    Session session = null;
11100    
11101                    try {
11102                            session = openSession();
11103    
11104                            JournalArticle[] array = new JournalArticleImpl[3];
11105    
11106                            array[0] = filterGetByG_UT_PrevAndNext(session, journalArticle,
11107                                            groupId, urlTitle, orderByComparator, true);
11108    
11109                            array[1] = journalArticle;
11110    
11111                            array[2] = filterGetByG_UT_PrevAndNext(session, journalArticle,
11112                                            groupId, urlTitle, orderByComparator, false);
11113    
11114                            return array;
11115                    }
11116                    catch (Exception e) {
11117                            throw processException(e);
11118                    }
11119                    finally {
11120                            closeSession(session);
11121                    }
11122            }
11123    
11124            protected JournalArticle filterGetByG_UT_PrevAndNext(Session session,
11125                    JournalArticle journalArticle, long groupId, String urlTitle,
11126                    OrderByComparator orderByComparator, boolean previous) {
11127                    StringBundler query = null;
11128    
11129                    if (orderByComparator != null) {
11130                            query = new StringBundler(6 +
11131                                            (orderByComparator.getOrderByFields().length * 6));
11132                    }
11133                    else {
11134                            query = new StringBundler(3);
11135                    }
11136    
11137                    if (getDB().isSupportsInlineDistinct()) {
11138                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11139                    }
11140                    else {
11141                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11142                    }
11143    
11144                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
11145    
11146                    boolean bindUrlTitle = false;
11147    
11148                    if (urlTitle == null) {
11149                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
11150                    }
11151                    else if (urlTitle.equals(StringPool.BLANK)) {
11152                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
11153                    }
11154                    else {
11155                            bindUrlTitle = true;
11156    
11157                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
11158                    }
11159    
11160                    if (!getDB().isSupportsInlineDistinct()) {
11161                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11162                    }
11163    
11164                    if (orderByComparator != null) {
11165                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11166    
11167                            if (orderByConditionFields.length > 0) {
11168                                    query.append(WHERE_AND);
11169                            }
11170    
11171                            for (int i = 0; i < orderByConditionFields.length; i++) {
11172                                    if (getDB().isSupportsInlineDistinct()) {
11173                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11174                                    }
11175                                    else {
11176                                            query.append(_ORDER_BY_ENTITY_TABLE);
11177                                    }
11178    
11179                                    query.append(orderByConditionFields[i]);
11180    
11181                                    if ((i + 1) < orderByConditionFields.length) {
11182                                            if (orderByComparator.isAscending() ^ previous) {
11183                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11184                                            }
11185                                            else {
11186                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11187                                            }
11188                                    }
11189                                    else {
11190                                            if (orderByComparator.isAscending() ^ previous) {
11191                                                    query.append(WHERE_GREATER_THAN);
11192                                            }
11193                                            else {
11194                                                    query.append(WHERE_LESSER_THAN);
11195                                            }
11196                                    }
11197                            }
11198    
11199                            query.append(ORDER_BY_CLAUSE);
11200    
11201                            String[] orderByFields = orderByComparator.getOrderByFields();
11202    
11203                            for (int i = 0; i < orderByFields.length; i++) {
11204                                    if (getDB().isSupportsInlineDistinct()) {
11205                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11206                                    }
11207                                    else {
11208                                            query.append(_ORDER_BY_ENTITY_TABLE);
11209                                    }
11210    
11211                                    query.append(orderByFields[i]);
11212    
11213                                    if ((i + 1) < orderByFields.length) {
11214                                            if (orderByComparator.isAscending() ^ previous) {
11215                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11216                                            }
11217                                            else {
11218                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11219                                            }
11220                                    }
11221                                    else {
11222                                            if (orderByComparator.isAscending() ^ previous) {
11223                                                    query.append(ORDER_BY_ASC);
11224                                            }
11225                                            else {
11226                                                    query.append(ORDER_BY_DESC);
11227                                            }
11228                                    }
11229                            }
11230                    }
11231                    else {
11232                            if (getDB().isSupportsInlineDistinct()) {
11233                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11234                            }
11235                            else {
11236                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11237                            }
11238                    }
11239    
11240                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11241                                    JournalArticle.class.getName(),
11242                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11243    
11244                    SQLQuery q = session.createSQLQuery(sql);
11245    
11246                    q.setFirstResult(0);
11247                    q.setMaxResults(2);
11248    
11249                    if (getDB().isSupportsInlineDistinct()) {
11250                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11251                    }
11252                    else {
11253                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11254                    }
11255    
11256                    QueryPos qPos = QueryPos.getInstance(q);
11257    
11258                    qPos.add(groupId);
11259    
11260                    if (bindUrlTitle) {
11261                            qPos.add(urlTitle);
11262                    }
11263    
11264                    if (orderByComparator != null) {
11265                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11266    
11267                            for (Object value : values) {
11268                                    qPos.add(value);
11269                            }
11270                    }
11271    
11272                    List<JournalArticle> list = q.list();
11273    
11274                    if (list.size() == 2) {
11275                            return list.get(1);
11276                    }
11277                    else {
11278                            return null;
11279                    }
11280            }
11281    
11282            /**
11283             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; from the database.
11284             *
11285             * @param groupId the group ID
11286             * @param urlTitle the url title
11287             * @throws SystemException if a system exception occurred
11288             */
11289            @Override
11290            public void removeByG_UT(long groupId, String urlTitle)
11291                    throws SystemException {
11292                    for (JournalArticle journalArticle : findByG_UT(groupId, urlTitle,
11293                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
11294                            remove(journalArticle);
11295                    }
11296            }
11297    
11298            /**
11299             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63;.
11300             *
11301             * @param groupId the group ID
11302             * @param urlTitle the url title
11303             * @return the number of matching journal articles
11304             * @throws SystemException if a system exception occurred
11305             */
11306            @Override
11307            public int countByG_UT(long groupId, String urlTitle)
11308                    throws SystemException {
11309                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT;
11310    
11311                    Object[] finderArgs = new Object[] { groupId, urlTitle };
11312    
11313                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
11314                                    this);
11315    
11316                    if (count == null) {
11317                            StringBundler query = new StringBundler(3);
11318    
11319                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
11320    
11321                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
11322    
11323                            boolean bindUrlTitle = false;
11324    
11325                            if (urlTitle == null) {
11326                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
11327                            }
11328                            else if (urlTitle.equals(StringPool.BLANK)) {
11329                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
11330                            }
11331                            else {
11332                                    bindUrlTitle = true;
11333    
11334                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
11335                            }
11336    
11337                            String sql = query.toString();
11338    
11339                            Session session = null;
11340    
11341                            try {
11342                                    session = openSession();
11343    
11344                                    Query q = session.createQuery(sql);
11345    
11346                                    QueryPos qPos = QueryPos.getInstance(q);
11347    
11348                                    qPos.add(groupId);
11349    
11350                                    if (bindUrlTitle) {
11351                                            qPos.add(urlTitle);
11352                                    }
11353    
11354                                    count = (Long)q.uniqueResult();
11355    
11356                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
11357                            }
11358                            catch (Exception e) {
11359                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11360    
11361                                    throw processException(e);
11362                            }
11363                            finally {
11364                                    closeSession(session);
11365                            }
11366                    }
11367    
11368                    return count.intValue();
11369            }
11370    
11371            /**
11372             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
11373             *
11374             * @param groupId the group ID
11375             * @param urlTitle the url title
11376             * @return the number of matching journal articles that the user has permission to view
11377             * @throws SystemException if a system exception occurred
11378             */
11379            @Override
11380            public int filterCountByG_UT(long groupId, String urlTitle)
11381                    throws SystemException {
11382                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11383                            return countByG_UT(groupId, urlTitle);
11384                    }
11385    
11386                    StringBundler query = new StringBundler(3);
11387    
11388                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
11389    
11390                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
11391    
11392                    boolean bindUrlTitle = false;
11393    
11394                    if (urlTitle == null) {
11395                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
11396                    }
11397                    else if (urlTitle.equals(StringPool.BLANK)) {
11398                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
11399                    }
11400                    else {
11401                            bindUrlTitle = true;
11402    
11403                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
11404                    }
11405    
11406                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11407                                    JournalArticle.class.getName(),
11408                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11409    
11410                    Session session = null;
11411    
11412                    try {
11413                            session = openSession();
11414    
11415                            SQLQuery q = session.createSQLQuery(sql);
11416    
11417                            q.addScalar(COUNT_COLUMN_NAME,
11418                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11419    
11420                            QueryPos qPos = QueryPos.getInstance(q);
11421    
11422                            qPos.add(groupId);
11423    
11424                            if (bindUrlTitle) {
11425                                    qPos.add(urlTitle);
11426                            }
11427    
11428                            Long count = (Long)q.uniqueResult();
11429    
11430                            return count.intValue();
11431                    }
11432                    catch (Exception e) {
11433                            throw processException(e);
11434                    }
11435                    finally {
11436                            closeSession(session);
11437                    }
11438            }
11439    
11440            private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "journalArticle.groupId = ? AND ";
11441            private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "journalArticle.urlTitle IS NULL";
11442            private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "journalArticle.urlTitle = ?";
11443            private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = '')";
11444            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11445                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
11446                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
11447                            "findByG_S",
11448                            new String[] {
11449                                    Long.class.getName(), String.class.getName(),
11450                                    
11451                            Integer.class.getName(), Integer.class.getName(),
11452                                    OrderByComparator.class.getName()
11453                            });
11454            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11455                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
11456                            JournalArticleImpl.class,
11457                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
11458                            new String[] { Long.class.getName(), String.class.getName() },
11459                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
11460                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK |
11461                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
11462                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
11463            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11464                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
11465                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
11466                            new String[] { Long.class.getName(), String.class.getName() });
11467    
11468            /**
11469             * Returns all the journal articles where groupId = &#63; and structureId = &#63;.
11470             *
11471             * @param groupId the group ID
11472             * @param structureId the structure ID
11473             * @return the matching journal articles
11474             * @throws SystemException if a system exception occurred
11475             */
11476            @Override
11477            public List<JournalArticle> findByG_S(long groupId, String structureId)
11478                    throws SystemException {
11479                    return findByG_S(groupId, structureId, QueryUtil.ALL_POS,
11480                            QueryUtil.ALL_POS, null);
11481            }
11482    
11483            /**
11484             * Returns a range of all the journal articles where groupId = &#63; and structureId = &#63;.
11485             *
11486             * <p>
11487             * 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.
11488             * </p>
11489             *
11490             * @param groupId the group ID
11491             * @param structureId the structure ID
11492             * @param start the lower bound of the range of journal articles
11493             * @param end the upper bound of the range of journal articles (not inclusive)
11494             * @return the range of matching journal articles
11495             * @throws SystemException if a system exception occurred
11496             */
11497            @Override
11498            public List<JournalArticle> findByG_S(long groupId, String structureId,
11499                    int start, int end) throws SystemException {
11500                    return findByG_S(groupId, structureId, start, end, null);
11501            }
11502    
11503            /**
11504             * Returns an ordered range of all the journal articles where groupId = &#63; and structureId = &#63;.
11505             *
11506             * <p>
11507             * 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.
11508             * </p>
11509             *
11510             * @param groupId the group ID
11511             * @param structureId the structure ID
11512             * @param start the lower bound of the range of journal articles
11513             * @param end the upper bound of the range of journal articles (not inclusive)
11514             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11515             * @return the ordered range of matching journal articles
11516             * @throws SystemException if a system exception occurred
11517             */
11518            @Override
11519            public List<JournalArticle> findByG_S(long groupId, String structureId,
11520                    int start, int end, OrderByComparator orderByComparator)
11521                    throws SystemException {
11522                    boolean pagination = true;
11523                    FinderPath finderPath = null;
11524                    Object[] finderArgs = null;
11525    
11526                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11527                                    (orderByComparator == null)) {
11528                            pagination = false;
11529                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
11530                            finderArgs = new Object[] { groupId, structureId };
11531                    }
11532                    else {
11533                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
11534                            finderArgs = new Object[] {
11535                                            groupId, structureId,
11536                                            
11537                                            start, end, orderByComparator
11538                                    };
11539                    }
11540    
11541                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
11542                                    finderArgs, this);
11543    
11544                    if ((list != null) && !list.isEmpty()) {
11545                            for (JournalArticle journalArticle : list) {
11546                                    if ((groupId != journalArticle.getGroupId()) ||
11547                                                    !Validator.equals(structureId,
11548                                                            journalArticle.getStructureId())) {
11549                                            list = null;
11550    
11551                                            break;
11552                                    }
11553                            }
11554                    }
11555    
11556                    if (list == null) {
11557                            StringBundler query = null;
11558    
11559                            if (orderByComparator != null) {
11560                                    query = new StringBundler(4 +
11561                                                    (orderByComparator.getOrderByFields().length * 3));
11562                            }
11563                            else {
11564                                    query = new StringBundler(4);
11565                            }
11566    
11567                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11568    
11569                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
11570    
11571                            boolean bindStructureId = false;
11572    
11573                            if (structureId == null) {
11574                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
11575                            }
11576                            else if (structureId.equals(StringPool.BLANK)) {
11577                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
11578                            }
11579                            else {
11580                                    bindStructureId = true;
11581    
11582                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
11583                            }
11584    
11585                            if (orderByComparator != null) {
11586                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11587                                            orderByComparator);
11588                            }
11589                            else
11590                             if (pagination) {
11591                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11592                            }
11593    
11594                            String sql = query.toString();
11595    
11596                            Session session = null;
11597    
11598                            try {
11599                                    session = openSession();
11600    
11601                                    Query q = session.createQuery(sql);
11602    
11603                                    QueryPos qPos = QueryPos.getInstance(q);
11604    
11605                                    qPos.add(groupId);
11606    
11607                                    if (bindStructureId) {
11608                                            qPos.add(structureId);
11609                                    }
11610    
11611                                    if (!pagination) {
11612                                            list = (List<JournalArticle>)QueryUtil.list(q,
11613                                                            getDialect(), start, end, false);
11614    
11615                                            Collections.sort(list);
11616    
11617                                            list = new UnmodifiableList<JournalArticle>(list);
11618                                    }
11619                                    else {
11620                                            list = (List<JournalArticle>)QueryUtil.list(q,
11621                                                            getDialect(), start, end);
11622                                    }
11623    
11624                                    cacheResult(list);
11625    
11626                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
11627                            }
11628                            catch (Exception e) {
11629                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11630    
11631                                    throw processException(e);
11632                            }
11633                            finally {
11634                                    closeSession(session);
11635                            }
11636                    }
11637    
11638                    return list;
11639            }
11640    
11641            /**
11642             * Returns the first journal article in the ordered set where groupId = &#63; and structureId = &#63;.
11643             *
11644             * @param groupId the group ID
11645             * @param structureId the structure ID
11646             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11647             * @return the first matching journal article
11648             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11649             * @throws SystemException if a system exception occurred
11650             */
11651            @Override
11652            public JournalArticle findByG_S_First(long groupId, String structureId,
11653                    OrderByComparator orderByComparator)
11654                    throws NoSuchArticleException, SystemException {
11655                    JournalArticle journalArticle = fetchByG_S_First(groupId, structureId,
11656                                    orderByComparator);
11657    
11658                    if (journalArticle != null) {
11659                            return journalArticle;
11660                    }
11661    
11662                    StringBundler msg = new StringBundler(6);
11663    
11664                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11665    
11666                    msg.append("groupId=");
11667                    msg.append(groupId);
11668    
11669                    msg.append(", structureId=");
11670                    msg.append(structureId);
11671    
11672                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11673    
11674                    throw new NoSuchArticleException(msg.toString());
11675            }
11676    
11677            /**
11678             * Returns the first journal article in the ordered set where groupId = &#63; and structureId = &#63;.
11679             *
11680             * @param groupId the group ID
11681             * @param structureId the structure ID
11682             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11683             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
11684             * @throws SystemException if a system exception occurred
11685             */
11686            @Override
11687            public JournalArticle fetchByG_S_First(long groupId, String structureId,
11688                    OrderByComparator orderByComparator) throws SystemException {
11689                    List<JournalArticle> list = findByG_S(groupId, structureId, 0, 1,
11690                                    orderByComparator);
11691    
11692                    if (!list.isEmpty()) {
11693                            return list.get(0);
11694                    }
11695    
11696                    return null;
11697            }
11698    
11699            /**
11700             * Returns the last journal article in the ordered set where groupId = &#63; and structureId = &#63;.
11701             *
11702             * @param groupId the group ID
11703             * @param structureId the structure ID
11704             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11705             * @return the last matching journal article
11706             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11707             * @throws SystemException if a system exception occurred
11708             */
11709            @Override
11710            public JournalArticle findByG_S_Last(long groupId, String structureId,
11711                    OrderByComparator orderByComparator)
11712                    throws NoSuchArticleException, SystemException {
11713                    JournalArticle journalArticle = fetchByG_S_Last(groupId, structureId,
11714                                    orderByComparator);
11715    
11716                    if (journalArticle != null) {
11717                            return journalArticle;
11718                    }
11719    
11720                    StringBundler msg = new StringBundler(6);
11721    
11722                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11723    
11724                    msg.append("groupId=");
11725                    msg.append(groupId);
11726    
11727                    msg.append(", structureId=");
11728                    msg.append(structureId);
11729    
11730                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11731    
11732                    throw new NoSuchArticleException(msg.toString());
11733            }
11734    
11735            /**
11736             * Returns the last journal article in the ordered set where groupId = &#63; and structureId = &#63;.
11737             *
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 last matching journal article, or <code>null</code> if a matching journal article could not be found
11742             * @throws SystemException if a system exception occurred
11743             */
11744            @Override
11745            public JournalArticle fetchByG_S_Last(long groupId, String structureId,
11746                    OrderByComparator orderByComparator) throws SystemException {
11747                    int count = countByG_S(groupId, structureId);
11748    
11749                    if (count == 0) {
11750                            return null;
11751                    }
11752    
11753                    List<JournalArticle> list = findByG_S(groupId, structureId, count - 1,
11754                                    count, orderByComparator);
11755    
11756                    if (!list.isEmpty()) {
11757                            return list.get(0);
11758                    }
11759    
11760                    return null;
11761            }
11762    
11763            /**
11764             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and structureId = &#63;.
11765             *
11766             * @param id the primary key of the current journal article
11767             * @param groupId the group ID
11768             * @param structureId the structure ID
11769             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11770             * @return the previous, current, and next journal article
11771             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11772             * @throws SystemException if a system exception occurred
11773             */
11774            @Override
11775            public JournalArticle[] findByG_S_PrevAndNext(long id, long groupId,
11776                    String structureId, OrderByComparator orderByComparator)
11777                    throws NoSuchArticleException, SystemException {
11778                    JournalArticle journalArticle = findByPrimaryKey(id);
11779    
11780                    Session session = null;
11781    
11782                    try {
11783                            session = openSession();
11784    
11785                            JournalArticle[] array = new JournalArticleImpl[3];
11786    
11787                            array[0] = getByG_S_PrevAndNext(session, journalArticle, groupId,
11788                                            structureId, orderByComparator, true);
11789    
11790                            array[1] = journalArticle;
11791    
11792                            array[2] = getByG_S_PrevAndNext(session, journalArticle, groupId,
11793                                            structureId, orderByComparator, false);
11794    
11795                            return array;
11796                    }
11797                    catch (Exception e) {
11798                            throw processException(e);
11799                    }
11800                    finally {
11801                            closeSession(session);
11802                    }
11803            }
11804    
11805            protected JournalArticle getByG_S_PrevAndNext(Session session,
11806                    JournalArticle journalArticle, long groupId, String structureId,
11807                    OrderByComparator orderByComparator, boolean previous) {
11808                    StringBundler query = null;
11809    
11810                    if (orderByComparator != null) {
11811                            query = new StringBundler(6 +
11812                                            (orderByComparator.getOrderByFields().length * 6));
11813                    }
11814                    else {
11815                            query = new StringBundler(3);
11816                    }
11817    
11818                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11819    
11820                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
11821    
11822                    boolean bindStructureId = false;
11823    
11824                    if (structureId == null) {
11825                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
11826                    }
11827                    else if (structureId.equals(StringPool.BLANK)) {
11828                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
11829                    }
11830                    else {
11831                            bindStructureId = true;
11832    
11833                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
11834                    }
11835    
11836                    if (orderByComparator != null) {
11837                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11838    
11839                            if (orderByConditionFields.length > 0) {
11840                                    query.append(WHERE_AND);
11841                            }
11842    
11843                            for (int i = 0; i < orderByConditionFields.length; i++) {
11844                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11845                                    query.append(orderByConditionFields[i]);
11846    
11847                                    if ((i + 1) < orderByConditionFields.length) {
11848                                            if (orderByComparator.isAscending() ^ previous) {
11849                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11850                                            }
11851                                            else {
11852                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11853                                            }
11854                                    }
11855                                    else {
11856                                            if (orderByComparator.isAscending() ^ previous) {
11857                                                    query.append(WHERE_GREATER_THAN);
11858                                            }
11859                                            else {
11860                                                    query.append(WHERE_LESSER_THAN);
11861                                            }
11862                                    }
11863                            }
11864    
11865                            query.append(ORDER_BY_CLAUSE);
11866    
11867                            String[] orderByFields = orderByComparator.getOrderByFields();
11868    
11869                            for (int i = 0; i < orderByFields.length; i++) {
11870                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11871                                    query.append(orderByFields[i]);
11872    
11873                                    if ((i + 1) < orderByFields.length) {
11874                                            if (orderByComparator.isAscending() ^ previous) {
11875                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11876                                            }
11877                                            else {
11878                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11879                                            }
11880                                    }
11881                                    else {
11882                                            if (orderByComparator.isAscending() ^ previous) {
11883                                                    query.append(ORDER_BY_ASC);
11884                                            }
11885                                            else {
11886                                                    query.append(ORDER_BY_DESC);
11887                                            }
11888                                    }
11889                            }
11890                    }
11891                    else {
11892                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11893                    }
11894    
11895                    String sql = query.toString();
11896    
11897                    Query q = session.createQuery(sql);
11898    
11899                    q.setFirstResult(0);
11900                    q.setMaxResults(2);
11901    
11902                    QueryPos qPos = QueryPos.getInstance(q);
11903    
11904                    qPos.add(groupId);
11905    
11906                    if (bindStructureId) {
11907                            qPos.add(structureId);
11908                    }
11909    
11910                    if (orderByComparator != null) {
11911                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11912    
11913                            for (Object value : values) {
11914                                    qPos.add(value);
11915                            }
11916                    }
11917    
11918                    List<JournalArticle> list = q.list();
11919    
11920                    if (list.size() == 2) {
11921                            return list.get(1);
11922                    }
11923                    else {
11924                            return null;
11925                    }
11926            }
11927    
11928            /**
11929             * Returns all the journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
11930             *
11931             * @param groupId the group ID
11932             * @param structureId the structure ID
11933             * @return the matching journal articles that the user has permission to view
11934             * @throws SystemException if a system exception occurred
11935             */
11936            @Override
11937            public List<JournalArticle> filterFindByG_S(long groupId, String structureId)
11938                    throws SystemException {
11939                    return filterFindByG_S(groupId, structureId, QueryUtil.ALL_POS,
11940                            QueryUtil.ALL_POS, null);
11941            }
11942    
11943            /**
11944             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
11945             *
11946             * <p>
11947             * 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.
11948             * </p>
11949             *
11950             * @param groupId the group ID
11951             * @param structureId the structure ID
11952             * @param start the lower bound of the range of journal articles
11953             * @param end the upper bound of the range of journal articles (not inclusive)
11954             * @return the range of matching journal articles that the user has permission to view
11955             * @throws SystemException if a system exception occurred
11956             */
11957            @Override
11958            public List<JournalArticle> filterFindByG_S(long groupId,
11959                    String structureId, int start, int end) throws SystemException {
11960                    return filterFindByG_S(groupId, structureId, start, end, null);
11961            }
11962    
11963            /**
11964             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and structureId = &#63;.
11965             *
11966             * <p>
11967             * 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.
11968             * </p>
11969             *
11970             * @param groupId the group ID
11971             * @param structureId the structure ID
11972             * @param start the lower bound of the range of journal articles
11973             * @param end the upper bound of the range of journal articles (not inclusive)
11974             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11975             * @return the ordered range of matching journal articles that the user has permission to view
11976             * @throws SystemException if a system exception occurred
11977             */
11978            @Override
11979            public List<JournalArticle> filterFindByG_S(long groupId,
11980                    String structureId, int start, int end,
11981                    OrderByComparator orderByComparator) throws SystemException {
11982                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11983                            return findByG_S(groupId, structureId, start, end, orderByComparator);
11984                    }
11985    
11986                    StringBundler query = null;
11987    
11988                    if (orderByComparator != null) {
11989                            query = new StringBundler(4 +
11990                                            (orderByComparator.getOrderByFields().length * 3));
11991                    }
11992                    else {
11993                            query = new StringBundler(4);
11994                    }
11995    
11996                    if (getDB().isSupportsInlineDistinct()) {
11997                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11998                    }
11999                    else {
12000                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12001                    }
12002    
12003                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
12004    
12005                    boolean bindStructureId = false;
12006    
12007                    if (structureId == null) {
12008                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
12009                    }
12010                    else if (structureId.equals(StringPool.BLANK)) {
12011                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
12012                    }
12013                    else {
12014                            bindStructureId = true;
12015    
12016                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
12017                    }
12018    
12019                    if (!getDB().isSupportsInlineDistinct()) {
12020                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12021                    }
12022    
12023                    if (orderByComparator != null) {
12024                            if (getDB().isSupportsInlineDistinct()) {
12025                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12026                                            orderByComparator, true);
12027                            }
12028                            else {
12029                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12030                                            orderByComparator, true);
12031                            }
12032                    }
12033                    else {
12034                            if (getDB().isSupportsInlineDistinct()) {
12035                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12036                            }
12037                            else {
12038                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12039                            }
12040                    }
12041    
12042                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12043                                    JournalArticle.class.getName(),
12044                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12045    
12046                    Session session = null;
12047    
12048                    try {
12049                            session = openSession();
12050    
12051                            SQLQuery q = session.createSQLQuery(sql);
12052    
12053                            if (getDB().isSupportsInlineDistinct()) {
12054                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12055                            }
12056                            else {
12057                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12058                            }
12059    
12060                            QueryPos qPos = QueryPos.getInstance(q);
12061    
12062                            qPos.add(groupId);
12063    
12064                            if (bindStructureId) {
12065                                    qPos.add(structureId);
12066                            }
12067    
12068                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
12069                                    end);
12070                    }
12071                    catch (Exception e) {
12072                            throw processException(e);
12073                    }
12074                    finally {
12075                            closeSession(session);
12076                    }
12077            }
12078    
12079            /**
12080             * 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;.
12081             *
12082             * @param id the primary key of the current journal article
12083             * @param groupId the group ID
12084             * @param structureId the structure ID
12085             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12086             * @return the previous, current, and next journal article
12087             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12088             * @throws SystemException if a system exception occurred
12089             */
12090            @Override
12091            public JournalArticle[] filterFindByG_S_PrevAndNext(long id, long groupId,
12092                    String structureId, OrderByComparator orderByComparator)
12093                    throws NoSuchArticleException, SystemException {
12094                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12095                            return findByG_S_PrevAndNext(id, groupId, structureId,
12096                                    orderByComparator);
12097                    }
12098    
12099                    JournalArticle journalArticle = findByPrimaryKey(id);
12100    
12101                    Session session = null;
12102    
12103                    try {
12104                            session = openSession();
12105    
12106                            JournalArticle[] array = new JournalArticleImpl[3];
12107    
12108                            array[0] = filterGetByG_S_PrevAndNext(session, journalArticle,
12109                                            groupId, structureId, orderByComparator, true);
12110    
12111                            array[1] = journalArticle;
12112    
12113                            array[2] = filterGetByG_S_PrevAndNext(session, journalArticle,
12114                                            groupId, structureId, orderByComparator, false);
12115    
12116                            return array;
12117                    }
12118                    catch (Exception e) {
12119                            throw processException(e);
12120                    }
12121                    finally {
12122                            closeSession(session);
12123                    }
12124            }
12125    
12126            protected JournalArticle filterGetByG_S_PrevAndNext(Session session,
12127                    JournalArticle journalArticle, long groupId, String structureId,
12128                    OrderByComparator orderByComparator, boolean previous) {
12129                    StringBundler query = null;
12130    
12131                    if (orderByComparator != null) {
12132                            query = new StringBundler(6 +
12133                                            (orderByComparator.getOrderByFields().length * 6));
12134                    }
12135                    else {
12136                            query = new StringBundler(3);
12137                    }
12138    
12139                    if (getDB().isSupportsInlineDistinct()) {
12140                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12141                    }
12142                    else {
12143                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12144                    }
12145    
12146                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
12147    
12148                    boolean bindStructureId = false;
12149    
12150                    if (structureId == null) {
12151                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
12152                    }
12153                    else if (structureId.equals(StringPool.BLANK)) {
12154                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
12155                    }
12156                    else {
12157                            bindStructureId = true;
12158    
12159                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
12160                    }
12161    
12162                    if (!getDB().isSupportsInlineDistinct()) {
12163                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12164                    }
12165    
12166                    if (orderByComparator != null) {
12167                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12168    
12169                            if (orderByConditionFields.length > 0) {
12170                                    query.append(WHERE_AND);
12171                            }
12172    
12173                            for (int i = 0; i < orderByConditionFields.length; i++) {
12174                                    if (getDB().isSupportsInlineDistinct()) {
12175                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12176                                    }
12177                                    else {
12178                                            query.append(_ORDER_BY_ENTITY_TABLE);
12179                                    }
12180    
12181                                    query.append(orderByConditionFields[i]);
12182    
12183                                    if ((i + 1) < orderByConditionFields.length) {
12184                                            if (orderByComparator.isAscending() ^ previous) {
12185                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12186                                            }
12187                                            else {
12188                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12189                                            }
12190                                    }
12191                                    else {
12192                                            if (orderByComparator.isAscending() ^ previous) {
12193                                                    query.append(WHERE_GREATER_THAN);
12194                                            }
12195                                            else {
12196                                                    query.append(WHERE_LESSER_THAN);
12197                                            }
12198                                    }
12199                            }
12200    
12201                            query.append(ORDER_BY_CLAUSE);
12202    
12203                            String[] orderByFields = orderByComparator.getOrderByFields();
12204    
12205                            for (int i = 0; i < orderByFields.length; i++) {
12206                                    if (getDB().isSupportsInlineDistinct()) {
12207                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12208                                    }
12209                                    else {
12210                                            query.append(_ORDER_BY_ENTITY_TABLE);
12211                                    }
12212    
12213                                    query.append(orderByFields[i]);
12214    
12215                                    if ((i + 1) < orderByFields.length) {
12216                                            if (orderByComparator.isAscending() ^ previous) {
12217                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12218                                            }
12219                                            else {
12220                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12221                                            }
12222                                    }
12223                                    else {
12224                                            if (orderByComparator.isAscending() ^ previous) {
12225                                                    query.append(ORDER_BY_ASC);
12226                                            }
12227                                            else {
12228                                                    query.append(ORDER_BY_DESC);
12229                                            }
12230                                    }
12231                            }
12232                    }
12233                    else {
12234                            if (getDB().isSupportsInlineDistinct()) {
12235                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12236                            }
12237                            else {
12238                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12239                            }
12240                    }
12241    
12242                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12243                                    JournalArticle.class.getName(),
12244                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12245    
12246                    SQLQuery q = session.createSQLQuery(sql);
12247    
12248                    q.setFirstResult(0);
12249                    q.setMaxResults(2);
12250    
12251                    if (getDB().isSupportsInlineDistinct()) {
12252                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12253                    }
12254                    else {
12255                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12256                    }
12257    
12258                    QueryPos qPos = QueryPos.getInstance(q);
12259    
12260                    qPos.add(groupId);
12261    
12262                    if (bindStructureId) {
12263                            qPos.add(structureId);
12264                    }
12265    
12266                    if (orderByComparator != null) {
12267                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12268    
12269                            for (Object value : values) {
12270                                    qPos.add(value);
12271                            }
12272                    }
12273    
12274                    List<JournalArticle> list = q.list();
12275    
12276                    if (list.size() == 2) {
12277                            return list.get(1);
12278                    }
12279                    else {
12280                            return null;
12281                    }
12282            }
12283    
12284            /**
12285             * Removes all the journal articles where groupId = &#63; and structureId = &#63; from the database.
12286             *
12287             * @param groupId the group ID
12288             * @param structureId the structure ID
12289             * @throws SystemException if a system exception occurred
12290             */
12291            @Override
12292            public void removeByG_S(long groupId, String structureId)
12293                    throws SystemException {
12294                    for (JournalArticle journalArticle : findByG_S(groupId, structureId,
12295                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
12296                            remove(journalArticle);
12297                    }
12298            }
12299    
12300            /**
12301             * Returns the number of journal articles where groupId = &#63; and structureId = &#63;.
12302             *
12303             * @param groupId the group ID
12304             * @param structureId the structure ID
12305             * @return the number of matching journal articles
12306             * @throws SystemException if a system exception occurred
12307             */
12308            @Override
12309            public int countByG_S(long groupId, String structureId)
12310                    throws SystemException {
12311                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
12312    
12313                    Object[] finderArgs = new Object[] { groupId, structureId };
12314    
12315                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
12316                                    this);
12317    
12318                    if (count == null) {
12319                            StringBundler query = new StringBundler(3);
12320    
12321                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
12322    
12323                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
12324    
12325                            boolean bindStructureId = false;
12326    
12327                            if (structureId == null) {
12328                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
12329                            }
12330                            else if (structureId.equals(StringPool.BLANK)) {
12331                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
12332                            }
12333                            else {
12334                                    bindStructureId = true;
12335    
12336                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
12337                            }
12338    
12339                            String sql = query.toString();
12340    
12341                            Session session = null;
12342    
12343                            try {
12344                                    session = openSession();
12345    
12346                                    Query q = session.createQuery(sql);
12347    
12348                                    QueryPos qPos = QueryPos.getInstance(q);
12349    
12350                                    qPos.add(groupId);
12351    
12352                                    if (bindStructureId) {
12353                                            qPos.add(structureId);
12354                                    }
12355    
12356                                    count = (Long)q.uniqueResult();
12357    
12358                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
12359                            }
12360                            catch (Exception e) {
12361                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12362    
12363                                    throw processException(e);
12364                            }
12365                            finally {
12366                                    closeSession(session);
12367                            }
12368                    }
12369    
12370                    return count.intValue();
12371            }
12372    
12373            /**
12374             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
12375             *
12376             * @param groupId the group ID
12377             * @param structureId the structure ID
12378             * @return the number of matching journal articles that the user has permission to view
12379             * @throws SystemException if a system exception occurred
12380             */
12381            @Override
12382            public int filterCountByG_S(long groupId, String structureId)
12383                    throws SystemException {
12384                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12385                            return countByG_S(groupId, structureId);
12386                    }
12387    
12388                    StringBundler query = new StringBundler(3);
12389    
12390                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
12391    
12392                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
12393    
12394                    boolean bindStructureId = false;
12395    
12396                    if (structureId == null) {
12397                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
12398                    }
12399                    else if (structureId.equals(StringPool.BLANK)) {
12400                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
12401                    }
12402                    else {
12403                            bindStructureId = true;
12404    
12405                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
12406                    }
12407    
12408                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12409                                    JournalArticle.class.getName(),
12410                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12411    
12412                    Session session = null;
12413    
12414                    try {
12415                            session = openSession();
12416    
12417                            SQLQuery q = session.createSQLQuery(sql);
12418    
12419                            q.addScalar(COUNT_COLUMN_NAME,
12420                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
12421    
12422                            QueryPos qPos = QueryPos.getInstance(q);
12423    
12424                            qPos.add(groupId);
12425    
12426                            if (bindStructureId) {
12427                                    qPos.add(structureId);
12428                            }
12429    
12430                            Long count = (Long)q.uniqueResult();
12431    
12432                            return count.intValue();
12433                    }
12434                    catch (Exception e) {
12435                            throw processException(e);
12436                    }
12437                    finally {
12438                            closeSession(session);
12439                    }
12440            }
12441    
12442            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
12443            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
12444            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
12445            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = '')";
12446            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12447                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
12448                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
12449                            "findByG_T",
12450                            new String[] {
12451                                    Long.class.getName(), String.class.getName(),
12452                                    
12453                            Integer.class.getName(), Integer.class.getName(),
12454                                    OrderByComparator.class.getName()
12455                            });
12456            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12457                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
12458                            JournalArticleImpl.class,
12459                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_T",
12460                            new String[] { Long.class.getName(), String.class.getName() },
12461                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
12462                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
12463                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
12464                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
12465            public static final FinderPath FINDER_PATH_COUNT_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12466                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
12467                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_T",
12468                            new String[] { Long.class.getName(), String.class.getName() });
12469    
12470            /**
12471             * Returns all the journal articles where groupId = &#63; and templateId = &#63;.
12472             *
12473             * @param groupId the group ID
12474             * @param templateId the template ID
12475             * @return the matching journal articles
12476             * @throws SystemException if a system exception occurred
12477             */
12478            @Override
12479            public List<JournalArticle> findByG_T(long groupId, String templateId)
12480                    throws SystemException {
12481                    return findByG_T(groupId, templateId, QueryUtil.ALL_POS,
12482                            QueryUtil.ALL_POS, null);
12483            }
12484    
12485            /**
12486             * Returns a range of all the journal articles where groupId = &#63; and templateId = &#63;.
12487             *
12488             * <p>
12489             * 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.
12490             * </p>
12491             *
12492             * @param groupId the group ID
12493             * @param templateId the template ID
12494             * @param start the lower bound of the range of journal articles
12495             * @param end the upper bound of the range of journal articles (not inclusive)
12496             * @return the range of matching journal articles
12497             * @throws SystemException if a system exception occurred
12498             */
12499            @Override
12500            public List<JournalArticle> findByG_T(long groupId, String templateId,
12501                    int start, int end) throws SystemException {
12502                    return findByG_T(groupId, templateId, start, end, null);
12503            }
12504    
12505            /**
12506             * Returns an ordered range of all the journal articles where groupId = &#63; and templateId = &#63;.
12507             *
12508             * <p>
12509             * 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.
12510             * </p>
12511             *
12512             * @param groupId the group ID
12513             * @param templateId the template ID
12514             * @param start the lower bound of the range of journal articles
12515             * @param end the upper bound of the range of journal articles (not inclusive)
12516             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12517             * @return the ordered range of matching journal articles
12518             * @throws SystemException if a system exception occurred
12519             */
12520            @Override
12521            public List<JournalArticle> findByG_T(long groupId, String templateId,
12522                    int start, int end, OrderByComparator orderByComparator)
12523                    throws SystemException {
12524                    boolean pagination = true;
12525                    FinderPath finderPath = null;
12526                    Object[] finderArgs = null;
12527    
12528                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12529                                    (orderByComparator == null)) {
12530                            pagination = false;
12531                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T;
12532                            finderArgs = new Object[] { groupId, templateId };
12533                    }
12534                    else {
12535                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T;
12536                            finderArgs = new Object[] {
12537                                            groupId, templateId,
12538                                            
12539                                            start, end, orderByComparator
12540                                    };
12541                    }
12542    
12543                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
12544                                    finderArgs, this);
12545    
12546                    if ((list != null) && !list.isEmpty()) {
12547                            for (JournalArticle journalArticle : list) {
12548                                    if ((groupId != journalArticle.getGroupId()) ||
12549                                                    !Validator.equals(templateId,
12550                                                            journalArticle.getTemplateId())) {
12551                                            list = null;
12552    
12553                                            break;
12554                                    }
12555                            }
12556                    }
12557    
12558                    if (list == null) {
12559                            StringBundler query = null;
12560    
12561                            if (orderByComparator != null) {
12562                                    query = new StringBundler(4 +
12563                                                    (orderByComparator.getOrderByFields().length * 3));
12564                            }
12565                            else {
12566                                    query = new StringBundler(4);
12567                            }
12568    
12569                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12570    
12571                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
12572    
12573                            boolean bindTemplateId = false;
12574    
12575                            if (templateId == null) {
12576                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
12577                            }
12578                            else if (templateId.equals(StringPool.BLANK)) {
12579                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
12580                            }
12581                            else {
12582                                    bindTemplateId = true;
12583    
12584                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
12585                            }
12586    
12587                            if (orderByComparator != null) {
12588                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12589                                            orderByComparator);
12590                            }
12591                            else
12592                             if (pagination) {
12593                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12594                            }
12595    
12596                            String sql = query.toString();
12597    
12598                            Session session = null;
12599    
12600                            try {
12601                                    session = openSession();
12602    
12603                                    Query q = session.createQuery(sql);
12604    
12605                                    QueryPos qPos = QueryPos.getInstance(q);
12606    
12607                                    qPos.add(groupId);
12608    
12609                                    if (bindTemplateId) {
12610                                            qPos.add(templateId);
12611                                    }
12612    
12613                                    if (!pagination) {
12614                                            list = (List<JournalArticle>)QueryUtil.list(q,
12615                                                            getDialect(), start, end, false);
12616    
12617                                            Collections.sort(list);
12618    
12619                                            list = new UnmodifiableList<JournalArticle>(list);
12620                                    }
12621                                    else {
12622                                            list = (List<JournalArticle>)QueryUtil.list(q,
12623                                                            getDialect(), start, end);
12624                                    }
12625    
12626                                    cacheResult(list);
12627    
12628                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
12629                            }
12630                            catch (Exception e) {
12631                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12632    
12633                                    throw processException(e);
12634                            }
12635                            finally {
12636                                    closeSession(session);
12637                            }
12638                    }
12639    
12640                    return list;
12641            }
12642    
12643            /**
12644             * Returns the first journal article in the ordered set where groupId = &#63; and templateId = &#63;.
12645             *
12646             * @param groupId the group ID
12647             * @param templateId the template ID
12648             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12649             * @return the first matching journal article
12650             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12651             * @throws SystemException if a system exception occurred
12652             */
12653            @Override
12654            public JournalArticle findByG_T_First(long groupId, String templateId,
12655                    OrderByComparator orderByComparator)
12656                    throws NoSuchArticleException, SystemException {
12657                    JournalArticle journalArticle = fetchByG_T_First(groupId, templateId,
12658                                    orderByComparator);
12659    
12660                    if (journalArticle != null) {
12661                            return journalArticle;
12662                    }
12663    
12664                    StringBundler msg = new StringBundler(6);
12665    
12666                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12667    
12668                    msg.append("groupId=");
12669                    msg.append(groupId);
12670    
12671                    msg.append(", templateId=");
12672                    msg.append(templateId);
12673    
12674                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12675    
12676                    throw new NoSuchArticleException(msg.toString());
12677            }
12678    
12679            /**
12680             * Returns the first journal article in the ordered set where groupId = &#63; and templateId = &#63;.
12681             *
12682             * @param groupId the group ID
12683             * @param templateId the template ID
12684             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12685             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
12686             * @throws SystemException if a system exception occurred
12687             */
12688            @Override
12689            public JournalArticle fetchByG_T_First(long groupId, String templateId,
12690                    OrderByComparator orderByComparator) throws SystemException {
12691                    List<JournalArticle> list = findByG_T(groupId, templateId, 0, 1,
12692                                    orderByComparator);
12693    
12694                    if (!list.isEmpty()) {
12695                            return list.get(0);
12696                    }
12697    
12698                    return null;
12699            }
12700    
12701            /**
12702             * Returns the last journal article in the ordered set where groupId = &#63; and templateId = &#63;.
12703             *
12704             * @param groupId the group ID
12705             * @param templateId the template ID
12706             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12707             * @return the last matching journal article
12708             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12709             * @throws SystemException if a system exception occurred
12710             */
12711            @Override
12712            public JournalArticle findByG_T_Last(long groupId, String templateId,
12713                    OrderByComparator orderByComparator)
12714                    throws NoSuchArticleException, SystemException {
12715                    JournalArticle journalArticle = fetchByG_T_Last(groupId, templateId,
12716                                    orderByComparator);
12717    
12718                    if (journalArticle != null) {
12719                            return journalArticle;
12720                    }
12721    
12722                    StringBundler msg = new StringBundler(6);
12723    
12724                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12725    
12726                    msg.append("groupId=");
12727                    msg.append(groupId);
12728    
12729                    msg.append(", templateId=");
12730                    msg.append(templateId);
12731    
12732                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12733    
12734                    throw new NoSuchArticleException(msg.toString());
12735            }
12736    
12737            /**
12738             * Returns the last journal article in the ordered set where groupId = &#63; and templateId = &#63;.
12739             *
12740             * @param groupId the group ID
12741             * @param templateId the template ID
12742             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12743             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
12744             * @throws SystemException if a system exception occurred
12745             */
12746            @Override
12747            public JournalArticle fetchByG_T_Last(long groupId, String templateId,
12748                    OrderByComparator orderByComparator) throws SystemException {
12749                    int count = countByG_T(groupId, templateId);
12750    
12751                    if (count == 0) {
12752                            return null;
12753                    }
12754    
12755                    List<JournalArticle> list = findByG_T(groupId, templateId, count - 1,
12756                                    count, orderByComparator);
12757    
12758                    if (!list.isEmpty()) {
12759                            return list.get(0);
12760                    }
12761    
12762                    return null;
12763            }
12764    
12765            /**
12766             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and templateId = &#63;.
12767             *
12768             * @param id the primary key of the current journal article
12769             * @param groupId the group ID
12770             * @param templateId the template ID
12771             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12772             * @return the previous, current, and next journal article
12773             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12774             * @throws SystemException if a system exception occurred
12775             */
12776            @Override
12777            public JournalArticle[] findByG_T_PrevAndNext(long id, long groupId,
12778                    String templateId, OrderByComparator orderByComparator)
12779                    throws NoSuchArticleException, SystemException {
12780                    JournalArticle journalArticle = findByPrimaryKey(id);
12781    
12782                    Session session = null;
12783    
12784                    try {
12785                            session = openSession();
12786    
12787                            JournalArticle[] array = new JournalArticleImpl[3];
12788    
12789                            array[0] = getByG_T_PrevAndNext(session, journalArticle, groupId,
12790                                            templateId, orderByComparator, true);
12791    
12792                            array[1] = journalArticle;
12793    
12794                            array[2] = getByG_T_PrevAndNext(session, journalArticle, groupId,
12795                                            templateId, orderByComparator, false);
12796    
12797                            return array;
12798                    }
12799                    catch (Exception e) {
12800                            throw processException(e);
12801                    }
12802                    finally {
12803                            closeSession(session);
12804                    }
12805            }
12806    
12807            protected JournalArticle getByG_T_PrevAndNext(Session session,
12808                    JournalArticle journalArticle, long groupId, String templateId,
12809                    OrderByComparator orderByComparator, boolean previous) {
12810                    StringBundler query = null;
12811    
12812                    if (orderByComparator != null) {
12813                            query = new StringBundler(6 +
12814                                            (orderByComparator.getOrderByFields().length * 6));
12815                    }
12816                    else {
12817                            query = new StringBundler(3);
12818                    }
12819    
12820                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12821    
12822                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
12823    
12824                    boolean bindTemplateId = false;
12825    
12826                    if (templateId == null) {
12827                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
12828                    }
12829                    else if (templateId.equals(StringPool.BLANK)) {
12830                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
12831                    }
12832                    else {
12833                            bindTemplateId = true;
12834    
12835                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
12836                    }
12837    
12838                    if (orderByComparator != null) {
12839                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12840    
12841                            if (orderByConditionFields.length > 0) {
12842                                    query.append(WHERE_AND);
12843                            }
12844    
12845                            for (int i = 0; i < orderByConditionFields.length; i++) {
12846                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12847                                    query.append(orderByConditionFields[i]);
12848    
12849                                    if ((i + 1) < orderByConditionFields.length) {
12850                                            if (orderByComparator.isAscending() ^ previous) {
12851                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12852                                            }
12853                                            else {
12854                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12855                                            }
12856                                    }
12857                                    else {
12858                                            if (orderByComparator.isAscending() ^ previous) {
12859                                                    query.append(WHERE_GREATER_THAN);
12860                                            }
12861                                            else {
12862                                                    query.append(WHERE_LESSER_THAN);
12863                                            }
12864                                    }
12865                            }
12866    
12867                            query.append(ORDER_BY_CLAUSE);
12868    
12869                            String[] orderByFields = orderByComparator.getOrderByFields();
12870    
12871                            for (int i = 0; i < orderByFields.length; i++) {
12872                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12873                                    query.append(orderByFields[i]);
12874    
12875                                    if ((i + 1) < orderByFields.length) {
12876                                            if (orderByComparator.isAscending() ^ previous) {
12877                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12878                                            }
12879                                            else {
12880                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12881                                            }
12882                                    }
12883                                    else {
12884                                            if (orderByComparator.isAscending() ^ previous) {
12885                                                    query.append(ORDER_BY_ASC);
12886                                            }
12887                                            else {
12888                                                    query.append(ORDER_BY_DESC);
12889                                            }
12890                                    }
12891                            }
12892                    }
12893                    else {
12894                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12895                    }
12896    
12897                    String sql = query.toString();
12898    
12899                    Query q = session.createQuery(sql);
12900    
12901                    q.setFirstResult(0);
12902                    q.setMaxResults(2);
12903    
12904                    QueryPos qPos = QueryPos.getInstance(q);
12905    
12906                    qPos.add(groupId);
12907    
12908                    if (bindTemplateId) {
12909                            qPos.add(templateId);
12910                    }
12911    
12912                    if (orderByComparator != null) {
12913                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12914    
12915                            for (Object value : values) {
12916                                    qPos.add(value);
12917                            }
12918                    }
12919    
12920                    List<JournalArticle> list = q.list();
12921    
12922                    if (list.size() == 2) {
12923                            return list.get(1);
12924                    }
12925                    else {
12926                            return null;
12927                    }
12928            }
12929    
12930            /**
12931             * Returns all the journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
12932             *
12933             * @param groupId the group ID
12934             * @param templateId the template ID
12935             * @return the matching journal articles that the user has permission to view
12936             * @throws SystemException if a system exception occurred
12937             */
12938            @Override
12939            public List<JournalArticle> filterFindByG_T(long groupId, String templateId)
12940                    throws SystemException {
12941                    return filterFindByG_T(groupId, templateId, QueryUtil.ALL_POS,
12942                            QueryUtil.ALL_POS, null);
12943            }
12944    
12945            /**
12946             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
12947             *
12948             * <p>
12949             * 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.
12950             * </p>
12951             *
12952             * @param groupId the group ID
12953             * @param templateId the template ID
12954             * @param start the lower bound of the range of journal articles
12955             * @param end the upper bound of the range of journal articles (not inclusive)
12956             * @return the range of matching journal articles that the user has permission to view
12957             * @throws SystemException if a system exception occurred
12958             */
12959            @Override
12960            public List<JournalArticle> filterFindByG_T(long groupId,
12961                    String templateId, int start, int end) throws SystemException {
12962                    return filterFindByG_T(groupId, templateId, start, end, null);
12963            }
12964    
12965            /**
12966             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and templateId = &#63;.
12967             *
12968             * <p>
12969             * 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.
12970             * </p>
12971             *
12972             * @param groupId the group ID
12973             * @param templateId the template ID
12974             * @param start the lower bound of the range of journal articles
12975             * @param end the upper bound of the range of journal articles (not inclusive)
12976             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12977             * @return the ordered range of matching journal articles that the user has permission to view
12978             * @throws SystemException if a system exception occurred
12979             */
12980            @Override
12981            public List<JournalArticle> filterFindByG_T(long groupId,
12982                    String templateId, int start, int end,
12983                    OrderByComparator orderByComparator) throws SystemException {
12984                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12985                            return findByG_T(groupId, templateId, start, end, orderByComparator);
12986                    }
12987    
12988                    StringBundler query = null;
12989    
12990                    if (orderByComparator != null) {
12991                            query = new StringBundler(4 +
12992                                            (orderByComparator.getOrderByFields().length * 3));
12993                    }
12994                    else {
12995                            query = new StringBundler(4);
12996                    }
12997    
12998                    if (getDB().isSupportsInlineDistinct()) {
12999                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13000                    }
13001                    else {
13002                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13003                    }
13004    
13005                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
13006    
13007                    boolean bindTemplateId = false;
13008    
13009                    if (templateId == null) {
13010                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
13011                    }
13012                    else if (templateId.equals(StringPool.BLANK)) {
13013                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
13014                    }
13015                    else {
13016                            bindTemplateId = true;
13017    
13018                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
13019                    }
13020    
13021                    if (!getDB().isSupportsInlineDistinct()) {
13022                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13023                    }
13024    
13025                    if (orderByComparator != null) {
13026                            if (getDB().isSupportsInlineDistinct()) {
13027                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13028                                            orderByComparator, true);
13029                            }
13030                            else {
13031                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13032                                            orderByComparator, true);
13033                            }
13034                    }
13035                    else {
13036                            if (getDB().isSupportsInlineDistinct()) {
13037                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13038                            }
13039                            else {
13040                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13041                            }
13042                    }
13043    
13044                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13045                                    JournalArticle.class.getName(),
13046                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13047    
13048                    Session session = null;
13049    
13050                    try {
13051                            session = openSession();
13052    
13053                            SQLQuery q = session.createSQLQuery(sql);
13054    
13055                            if (getDB().isSupportsInlineDistinct()) {
13056                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13057                            }
13058                            else {
13059                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13060                            }
13061    
13062                            QueryPos qPos = QueryPos.getInstance(q);
13063    
13064                            qPos.add(groupId);
13065    
13066                            if (bindTemplateId) {
13067                                    qPos.add(templateId);
13068                            }
13069    
13070                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
13071                                    end);
13072                    }
13073                    catch (Exception e) {
13074                            throw processException(e);
13075                    }
13076                    finally {
13077                            closeSession(session);
13078                    }
13079            }
13080    
13081            /**
13082             * 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;.
13083             *
13084             * @param id the primary key of the current journal article
13085             * @param groupId the group ID
13086             * @param templateId the template ID
13087             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13088             * @return the previous, current, and next journal article
13089             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13090             * @throws SystemException if a system exception occurred
13091             */
13092            @Override
13093            public JournalArticle[] filterFindByG_T_PrevAndNext(long id, long groupId,
13094                    String templateId, OrderByComparator orderByComparator)
13095                    throws NoSuchArticleException, SystemException {
13096                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13097                            return findByG_T_PrevAndNext(id, groupId, templateId,
13098                                    orderByComparator);
13099                    }
13100    
13101                    JournalArticle journalArticle = findByPrimaryKey(id);
13102    
13103                    Session session = null;
13104    
13105                    try {
13106                            session = openSession();
13107    
13108                            JournalArticle[] array = new JournalArticleImpl[3];
13109    
13110                            array[0] = filterGetByG_T_PrevAndNext(session, journalArticle,
13111                                            groupId, templateId, orderByComparator, true);
13112    
13113                            array[1] = journalArticle;
13114    
13115                            array[2] = filterGetByG_T_PrevAndNext(session, journalArticle,
13116                                            groupId, templateId, orderByComparator, false);
13117    
13118                            return array;
13119                    }
13120                    catch (Exception e) {
13121                            throw processException(e);
13122                    }
13123                    finally {
13124                            closeSession(session);
13125                    }
13126            }
13127    
13128            protected JournalArticle filterGetByG_T_PrevAndNext(Session session,
13129                    JournalArticle journalArticle, long groupId, String templateId,
13130                    OrderByComparator orderByComparator, boolean previous) {
13131                    StringBundler query = null;
13132    
13133                    if (orderByComparator != null) {
13134                            query = new StringBundler(6 +
13135                                            (orderByComparator.getOrderByFields().length * 6));
13136                    }
13137                    else {
13138                            query = new StringBundler(3);
13139                    }
13140    
13141                    if (getDB().isSupportsInlineDistinct()) {
13142                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13143                    }
13144                    else {
13145                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13146                    }
13147    
13148                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
13149    
13150                    boolean bindTemplateId = false;
13151    
13152                    if (templateId == null) {
13153                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
13154                    }
13155                    else if (templateId.equals(StringPool.BLANK)) {
13156                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
13157                    }
13158                    else {
13159                            bindTemplateId = true;
13160    
13161                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
13162                    }
13163    
13164                    if (!getDB().isSupportsInlineDistinct()) {
13165                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13166                    }
13167    
13168                    if (orderByComparator != null) {
13169                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13170    
13171                            if (orderByConditionFields.length > 0) {
13172                                    query.append(WHERE_AND);
13173                            }
13174    
13175                            for (int i = 0; i < orderByConditionFields.length; i++) {
13176                                    if (getDB().isSupportsInlineDistinct()) {
13177                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13178                                    }
13179                                    else {
13180                                            query.append(_ORDER_BY_ENTITY_TABLE);
13181                                    }
13182    
13183                                    query.append(orderByConditionFields[i]);
13184    
13185                                    if ((i + 1) < orderByConditionFields.length) {
13186                                            if (orderByComparator.isAscending() ^ previous) {
13187                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13188                                            }
13189                                            else {
13190                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13191                                            }
13192                                    }
13193                                    else {
13194                                            if (orderByComparator.isAscending() ^ previous) {
13195                                                    query.append(WHERE_GREATER_THAN);
13196                                            }
13197                                            else {
13198                                                    query.append(WHERE_LESSER_THAN);
13199                                            }
13200                                    }
13201                            }
13202    
13203                            query.append(ORDER_BY_CLAUSE);
13204    
13205                            String[] orderByFields = orderByComparator.getOrderByFields();
13206    
13207                            for (int i = 0; i < orderByFields.length; i++) {
13208                                    if (getDB().isSupportsInlineDistinct()) {
13209                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13210                                    }
13211                                    else {
13212                                            query.append(_ORDER_BY_ENTITY_TABLE);
13213                                    }
13214    
13215                                    query.append(orderByFields[i]);
13216    
13217                                    if ((i + 1) < orderByFields.length) {
13218                                            if (orderByComparator.isAscending() ^ previous) {
13219                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13220                                            }
13221                                            else {
13222                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13223                                            }
13224                                    }
13225                                    else {
13226                                            if (orderByComparator.isAscending() ^ previous) {
13227                                                    query.append(ORDER_BY_ASC);
13228                                            }
13229                                            else {
13230                                                    query.append(ORDER_BY_DESC);
13231                                            }
13232                                    }
13233                            }
13234                    }
13235                    else {
13236                            if (getDB().isSupportsInlineDistinct()) {
13237                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13238                            }
13239                            else {
13240                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13241                            }
13242                    }
13243    
13244                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13245                                    JournalArticle.class.getName(),
13246                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13247    
13248                    SQLQuery q = session.createSQLQuery(sql);
13249    
13250                    q.setFirstResult(0);
13251                    q.setMaxResults(2);
13252    
13253                    if (getDB().isSupportsInlineDistinct()) {
13254                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13255                    }
13256                    else {
13257                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13258                    }
13259    
13260                    QueryPos qPos = QueryPos.getInstance(q);
13261    
13262                    qPos.add(groupId);
13263    
13264                    if (bindTemplateId) {
13265                            qPos.add(templateId);
13266                    }
13267    
13268                    if (orderByComparator != null) {
13269                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13270    
13271                            for (Object value : values) {
13272                                    qPos.add(value);
13273                            }
13274                    }
13275    
13276                    List<JournalArticle> list = q.list();
13277    
13278                    if (list.size() == 2) {
13279                            return list.get(1);
13280                    }
13281                    else {
13282                            return null;
13283                    }
13284            }
13285    
13286            /**
13287             * Removes all the journal articles where groupId = &#63; and templateId = &#63; from the database.
13288             *
13289             * @param groupId the group ID
13290             * @param templateId the template ID
13291             * @throws SystemException if a system exception occurred
13292             */
13293            @Override
13294            public void removeByG_T(long groupId, String templateId)
13295                    throws SystemException {
13296                    for (JournalArticle journalArticle : findByG_T(groupId, templateId,
13297                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
13298                            remove(journalArticle);
13299                    }
13300            }
13301    
13302            /**
13303             * Returns the number of journal articles where groupId = &#63; and templateId = &#63;.
13304             *
13305             * @param groupId the group ID
13306             * @param templateId the template ID
13307             * @return the number of matching journal articles
13308             * @throws SystemException if a system exception occurred
13309             */
13310            @Override
13311            public int countByG_T(long groupId, String templateId)
13312                    throws SystemException {
13313                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_T;
13314    
13315                    Object[] finderArgs = new Object[] { groupId, templateId };
13316    
13317                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
13318                                    this);
13319    
13320                    if (count == null) {
13321                            StringBundler query = new StringBundler(3);
13322    
13323                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
13324    
13325                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
13326    
13327                            boolean bindTemplateId = false;
13328    
13329                            if (templateId == null) {
13330                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
13331                            }
13332                            else if (templateId.equals(StringPool.BLANK)) {
13333                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
13334                            }
13335                            else {
13336                                    bindTemplateId = true;
13337    
13338                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
13339                            }
13340    
13341                            String sql = query.toString();
13342    
13343                            Session session = null;
13344    
13345                            try {
13346                                    session = openSession();
13347    
13348                                    Query q = session.createQuery(sql);
13349    
13350                                    QueryPos qPos = QueryPos.getInstance(q);
13351    
13352                                    qPos.add(groupId);
13353    
13354                                    if (bindTemplateId) {
13355                                            qPos.add(templateId);
13356                                    }
13357    
13358                                    count = (Long)q.uniqueResult();
13359    
13360                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
13361                            }
13362                            catch (Exception e) {
13363                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13364    
13365                                    throw processException(e);
13366                            }
13367                            finally {
13368                                    closeSession(session);
13369                            }
13370                    }
13371    
13372                    return count.intValue();
13373            }
13374    
13375            /**
13376             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
13377             *
13378             * @param groupId the group ID
13379             * @param templateId the template ID
13380             * @return the number of matching journal articles that the user has permission to view
13381             * @throws SystemException if a system exception occurred
13382             */
13383            @Override
13384            public int filterCountByG_T(long groupId, String templateId)
13385                    throws SystemException {
13386                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13387                            return countByG_T(groupId, templateId);
13388                    }
13389    
13390                    StringBundler query = new StringBundler(3);
13391    
13392                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
13393    
13394                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
13395    
13396                    boolean bindTemplateId = false;
13397    
13398                    if (templateId == null) {
13399                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
13400                    }
13401                    else if (templateId.equals(StringPool.BLANK)) {
13402                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
13403                    }
13404                    else {
13405                            bindTemplateId = true;
13406    
13407                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
13408                    }
13409    
13410                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13411                                    JournalArticle.class.getName(),
13412                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13413    
13414                    Session session = null;
13415    
13416                    try {
13417                            session = openSession();
13418    
13419                            SQLQuery q = session.createSQLQuery(sql);
13420    
13421                            q.addScalar(COUNT_COLUMN_NAME,
13422                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
13423    
13424                            QueryPos qPos = QueryPos.getInstance(q);
13425    
13426                            qPos.add(groupId);
13427    
13428                            if (bindTemplateId) {
13429                                    qPos.add(templateId);
13430                            }
13431    
13432                            Long count = (Long)q.uniqueResult();
13433    
13434                            return count.intValue();
13435                    }
13436                    catch (Exception e) {
13437                            throw processException(e);
13438                    }
13439                    finally {
13440                            closeSession(session);
13441                    }
13442            }
13443    
13444            private static final String _FINDER_COLUMN_G_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
13445            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
13446            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
13447            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = '')";
13448            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13449                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
13450                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
13451                            "findByG_L",
13452                            new String[] {
13453                                    Long.class.getName(), String.class.getName(),
13454                                    
13455                            Integer.class.getName(), Integer.class.getName(),
13456                                    OrderByComparator.class.getName()
13457                            });
13458            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13459                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
13460                            JournalArticleImpl.class,
13461                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_L",
13462                            new String[] { Long.class.getName(), String.class.getName() },
13463                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
13464                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
13465                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
13466                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
13467            public static final FinderPath FINDER_PATH_COUNT_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13468                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
13469                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_L",
13470                            new String[] { Long.class.getName(), String.class.getName() });
13471    
13472            /**
13473             * Returns all the journal articles where groupId = &#63; and layoutUuid = &#63;.
13474             *
13475             * @param groupId the group ID
13476             * @param layoutUuid the layout uuid
13477             * @return the matching journal articles
13478             * @throws SystemException if a system exception occurred
13479             */
13480            @Override
13481            public List<JournalArticle> findByG_L(long groupId, String layoutUuid)
13482                    throws SystemException {
13483                    return findByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
13484                            QueryUtil.ALL_POS, null);
13485            }
13486    
13487            /**
13488             * Returns a range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
13489             *
13490             * <p>
13491             * 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.
13492             * </p>
13493             *
13494             * @param groupId the group ID
13495             * @param layoutUuid the layout uuid
13496             * @param start the lower bound of the range of journal articles
13497             * @param end the upper bound of the range of journal articles (not inclusive)
13498             * @return the range of matching journal articles
13499             * @throws SystemException if a system exception occurred
13500             */
13501            @Override
13502            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
13503                    int start, int end) throws SystemException {
13504                    return findByG_L(groupId, layoutUuid, start, end, null);
13505            }
13506    
13507            /**
13508             * Returns an ordered range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
13509             *
13510             * <p>
13511             * 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.
13512             * </p>
13513             *
13514             * @param groupId the group ID
13515             * @param layoutUuid the layout uuid
13516             * @param start the lower bound of the range of journal articles
13517             * @param end the upper bound of the range of journal articles (not inclusive)
13518             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13519             * @return the ordered range of matching journal articles
13520             * @throws SystemException if a system exception occurred
13521             */
13522            @Override
13523            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
13524                    int start, int end, OrderByComparator orderByComparator)
13525                    throws SystemException {
13526                    boolean pagination = true;
13527                    FinderPath finderPath = null;
13528                    Object[] finderArgs = null;
13529    
13530                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13531                                    (orderByComparator == null)) {
13532                            pagination = false;
13533                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L;
13534                            finderArgs = new Object[] { groupId, layoutUuid };
13535                    }
13536                    else {
13537                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L;
13538                            finderArgs = new Object[] {
13539                                            groupId, layoutUuid,
13540                                            
13541                                            start, end, orderByComparator
13542                                    };
13543                    }
13544    
13545                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
13546                                    finderArgs, this);
13547    
13548                    if ((list != null) && !list.isEmpty()) {
13549                            for (JournalArticle journalArticle : list) {
13550                                    if ((groupId != journalArticle.getGroupId()) ||
13551                                                    !Validator.equals(layoutUuid,
13552                                                            journalArticle.getLayoutUuid())) {
13553                                            list = null;
13554    
13555                                            break;
13556                                    }
13557                            }
13558                    }
13559    
13560                    if (list == null) {
13561                            StringBundler query = null;
13562    
13563                            if (orderByComparator != null) {
13564                                    query = new StringBundler(4 +
13565                                                    (orderByComparator.getOrderByFields().length * 3));
13566                            }
13567                            else {
13568                                    query = new StringBundler(4);
13569                            }
13570    
13571                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13572    
13573                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
13574    
13575                            boolean bindLayoutUuid = false;
13576    
13577                            if (layoutUuid == null) {
13578                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
13579                            }
13580                            else if (layoutUuid.equals(StringPool.BLANK)) {
13581                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
13582                            }
13583                            else {
13584                                    bindLayoutUuid = true;
13585    
13586                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
13587                            }
13588    
13589                            if (orderByComparator != null) {
13590                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13591                                            orderByComparator);
13592                            }
13593                            else
13594                             if (pagination) {
13595                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13596                            }
13597    
13598                            String sql = query.toString();
13599    
13600                            Session session = null;
13601    
13602                            try {
13603                                    session = openSession();
13604    
13605                                    Query q = session.createQuery(sql);
13606    
13607                                    QueryPos qPos = QueryPos.getInstance(q);
13608    
13609                                    qPos.add(groupId);
13610    
13611                                    if (bindLayoutUuid) {
13612                                            qPos.add(layoutUuid);
13613                                    }
13614    
13615                                    if (!pagination) {
13616                                            list = (List<JournalArticle>)QueryUtil.list(q,
13617                                                            getDialect(), start, end, false);
13618    
13619                                            Collections.sort(list);
13620    
13621                                            list = new UnmodifiableList<JournalArticle>(list);
13622                                    }
13623                                    else {
13624                                            list = (List<JournalArticle>)QueryUtil.list(q,
13625                                                            getDialect(), start, end);
13626                                    }
13627    
13628                                    cacheResult(list);
13629    
13630                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
13631                            }
13632                            catch (Exception e) {
13633                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13634    
13635                                    throw processException(e);
13636                            }
13637                            finally {
13638                                    closeSession(session);
13639                            }
13640                    }
13641    
13642                    return list;
13643            }
13644    
13645            /**
13646             * Returns the first journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13647             *
13648             * @param groupId the group ID
13649             * @param layoutUuid the layout uuid
13650             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13651             * @return the first matching journal article
13652             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13653             * @throws SystemException if a system exception occurred
13654             */
13655            @Override
13656            public JournalArticle findByG_L_First(long groupId, String layoutUuid,
13657                    OrderByComparator orderByComparator)
13658                    throws NoSuchArticleException, SystemException {
13659                    JournalArticle journalArticle = fetchByG_L_First(groupId, layoutUuid,
13660                                    orderByComparator);
13661    
13662                    if (journalArticle != null) {
13663                            return journalArticle;
13664                    }
13665    
13666                    StringBundler msg = new StringBundler(6);
13667    
13668                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13669    
13670                    msg.append("groupId=");
13671                    msg.append(groupId);
13672    
13673                    msg.append(", layoutUuid=");
13674                    msg.append(layoutUuid);
13675    
13676                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13677    
13678                    throw new NoSuchArticleException(msg.toString());
13679            }
13680    
13681            /**
13682             * Returns the first journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13683             *
13684             * @param groupId the group ID
13685             * @param layoutUuid the layout uuid
13686             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13687             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
13688             * @throws SystemException if a system exception occurred
13689             */
13690            @Override
13691            public JournalArticle fetchByG_L_First(long groupId, String layoutUuid,
13692                    OrderByComparator orderByComparator) throws SystemException {
13693                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, 0, 1,
13694                                    orderByComparator);
13695    
13696                    if (!list.isEmpty()) {
13697                            return list.get(0);
13698                    }
13699    
13700                    return null;
13701            }
13702    
13703            /**
13704             * Returns the last journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13705             *
13706             * @param groupId the group ID
13707             * @param layoutUuid the layout uuid
13708             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13709             * @return the last matching journal article
13710             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13711             * @throws SystemException if a system exception occurred
13712             */
13713            @Override
13714            public JournalArticle findByG_L_Last(long groupId, String layoutUuid,
13715                    OrderByComparator orderByComparator)
13716                    throws NoSuchArticleException, SystemException {
13717                    JournalArticle journalArticle = fetchByG_L_Last(groupId, layoutUuid,
13718                                    orderByComparator);
13719    
13720                    if (journalArticle != null) {
13721                            return journalArticle;
13722                    }
13723    
13724                    StringBundler msg = new StringBundler(6);
13725    
13726                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13727    
13728                    msg.append("groupId=");
13729                    msg.append(groupId);
13730    
13731                    msg.append(", layoutUuid=");
13732                    msg.append(layoutUuid);
13733    
13734                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13735    
13736                    throw new NoSuchArticleException(msg.toString());
13737            }
13738    
13739            /**
13740             * Returns the last journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13741             *
13742             * @param groupId the group ID
13743             * @param layoutUuid the layout uuid
13744             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13745             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
13746             * @throws SystemException if a system exception occurred
13747             */
13748            @Override
13749            public JournalArticle fetchByG_L_Last(long groupId, String layoutUuid,
13750                    OrderByComparator orderByComparator) throws SystemException {
13751                    int count = countByG_L(groupId, layoutUuid);
13752    
13753                    if (count == 0) {
13754                            return null;
13755                    }
13756    
13757                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, count - 1,
13758                                    count, orderByComparator);
13759    
13760                    if (!list.isEmpty()) {
13761                            return list.get(0);
13762                    }
13763    
13764                    return null;
13765            }
13766    
13767            /**
13768             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13769             *
13770             * @param id the primary key of the current journal article
13771             * @param groupId the group ID
13772             * @param layoutUuid the layout uuid
13773             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13774             * @return the previous, current, and next journal article
13775             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13776             * @throws SystemException if a system exception occurred
13777             */
13778            @Override
13779            public JournalArticle[] findByG_L_PrevAndNext(long id, long groupId,
13780                    String layoutUuid, OrderByComparator orderByComparator)
13781                    throws NoSuchArticleException, SystemException {
13782                    JournalArticle journalArticle = findByPrimaryKey(id);
13783    
13784                    Session session = null;
13785    
13786                    try {
13787                            session = openSession();
13788    
13789                            JournalArticle[] array = new JournalArticleImpl[3];
13790    
13791                            array[0] = getByG_L_PrevAndNext(session, journalArticle, groupId,
13792                                            layoutUuid, orderByComparator, true);
13793    
13794                            array[1] = journalArticle;
13795    
13796                            array[2] = getByG_L_PrevAndNext(session, journalArticle, groupId,
13797                                            layoutUuid, orderByComparator, false);
13798    
13799                            return array;
13800                    }
13801                    catch (Exception e) {
13802                            throw processException(e);
13803                    }
13804                    finally {
13805                            closeSession(session);
13806                    }
13807            }
13808    
13809            protected JournalArticle getByG_L_PrevAndNext(Session session,
13810                    JournalArticle journalArticle, long groupId, String layoutUuid,
13811                    OrderByComparator orderByComparator, boolean previous) {
13812                    StringBundler query = null;
13813    
13814                    if (orderByComparator != null) {
13815                            query = new StringBundler(6 +
13816                                            (orderByComparator.getOrderByFields().length * 6));
13817                    }
13818                    else {
13819                            query = new StringBundler(3);
13820                    }
13821    
13822                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13823    
13824                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
13825    
13826                    boolean bindLayoutUuid = false;
13827    
13828                    if (layoutUuid == null) {
13829                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
13830                    }
13831                    else if (layoutUuid.equals(StringPool.BLANK)) {
13832                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
13833                    }
13834                    else {
13835                            bindLayoutUuid = true;
13836    
13837                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
13838                    }
13839    
13840                    if (orderByComparator != null) {
13841                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13842    
13843                            if (orderByConditionFields.length > 0) {
13844                                    query.append(WHERE_AND);
13845                            }
13846    
13847                            for (int i = 0; i < orderByConditionFields.length; i++) {
13848                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13849                                    query.append(orderByConditionFields[i]);
13850    
13851                                    if ((i + 1) < orderByConditionFields.length) {
13852                                            if (orderByComparator.isAscending() ^ previous) {
13853                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13854                                            }
13855                                            else {
13856                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13857                                            }
13858                                    }
13859                                    else {
13860                                            if (orderByComparator.isAscending() ^ previous) {
13861                                                    query.append(WHERE_GREATER_THAN);
13862                                            }
13863                                            else {
13864                                                    query.append(WHERE_LESSER_THAN);
13865                                            }
13866                                    }
13867                            }
13868    
13869                            query.append(ORDER_BY_CLAUSE);
13870    
13871                            String[] orderByFields = orderByComparator.getOrderByFields();
13872    
13873                            for (int i = 0; i < orderByFields.length; i++) {
13874                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13875                                    query.append(orderByFields[i]);
13876    
13877                                    if ((i + 1) < orderByFields.length) {
13878                                            if (orderByComparator.isAscending() ^ previous) {
13879                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13880                                            }
13881                                            else {
13882                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13883                                            }
13884                                    }
13885                                    else {
13886                                            if (orderByComparator.isAscending() ^ previous) {
13887                                                    query.append(ORDER_BY_ASC);
13888                                            }
13889                                            else {
13890                                                    query.append(ORDER_BY_DESC);
13891                                            }
13892                                    }
13893                            }
13894                    }
13895                    else {
13896                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13897                    }
13898    
13899                    String sql = query.toString();
13900    
13901                    Query q = session.createQuery(sql);
13902    
13903                    q.setFirstResult(0);
13904                    q.setMaxResults(2);
13905    
13906                    QueryPos qPos = QueryPos.getInstance(q);
13907    
13908                    qPos.add(groupId);
13909    
13910                    if (bindLayoutUuid) {
13911                            qPos.add(layoutUuid);
13912                    }
13913    
13914                    if (orderByComparator != null) {
13915                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13916    
13917                            for (Object value : values) {
13918                                    qPos.add(value);
13919                            }
13920                    }
13921    
13922                    List<JournalArticle> list = q.list();
13923    
13924                    if (list.size() == 2) {
13925                            return list.get(1);
13926                    }
13927                    else {
13928                            return null;
13929                    }
13930            }
13931    
13932            /**
13933             * Returns all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
13934             *
13935             * @param groupId the group ID
13936             * @param layoutUuid the layout uuid
13937             * @return the matching journal articles that the user has permission to view
13938             * @throws SystemException if a system exception occurred
13939             */
13940            @Override
13941            public List<JournalArticle> filterFindByG_L(long groupId, String layoutUuid)
13942                    throws SystemException {
13943                    return filterFindByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
13944                            QueryUtil.ALL_POS, null);
13945            }
13946    
13947            /**
13948             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
13949             *
13950             * <p>
13951             * 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.
13952             * </p>
13953             *
13954             * @param groupId the group ID
13955             * @param layoutUuid the layout uuid
13956             * @param start the lower bound of the range of journal articles
13957             * @param end the upper bound of the range of journal articles (not inclusive)
13958             * @return the range of matching journal articles that the user has permission to view
13959             * @throws SystemException if a system exception occurred
13960             */
13961            @Override
13962            public List<JournalArticle> filterFindByG_L(long groupId,
13963                    String layoutUuid, int start, int end) throws SystemException {
13964                    return filterFindByG_L(groupId, layoutUuid, start, end, null);
13965            }
13966    
13967            /**
13968             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and layoutUuid = &#63;.
13969             *
13970             * <p>
13971             * 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.
13972             * </p>
13973             *
13974             * @param groupId the group ID
13975             * @param layoutUuid the layout uuid
13976             * @param start the lower bound of the range of journal articles
13977             * @param end the upper bound of the range of journal articles (not inclusive)
13978             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13979             * @return the ordered range of matching journal articles that the user has permission to view
13980             * @throws SystemException if a system exception occurred
13981             */
13982            @Override
13983            public List<JournalArticle> filterFindByG_L(long groupId,
13984                    String layoutUuid, int start, int end,
13985                    OrderByComparator orderByComparator) throws SystemException {
13986                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13987                            return findByG_L(groupId, layoutUuid, start, end, orderByComparator);
13988                    }
13989    
13990                    StringBundler query = null;
13991    
13992                    if (orderByComparator != null) {
13993                            query = new StringBundler(4 +
13994                                            (orderByComparator.getOrderByFields().length * 3));
13995                    }
13996                    else {
13997                            query = new StringBundler(4);
13998                    }
13999    
14000                    if (getDB().isSupportsInlineDistinct()) {
14001                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
14002                    }
14003                    else {
14004                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
14005                    }
14006    
14007                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
14008    
14009                    boolean bindLayoutUuid = false;
14010    
14011                    if (layoutUuid == null) {
14012                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
14013                    }
14014                    else if (layoutUuid.equals(StringPool.BLANK)) {
14015                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
14016                    }
14017                    else {
14018                            bindLayoutUuid = true;
14019    
14020                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
14021                    }
14022    
14023                    if (!getDB().isSupportsInlineDistinct()) {
14024                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
14025                    }
14026    
14027                    if (orderByComparator != null) {
14028                            if (getDB().isSupportsInlineDistinct()) {
14029                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14030                                            orderByComparator, true);
14031                            }
14032                            else {
14033                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
14034                                            orderByComparator, true);
14035                            }
14036                    }
14037                    else {
14038                            if (getDB().isSupportsInlineDistinct()) {
14039                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14040                            }
14041                            else {
14042                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
14043                            }
14044                    }
14045    
14046                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14047                                    JournalArticle.class.getName(),
14048                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14049    
14050                    Session session = null;
14051    
14052                    try {
14053                            session = openSession();
14054    
14055                            SQLQuery q = session.createSQLQuery(sql);
14056    
14057                            if (getDB().isSupportsInlineDistinct()) {
14058                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
14059                            }
14060                            else {
14061                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
14062                            }
14063    
14064                            QueryPos qPos = QueryPos.getInstance(q);
14065    
14066                            qPos.add(groupId);
14067    
14068                            if (bindLayoutUuid) {
14069                                    qPos.add(layoutUuid);
14070                            }
14071    
14072                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
14073                                    end);
14074                    }
14075                    catch (Exception e) {
14076                            throw processException(e);
14077                    }
14078                    finally {
14079                            closeSession(session);
14080                    }
14081            }
14082    
14083            /**
14084             * 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;.
14085             *
14086             * @param id the primary key of the current journal article
14087             * @param groupId the group ID
14088             * @param layoutUuid the layout uuid
14089             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14090             * @return the previous, current, and next journal article
14091             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
14092             * @throws SystemException if a system exception occurred
14093             */
14094            @Override
14095            public JournalArticle[] filterFindByG_L_PrevAndNext(long id, long groupId,
14096                    String layoutUuid, OrderByComparator orderByComparator)
14097                    throws NoSuchArticleException, SystemException {
14098                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14099                            return findByG_L_PrevAndNext(id, groupId, layoutUuid,
14100                                    orderByComparator);
14101                    }
14102    
14103                    JournalArticle journalArticle = findByPrimaryKey(id);
14104    
14105                    Session session = null;
14106    
14107                    try {
14108                            session = openSession();
14109    
14110                            JournalArticle[] array = new JournalArticleImpl[3];
14111    
14112                            array[0] = filterGetByG_L_PrevAndNext(session, journalArticle,
14113                                            groupId, layoutUuid, orderByComparator, true);
14114    
14115                            array[1] = journalArticle;
14116    
14117                            array[2] = filterGetByG_L_PrevAndNext(session, journalArticle,
14118                                            groupId, layoutUuid, orderByComparator, false);
14119    
14120                            return array;
14121                    }
14122                    catch (Exception e) {
14123                            throw processException(e);
14124                    }
14125                    finally {
14126                            closeSession(session);
14127                    }
14128            }
14129    
14130            protected JournalArticle filterGetByG_L_PrevAndNext(Session session,
14131                    JournalArticle journalArticle, long groupId, String layoutUuid,
14132                    OrderByComparator orderByComparator, boolean previous) {
14133                    StringBundler query = null;
14134    
14135                    if (orderByComparator != null) {
14136                            query = new StringBundler(6 +
14137                                            (orderByComparator.getOrderByFields().length * 6));
14138                    }
14139                    else {
14140                            query = new StringBundler(3);
14141                    }
14142    
14143                    if (getDB().isSupportsInlineDistinct()) {
14144                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
14145                    }
14146                    else {
14147                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
14148                    }
14149    
14150                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
14151    
14152                    boolean bindLayoutUuid = false;
14153    
14154                    if (layoutUuid == null) {
14155                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
14156                    }
14157                    else if (layoutUuid.equals(StringPool.BLANK)) {
14158                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
14159                    }
14160                    else {
14161                            bindLayoutUuid = true;
14162    
14163                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
14164                    }
14165    
14166                    if (!getDB().isSupportsInlineDistinct()) {
14167                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
14168                    }
14169    
14170                    if (orderByComparator != null) {
14171                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14172    
14173                            if (orderByConditionFields.length > 0) {
14174                                    query.append(WHERE_AND);
14175                            }
14176    
14177                            for (int i = 0; i < orderByConditionFields.length; i++) {
14178                                    if (getDB().isSupportsInlineDistinct()) {
14179                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14180                                    }
14181                                    else {
14182                                            query.append(_ORDER_BY_ENTITY_TABLE);
14183                                    }
14184    
14185                                    query.append(orderByConditionFields[i]);
14186    
14187                                    if ((i + 1) < orderByConditionFields.length) {
14188                                            if (orderByComparator.isAscending() ^ previous) {
14189                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14190                                            }
14191                                            else {
14192                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14193                                            }
14194                                    }
14195                                    else {
14196                                            if (orderByComparator.isAscending() ^ previous) {
14197                                                    query.append(WHERE_GREATER_THAN);
14198                                            }
14199                                            else {
14200                                                    query.append(WHERE_LESSER_THAN);
14201                                            }
14202                                    }
14203                            }
14204    
14205                            query.append(ORDER_BY_CLAUSE);
14206    
14207                            String[] orderByFields = orderByComparator.getOrderByFields();
14208    
14209                            for (int i = 0; i < orderByFields.length; i++) {
14210                                    if (getDB().isSupportsInlineDistinct()) {
14211                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14212                                    }
14213                                    else {
14214                                            query.append(_ORDER_BY_ENTITY_TABLE);
14215                                    }
14216    
14217                                    query.append(orderByFields[i]);
14218    
14219                                    if ((i + 1) < orderByFields.length) {
14220                                            if (orderByComparator.isAscending() ^ previous) {
14221                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14222                                            }
14223                                            else {
14224                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14225                                            }
14226                                    }
14227                                    else {
14228                                            if (orderByComparator.isAscending() ^ previous) {
14229                                                    query.append(ORDER_BY_ASC);
14230                                            }
14231                                            else {
14232                                                    query.append(ORDER_BY_DESC);
14233                                            }
14234                                    }
14235                            }
14236                    }
14237                    else {
14238                            if (getDB().isSupportsInlineDistinct()) {
14239                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14240                            }
14241                            else {
14242                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
14243                            }
14244                    }
14245    
14246                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14247                                    JournalArticle.class.getName(),
14248                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14249    
14250                    SQLQuery q = session.createSQLQuery(sql);
14251    
14252                    q.setFirstResult(0);
14253                    q.setMaxResults(2);
14254    
14255                    if (getDB().isSupportsInlineDistinct()) {
14256                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
14257                    }
14258                    else {
14259                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
14260                    }
14261    
14262                    QueryPos qPos = QueryPos.getInstance(q);
14263    
14264                    qPos.add(groupId);
14265    
14266                    if (bindLayoutUuid) {
14267                            qPos.add(layoutUuid);
14268                    }
14269    
14270                    if (orderByComparator != null) {
14271                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
14272    
14273                            for (Object value : values) {
14274                                    qPos.add(value);
14275                            }
14276                    }
14277    
14278                    List<JournalArticle> list = q.list();
14279    
14280                    if (list.size() == 2) {
14281                            return list.get(1);
14282                    }
14283                    else {
14284                            return null;
14285                    }
14286            }
14287    
14288            /**
14289             * Removes all the journal articles where groupId = &#63; and layoutUuid = &#63; from the database.
14290             *
14291             * @param groupId the group ID
14292             * @param layoutUuid the layout uuid
14293             * @throws SystemException if a system exception occurred
14294             */
14295            @Override
14296            public void removeByG_L(long groupId, String layoutUuid)
14297                    throws SystemException {
14298                    for (JournalArticle journalArticle : findByG_L(groupId, layoutUuid,
14299                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14300                            remove(journalArticle);
14301                    }
14302            }
14303    
14304            /**
14305             * Returns the number of journal articles where groupId = &#63; and layoutUuid = &#63;.
14306             *
14307             * @param groupId the group ID
14308             * @param layoutUuid the layout uuid
14309             * @return the number of matching journal articles
14310             * @throws SystemException if a system exception occurred
14311             */
14312            @Override
14313            public int countByG_L(long groupId, String layoutUuid)
14314                    throws SystemException {
14315                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_L;
14316    
14317                    Object[] finderArgs = new Object[] { groupId, layoutUuid };
14318    
14319                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
14320                                    this);
14321    
14322                    if (count == null) {
14323                            StringBundler query = new StringBundler(3);
14324    
14325                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14326    
14327                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
14328    
14329                            boolean bindLayoutUuid = false;
14330    
14331                            if (layoutUuid == null) {
14332                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
14333                            }
14334                            else if (layoutUuid.equals(StringPool.BLANK)) {
14335                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
14336                            }
14337                            else {
14338                                    bindLayoutUuid = true;
14339    
14340                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
14341                            }
14342    
14343                            String sql = query.toString();
14344    
14345                            Session session = null;
14346    
14347                            try {
14348                                    session = openSession();
14349    
14350                                    Query q = session.createQuery(sql);
14351    
14352                                    QueryPos qPos = QueryPos.getInstance(q);
14353    
14354                                    qPos.add(groupId);
14355    
14356                                    if (bindLayoutUuid) {
14357                                            qPos.add(layoutUuid);
14358                                    }
14359    
14360                                    count = (Long)q.uniqueResult();
14361    
14362                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
14363                            }
14364                            catch (Exception e) {
14365                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14366    
14367                                    throw processException(e);
14368                            }
14369                            finally {
14370                                    closeSession(session);
14371                            }
14372                    }
14373    
14374                    return count.intValue();
14375            }
14376    
14377            /**
14378             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
14379             *
14380             * @param groupId the group ID
14381             * @param layoutUuid the layout uuid
14382             * @return the number of matching journal articles that the user has permission to view
14383             * @throws SystemException if a system exception occurred
14384             */
14385            @Override
14386            public int filterCountByG_L(long groupId, String layoutUuid)
14387                    throws SystemException {
14388                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14389                            return countByG_L(groupId, layoutUuid);
14390                    }
14391    
14392                    StringBundler query = new StringBundler(3);
14393    
14394                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
14395    
14396                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
14397    
14398                    boolean bindLayoutUuid = false;
14399    
14400                    if (layoutUuid == null) {
14401                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
14402                    }
14403                    else if (layoutUuid.equals(StringPool.BLANK)) {
14404                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
14405                    }
14406                    else {
14407                            bindLayoutUuid = true;
14408    
14409                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
14410                    }
14411    
14412                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14413                                    JournalArticle.class.getName(),
14414                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14415    
14416                    Session session = null;
14417    
14418                    try {
14419                            session = openSession();
14420    
14421                            SQLQuery q = session.createSQLQuery(sql);
14422    
14423                            q.addScalar(COUNT_COLUMN_NAME,
14424                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
14425    
14426                            QueryPos qPos = QueryPos.getInstance(q);
14427    
14428                            qPos.add(groupId);
14429    
14430                            if (bindLayoutUuid) {
14431                                    qPos.add(layoutUuid);
14432                            }
14433    
14434                            Long count = (Long)q.uniqueResult();
14435    
14436                            return count.intValue();
14437                    }
14438                    catch (Exception e) {
14439                            throw processException(e);
14440                    }
14441                    finally {
14442                            closeSession(session);
14443                    }
14444            }
14445    
14446            private static final String _FINDER_COLUMN_G_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
14447            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
14448            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
14449            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = '')";
14450            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14451                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
14452                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
14453                            "findByG_NotL",
14454                            new String[] {
14455                                    Long.class.getName(), String.class.getName(),
14456                                    
14457                            Integer.class.getName(), Integer.class.getName(),
14458                                    OrderByComparator.class.getName()
14459                            });
14460            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14461                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
14462                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_NotL",
14463                            new String[] { Long.class.getName(), String.class.getName() });
14464    
14465            /**
14466             * Returns all the journal articles where groupId = &#63; and layoutUuid &ne; &#63;.
14467             *
14468             * @param groupId the group ID
14469             * @param layoutUuid the layout uuid
14470             * @return the matching journal articles
14471             * @throws SystemException if a system exception occurred
14472             */
14473            @Override
14474            public List<JournalArticle> findByG_NotL(long groupId, String layoutUuid)
14475                    throws SystemException {
14476                    return findByG_NotL(groupId, layoutUuid, QueryUtil.ALL_POS,
14477                            QueryUtil.ALL_POS, null);
14478            }
14479    
14480            /**
14481             * Returns a range of all the journal articles where groupId = &#63; and layoutUuid &ne; &#63;.
14482             *
14483             * <p>
14484             * 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.
14485             * </p>
14486             *
14487             * @param groupId the group ID
14488             * @param layoutUuid the layout uuid
14489             * @param start the lower bound of the range of journal articles
14490             * @param end the upper bound of the range of journal articles (not inclusive)
14491             * @return the range of matching journal articles
14492             * @throws SystemException if a system exception occurred
14493             */
14494            @Override
14495            public List<JournalArticle> findByG_NotL(long groupId, String layoutUuid,
14496                    int start, int end) throws SystemException {
14497                    return findByG_NotL(groupId, layoutUuid, start, end, null);
14498            }
14499    
14500            /**
14501             * Returns an ordered range of all the journal articles where groupId = &#63; and layoutUuid &ne; &#63;.
14502             *
14503             * <p>
14504             * 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.
14505             * </p>
14506             *
14507             * @param groupId the group ID
14508             * @param layoutUuid the layout uuid
14509             * @param start the lower bound of the range of journal articles
14510             * @param end the upper bound of the range of journal articles (not inclusive)
14511             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14512             * @return the ordered range of matching journal articles
14513             * @throws SystemException if a system exception occurred
14514             */
14515            @Override
14516            public List<JournalArticle> findByG_NotL(long groupId, String layoutUuid,
14517                    int start, int end, OrderByComparator orderByComparator)
14518                    throws SystemException {
14519                    boolean pagination = true;
14520                    FinderPath finderPath = null;
14521                    Object[] finderArgs = null;
14522    
14523                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTL;
14524                    finderArgs = new Object[] {
14525                                    groupId, layoutUuid,
14526                                    
14527                                    start, end, orderByComparator
14528                            };
14529    
14530                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
14531                                    finderArgs, this);
14532    
14533                    if ((list != null) && !list.isEmpty()) {
14534                            for (JournalArticle journalArticle : list) {
14535                                    if ((groupId != journalArticle.getGroupId()) ||
14536                                                    Validator.equals(layoutUuid,
14537                                                            journalArticle.getLayoutUuid())) {
14538                                            list = null;
14539    
14540                                            break;
14541                                    }
14542                            }
14543                    }
14544    
14545                    if (list == null) {
14546                            StringBundler query = null;
14547    
14548                            if (orderByComparator != null) {
14549                                    query = new StringBundler(4 +
14550                                                    (orderByComparator.getOrderByFields().length * 3));
14551                            }
14552                            else {
14553                                    query = new StringBundler(4);
14554                            }
14555    
14556                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14557    
14558                            query.append(_FINDER_COLUMN_G_NOTL_GROUPID_2);
14559    
14560                            boolean bindLayoutUuid = false;
14561    
14562                            if (layoutUuid == null) {
14563                                    query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_1);
14564                            }
14565                            else if (layoutUuid.equals(StringPool.BLANK)) {
14566                                    query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_3);
14567                            }
14568                            else {
14569                                    bindLayoutUuid = true;
14570    
14571                                    query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_2);
14572                            }
14573    
14574                            if (orderByComparator != null) {
14575                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14576                                            orderByComparator);
14577                            }
14578                            else
14579                             if (pagination) {
14580                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14581                            }
14582    
14583                            String sql = query.toString();
14584    
14585                            Session session = null;
14586    
14587                            try {
14588                                    session = openSession();
14589    
14590                                    Query q = session.createQuery(sql);
14591    
14592                                    QueryPos qPos = QueryPos.getInstance(q);
14593    
14594                                    qPos.add(groupId);
14595    
14596                                    if (bindLayoutUuid) {
14597                                            qPos.add(layoutUuid);
14598                                    }
14599    
14600                                    if (!pagination) {
14601                                            list = (List<JournalArticle>)QueryUtil.list(q,
14602                                                            getDialect(), start, end, false);
14603    
14604                                            Collections.sort(list);
14605    
14606                                            list = new UnmodifiableList<JournalArticle>(list);
14607                                    }
14608                                    else {
14609                                            list = (List<JournalArticle>)QueryUtil.list(q,
14610                                                            getDialect(), start, end);
14611                                    }
14612    
14613                                    cacheResult(list);
14614    
14615                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
14616                            }
14617                            catch (Exception e) {
14618                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14619    
14620                                    throw processException(e);
14621                            }
14622                            finally {
14623                                    closeSession(session);
14624                            }
14625                    }
14626    
14627                    return list;
14628            }
14629    
14630            /**
14631             * Returns the first journal article in the ordered set where groupId = &#63; and layoutUuid &ne; &#63;.
14632             *
14633             * @param groupId the group ID
14634             * @param layoutUuid the layout uuid
14635             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14636             * @return the first matching journal article
14637             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14638             * @throws SystemException if a system exception occurred
14639             */
14640            @Override
14641            public JournalArticle findByG_NotL_First(long groupId, String layoutUuid,
14642                    OrderByComparator orderByComparator)
14643                    throws NoSuchArticleException, SystemException {
14644                    JournalArticle journalArticle = fetchByG_NotL_First(groupId,
14645                                    layoutUuid, orderByComparator);
14646    
14647                    if (journalArticle != null) {
14648                            return journalArticle;
14649                    }
14650    
14651                    StringBundler msg = new StringBundler(6);
14652    
14653                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14654    
14655                    msg.append("groupId=");
14656                    msg.append(groupId);
14657    
14658                    msg.append(", layoutUuid=");
14659                    msg.append(layoutUuid);
14660    
14661                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14662    
14663                    throw new NoSuchArticleException(msg.toString());
14664            }
14665    
14666            /**
14667             * Returns the first journal article in the ordered set where groupId = &#63; and layoutUuid &ne; &#63;.
14668             *
14669             * @param groupId the group ID
14670             * @param layoutUuid the layout uuid
14671             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14672             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
14673             * @throws SystemException if a system exception occurred
14674             */
14675            @Override
14676            public JournalArticle fetchByG_NotL_First(long groupId, String layoutUuid,
14677                    OrderByComparator orderByComparator) throws SystemException {
14678                    List<JournalArticle> list = findByG_NotL(groupId, layoutUuid, 0, 1,
14679                                    orderByComparator);
14680    
14681                    if (!list.isEmpty()) {
14682                            return list.get(0);
14683                    }
14684    
14685                    return null;
14686            }
14687    
14688            /**
14689             * Returns the last journal article in the ordered set where groupId = &#63; and layoutUuid &ne; &#63;.
14690             *
14691             * @param groupId the group ID
14692             * @param layoutUuid the layout uuid
14693             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14694             * @return the last matching journal article
14695             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14696             * @throws SystemException if a system exception occurred
14697             */
14698            @Override
14699            public JournalArticle findByG_NotL_Last(long groupId, String layoutUuid,
14700                    OrderByComparator orderByComparator)
14701                    throws NoSuchArticleException, SystemException {
14702                    JournalArticle journalArticle = fetchByG_NotL_Last(groupId, layoutUuid,
14703                                    orderByComparator);
14704    
14705                    if (journalArticle != null) {
14706                            return journalArticle;
14707                    }
14708    
14709                    StringBundler msg = new StringBundler(6);
14710    
14711                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14712    
14713                    msg.append("groupId=");
14714                    msg.append(groupId);
14715    
14716                    msg.append(", layoutUuid=");
14717                    msg.append(layoutUuid);
14718    
14719                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14720    
14721                    throw new NoSuchArticleException(msg.toString());
14722            }
14723    
14724            /**
14725             * Returns the last journal article in the ordered set where groupId = &#63; and layoutUuid &ne; &#63;.
14726             *
14727             * @param groupId the group ID
14728             * @param layoutUuid the layout uuid
14729             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14730             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
14731             * @throws SystemException if a system exception occurred
14732             */
14733            @Override
14734            public JournalArticle fetchByG_NotL_Last(long groupId, String layoutUuid,
14735                    OrderByComparator orderByComparator) throws SystemException {
14736                    int count = countByG_NotL(groupId, layoutUuid);
14737    
14738                    if (count == 0) {
14739                            return null;
14740                    }
14741    
14742                    List<JournalArticle> list = findByG_NotL(groupId, layoutUuid,
14743                                    count - 1, count, orderByComparator);
14744    
14745                    if (!list.isEmpty()) {
14746                            return list.get(0);
14747                    }
14748    
14749                    return null;
14750            }
14751    
14752            /**
14753             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and layoutUuid &ne; &#63;.
14754             *
14755             * @param id the primary key of the current journal article
14756             * @param groupId the group ID
14757             * @param layoutUuid the layout uuid
14758             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14759             * @return the previous, current, and next journal article
14760             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
14761             * @throws SystemException if a system exception occurred
14762             */
14763            @Override
14764            public JournalArticle[] findByG_NotL_PrevAndNext(long id, long groupId,
14765                    String layoutUuid, OrderByComparator orderByComparator)
14766                    throws NoSuchArticleException, SystemException {
14767                    JournalArticle journalArticle = findByPrimaryKey(id);
14768    
14769                    Session session = null;
14770    
14771                    try {
14772                            session = openSession();
14773    
14774                            JournalArticle[] array = new JournalArticleImpl[3];
14775    
14776                            array[0] = getByG_NotL_PrevAndNext(session, journalArticle,
14777                                            groupId, layoutUuid, orderByComparator, true);
14778    
14779                            array[1] = journalArticle;
14780    
14781                            array[2] = getByG_NotL_PrevAndNext(session, journalArticle,
14782                                            groupId, layoutUuid, orderByComparator, false);
14783    
14784                            return array;
14785                    }
14786                    catch (Exception e) {
14787                            throw processException(e);
14788                    }
14789                    finally {
14790                            closeSession(session);
14791                    }
14792            }
14793    
14794            protected JournalArticle getByG_NotL_PrevAndNext(Session session,
14795                    JournalArticle journalArticle, long groupId, String layoutUuid,
14796                    OrderByComparator orderByComparator, boolean previous) {
14797                    StringBundler query = null;
14798    
14799                    if (orderByComparator != null) {
14800                            query = new StringBundler(6 +
14801                                            (orderByComparator.getOrderByFields().length * 6));
14802                    }
14803                    else {
14804                            query = new StringBundler(3);
14805                    }
14806    
14807                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14808    
14809                    query.append(_FINDER_COLUMN_G_NOTL_GROUPID_2);
14810    
14811                    boolean bindLayoutUuid = false;
14812    
14813                    if (layoutUuid == null) {
14814                            query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_1);
14815                    }
14816                    else if (layoutUuid.equals(StringPool.BLANK)) {
14817                            query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_3);
14818                    }
14819                    else {
14820                            bindLayoutUuid = true;
14821    
14822                            query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_2);
14823                    }
14824    
14825                    if (orderByComparator != null) {
14826                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14827    
14828                            if (orderByConditionFields.length > 0) {
14829                                    query.append(WHERE_AND);
14830                            }
14831    
14832                            for (int i = 0; i < orderByConditionFields.length; i++) {
14833                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14834                                    query.append(orderByConditionFields[i]);
14835    
14836                                    if ((i + 1) < orderByConditionFields.length) {
14837                                            if (orderByComparator.isAscending() ^ previous) {
14838                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14839                                            }
14840                                            else {
14841                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14842                                            }
14843                                    }
14844                                    else {
14845                                            if (orderByComparator.isAscending() ^ previous) {
14846                                                    query.append(WHERE_GREATER_THAN);
14847                                            }
14848                                            else {
14849                                                    query.append(WHERE_LESSER_THAN);
14850                                            }
14851                                    }
14852                            }
14853    
14854                            query.append(ORDER_BY_CLAUSE);
14855    
14856                            String[] orderByFields = orderByComparator.getOrderByFields();
14857    
14858                            for (int i = 0; i < orderByFields.length; i++) {
14859                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14860                                    query.append(orderByFields[i]);
14861    
14862                                    if ((i + 1) < orderByFields.length) {
14863                                            if (orderByComparator.isAscending() ^ previous) {
14864                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14865                                            }
14866                                            else {
14867                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14868                                            }
14869                                    }
14870                                    else {
14871                                            if (orderByComparator.isAscending() ^ previous) {
14872                                                    query.append(ORDER_BY_ASC);
14873                                            }
14874                                            else {
14875                                                    query.append(ORDER_BY_DESC);
14876                                            }
14877                                    }
14878                            }
14879                    }
14880                    else {
14881                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14882                    }
14883    
14884                    String sql = query.toString();
14885    
14886                    Query q = session.createQuery(sql);
14887    
14888                    q.setFirstResult(0);
14889                    q.setMaxResults(2);
14890    
14891                    QueryPos qPos = QueryPos.getInstance(q);
14892    
14893                    qPos.add(groupId);
14894    
14895                    if (bindLayoutUuid) {
14896                            qPos.add(layoutUuid);
14897                    }
14898    
14899                    if (orderByComparator != null) {
14900                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
14901    
14902                            for (Object value : values) {
14903                                    qPos.add(value);
14904                            }
14905                    }
14906    
14907                    List<JournalArticle> list = q.list();
14908    
14909                    if (list.size() == 2) {
14910                            return list.get(1);
14911                    }
14912                    else {
14913                            return null;
14914                    }
14915            }
14916    
14917            /**
14918             * Returns all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid &ne; &#63;.
14919             *
14920             * @param groupId the group ID
14921             * @param layoutUuid the layout uuid
14922             * @return the matching journal articles that the user has permission to view
14923             * @throws SystemException if a system exception occurred
14924             */
14925            @Override
14926            public List<JournalArticle> filterFindByG_NotL(long groupId,
14927                    String layoutUuid) throws SystemException {
14928                    return filterFindByG_NotL(groupId, layoutUuid, QueryUtil.ALL_POS,
14929                            QueryUtil.ALL_POS, null);
14930            }
14931    
14932            /**
14933             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid &ne; &#63;.
14934             *
14935             * <p>
14936             * 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.
14937             * </p>
14938             *
14939             * @param groupId the group ID
14940             * @param layoutUuid the layout uuid
14941             * @param start the lower bound of the range of journal articles
14942             * @param end the upper bound of the range of journal articles (not inclusive)
14943             * @return the range of matching journal articles that the user has permission to view
14944             * @throws SystemException if a system exception occurred
14945             */
14946            @Override
14947            public List<JournalArticle> filterFindByG_NotL(long groupId,
14948                    String layoutUuid, int start, int end) throws SystemException {
14949                    return filterFindByG_NotL(groupId, layoutUuid, start, end, null);
14950            }
14951    
14952            /**
14953             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and layoutUuid &ne; &#63;.
14954             *
14955             * <p>
14956             * 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.
14957             * </p>
14958             *
14959             * @param groupId the group ID
14960             * @param layoutUuid the layout uuid
14961             * @param start the lower bound of the range of journal articles
14962             * @param end the upper bound of the range of journal articles (not inclusive)
14963             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14964             * @return the ordered range of matching journal articles that the user has permission to view
14965             * @throws SystemException if a system exception occurred
14966             */
14967            @Override
14968            public List<JournalArticle> filterFindByG_NotL(long groupId,
14969                    String layoutUuid, int start, int end,
14970                    OrderByComparator orderByComparator) throws SystemException {
14971                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14972                            return findByG_NotL(groupId, layoutUuid, start, end,
14973                                    orderByComparator);
14974                    }
14975    
14976                    StringBundler query = null;
14977    
14978                    if (orderByComparator != null) {
14979                            query = new StringBundler(4 +
14980                                            (orderByComparator.getOrderByFields().length * 3));
14981                    }
14982                    else {
14983                            query = new StringBundler(4);
14984                    }
14985    
14986                    if (getDB().isSupportsInlineDistinct()) {
14987                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
14988                    }
14989                    else {
14990                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
14991                    }
14992    
14993                    query.append(_FINDER_COLUMN_G_NOTL_GROUPID_2);
14994    
14995                    boolean bindLayoutUuid = false;
14996    
14997                    if (layoutUuid == null) {
14998                            query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_1);
14999                    }
15000                    else if (layoutUuid.equals(StringPool.BLANK)) {
15001                            query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_3);
15002                    }
15003                    else {
15004                            bindLayoutUuid = true;
15005    
15006                            query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_2);
15007                    }
15008    
15009                    if (!getDB().isSupportsInlineDistinct()) {
15010                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
15011                    }
15012    
15013                    if (orderByComparator != null) {
15014                            if (getDB().isSupportsInlineDistinct()) {
15015                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15016                                            orderByComparator, true);
15017                            }
15018                            else {
15019                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
15020                                            orderByComparator, true);
15021                            }
15022                    }
15023                    else {
15024                            if (getDB().isSupportsInlineDistinct()) {
15025                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15026                            }
15027                            else {
15028                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
15029                            }
15030                    }
15031    
15032                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15033                                    JournalArticle.class.getName(),
15034                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15035    
15036                    Session session = null;
15037    
15038                    try {
15039                            session = openSession();
15040    
15041                            SQLQuery q = session.createSQLQuery(sql);
15042    
15043                            if (getDB().isSupportsInlineDistinct()) {
15044                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
15045                            }
15046                            else {
15047                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
15048                            }
15049    
15050                            QueryPos qPos = QueryPos.getInstance(q);
15051    
15052                            qPos.add(groupId);
15053    
15054                            if (bindLayoutUuid) {
15055                                    qPos.add(layoutUuid);
15056                            }
15057    
15058                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
15059                                    end);
15060                    }
15061                    catch (Exception e) {
15062                            throw processException(e);
15063                    }
15064                    finally {
15065                            closeSession(session);
15066                    }
15067            }
15068    
15069            /**
15070             * 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 &ne; &#63;.
15071             *
15072             * @param id the primary key of the current journal article
15073             * @param groupId the group ID
15074             * @param layoutUuid the layout uuid
15075             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15076             * @return the previous, current, and next journal article
15077             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
15078             * @throws SystemException if a system exception occurred
15079             */
15080            @Override
15081            public JournalArticle[] filterFindByG_NotL_PrevAndNext(long id,
15082                    long groupId, String layoutUuid, OrderByComparator orderByComparator)
15083                    throws NoSuchArticleException, SystemException {
15084                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15085                            return findByG_NotL_PrevAndNext(id, groupId, layoutUuid,
15086                                    orderByComparator);
15087                    }
15088    
15089                    JournalArticle journalArticle = findByPrimaryKey(id);
15090    
15091                    Session session = null;
15092    
15093                    try {
15094                            session = openSession();
15095    
15096                            JournalArticle[] array = new JournalArticleImpl[3];
15097    
15098                            array[0] = filterGetByG_NotL_PrevAndNext(session, journalArticle,
15099                                            groupId, layoutUuid, orderByComparator, true);
15100    
15101                            array[1] = journalArticle;
15102    
15103                            array[2] = filterGetByG_NotL_PrevAndNext(session, journalArticle,
15104                                            groupId, layoutUuid, orderByComparator, false);
15105    
15106                            return array;
15107                    }
15108                    catch (Exception e) {
15109                            throw processException(e);
15110                    }
15111                    finally {
15112                            closeSession(session);
15113                    }
15114            }
15115    
15116            protected JournalArticle filterGetByG_NotL_PrevAndNext(Session session,
15117                    JournalArticle journalArticle, long groupId, String layoutUuid,
15118                    OrderByComparator orderByComparator, boolean previous) {
15119                    StringBundler query = null;
15120    
15121                    if (orderByComparator != null) {
15122                            query = new StringBundler(6 +
15123                                            (orderByComparator.getOrderByFields().length * 6));
15124                    }
15125                    else {
15126                            query = new StringBundler(3);
15127                    }
15128    
15129                    if (getDB().isSupportsInlineDistinct()) {
15130                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
15131                    }
15132                    else {
15133                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
15134                    }
15135    
15136                    query.append(_FINDER_COLUMN_G_NOTL_GROUPID_2);
15137    
15138                    boolean bindLayoutUuid = false;
15139    
15140                    if (layoutUuid == null) {
15141                            query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_1);
15142                    }
15143                    else if (layoutUuid.equals(StringPool.BLANK)) {
15144                            query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_3);
15145                    }
15146                    else {
15147                            bindLayoutUuid = true;
15148    
15149                            query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_2);
15150                    }
15151    
15152                    if (!getDB().isSupportsInlineDistinct()) {
15153                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
15154                    }
15155    
15156                    if (orderByComparator != null) {
15157                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15158    
15159                            if (orderByConditionFields.length > 0) {
15160                                    query.append(WHERE_AND);
15161                            }
15162    
15163                            for (int i = 0; i < orderByConditionFields.length; i++) {
15164                                    if (getDB().isSupportsInlineDistinct()) {
15165                                            query.append(_ORDER_BY_ENTITY_ALIAS);
15166                                    }
15167                                    else {
15168                                            query.append(_ORDER_BY_ENTITY_TABLE);
15169                                    }
15170    
15171                                    query.append(orderByConditionFields[i]);
15172    
15173                                    if ((i + 1) < orderByConditionFields.length) {
15174                                            if (orderByComparator.isAscending() ^ previous) {
15175                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15176                                            }
15177                                            else {
15178                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15179                                            }
15180                                    }
15181                                    else {
15182                                            if (orderByComparator.isAscending() ^ previous) {
15183                                                    query.append(WHERE_GREATER_THAN);
15184                                            }
15185                                            else {
15186                                                    query.append(WHERE_LESSER_THAN);
15187                                            }
15188                                    }
15189                            }
15190    
15191                            query.append(ORDER_BY_CLAUSE);
15192    
15193                            String[] orderByFields = orderByComparator.getOrderByFields();
15194    
15195                            for (int i = 0; i < orderByFields.length; i++) {
15196                                    if (getDB().isSupportsInlineDistinct()) {
15197                                            query.append(_ORDER_BY_ENTITY_ALIAS);
15198                                    }
15199                                    else {
15200                                            query.append(_ORDER_BY_ENTITY_TABLE);
15201                                    }
15202    
15203                                    query.append(orderByFields[i]);
15204    
15205                                    if ((i + 1) < orderByFields.length) {
15206                                            if (orderByComparator.isAscending() ^ previous) {
15207                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15208                                            }
15209                                            else {
15210                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15211                                            }
15212                                    }
15213                                    else {
15214                                            if (orderByComparator.isAscending() ^ previous) {
15215                                                    query.append(ORDER_BY_ASC);
15216                                            }
15217                                            else {
15218                                                    query.append(ORDER_BY_DESC);
15219                                            }
15220                                    }
15221                            }
15222                    }
15223                    else {
15224                            if (getDB().isSupportsInlineDistinct()) {
15225                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15226                            }
15227                            else {
15228                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
15229                            }
15230                    }
15231    
15232                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15233                                    JournalArticle.class.getName(),
15234                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15235    
15236                    SQLQuery q = session.createSQLQuery(sql);
15237    
15238                    q.setFirstResult(0);
15239                    q.setMaxResults(2);
15240    
15241                    if (getDB().isSupportsInlineDistinct()) {
15242                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
15243                    }
15244                    else {
15245                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
15246                    }
15247    
15248                    QueryPos qPos = QueryPos.getInstance(q);
15249    
15250                    qPos.add(groupId);
15251    
15252                    if (bindLayoutUuid) {
15253                            qPos.add(layoutUuid);
15254                    }
15255    
15256                    if (orderByComparator != null) {
15257                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
15258    
15259                            for (Object value : values) {
15260                                    qPos.add(value);
15261                            }
15262                    }
15263    
15264                    List<JournalArticle> list = q.list();
15265    
15266                    if (list.size() == 2) {
15267                            return list.get(1);
15268                    }
15269                    else {
15270                            return null;
15271                    }
15272            }
15273    
15274            /**
15275             * Returns all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid &ne; all &#63;.
15276             *
15277             * @param groupId the group ID
15278             * @param layoutUuids the layout uuids
15279             * @return the matching journal articles that the user has permission to view
15280             * @throws SystemException if a system exception occurred
15281             */
15282            @Override
15283            public List<JournalArticle> filterFindByG_NotL(long groupId,
15284                    String[] layoutUuids) throws SystemException {
15285                    return filterFindByG_NotL(groupId, layoutUuids, QueryUtil.ALL_POS,
15286                            QueryUtil.ALL_POS, null);
15287            }
15288    
15289            /**
15290             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid &ne; all &#63;.
15291             *
15292             * <p>
15293             * 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.
15294             * </p>
15295             *
15296             * @param groupId the group ID
15297             * @param layoutUuids the layout uuids
15298             * @param start the lower bound of the range of journal articles
15299             * @param end the upper bound of the range of journal articles (not inclusive)
15300             * @return the range of matching journal articles that the user has permission to view
15301             * @throws SystemException if a system exception occurred
15302             */
15303            @Override
15304            public List<JournalArticle> filterFindByG_NotL(long groupId,
15305                    String[] layoutUuids, int start, int end) throws SystemException {
15306                    return filterFindByG_NotL(groupId, layoutUuids, start, end, null);
15307            }
15308    
15309            /**
15310             * Returns an ordered range of all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid &ne; all &#63;.
15311             *
15312             * <p>
15313             * 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.
15314             * </p>
15315             *
15316             * @param groupId the group ID
15317             * @param layoutUuids the layout uuids
15318             * @param start the lower bound of the range of journal articles
15319             * @param end the upper bound of the range of journal articles (not inclusive)
15320             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15321             * @return the ordered range of matching journal articles that the user has permission to view
15322             * @throws SystemException if a system exception occurred
15323             */
15324            @Override
15325            public List<JournalArticle> filterFindByG_NotL(long groupId,
15326                    String[] layoutUuids, int start, int end,
15327                    OrderByComparator orderByComparator) throws SystemException {
15328                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15329                            return findByG_NotL(groupId, layoutUuids, start, end,
15330                                    orderByComparator);
15331                    }
15332    
15333                    StringBundler query = new StringBundler();
15334    
15335                    if (getDB().isSupportsInlineDistinct()) {
15336                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
15337                    }
15338                    else {
15339                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
15340                    }
15341    
15342                    boolean conjunctionable = false;
15343    
15344                    if (conjunctionable) {
15345                            query.append(WHERE_AND);
15346                    }
15347    
15348                    query.append(_FINDER_COLUMN_G_NOTL_GROUPID_5);
15349    
15350                    conjunctionable = true;
15351    
15352                    if ((layoutUuids == null) || (layoutUuids.length > 0)) {
15353                            if (conjunctionable) {
15354                                    query.append(WHERE_AND);
15355                            }
15356    
15357                            query.append(StringPool.OPEN_PARENTHESIS);
15358    
15359                            for (int i = 0; i < layoutUuids.length; i++) {
15360                                    String layoutUuid = layoutUuids[i];
15361    
15362                                    if (layoutUuid == null) {
15363                                            query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_4);
15364                                    }
15365                                    else if (layoutUuid.equals(StringPool.BLANK)) {
15366                                            query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_6);
15367                                    }
15368                                    else {
15369                                            query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_5);
15370                                    }
15371    
15372                                    if ((i + 1) < layoutUuids.length) {
15373                                            query.append(WHERE_AND);
15374                                    }
15375                            }
15376    
15377                            query.append(StringPool.CLOSE_PARENTHESIS);
15378    
15379                            conjunctionable = true;
15380                    }
15381    
15382                    if (!getDB().isSupportsInlineDistinct()) {
15383                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
15384                    }
15385    
15386                    if (orderByComparator != null) {
15387                            if (getDB().isSupportsInlineDistinct()) {
15388                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15389                                            orderByComparator, true);
15390                            }
15391                            else {
15392                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
15393                                            orderByComparator, true);
15394                            }
15395                    }
15396                    else {
15397                            if (getDB().isSupportsInlineDistinct()) {
15398                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15399                            }
15400                            else {
15401                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
15402                            }
15403                    }
15404    
15405                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15406                                    JournalArticle.class.getName(),
15407                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15408    
15409                    Session session = null;
15410    
15411                    try {
15412                            session = openSession();
15413    
15414                            SQLQuery q = session.createSQLQuery(sql);
15415    
15416                            if (getDB().isSupportsInlineDistinct()) {
15417                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
15418                            }
15419                            else {
15420                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
15421                            }
15422    
15423                            QueryPos qPos = QueryPos.getInstance(q);
15424    
15425                            qPos.add(groupId);
15426    
15427                            if (layoutUuids != null) {
15428                                    for (String layoutUuid : layoutUuids) {
15429                                            if ((layoutUuid != null) && !layoutUuid.isEmpty()) {
15430                                                    qPos.add(layoutUuid);
15431                                            }
15432                                    }
15433                            }
15434    
15435                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
15436                                    end);
15437                    }
15438                    catch (Exception e) {
15439                            throw processException(e);
15440                    }
15441                    finally {
15442                            closeSession(session);
15443                    }
15444            }
15445    
15446            /**
15447             * Returns all the journal articles where groupId = &#63; and layoutUuid &ne; all &#63;.
15448             *
15449             * <p>
15450             * 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.
15451             * </p>
15452             *
15453             * @param groupId the group ID
15454             * @param layoutUuids the layout uuids
15455             * @return the matching journal articles
15456             * @throws SystemException if a system exception occurred
15457             */
15458            @Override
15459            public List<JournalArticle> findByG_NotL(long groupId, String[] layoutUuids)
15460                    throws SystemException {
15461                    return findByG_NotL(groupId, layoutUuids, QueryUtil.ALL_POS,
15462                            QueryUtil.ALL_POS, null);
15463            }
15464    
15465            /**
15466             * Returns a range of all the journal articles where groupId = &#63; and layoutUuid &ne; all &#63;.
15467             *
15468             * <p>
15469             * 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.
15470             * </p>
15471             *
15472             * @param groupId the group ID
15473             * @param layoutUuids the layout uuids
15474             * @param start the lower bound of the range of journal articles
15475             * @param end the upper bound of the range of journal articles (not inclusive)
15476             * @return the range of matching journal articles
15477             * @throws SystemException if a system exception occurred
15478             */
15479            @Override
15480            public List<JournalArticle> findByG_NotL(long groupId,
15481                    String[] layoutUuids, int start, int end) throws SystemException {
15482                    return findByG_NotL(groupId, layoutUuids, start, end, null);
15483            }
15484    
15485            /**
15486             * Returns an ordered range of all the journal articles where groupId = &#63; and layoutUuid &ne; all &#63;.
15487             *
15488             * <p>
15489             * 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.
15490             * </p>
15491             *
15492             * @param groupId the group ID
15493             * @param layoutUuids the layout uuids
15494             * @param start the lower bound of the range of journal articles
15495             * @param end the upper bound of the range of journal articles (not inclusive)
15496             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15497             * @return the ordered range of matching journal articles
15498             * @throws SystemException if a system exception occurred
15499             */
15500            @Override
15501            public List<JournalArticle> findByG_NotL(long groupId,
15502                    String[] layoutUuids, int start, int end,
15503                    OrderByComparator orderByComparator) throws SystemException {
15504                    if ((layoutUuids != null) && (layoutUuids.length == 1)) {
15505                            return findByG_NotL(groupId, layoutUuids[0], start, end,
15506                                    orderByComparator);
15507                    }
15508    
15509                    boolean pagination = true;
15510                    Object[] finderArgs = null;
15511    
15512                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
15513                                    (orderByComparator == null)) {
15514                            pagination = false;
15515                            finderArgs = new Object[] { groupId, StringUtil.merge(layoutUuids) };
15516                    }
15517                    else {
15518                            finderArgs = new Object[] {
15519                                            groupId, StringUtil.merge(layoutUuids),
15520                                            
15521                                            start, end, orderByComparator
15522                                    };
15523                    }
15524    
15525                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTL,
15526                                    finderArgs, this);
15527    
15528                    if ((list != null) && !list.isEmpty()) {
15529                            for (JournalArticle journalArticle : list) {
15530                                    if ((groupId != journalArticle.getGroupId()) ||
15531                                                    !ArrayUtil.contains(layoutUuids,
15532                                                            journalArticle.getLayoutUuid())) {
15533                                            list = null;
15534    
15535                                            break;
15536                                    }
15537                            }
15538                    }
15539    
15540                    if (list == null) {
15541                            StringBundler query = new StringBundler();
15542    
15543                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15544    
15545                            boolean conjunctionable = false;
15546    
15547                            if (conjunctionable) {
15548                                    query.append(WHERE_AND);
15549                            }
15550    
15551                            query.append(_FINDER_COLUMN_G_NOTL_GROUPID_5);
15552    
15553                            conjunctionable = true;
15554    
15555                            if ((layoutUuids == null) || (layoutUuids.length > 0)) {
15556                                    if (conjunctionable) {
15557                                            query.append(WHERE_AND);
15558                                    }
15559    
15560                                    query.append(StringPool.OPEN_PARENTHESIS);
15561    
15562                                    for (int i = 0; i < layoutUuids.length; i++) {
15563                                            String layoutUuid = layoutUuids[i];
15564    
15565                                            if (layoutUuid == null) {
15566                                                    query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_4);
15567                                            }
15568                                            else if (layoutUuid.equals(StringPool.BLANK)) {
15569                                                    query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_6);
15570                                            }
15571                                            else {
15572                                                    query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_5);
15573                                            }
15574    
15575                                            if ((i + 1) < layoutUuids.length) {
15576                                                    query.append(WHERE_AND);
15577                                            }
15578                                    }
15579    
15580                                    query.append(StringPool.CLOSE_PARENTHESIS);
15581    
15582                                    conjunctionable = true;
15583                            }
15584    
15585                            if (orderByComparator != null) {
15586                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15587                                            orderByComparator);
15588                            }
15589                            else
15590                             if (pagination) {
15591                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15592                            }
15593    
15594                            String sql = query.toString();
15595    
15596                            Session session = null;
15597    
15598                            try {
15599                                    session = openSession();
15600    
15601                                    Query q = session.createQuery(sql);
15602    
15603                                    QueryPos qPos = QueryPos.getInstance(q);
15604    
15605                                    qPos.add(groupId);
15606    
15607                                    if (layoutUuids != null) {
15608                                            for (String layoutUuid : layoutUuids) {
15609                                                    if ((layoutUuid != null) && !layoutUuid.isEmpty()) {
15610                                                            qPos.add(layoutUuid);
15611                                                    }
15612                                            }
15613                                    }
15614    
15615                                    if (!pagination) {
15616                                            list = (List<JournalArticle>)QueryUtil.list(q,
15617                                                            getDialect(), start, end, false);
15618    
15619                                            Collections.sort(list);
15620    
15621                                            list = new UnmodifiableList<JournalArticle>(list);
15622                                    }
15623                                    else {
15624                                            list = (List<JournalArticle>)QueryUtil.list(q,
15625                                                            getDialect(), start, end);
15626                                    }
15627    
15628                                    cacheResult(list);
15629    
15630                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTL,
15631                                            finderArgs, list);
15632                            }
15633                            catch (Exception e) {
15634                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTL,
15635                                            finderArgs);
15636    
15637                                    throw processException(e);
15638                            }
15639                            finally {
15640                                    closeSession(session);
15641                            }
15642                    }
15643    
15644                    return list;
15645            }
15646    
15647            /**
15648             * Removes all the journal articles where groupId = &#63; and layoutUuid &ne; &#63; from the database.
15649             *
15650             * @param groupId the group ID
15651             * @param layoutUuid the layout uuid
15652             * @throws SystemException if a system exception occurred
15653             */
15654            @Override
15655            public void removeByG_NotL(long groupId, String layoutUuid)
15656                    throws SystemException {
15657                    for (JournalArticle journalArticle : findByG_NotL(groupId, layoutUuid,
15658                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15659                            remove(journalArticle);
15660                    }
15661            }
15662    
15663            /**
15664             * Returns the number of journal articles where groupId = &#63; and layoutUuid &ne; &#63;.
15665             *
15666             * @param groupId the group ID
15667             * @param layoutUuid the layout uuid
15668             * @return the number of matching journal articles
15669             * @throws SystemException if a system exception occurred
15670             */
15671            @Override
15672            public int countByG_NotL(long groupId, String layoutUuid)
15673                    throws SystemException {
15674                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTL;
15675    
15676                    Object[] finderArgs = new Object[] { groupId, layoutUuid };
15677    
15678                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
15679                                    this);
15680    
15681                    if (count == null) {
15682                            StringBundler query = new StringBundler(3);
15683    
15684                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15685    
15686                            query.append(_FINDER_COLUMN_G_NOTL_GROUPID_2);
15687    
15688                            boolean bindLayoutUuid = false;
15689    
15690                            if (layoutUuid == null) {
15691                                    query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_1);
15692                            }
15693                            else if (layoutUuid.equals(StringPool.BLANK)) {
15694                                    query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_3);
15695                            }
15696                            else {
15697                                    bindLayoutUuid = true;
15698    
15699                                    query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_2);
15700                            }
15701    
15702                            String sql = query.toString();
15703    
15704                            Session session = null;
15705    
15706                            try {
15707                                    session = openSession();
15708    
15709                                    Query q = session.createQuery(sql);
15710    
15711                                    QueryPos qPos = QueryPos.getInstance(q);
15712    
15713                                    qPos.add(groupId);
15714    
15715                                    if (bindLayoutUuid) {
15716                                            qPos.add(layoutUuid);
15717                                    }
15718    
15719                                    count = (Long)q.uniqueResult();
15720    
15721                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
15722                            }
15723                            catch (Exception e) {
15724                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15725    
15726                                    throw processException(e);
15727                            }
15728                            finally {
15729                                    closeSession(session);
15730                            }
15731                    }
15732    
15733                    return count.intValue();
15734            }
15735    
15736            /**
15737             * Returns the number of journal articles where groupId = &#63; and layoutUuid &ne; all &#63;.
15738             *
15739             * @param groupId the group ID
15740             * @param layoutUuids the layout uuids
15741             * @return the number of matching journal articles
15742             * @throws SystemException if a system exception occurred
15743             */
15744            @Override
15745            public int countByG_NotL(long groupId, String[] layoutUuids)
15746                    throws SystemException {
15747                    Object[] finderArgs = new Object[] {
15748                                    groupId, StringUtil.merge(layoutUuids)
15749                            };
15750    
15751                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTL,
15752                                    finderArgs, this);
15753    
15754                    if (count == null) {
15755                            StringBundler query = new StringBundler();
15756    
15757                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15758    
15759                            boolean conjunctionable = false;
15760    
15761                            if (conjunctionable) {
15762                                    query.append(WHERE_AND);
15763                            }
15764    
15765                            query.append(_FINDER_COLUMN_G_NOTL_GROUPID_5);
15766    
15767                            conjunctionable = true;
15768    
15769                            if ((layoutUuids == null) || (layoutUuids.length > 0)) {
15770                                    if (conjunctionable) {
15771                                            query.append(WHERE_AND);
15772                                    }
15773    
15774                                    query.append(StringPool.OPEN_PARENTHESIS);
15775    
15776                                    for (int i = 0; i < layoutUuids.length; i++) {
15777                                            String layoutUuid = layoutUuids[i];
15778    
15779                                            if (layoutUuid == null) {
15780                                                    query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_4);
15781                                            }
15782                                            else if (layoutUuid.equals(StringPool.BLANK)) {
15783                                                    query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_6);
15784                                            }
15785                                            else {
15786                                                    query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_5);
15787                                            }
15788    
15789                                            if ((i + 1) < layoutUuids.length) {
15790                                                    query.append(WHERE_AND);
15791                                            }
15792                                    }
15793    
15794                                    query.append(StringPool.CLOSE_PARENTHESIS);
15795    
15796                                    conjunctionable = true;
15797                            }
15798    
15799                            String sql = query.toString();
15800    
15801                            Session session = null;
15802    
15803                            try {
15804                                    session = openSession();
15805    
15806                                    Query q = session.createQuery(sql);
15807    
15808                                    QueryPos qPos = QueryPos.getInstance(q);
15809    
15810                                    qPos.add(groupId);
15811    
15812                                    if (layoutUuids != null) {
15813                                            for (String layoutUuid : layoutUuids) {
15814                                                    if ((layoutUuid != null) && !layoutUuid.isEmpty()) {
15815                                                            qPos.add(layoutUuid);
15816                                                    }
15817                                            }
15818                                    }
15819    
15820                                    count = (Long)q.uniqueResult();
15821    
15822                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTL,
15823                                            finderArgs, count);
15824                            }
15825                            catch (Exception e) {
15826                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTL,
15827                                            finderArgs);
15828    
15829                                    throw processException(e);
15830                            }
15831                            finally {
15832                                    closeSession(session);
15833                            }
15834                    }
15835    
15836                    return count.intValue();
15837            }
15838    
15839            /**
15840             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and layoutUuid &ne; &#63;.
15841             *
15842             * @param groupId the group ID
15843             * @param layoutUuid the layout uuid
15844             * @return the number of matching journal articles that the user has permission to view
15845             * @throws SystemException if a system exception occurred
15846             */
15847            @Override
15848            public int filterCountByG_NotL(long groupId, String layoutUuid)
15849                    throws SystemException {
15850                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15851                            return countByG_NotL(groupId, layoutUuid);
15852                    }
15853    
15854                    StringBundler query = new StringBundler(3);
15855    
15856                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
15857    
15858                    query.append(_FINDER_COLUMN_G_NOTL_GROUPID_2);
15859    
15860                    boolean bindLayoutUuid = false;
15861    
15862                    if (layoutUuid == null) {
15863                            query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_1);
15864                    }
15865                    else if (layoutUuid.equals(StringPool.BLANK)) {
15866                            query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_3);
15867                    }
15868                    else {
15869                            bindLayoutUuid = true;
15870    
15871                            query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_2);
15872                    }
15873    
15874                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15875                                    JournalArticle.class.getName(),
15876                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15877    
15878                    Session session = null;
15879    
15880                    try {
15881                            session = openSession();
15882    
15883                            SQLQuery q = session.createSQLQuery(sql);
15884    
15885                            q.addScalar(COUNT_COLUMN_NAME,
15886                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15887    
15888                            QueryPos qPos = QueryPos.getInstance(q);
15889    
15890                            qPos.add(groupId);
15891    
15892                            if (bindLayoutUuid) {
15893                                    qPos.add(layoutUuid);
15894                            }
15895    
15896                            Long count = (Long)q.uniqueResult();
15897    
15898                            return count.intValue();
15899                    }
15900                    catch (Exception e) {
15901                            throw processException(e);
15902                    }
15903                    finally {
15904                            closeSession(session);
15905                    }
15906            }
15907    
15908            /**
15909             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and layoutUuid &ne; all &#63;.
15910             *
15911             * @param groupId the group ID
15912             * @param layoutUuids the layout uuids
15913             * @return the number of matching journal articles that the user has permission to view
15914             * @throws SystemException if a system exception occurred
15915             */
15916            @Override
15917            public int filterCountByG_NotL(long groupId, String[] layoutUuids)
15918                    throws SystemException {
15919                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15920                            return countByG_NotL(groupId, layoutUuids);
15921                    }
15922    
15923                    StringBundler query = new StringBundler();
15924    
15925                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
15926    
15927                    boolean conjunctionable = false;
15928    
15929                    if (conjunctionable) {
15930                            query.append(WHERE_AND);
15931                    }
15932    
15933                    query.append(_FINDER_COLUMN_G_NOTL_GROUPID_5);
15934    
15935                    conjunctionable = true;
15936    
15937                    if ((layoutUuids == null) || (layoutUuids.length > 0)) {
15938                            if (conjunctionable) {
15939                                    query.append(WHERE_AND);
15940                            }
15941    
15942                            query.append(StringPool.OPEN_PARENTHESIS);
15943    
15944                            for (int i = 0; i < layoutUuids.length; i++) {
15945                                    String layoutUuid = layoutUuids[i];
15946    
15947                                    if (layoutUuid == null) {
15948                                            query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_4);
15949                                    }
15950                                    else if (layoutUuid.equals(StringPool.BLANK)) {
15951                                            query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_6);
15952                                    }
15953                                    else {
15954                                            query.append(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_5);
15955                                    }
15956    
15957                                    if ((i + 1) < layoutUuids.length) {
15958                                            query.append(WHERE_AND);
15959                                    }
15960                            }
15961    
15962                            query.append(StringPool.CLOSE_PARENTHESIS);
15963    
15964                            conjunctionable = true;
15965                    }
15966    
15967                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15968                                    JournalArticle.class.getName(),
15969                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15970    
15971                    Session session = null;
15972    
15973                    try {
15974                            session = openSession();
15975    
15976                            SQLQuery q = session.createSQLQuery(sql);
15977    
15978                            q.addScalar(COUNT_COLUMN_NAME,
15979                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15980    
15981                            QueryPos qPos = QueryPos.getInstance(q);
15982    
15983                            qPos.add(groupId);
15984    
15985                            if (layoutUuids != null) {
15986                                    for (String layoutUuid : layoutUuids) {
15987                                            if ((layoutUuid != null) && !layoutUuid.isEmpty()) {
15988                                                    qPos.add(layoutUuid);
15989                                            }
15990                                    }
15991                            }
15992    
15993                            Long count = (Long)q.uniqueResult();
15994    
15995                            return count.intValue();
15996                    }
15997                    catch (Exception e) {
15998                            throw processException(e);
15999                    }
16000                    finally {
16001                            closeSession(session);
16002                    }
16003            }
16004    
16005            private static final String _FINDER_COLUMN_G_NOTL_GROUPID_2 = "journalArticle.groupId = ? AND ";
16006            private static final String _FINDER_COLUMN_G_NOTL_GROUPID_5 = "(" +
16007                    removeConjunction(_FINDER_COLUMN_G_NOTL_GROUPID_2) + ")";
16008            private static final String _FINDER_COLUMN_G_NOTL_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NOT NULL";
16009            private static final String _FINDER_COLUMN_G_NOTL_LAYOUTUUID_2 = "journalArticle.layoutUuid != ?";
16010            private static final String _FINDER_COLUMN_G_NOTL_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid != '')";
16011            private static final String _FINDER_COLUMN_G_NOTL_LAYOUTUUID_4 = "(" +
16012                    removeConjunction(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_1) + ")";
16013            private static final String _FINDER_COLUMN_G_NOTL_LAYOUTUUID_5 = "(" +
16014                    removeConjunction(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_2) + ")";
16015            private static final String _FINDER_COLUMN_G_NOTL_LAYOUTUUID_6 = "(" +
16016                    removeConjunction(_FINDER_COLUMN_G_NOTL_LAYOUTUUID_3) + ")";
16017            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16018                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
16019                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
16020                            "findByG_ST",
16021                            new String[] {
16022                                    Long.class.getName(), Integer.class.getName(),
16023                                    
16024                            Integer.class.getName(), Integer.class.getName(),
16025                                    OrderByComparator.class.getName()
16026                            });
16027            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16028                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
16029                            JournalArticleImpl.class,
16030                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_ST",
16031                            new String[] { Long.class.getName(), Integer.class.getName() },
16032                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
16033                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
16034                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
16035                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
16036            public static final FinderPath FINDER_PATH_COUNT_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16037                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
16038                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_ST",
16039                            new String[] { Long.class.getName(), Integer.class.getName() });
16040    
16041            /**
16042             * Returns all the journal articles where groupId = &#63; and status = &#63;.
16043             *
16044             * @param groupId the group ID
16045             * @param status the status
16046             * @return the matching journal articles
16047             * @throws SystemException if a system exception occurred
16048             */
16049            @Override
16050            public List<JournalArticle> findByG_ST(long groupId, int status)
16051                    throws SystemException {
16052                    return findByG_ST(groupId, status, QueryUtil.ALL_POS,
16053                            QueryUtil.ALL_POS, null);
16054            }
16055    
16056            /**
16057             * Returns a range of all the journal articles where groupId = &#63; and status = &#63;.
16058             *
16059             * <p>
16060             * 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.
16061             * </p>
16062             *
16063             * @param groupId the group ID
16064             * @param status the status
16065             * @param start the lower bound of the range of journal articles
16066             * @param end the upper bound of the range of journal articles (not inclusive)
16067             * @return the range of matching journal articles
16068             * @throws SystemException if a system exception occurred
16069             */
16070            @Override
16071            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
16072                    int end) throws SystemException {
16073                    return findByG_ST(groupId, status, start, end, null);
16074            }
16075    
16076            /**
16077             * Returns an ordered range of all the journal articles where groupId = &#63; and status = &#63;.
16078             *
16079             * <p>
16080             * 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.
16081             * </p>
16082             *
16083             * @param groupId the group ID
16084             * @param status the status
16085             * @param start the lower bound of the range of journal articles
16086             * @param end the upper bound of the range of journal articles (not inclusive)
16087             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16088             * @return the ordered range of matching journal articles
16089             * @throws SystemException if a system exception occurred
16090             */
16091            @Override
16092            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
16093                    int end, OrderByComparator orderByComparator) throws SystemException {
16094                    boolean pagination = true;
16095                    FinderPath finderPath = null;
16096                    Object[] finderArgs = null;
16097    
16098                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
16099                                    (orderByComparator == null)) {
16100                            pagination = false;
16101                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST;
16102                            finderArgs = new Object[] { groupId, status };
16103                    }
16104                    else {
16105                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_ST;
16106                            finderArgs = new Object[] {
16107                                            groupId, status,
16108                                            
16109                                            start, end, orderByComparator
16110                                    };
16111                    }
16112    
16113                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
16114                                    finderArgs, this);
16115    
16116                    if ((list != null) && !list.isEmpty()) {
16117                            for (JournalArticle journalArticle : list) {
16118                                    if ((groupId != journalArticle.getGroupId()) ||
16119                                                    (status != journalArticle.getStatus())) {
16120                                            list = null;
16121    
16122                                            break;
16123                                    }
16124                            }
16125                    }
16126    
16127                    if (list == null) {
16128                            StringBundler query = null;
16129    
16130                            if (orderByComparator != null) {
16131                                    query = new StringBundler(4 +
16132                                                    (orderByComparator.getOrderByFields().length * 3));
16133                            }
16134                            else {
16135                                    query = new StringBundler(4);
16136                            }
16137    
16138                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16139    
16140                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
16141    
16142                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
16143    
16144                            if (orderByComparator != null) {
16145                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16146                                            orderByComparator);
16147                            }
16148                            else
16149                             if (pagination) {
16150                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16151                            }
16152    
16153                            String sql = query.toString();
16154    
16155                            Session session = null;
16156    
16157                            try {
16158                                    session = openSession();
16159    
16160                                    Query q = session.createQuery(sql);
16161    
16162                                    QueryPos qPos = QueryPos.getInstance(q);
16163    
16164                                    qPos.add(groupId);
16165    
16166                                    qPos.add(status);
16167    
16168                                    if (!pagination) {
16169                                            list = (List<JournalArticle>)QueryUtil.list(q,
16170                                                            getDialect(), start, end, false);
16171    
16172                                            Collections.sort(list);
16173    
16174                                            list = new UnmodifiableList<JournalArticle>(list);
16175                                    }
16176                                    else {
16177                                            list = (List<JournalArticle>)QueryUtil.list(q,
16178                                                            getDialect(), start, end);
16179                                    }
16180    
16181                                    cacheResult(list);
16182    
16183                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
16184                            }
16185                            catch (Exception e) {
16186                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16187    
16188                                    throw processException(e);
16189                            }
16190                            finally {
16191                                    closeSession(session);
16192                            }
16193                    }
16194    
16195                    return list;
16196            }
16197    
16198            /**
16199             * Returns the first journal article in the ordered set where groupId = &#63; and status = &#63;.
16200             *
16201             * @param groupId the group ID
16202             * @param status the status
16203             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16204             * @return the first matching journal article
16205             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16206             * @throws SystemException if a system exception occurred
16207             */
16208            @Override
16209            public JournalArticle findByG_ST_First(long groupId, int status,
16210                    OrderByComparator orderByComparator)
16211                    throws NoSuchArticleException, SystemException {
16212                    JournalArticle journalArticle = fetchByG_ST_First(groupId, 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("groupId=");
16224                    msg.append(groupId);
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 first journal article in the ordered set where groupId = &#63; and status = &#63;.
16236             *
16237             * @param groupId the group ID
16238             * @param status the status
16239             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16240             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
16241             * @throws SystemException if a system exception occurred
16242             */
16243            @Override
16244            public JournalArticle fetchByG_ST_First(long groupId, int status,
16245                    OrderByComparator orderByComparator) throws SystemException {
16246                    List<JournalArticle> list = findByG_ST(groupId, status, 0, 1,
16247                                    orderByComparator);
16248    
16249                    if (!list.isEmpty()) {
16250                            return list.get(0);
16251                    }
16252    
16253                    return null;
16254            }
16255    
16256            /**
16257             * Returns the last journal article in the ordered set where groupId = &#63; and status = &#63;.
16258             *
16259             * @param groupId the group ID
16260             * @param status the status
16261             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16262             * @return the last matching journal article
16263             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16264             * @throws SystemException if a system exception occurred
16265             */
16266            @Override
16267            public JournalArticle findByG_ST_Last(long groupId, int status,
16268                    OrderByComparator orderByComparator)
16269                    throws NoSuchArticleException, SystemException {
16270                    JournalArticle journalArticle = fetchByG_ST_Last(groupId, status,
16271                                    orderByComparator);
16272    
16273                    if (journalArticle != null) {
16274                            return journalArticle;
16275                    }
16276    
16277                    StringBundler msg = new StringBundler(6);
16278    
16279                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16280    
16281                    msg.append("groupId=");
16282                    msg.append(groupId);
16283    
16284                    msg.append(", status=");
16285                    msg.append(status);
16286    
16287                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16288    
16289                    throw new NoSuchArticleException(msg.toString());
16290            }
16291    
16292            /**
16293             * Returns the last journal article in the ordered set where groupId = &#63; and status = &#63;.
16294             *
16295             * @param groupId the group ID
16296             * @param status the status
16297             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16298             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
16299             * @throws SystemException if a system exception occurred
16300             */
16301            @Override
16302            public JournalArticle fetchByG_ST_Last(long groupId, int status,
16303                    OrderByComparator orderByComparator) throws SystemException {
16304                    int count = countByG_ST(groupId, status);
16305    
16306                    if (count == 0) {
16307                            return null;
16308                    }
16309    
16310                    List<JournalArticle> list = findByG_ST(groupId, status, count - 1,
16311                                    count, orderByComparator);
16312    
16313                    if (!list.isEmpty()) {
16314                            return list.get(0);
16315                    }
16316    
16317                    return null;
16318            }
16319    
16320            /**
16321             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and status = &#63;.
16322             *
16323             * @param id the primary key of the current journal article
16324             * @param groupId the group ID
16325             * @param status the status
16326             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16327             * @return the previous, current, and next journal article
16328             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
16329             * @throws SystemException if a system exception occurred
16330             */
16331            @Override
16332            public JournalArticle[] findByG_ST_PrevAndNext(long id, long groupId,
16333                    int status, OrderByComparator orderByComparator)
16334                    throws NoSuchArticleException, SystemException {
16335                    JournalArticle journalArticle = findByPrimaryKey(id);
16336    
16337                    Session session = null;
16338    
16339                    try {
16340                            session = openSession();
16341    
16342                            JournalArticle[] array = new JournalArticleImpl[3];
16343    
16344                            array[0] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
16345                                            status, orderByComparator, true);
16346    
16347                            array[1] = journalArticle;
16348    
16349                            array[2] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
16350                                            status, orderByComparator, false);
16351    
16352                            return array;
16353                    }
16354                    catch (Exception e) {
16355                            throw processException(e);
16356                    }
16357                    finally {
16358                            closeSession(session);
16359                    }
16360            }
16361    
16362            protected JournalArticle getByG_ST_PrevAndNext(Session session,
16363                    JournalArticle journalArticle, long groupId, int status,
16364                    OrderByComparator orderByComparator, boolean previous) {
16365                    StringBundler query = null;
16366    
16367                    if (orderByComparator != null) {
16368                            query = new StringBundler(6 +
16369                                            (orderByComparator.getOrderByFields().length * 6));
16370                    }
16371                    else {
16372                            query = new StringBundler(3);
16373                    }
16374    
16375                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16376    
16377                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
16378    
16379                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
16380    
16381                    if (orderByComparator != null) {
16382                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16383    
16384                            if (orderByConditionFields.length > 0) {
16385                                    query.append(WHERE_AND);
16386                            }
16387    
16388                            for (int i = 0; i < orderByConditionFields.length; i++) {
16389                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16390                                    query.append(orderByConditionFields[i]);
16391    
16392                                    if ((i + 1) < orderByConditionFields.length) {
16393                                            if (orderByComparator.isAscending() ^ previous) {
16394                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16395                                            }
16396                                            else {
16397                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16398                                            }
16399                                    }
16400                                    else {
16401                                            if (orderByComparator.isAscending() ^ previous) {
16402                                                    query.append(WHERE_GREATER_THAN);
16403                                            }
16404                                            else {
16405                                                    query.append(WHERE_LESSER_THAN);
16406                                            }
16407                                    }
16408                            }
16409    
16410                            query.append(ORDER_BY_CLAUSE);
16411    
16412                            String[] orderByFields = orderByComparator.getOrderByFields();
16413    
16414                            for (int i = 0; i < orderByFields.length; i++) {
16415                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16416                                    query.append(orderByFields[i]);
16417    
16418                                    if ((i + 1) < orderByFields.length) {
16419                                            if (orderByComparator.isAscending() ^ previous) {
16420                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16421                                            }
16422                                            else {
16423                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16424                                            }
16425                                    }
16426                                    else {
16427                                            if (orderByComparator.isAscending() ^ previous) {
16428                                                    query.append(ORDER_BY_ASC);
16429                                            }
16430                                            else {
16431                                                    query.append(ORDER_BY_DESC);
16432                                            }
16433                                    }
16434                            }
16435                    }
16436                    else {
16437                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16438                    }
16439    
16440                    String sql = query.toString();
16441    
16442                    Query q = session.createQuery(sql);
16443    
16444                    q.setFirstResult(0);
16445                    q.setMaxResults(2);
16446    
16447                    QueryPos qPos = QueryPos.getInstance(q);
16448    
16449                    qPos.add(groupId);
16450    
16451                    qPos.add(status);
16452    
16453                    if (orderByComparator != null) {
16454                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
16455    
16456                            for (Object value : values) {
16457                                    qPos.add(value);
16458                            }
16459                    }
16460    
16461                    List<JournalArticle> list = q.list();
16462    
16463                    if (list.size() == 2) {
16464                            return list.get(1);
16465                    }
16466                    else {
16467                            return null;
16468                    }
16469            }
16470    
16471            /**
16472             * Returns all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
16473             *
16474             * @param groupId the group ID
16475             * @param status the status
16476             * @return the matching journal articles that the user has permission to view
16477             * @throws SystemException if a system exception occurred
16478             */
16479            @Override
16480            public List<JournalArticle> filterFindByG_ST(long groupId, int status)
16481                    throws SystemException {
16482                    return filterFindByG_ST(groupId, status, QueryUtil.ALL_POS,
16483                            QueryUtil.ALL_POS, null);
16484            }
16485    
16486            /**
16487             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
16488             *
16489             * <p>
16490             * 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.
16491             * </p>
16492             *
16493             * @param groupId the group ID
16494             * @param status the status
16495             * @param start the lower bound of the range of journal articles
16496             * @param end the upper bound of the range of journal articles (not inclusive)
16497             * @return the range of matching journal articles that the user has permission to view
16498             * @throws SystemException if a system exception occurred
16499             */
16500            @Override
16501            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
16502                    int start, int end) throws SystemException {
16503                    return filterFindByG_ST(groupId, status, start, end, null);
16504            }
16505    
16506            /**
16507             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and status = &#63;.
16508             *
16509             * <p>
16510             * 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.
16511             * </p>
16512             *
16513             * @param groupId the group ID
16514             * @param status the status
16515             * @param start the lower bound of the range of journal articles
16516             * @param end the upper bound of the range of journal articles (not inclusive)
16517             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16518             * @return the ordered range of matching journal articles that the user has permission to view
16519             * @throws SystemException if a system exception occurred
16520             */
16521            @Override
16522            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
16523                    int start, int end, OrderByComparator orderByComparator)
16524                    throws SystemException {
16525                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16526                            return findByG_ST(groupId, status, start, end, orderByComparator);
16527                    }
16528    
16529                    StringBundler query = null;
16530    
16531                    if (orderByComparator != null) {
16532                            query = new StringBundler(4 +
16533                                            (orderByComparator.getOrderByFields().length * 3));
16534                    }
16535                    else {
16536                            query = new StringBundler(4);
16537                    }
16538    
16539                    if (getDB().isSupportsInlineDistinct()) {
16540                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
16541                    }
16542                    else {
16543                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
16544                    }
16545    
16546                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
16547    
16548                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
16549    
16550                    if (!getDB().isSupportsInlineDistinct()) {
16551                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
16552                    }
16553    
16554                    if (orderByComparator != null) {
16555                            if (getDB().isSupportsInlineDistinct()) {
16556                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16557                                            orderByComparator, true);
16558                            }
16559                            else {
16560                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
16561                                            orderByComparator, true);
16562                            }
16563                    }
16564                    else {
16565                            if (getDB().isSupportsInlineDistinct()) {
16566                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16567                            }
16568                            else {
16569                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
16570                            }
16571                    }
16572    
16573                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16574                                    JournalArticle.class.getName(),
16575                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16576    
16577                    Session session = null;
16578    
16579                    try {
16580                            session = openSession();
16581    
16582                            SQLQuery q = session.createSQLQuery(sql);
16583    
16584                            if (getDB().isSupportsInlineDistinct()) {
16585                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
16586                            }
16587                            else {
16588                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
16589                            }
16590    
16591                            QueryPos qPos = QueryPos.getInstance(q);
16592    
16593                            qPos.add(groupId);
16594    
16595                            qPos.add(status);
16596    
16597                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
16598                                    end);
16599                    }
16600                    catch (Exception e) {
16601                            throw processException(e);
16602                    }
16603                    finally {
16604                            closeSession(session);
16605                    }
16606            }
16607    
16608            /**
16609             * 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;.
16610             *
16611             * @param id the primary key of the current journal article
16612             * @param groupId the group ID
16613             * @param status the status
16614             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16615             * @return the previous, current, and next journal article
16616             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
16617             * @throws SystemException if a system exception occurred
16618             */
16619            @Override
16620            public JournalArticle[] filterFindByG_ST_PrevAndNext(long id, long groupId,
16621                    int status, OrderByComparator orderByComparator)
16622                    throws NoSuchArticleException, SystemException {
16623                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16624                            return findByG_ST_PrevAndNext(id, groupId, status, orderByComparator);
16625                    }
16626    
16627                    JournalArticle journalArticle = findByPrimaryKey(id);
16628    
16629                    Session session = null;
16630    
16631                    try {
16632                            session = openSession();
16633    
16634                            JournalArticle[] array = new JournalArticleImpl[3];
16635    
16636                            array[0] = filterGetByG_ST_PrevAndNext(session, journalArticle,
16637                                            groupId, status, orderByComparator, true);
16638    
16639                            array[1] = journalArticle;
16640    
16641                            array[2] = filterGetByG_ST_PrevAndNext(session, journalArticle,
16642                                            groupId, status, orderByComparator, false);
16643    
16644                            return array;
16645                    }
16646                    catch (Exception e) {
16647                            throw processException(e);
16648                    }
16649                    finally {
16650                            closeSession(session);
16651                    }
16652            }
16653    
16654            protected JournalArticle filterGetByG_ST_PrevAndNext(Session session,
16655                    JournalArticle journalArticle, long groupId, int status,
16656                    OrderByComparator orderByComparator, boolean previous) {
16657                    StringBundler query = null;
16658    
16659                    if (orderByComparator != null) {
16660                            query = new StringBundler(6 +
16661                                            (orderByComparator.getOrderByFields().length * 6));
16662                    }
16663                    else {
16664                            query = new StringBundler(3);
16665                    }
16666    
16667                    if (getDB().isSupportsInlineDistinct()) {
16668                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
16669                    }
16670                    else {
16671                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
16672                    }
16673    
16674                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
16675    
16676                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
16677    
16678                    if (!getDB().isSupportsInlineDistinct()) {
16679                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
16680                    }
16681    
16682                    if (orderByComparator != null) {
16683                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16684    
16685                            if (orderByConditionFields.length > 0) {
16686                                    query.append(WHERE_AND);
16687                            }
16688    
16689                            for (int i = 0; i < orderByConditionFields.length; i++) {
16690                                    if (getDB().isSupportsInlineDistinct()) {
16691                                            query.append(_ORDER_BY_ENTITY_ALIAS);
16692                                    }
16693                                    else {
16694                                            query.append(_ORDER_BY_ENTITY_TABLE);
16695                                    }
16696    
16697                                    query.append(orderByConditionFields[i]);
16698    
16699                                    if ((i + 1) < orderByConditionFields.length) {
16700                                            if (orderByComparator.isAscending() ^ previous) {
16701                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16702                                            }
16703                                            else {
16704                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16705                                            }
16706                                    }
16707                                    else {
16708                                            if (orderByComparator.isAscending() ^ previous) {
16709                                                    query.append(WHERE_GREATER_THAN);
16710                                            }
16711                                            else {
16712                                                    query.append(WHERE_LESSER_THAN);
16713                                            }
16714                                    }
16715                            }
16716    
16717                            query.append(ORDER_BY_CLAUSE);
16718    
16719                            String[] orderByFields = orderByComparator.getOrderByFields();
16720    
16721                            for (int i = 0; i < orderByFields.length; i++) {
16722                                    if (getDB().isSupportsInlineDistinct()) {
16723                                            query.append(_ORDER_BY_ENTITY_ALIAS);
16724                                    }
16725                                    else {
16726                                            query.append(_ORDER_BY_ENTITY_TABLE);
16727                                    }
16728    
16729                                    query.append(orderByFields[i]);
16730    
16731                                    if ((i + 1) < orderByFields.length) {
16732                                            if (orderByComparator.isAscending() ^ previous) {
16733                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16734                                            }
16735                                            else {
16736                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16737                                            }
16738                                    }
16739                                    else {
16740                                            if (orderByComparator.isAscending() ^ previous) {
16741                                                    query.append(ORDER_BY_ASC);
16742                                            }
16743                                            else {
16744                                                    query.append(ORDER_BY_DESC);
16745                                            }
16746                                    }
16747                            }
16748                    }
16749                    else {
16750                            if (getDB().isSupportsInlineDistinct()) {
16751                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16752                            }
16753                            else {
16754                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
16755                            }
16756                    }
16757    
16758                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16759                                    JournalArticle.class.getName(),
16760                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16761    
16762                    SQLQuery q = session.createSQLQuery(sql);
16763    
16764                    q.setFirstResult(0);
16765                    q.setMaxResults(2);
16766    
16767                    if (getDB().isSupportsInlineDistinct()) {
16768                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
16769                    }
16770                    else {
16771                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
16772                    }
16773    
16774                    QueryPos qPos = QueryPos.getInstance(q);
16775    
16776                    qPos.add(groupId);
16777    
16778                    qPos.add(status);
16779    
16780                    if (orderByComparator != null) {
16781                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
16782    
16783                            for (Object value : values) {
16784                                    qPos.add(value);
16785                            }
16786                    }
16787    
16788                    List<JournalArticle> list = q.list();
16789    
16790                    if (list.size() == 2) {
16791                            return list.get(1);
16792                    }
16793                    else {
16794                            return null;
16795                    }
16796            }
16797    
16798            /**
16799             * Removes all the journal articles where groupId = &#63; and status = &#63; from the database.
16800             *
16801             * @param groupId the group ID
16802             * @param status the status
16803             * @throws SystemException if a system exception occurred
16804             */
16805            @Override
16806            public void removeByG_ST(long groupId, int status)
16807                    throws SystemException {
16808                    for (JournalArticle journalArticle : findByG_ST(groupId, status,
16809                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16810                            remove(journalArticle);
16811                    }
16812            }
16813    
16814            /**
16815             * Returns the number of journal articles where groupId = &#63; and status = &#63;.
16816             *
16817             * @param groupId the group ID
16818             * @param status the status
16819             * @return the number of matching journal articles
16820             * @throws SystemException if a system exception occurred
16821             */
16822            @Override
16823            public int countByG_ST(long groupId, int status) throws SystemException {
16824                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_ST;
16825    
16826                    Object[] finderArgs = new Object[] { groupId, status };
16827    
16828                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
16829                                    this);
16830    
16831                    if (count == null) {
16832                            StringBundler query = new StringBundler(3);
16833    
16834                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16835    
16836                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
16837    
16838                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
16839    
16840                            String sql = query.toString();
16841    
16842                            Session session = null;
16843    
16844                            try {
16845                                    session = openSession();
16846    
16847                                    Query q = session.createQuery(sql);
16848    
16849                                    QueryPos qPos = QueryPos.getInstance(q);
16850    
16851                                    qPos.add(groupId);
16852    
16853                                    qPos.add(status);
16854    
16855                                    count = (Long)q.uniqueResult();
16856    
16857                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
16858                            }
16859                            catch (Exception e) {
16860                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16861    
16862                                    throw processException(e);
16863                            }
16864                            finally {
16865                                    closeSession(session);
16866                            }
16867                    }
16868    
16869                    return count.intValue();
16870            }
16871    
16872            /**
16873             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
16874             *
16875             * @param groupId the group ID
16876             * @param status the status
16877             * @return the number of matching journal articles that the user has permission to view
16878             * @throws SystemException if a system exception occurred
16879             */
16880            @Override
16881            public int filterCountByG_ST(long groupId, int status)
16882                    throws SystemException {
16883                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16884                            return countByG_ST(groupId, status);
16885                    }
16886    
16887                    StringBundler query = new StringBundler(3);
16888    
16889                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
16890    
16891                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
16892    
16893                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
16894    
16895                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16896                                    JournalArticle.class.getName(),
16897                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16898    
16899                    Session session = null;
16900    
16901                    try {
16902                            session = openSession();
16903    
16904                            SQLQuery q = session.createSQLQuery(sql);
16905    
16906                            q.addScalar(COUNT_COLUMN_NAME,
16907                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16908    
16909                            QueryPos qPos = QueryPos.getInstance(q);
16910    
16911                            qPos.add(groupId);
16912    
16913                            qPos.add(status);
16914    
16915                            Long count = (Long)q.uniqueResult();
16916    
16917                            return count.intValue();
16918                    }
16919                    catch (Exception e) {
16920                            throw processException(e);
16921                    }
16922                    finally {
16923                            closeSession(session);
16924                    }
16925            }
16926    
16927            private static final String _FINDER_COLUMN_G_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
16928            private static final String _FINDER_COLUMN_G_ST_STATUS_2 = "journalArticle.status = ?";
16929            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16930                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
16931                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
16932                            "findByC_V",
16933                            new String[] {
16934                                    Long.class.getName(), Double.class.getName(),
16935                                    
16936                            Integer.class.getName(), Integer.class.getName(),
16937                                    OrderByComparator.class.getName()
16938                            });
16939            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16940                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
16941                            JournalArticleImpl.class,
16942                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_V",
16943                            new String[] { Long.class.getName(), Double.class.getName() },
16944                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
16945                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK |
16946                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK);
16947            public static final FinderPath FINDER_PATH_COUNT_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16948                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
16949                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_V",
16950                            new String[] { Long.class.getName(), Double.class.getName() });
16951    
16952            /**
16953             * Returns all the journal articles where companyId = &#63; and version = &#63;.
16954             *
16955             * @param companyId the company ID
16956             * @param version the version
16957             * @return the matching journal articles
16958             * @throws SystemException if a system exception occurred
16959             */
16960            @Override
16961            public List<JournalArticle> findByC_V(long companyId, double version)
16962                    throws SystemException {
16963                    return findByC_V(companyId, version, QueryUtil.ALL_POS,
16964                            QueryUtil.ALL_POS, null);
16965            }
16966    
16967            /**
16968             * Returns a range of all the journal articles where companyId = &#63; and version = &#63;.
16969             *
16970             * <p>
16971             * 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.
16972             * </p>
16973             *
16974             * @param companyId the company ID
16975             * @param version the version
16976             * @param start the lower bound of the range of journal articles
16977             * @param end the upper bound of the range of journal articles (not inclusive)
16978             * @return the range of matching journal articles
16979             * @throws SystemException if a system exception occurred
16980             */
16981            @Override
16982            public List<JournalArticle> findByC_V(long companyId, double version,
16983                    int start, int end) throws SystemException {
16984                    return findByC_V(companyId, version, start, end, null);
16985            }
16986    
16987            /**
16988             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63;.
16989             *
16990             * <p>
16991             * 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.
16992             * </p>
16993             *
16994             * @param companyId the company ID
16995             * @param version the version
16996             * @param start the lower bound of the range of journal articles
16997             * @param end the upper bound of the range of journal articles (not inclusive)
16998             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16999             * @return the ordered range of matching journal articles
17000             * @throws SystemException if a system exception occurred
17001             */
17002            @Override
17003            public List<JournalArticle> findByC_V(long companyId, double version,
17004                    int start, int end, OrderByComparator orderByComparator)
17005                    throws SystemException {
17006                    boolean pagination = true;
17007                    FinderPath finderPath = null;
17008                    Object[] finderArgs = null;
17009    
17010                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
17011                                    (orderByComparator == null)) {
17012                            pagination = false;
17013                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V;
17014                            finderArgs = new Object[] { companyId, version };
17015                    }
17016                    else {
17017                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V;
17018                            finderArgs = new Object[] {
17019                                            companyId, version,
17020                                            
17021                                            start, end, orderByComparator
17022                                    };
17023                    }
17024    
17025                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
17026                                    finderArgs, this);
17027    
17028                    if ((list != null) && !list.isEmpty()) {
17029                            for (JournalArticle journalArticle : list) {
17030                                    if ((companyId != journalArticle.getCompanyId()) ||
17031                                                    (version != journalArticle.getVersion())) {
17032                                            list = null;
17033    
17034                                            break;
17035                                    }
17036                            }
17037                    }
17038    
17039                    if (list == null) {
17040                            StringBundler query = null;
17041    
17042                            if (orderByComparator != null) {
17043                                    query = new StringBundler(4 +
17044                                                    (orderByComparator.getOrderByFields().length * 3));
17045                            }
17046                            else {
17047                                    query = new StringBundler(4);
17048                            }
17049    
17050                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17051    
17052                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
17053    
17054                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
17055    
17056                            if (orderByComparator != null) {
17057                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17058                                            orderByComparator);
17059                            }
17060                            else
17061                             if (pagination) {
17062                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17063                            }
17064    
17065                            String sql = query.toString();
17066    
17067                            Session session = null;
17068    
17069                            try {
17070                                    session = openSession();
17071    
17072                                    Query q = session.createQuery(sql);
17073    
17074                                    QueryPos qPos = QueryPos.getInstance(q);
17075    
17076                                    qPos.add(companyId);
17077    
17078                                    qPos.add(version);
17079    
17080                                    if (!pagination) {
17081                                            list = (List<JournalArticle>)QueryUtil.list(q,
17082                                                            getDialect(), start, end, false);
17083    
17084                                            Collections.sort(list);
17085    
17086                                            list = new UnmodifiableList<JournalArticle>(list);
17087                                    }
17088                                    else {
17089                                            list = (List<JournalArticle>)QueryUtil.list(q,
17090                                                            getDialect(), start, end);
17091                                    }
17092    
17093                                    cacheResult(list);
17094    
17095                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
17096                            }
17097                            catch (Exception e) {
17098                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17099    
17100                                    throw processException(e);
17101                            }
17102                            finally {
17103                                    closeSession(session);
17104                            }
17105                    }
17106    
17107                    return list;
17108            }
17109    
17110            /**
17111             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63;.
17112             *
17113             * @param companyId the company ID
17114             * @param version the version
17115             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17116             * @return the first matching journal article
17117             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17118             * @throws SystemException if a system exception occurred
17119             */
17120            @Override
17121            public JournalArticle findByC_V_First(long companyId, double version,
17122                    OrderByComparator orderByComparator)
17123                    throws NoSuchArticleException, SystemException {
17124                    JournalArticle journalArticle = fetchByC_V_First(companyId, version,
17125                                    orderByComparator);
17126    
17127                    if (journalArticle != null) {
17128                            return journalArticle;
17129                    }
17130    
17131                    StringBundler msg = new StringBundler(6);
17132    
17133                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17134    
17135                    msg.append("companyId=");
17136                    msg.append(companyId);
17137    
17138                    msg.append(", version=");
17139                    msg.append(version);
17140    
17141                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17142    
17143                    throw new NoSuchArticleException(msg.toString());
17144            }
17145    
17146            /**
17147             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63;.
17148             *
17149             * @param companyId the company ID
17150             * @param version the version
17151             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17152             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
17153             * @throws SystemException if a system exception occurred
17154             */
17155            @Override
17156            public JournalArticle fetchByC_V_First(long companyId, double version,
17157                    OrderByComparator orderByComparator) throws SystemException {
17158                    List<JournalArticle> list = findByC_V(companyId, version, 0, 1,
17159                                    orderByComparator);
17160    
17161                    if (!list.isEmpty()) {
17162                            return list.get(0);
17163                    }
17164    
17165                    return null;
17166            }
17167    
17168            /**
17169             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63;.
17170             *
17171             * @param companyId the company ID
17172             * @param version the version
17173             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17174             * @return the last matching journal article
17175             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17176             * @throws SystemException if a system exception occurred
17177             */
17178            @Override
17179            public JournalArticle findByC_V_Last(long companyId, double version,
17180                    OrderByComparator orderByComparator)
17181                    throws NoSuchArticleException, SystemException {
17182                    JournalArticle journalArticle = fetchByC_V_Last(companyId, version,
17183                                    orderByComparator);
17184    
17185                    if (journalArticle != null) {
17186                            return journalArticle;
17187                    }
17188    
17189                    StringBundler msg = new StringBundler(6);
17190    
17191                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17192    
17193                    msg.append("companyId=");
17194                    msg.append(companyId);
17195    
17196                    msg.append(", version=");
17197                    msg.append(version);
17198    
17199                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17200    
17201                    throw new NoSuchArticleException(msg.toString());
17202            }
17203    
17204            /**
17205             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63;.
17206             *
17207             * @param companyId the company ID
17208             * @param version the version
17209             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17210             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
17211             * @throws SystemException if a system exception occurred
17212             */
17213            @Override
17214            public JournalArticle fetchByC_V_Last(long companyId, double version,
17215                    OrderByComparator orderByComparator) throws SystemException {
17216                    int count = countByC_V(companyId, version);
17217    
17218                    if (count == 0) {
17219                            return null;
17220                    }
17221    
17222                    List<JournalArticle> list = findByC_V(companyId, version, count - 1,
17223                                    count, orderByComparator);
17224    
17225                    if (!list.isEmpty()) {
17226                            return list.get(0);
17227                    }
17228    
17229                    return null;
17230            }
17231    
17232            /**
17233             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63;.
17234             *
17235             * @param id the primary key of the current journal article
17236             * @param companyId the company ID
17237             * @param version the version
17238             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17239             * @return the previous, current, and next journal article
17240             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
17241             * @throws SystemException if a system exception occurred
17242             */
17243            @Override
17244            public JournalArticle[] findByC_V_PrevAndNext(long id, long companyId,
17245                    double version, OrderByComparator orderByComparator)
17246                    throws NoSuchArticleException, SystemException {
17247                    JournalArticle journalArticle = findByPrimaryKey(id);
17248    
17249                    Session session = null;
17250    
17251                    try {
17252                            session = openSession();
17253    
17254                            JournalArticle[] array = new JournalArticleImpl[3];
17255    
17256                            array[0] = getByC_V_PrevAndNext(session, journalArticle, companyId,
17257                                            version, orderByComparator, true);
17258    
17259                            array[1] = journalArticle;
17260    
17261                            array[2] = getByC_V_PrevAndNext(session, journalArticle, companyId,
17262                                            version, orderByComparator, false);
17263    
17264                            return array;
17265                    }
17266                    catch (Exception e) {
17267                            throw processException(e);
17268                    }
17269                    finally {
17270                            closeSession(session);
17271                    }
17272            }
17273    
17274            protected JournalArticle getByC_V_PrevAndNext(Session session,
17275                    JournalArticle journalArticle, long companyId, double version,
17276                    OrderByComparator orderByComparator, boolean previous) {
17277                    StringBundler query = null;
17278    
17279                    if (orderByComparator != null) {
17280                            query = new StringBundler(6 +
17281                                            (orderByComparator.getOrderByFields().length * 6));
17282                    }
17283                    else {
17284                            query = new StringBundler(3);
17285                    }
17286    
17287                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17288    
17289                    query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
17290    
17291                    query.append(_FINDER_COLUMN_C_V_VERSION_2);
17292    
17293                    if (orderByComparator != null) {
17294                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17295    
17296                            if (orderByConditionFields.length > 0) {
17297                                    query.append(WHERE_AND);
17298                            }
17299    
17300                            for (int i = 0; i < orderByConditionFields.length; i++) {
17301                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17302                                    query.append(orderByConditionFields[i]);
17303    
17304                                    if ((i + 1) < orderByConditionFields.length) {
17305                                            if (orderByComparator.isAscending() ^ previous) {
17306                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17307                                            }
17308                                            else {
17309                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17310                                            }
17311                                    }
17312                                    else {
17313                                            if (orderByComparator.isAscending() ^ previous) {
17314                                                    query.append(WHERE_GREATER_THAN);
17315                                            }
17316                                            else {
17317                                                    query.append(WHERE_LESSER_THAN);
17318                                            }
17319                                    }
17320                            }
17321    
17322                            query.append(ORDER_BY_CLAUSE);
17323    
17324                            String[] orderByFields = orderByComparator.getOrderByFields();
17325    
17326                            for (int i = 0; i < orderByFields.length; i++) {
17327                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17328                                    query.append(orderByFields[i]);
17329    
17330                                    if ((i + 1) < orderByFields.length) {
17331                                            if (orderByComparator.isAscending() ^ previous) {
17332                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17333                                            }
17334                                            else {
17335                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17336                                            }
17337                                    }
17338                                    else {
17339                                            if (orderByComparator.isAscending() ^ previous) {
17340                                                    query.append(ORDER_BY_ASC);
17341                                            }
17342                                            else {
17343                                                    query.append(ORDER_BY_DESC);
17344                                            }
17345                                    }
17346                            }
17347                    }
17348                    else {
17349                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17350                    }
17351    
17352                    String sql = query.toString();
17353    
17354                    Query q = session.createQuery(sql);
17355    
17356                    q.setFirstResult(0);
17357                    q.setMaxResults(2);
17358    
17359                    QueryPos qPos = QueryPos.getInstance(q);
17360    
17361                    qPos.add(companyId);
17362    
17363                    qPos.add(version);
17364    
17365                    if (orderByComparator != null) {
17366                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
17367    
17368                            for (Object value : values) {
17369                                    qPos.add(value);
17370                            }
17371                    }
17372    
17373                    List<JournalArticle> list = q.list();
17374    
17375                    if (list.size() == 2) {
17376                            return list.get(1);
17377                    }
17378                    else {
17379                            return null;
17380                    }
17381            }
17382    
17383            /**
17384             * Removes all the journal articles where companyId = &#63; and version = &#63; from the database.
17385             *
17386             * @param companyId the company ID
17387             * @param version the version
17388             * @throws SystemException if a system exception occurred
17389             */
17390            @Override
17391            public void removeByC_V(long companyId, double version)
17392                    throws SystemException {
17393                    for (JournalArticle journalArticle : findByC_V(companyId, version,
17394                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
17395                            remove(journalArticle);
17396                    }
17397            }
17398    
17399            /**
17400             * Returns the number of journal articles where companyId = &#63; and version = &#63;.
17401             *
17402             * @param companyId the company ID
17403             * @param version the version
17404             * @return the number of matching journal articles
17405             * @throws SystemException if a system exception occurred
17406             */
17407            @Override
17408            public int countByC_V(long companyId, double version)
17409                    throws SystemException {
17410                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_V;
17411    
17412                    Object[] finderArgs = new Object[] { companyId, version };
17413    
17414                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
17415                                    this);
17416    
17417                    if (count == null) {
17418                            StringBundler query = new StringBundler(3);
17419    
17420                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17421    
17422                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
17423    
17424                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
17425    
17426                            String sql = query.toString();
17427    
17428                            Session session = null;
17429    
17430                            try {
17431                                    session = openSession();
17432    
17433                                    Query q = session.createQuery(sql);
17434    
17435                                    QueryPos qPos = QueryPos.getInstance(q);
17436    
17437                                    qPos.add(companyId);
17438    
17439                                    qPos.add(version);
17440    
17441                                    count = (Long)q.uniqueResult();
17442    
17443                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
17444                            }
17445                            catch (Exception e) {
17446                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17447    
17448                                    throw processException(e);
17449                            }
17450                            finally {
17451                                    closeSession(session);
17452                            }
17453                    }
17454    
17455                    return count.intValue();
17456            }
17457    
17458            private static final String _FINDER_COLUMN_C_V_COMPANYID_2 = "journalArticle.companyId = ? AND ";
17459            private static final String _FINDER_COLUMN_C_V_VERSION_2 = "journalArticle.version = ?";
17460            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17461                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
17462                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
17463                            "findByC_ST",
17464                            new String[] {
17465                                    Long.class.getName(), Integer.class.getName(),
17466                                    
17467                            Integer.class.getName(), Integer.class.getName(),
17468                                    OrderByComparator.class.getName()
17469                            });
17470            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17471                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
17472                            JournalArticleImpl.class,
17473                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_ST",
17474                            new String[] { Long.class.getName(), Integer.class.getName() },
17475                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
17476                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
17477                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
17478                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
17479            public static final FinderPath FINDER_PATH_COUNT_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17480                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
17481                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_ST",
17482                            new String[] { Long.class.getName(), Integer.class.getName() });
17483    
17484            /**
17485             * Returns all the journal articles where companyId = &#63; and status = &#63;.
17486             *
17487             * @param companyId the company ID
17488             * @param status the status
17489             * @return the matching journal articles
17490             * @throws SystemException if a system exception occurred
17491             */
17492            @Override
17493            public List<JournalArticle> findByC_ST(long companyId, int status)
17494                    throws SystemException {
17495                    return findByC_ST(companyId, status, QueryUtil.ALL_POS,
17496                            QueryUtil.ALL_POS, null);
17497            }
17498    
17499            /**
17500             * Returns a range of all the journal articles where companyId = &#63; and status = &#63;.
17501             *
17502             * <p>
17503             * 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.
17504             * </p>
17505             *
17506             * @param companyId the company ID
17507             * @param status the status
17508             * @param start the lower bound of the range of journal articles
17509             * @param end the upper bound of the range of journal articles (not inclusive)
17510             * @return the range of matching journal articles
17511             * @throws SystemException if a system exception occurred
17512             */
17513            @Override
17514            public List<JournalArticle> findByC_ST(long companyId, int status,
17515                    int start, int end) throws SystemException {
17516                    return findByC_ST(companyId, status, start, end, null);
17517            }
17518    
17519            /**
17520             * Returns an ordered range of all the journal articles where companyId = &#63; and status = &#63;.
17521             *
17522             * <p>
17523             * 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.
17524             * </p>
17525             *
17526             * @param companyId the company ID
17527             * @param status the status
17528             * @param start the lower bound of the range of journal articles
17529             * @param end the upper bound of the range of journal articles (not inclusive)
17530             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17531             * @return the ordered range of matching journal articles
17532             * @throws SystemException if a system exception occurred
17533             */
17534            @Override
17535            public List<JournalArticle> findByC_ST(long companyId, int status,
17536                    int start, int end, OrderByComparator orderByComparator)
17537                    throws SystemException {
17538                    boolean pagination = true;
17539                    FinderPath finderPath = null;
17540                    Object[] finderArgs = null;
17541    
17542                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
17543                                    (orderByComparator == null)) {
17544                            pagination = false;
17545                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST;
17546                            finderArgs = new Object[] { companyId, status };
17547                    }
17548                    else {
17549                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_ST;
17550                            finderArgs = new Object[] {
17551                                            companyId, status,
17552                                            
17553                                            start, end, orderByComparator
17554                                    };
17555                    }
17556    
17557                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
17558                                    finderArgs, this);
17559    
17560                    if ((list != null) && !list.isEmpty()) {
17561                            for (JournalArticle journalArticle : list) {
17562                                    if ((companyId != journalArticle.getCompanyId()) ||
17563                                                    (status != journalArticle.getStatus())) {
17564                                            list = null;
17565    
17566                                            break;
17567                                    }
17568                            }
17569                    }
17570    
17571                    if (list == null) {
17572                            StringBundler query = null;
17573    
17574                            if (orderByComparator != null) {
17575                                    query = new StringBundler(4 +
17576                                                    (orderByComparator.getOrderByFields().length * 3));
17577                            }
17578                            else {
17579                                    query = new StringBundler(4);
17580                            }
17581    
17582                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17583    
17584                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
17585    
17586                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
17587    
17588                            if (orderByComparator != null) {
17589                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17590                                            orderByComparator);
17591                            }
17592                            else
17593                             if (pagination) {
17594                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17595                            }
17596    
17597                            String sql = query.toString();
17598    
17599                            Session session = null;
17600    
17601                            try {
17602                                    session = openSession();
17603    
17604                                    Query q = session.createQuery(sql);
17605    
17606                                    QueryPos qPos = QueryPos.getInstance(q);
17607    
17608                                    qPos.add(companyId);
17609    
17610                                    qPos.add(status);
17611    
17612                                    if (!pagination) {
17613                                            list = (List<JournalArticle>)QueryUtil.list(q,
17614                                                            getDialect(), start, end, false);
17615    
17616                                            Collections.sort(list);
17617    
17618                                            list = new UnmodifiableList<JournalArticle>(list);
17619                                    }
17620                                    else {
17621                                            list = (List<JournalArticle>)QueryUtil.list(q,
17622                                                            getDialect(), start, end);
17623                                    }
17624    
17625                                    cacheResult(list);
17626    
17627                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
17628                            }
17629                            catch (Exception e) {
17630                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17631    
17632                                    throw processException(e);
17633                            }
17634                            finally {
17635                                    closeSession(session);
17636                            }
17637                    }
17638    
17639                    return list;
17640            }
17641    
17642            /**
17643             * Returns the first journal article in the ordered set where companyId = &#63; and status = &#63;.
17644             *
17645             * @param companyId the company ID
17646             * @param status the status
17647             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17648             * @return the first matching journal article
17649             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17650             * @throws SystemException if a system exception occurred
17651             */
17652            @Override
17653            public JournalArticle findByC_ST_First(long companyId, int status,
17654                    OrderByComparator orderByComparator)
17655                    throws NoSuchArticleException, SystemException {
17656                    JournalArticle journalArticle = fetchByC_ST_First(companyId, status,
17657                                    orderByComparator);
17658    
17659                    if (journalArticle != null) {
17660                            return journalArticle;
17661                    }
17662    
17663                    StringBundler msg = new StringBundler(6);
17664    
17665                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17666    
17667                    msg.append("companyId=");
17668                    msg.append(companyId);
17669    
17670                    msg.append(", status=");
17671                    msg.append(status);
17672    
17673                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17674    
17675                    throw new NoSuchArticleException(msg.toString());
17676            }
17677    
17678            /**
17679             * Returns the first journal article in the ordered set where companyId = &#63; and status = &#63;.
17680             *
17681             * @param companyId the company ID
17682             * @param status the status
17683             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17684             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
17685             * @throws SystemException if a system exception occurred
17686             */
17687            @Override
17688            public JournalArticle fetchByC_ST_First(long companyId, int status,
17689                    OrderByComparator orderByComparator) throws SystemException {
17690                    List<JournalArticle> list = findByC_ST(companyId, status, 0, 1,
17691                                    orderByComparator);
17692    
17693                    if (!list.isEmpty()) {
17694                            return list.get(0);
17695                    }
17696    
17697                    return null;
17698            }
17699    
17700            /**
17701             * Returns the last journal article in the ordered set where companyId = &#63; and status = &#63;.
17702             *
17703             * @param companyId the company ID
17704             * @param status the status
17705             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17706             * @return the last matching journal article
17707             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17708             * @throws SystemException if a system exception occurred
17709             */
17710            @Override
17711            public JournalArticle findByC_ST_Last(long companyId, int status,
17712                    OrderByComparator orderByComparator)
17713                    throws NoSuchArticleException, SystemException {
17714                    JournalArticle journalArticle = fetchByC_ST_Last(companyId, status,
17715                                    orderByComparator);
17716    
17717                    if (journalArticle != null) {
17718                            return journalArticle;
17719                    }
17720    
17721                    StringBundler msg = new StringBundler(6);
17722    
17723                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17724    
17725                    msg.append("companyId=");
17726                    msg.append(companyId);
17727    
17728                    msg.append(", status=");
17729                    msg.append(status);
17730    
17731                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17732    
17733                    throw new NoSuchArticleException(msg.toString());
17734            }
17735    
17736            /**
17737             * Returns the last journal article in the ordered set where companyId = &#63; and status = &#63;.
17738             *
17739             * @param companyId the company ID
17740             * @param status the status
17741             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17742             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
17743             * @throws SystemException if a system exception occurred
17744             */
17745            @Override
17746            public JournalArticle fetchByC_ST_Last(long companyId, int status,
17747                    OrderByComparator orderByComparator) throws SystemException {
17748                    int count = countByC_ST(companyId, status);
17749    
17750                    if (count == 0) {
17751                            return null;
17752                    }
17753    
17754                    List<JournalArticle> list = findByC_ST(companyId, status, count - 1,
17755                                    count, orderByComparator);
17756    
17757                    if (!list.isEmpty()) {
17758                            return list.get(0);
17759                    }
17760    
17761                    return null;
17762            }
17763    
17764            /**
17765             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and status = &#63;.
17766             *
17767             * @param id the primary key of the current journal article
17768             * @param companyId the company ID
17769             * @param status the status
17770             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17771             * @return the previous, current, and next journal article
17772             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
17773             * @throws SystemException if a system exception occurred
17774             */
17775            @Override
17776            public JournalArticle[] findByC_ST_PrevAndNext(long id, long companyId,
17777                    int status, OrderByComparator orderByComparator)
17778                    throws NoSuchArticleException, SystemException {
17779                    JournalArticle journalArticle = findByPrimaryKey(id);
17780    
17781                    Session session = null;
17782    
17783                    try {
17784                            session = openSession();
17785    
17786                            JournalArticle[] array = new JournalArticleImpl[3];
17787    
17788                            array[0] = getByC_ST_PrevAndNext(session, journalArticle,
17789                                            companyId, status, orderByComparator, true);
17790    
17791                            array[1] = journalArticle;
17792    
17793                            array[2] = getByC_ST_PrevAndNext(session, journalArticle,
17794                                            companyId, status, orderByComparator, false);
17795    
17796                            return array;
17797                    }
17798                    catch (Exception e) {
17799                            throw processException(e);
17800                    }
17801                    finally {
17802                            closeSession(session);
17803                    }
17804            }
17805    
17806            protected JournalArticle getByC_ST_PrevAndNext(Session session,
17807                    JournalArticle journalArticle, long companyId, int status,
17808                    OrderByComparator orderByComparator, boolean previous) {
17809                    StringBundler query = null;
17810    
17811                    if (orderByComparator != null) {
17812                            query = new StringBundler(6 +
17813                                            (orderByComparator.getOrderByFields().length * 6));
17814                    }
17815                    else {
17816                            query = new StringBundler(3);
17817                    }
17818    
17819                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17820    
17821                    query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
17822    
17823                    query.append(_FINDER_COLUMN_C_ST_STATUS_2);
17824    
17825                    if (orderByComparator != null) {
17826                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17827    
17828                            if (orderByConditionFields.length > 0) {
17829                                    query.append(WHERE_AND);
17830                            }
17831    
17832                            for (int i = 0; i < orderByConditionFields.length; i++) {
17833                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17834                                    query.append(orderByConditionFields[i]);
17835    
17836                                    if ((i + 1) < orderByConditionFields.length) {
17837                                            if (orderByComparator.isAscending() ^ previous) {
17838                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17839                                            }
17840                                            else {
17841                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17842                                            }
17843                                    }
17844                                    else {
17845                                            if (orderByComparator.isAscending() ^ previous) {
17846                                                    query.append(WHERE_GREATER_THAN);
17847                                            }
17848                                            else {
17849                                                    query.append(WHERE_LESSER_THAN);
17850                                            }
17851                                    }
17852                            }
17853    
17854                            query.append(ORDER_BY_CLAUSE);
17855    
17856                            String[] orderByFields = orderByComparator.getOrderByFields();
17857    
17858                            for (int i = 0; i < orderByFields.length; i++) {
17859                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17860                                    query.append(orderByFields[i]);
17861    
17862                                    if ((i + 1) < orderByFields.length) {
17863                                            if (orderByComparator.isAscending() ^ previous) {
17864                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17865                                            }
17866                                            else {
17867                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17868                                            }
17869                                    }
17870                                    else {
17871                                            if (orderByComparator.isAscending() ^ previous) {
17872                                                    query.append(ORDER_BY_ASC);
17873                                            }
17874                                            else {
17875                                                    query.append(ORDER_BY_DESC);
17876                                            }
17877                                    }
17878                            }
17879                    }
17880                    else {
17881                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17882                    }
17883    
17884                    String sql = query.toString();
17885    
17886                    Query q = session.createQuery(sql);
17887    
17888                    q.setFirstResult(0);
17889                    q.setMaxResults(2);
17890    
17891                    QueryPos qPos = QueryPos.getInstance(q);
17892    
17893                    qPos.add(companyId);
17894    
17895                    qPos.add(status);
17896    
17897                    if (orderByComparator != null) {
17898                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
17899    
17900                            for (Object value : values) {
17901                                    qPos.add(value);
17902                            }
17903                    }
17904    
17905                    List<JournalArticle> list = q.list();
17906    
17907                    if (list.size() == 2) {
17908                            return list.get(1);
17909                    }
17910                    else {
17911                            return null;
17912                    }
17913            }
17914    
17915            /**
17916             * Removes all the journal articles where companyId = &#63; and status = &#63; from the database.
17917             *
17918             * @param companyId the company ID
17919             * @param status the status
17920             * @throws SystemException if a system exception occurred
17921             */
17922            @Override
17923            public void removeByC_ST(long companyId, int status)
17924                    throws SystemException {
17925                    for (JournalArticle journalArticle : findByC_ST(companyId, status,
17926                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
17927                            remove(journalArticle);
17928                    }
17929            }
17930    
17931            /**
17932             * Returns the number of journal articles where companyId = &#63; and status = &#63;.
17933             *
17934             * @param companyId the company ID
17935             * @param status the status
17936             * @return the number of matching journal articles
17937             * @throws SystemException if a system exception occurred
17938             */
17939            @Override
17940            public int countByC_ST(long companyId, int status)
17941                    throws SystemException {
17942                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_ST;
17943    
17944                    Object[] finderArgs = new Object[] { companyId, status };
17945    
17946                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
17947                                    this);
17948    
17949                    if (count == null) {
17950                            StringBundler query = new StringBundler(3);
17951    
17952                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17953    
17954                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
17955    
17956                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
17957    
17958                            String sql = query.toString();
17959    
17960                            Session session = null;
17961    
17962                            try {
17963                                    session = openSession();
17964    
17965                                    Query q = session.createQuery(sql);
17966    
17967                                    QueryPos qPos = QueryPos.getInstance(q);
17968    
17969                                    qPos.add(companyId);
17970    
17971                                    qPos.add(status);
17972    
17973                                    count = (Long)q.uniqueResult();
17974    
17975                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
17976                            }
17977                            catch (Exception e) {
17978                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17979    
17980                                    throw processException(e);
17981                            }
17982                            finally {
17983                                    closeSession(session);
17984                            }
17985                    }
17986    
17987                    return count.intValue();
17988            }
17989    
17990            private static final String _FINDER_COLUMN_C_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
17991            private static final String _FINDER_COLUMN_C_ST_STATUS_2 = "journalArticle.status = ?";
17992            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17993                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
17994                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
17995                            "findByC_NotST",
17996                            new String[] {
17997                                    Long.class.getName(), Integer.class.getName(),
17998                                    
17999                            Integer.class.getName(), Integer.class.getName(),
18000                                    OrderByComparator.class.getName()
18001                            });
18002            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18003                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
18004                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_NotST",
18005                            new String[] { Long.class.getName(), Integer.class.getName() });
18006    
18007            /**
18008             * Returns all the journal articles where companyId = &#63; and status &ne; &#63;.
18009             *
18010             * @param companyId the company ID
18011             * @param status the status
18012             * @return the matching journal articles
18013             * @throws SystemException if a system exception occurred
18014             */
18015            @Override
18016            public List<JournalArticle> findByC_NotST(long companyId, int status)
18017                    throws SystemException {
18018                    return findByC_NotST(companyId, status, QueryUtil.ALL_POS,
18019                            QueryUtil.ALL_POS, null);
18020            }
18021    
18022            /**
18023             * Returns a range of all the journal articles where companyId = &#63; and status &ne; &#63;.
18024             *
18025             * <p>
18026             * 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.
18027             * </p>
18028             *
18029             * @param companyId the company ID
18030             * @param status the status
18031             * @param start the lower bound of the range of journal articles
18032             * @param end the upper bound of the range of journal articles (not inclusive)
18033             * @return the range of matching journal articles
18034             * @throws SystemException if a system exception occurred
18035             */
18036            @Override
18037            public List<JournalArticle> findByC_NotST(long companyId, int status,
18038                    int start, int end) throws SystemException {
18039                    return findByC_NotST(companyId, status, start, end, null);
18040            }
18041    
18042            /**
18043             * Returns an ordered range of all the journal articles where companyId = &#63; and status &ne; &#63;.
18044             *
18045             * <p>
18046             * 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.
18047             * </p>
18048             *
18049             * @param companyId the company ID
18050             * @param status the status
18051             * @param start the lower bound of the range of journal articles
18052             * @param end the upper bound of the range of journal articles (not inclusive)
18053             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18054             * @return the ordered range of matching journal articles
18055             * @throws SystemException if a system exception occurred
18056             */
18057            @Override
18058            public List<JournalArticle> findByC_NotST(long companyId, int status,
18059                    int start, int end, OrderByComparator orderByComparator)
18060                    throws SystemException {
18061                    boolean pagination = true;
18062                    FinderPath finderPath = null;
18063                    Object[] finderArgs = null;
18064    
18065                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTST;
18066                    finderArgs = new Object[] {
18067                                    companyId, status,
18068                                    
18069                                    start, end, orderByComparator
18070                            };
18071    
18072                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
18073                                    finderArgs, this);
18074    
18075                    if ((list != null) && !list.isEmpty()) {
18076                            for (JournalArticle journalArticle : list) {
18077                                    if ((companyId != journalArticle.getCompanyId()) ||
18078                                                    (status == journalArticle.getStatus())) {
18079                                            list = null;
18080    
18081                                            break;
18082                                    }
18083                            }
18084                    }
18085    
18086                    if (list == null) {
18087                            StringBundler query = null;
18088    
18089                            if (orderByComparator != null) {
18090                                    query = new StringBundler(4 +
18091                                                    (orderByComparator.getOrderByFields().length * 3));
18092                            }
18093                            else {
18094                                    query = new StringBundler(4);
18095                            }
18096    
18097                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18098    
18099                            query.append(_FINDER_COLUMN_C_NOTST_COMPANYID_2);
18100    
18101                            query.append(_FINDER_COLUMN_C_NOTST_STATUS_2);
18102    
18103                            if (orderByComparator != null) {
18104                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18105                                            orderByComparator);
18106                            }
18107                            else
18108                             if (pagination) {
18109                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18110                            }
18111    
18112                            String sql = query.toString();
18113    
18114                            Session session = null;
18115    
18116                            try {
18117                                    session = openSession();
18118    
18119                                    Query q = session.createQuery(sql);
18120    
18121                                    QueryPos qPos = QueryPos.getInstance(q);
18122    
18123                                    qPos.add(companyId);
18124    
18125                                    qPos.add(status);
18126    
18127                                    if (!pagination) {
18128                                            list = (List<JournalArticle>)QueryUtil.list(q,
18129                                                            getDialect(), start, end, false);
18130    
18131                                            Collections.sort(list);
18132    
18133                                            list = new UnmodifiableList<JournalArticle>(list);
18134                                    }
18135                                    else {
18136                                            list = (List<JournalArticle>)QueryUtil.list(q,
18137                                                            getDialect(), start, end);
18138                                    }
18139    
18140                                    cacheResult(list);
18141    
18142                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
18143                            }
18144                            catch (Exception e) {
18145                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18146    
18147                                    throw processException(e);
18148                            }
18149                            finally {
18150                                    closeSession(session);
18151                            }
18152                    }
18153    
18154                    return list;
18155            }
18156    
18157            /**
18158             * Returns the first journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
18159             *
18160             * @param companyId the company ID
18161             * @param status the status
18162             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18163             * @return the first matching journal article
18164             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
18165             * @throws SystemException if a system exception occurred
18166             */
18167            @Override
18168            public JournalArticle findByC_NotST_First(long companyId, int status,
18169                    OrderByComparator orderByComparator)
18170                    throws NoSuchArticleException, SystemException {
18171                    JournalArticle journalArticle = fetchByC_NotST_First(companyId, status,
18172                                    orderByComparator);
18173    
18174                    if (journalArticle != null) {
18175                            return journalArticle;
18176                    }
18177    
18178                    StringBundler msg = new StringBundler(6);
18179    
18180                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
18181    
18182                    msg.append("companyId=");
18183                    msg.append(companyId);
18184    
18185                    msg.append(", status=");
18186                    msg.append(status);
18187    
18188                    msg.append(StringPool.CLOSE_CURLY_BRACE);
18189    
18190                    throw new NoSuchArticleException(msg.toString());
18191            }
18192    
18193            /**
18194             * Returns the first journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
18195             *
18196             * @param companyId the company ID
18197             * @param status the status
18198             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18199             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
18200             * @throws SystemException if a system exception occurred
18201             */
18202            @Override
18203            public JournalArticle fetchByC_NotST_First(long companyId, int status,
18204                    OrderByComparator orderByComparator) throws SystemException {
18205                    List<JournalArticle> list = findByC_NotST(companyId, status, 0, 1,
18206                                    orderByComparator);
18207    
18208                    if (!list.isEmpty()) {
18209                            return list.get(0);
18210                    }
18211    
18212                    return null;
18213            }
18214    
18215            /**
18216             * Returns the last journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
18217             *
18218             * @param companyId the company ID
18219             * @param status the status
18220             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18221             * @return the last matching journal article
18222             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
18223             * @throws SystemException if a system exception occurred
18224             */
18225            @Override
18226            public JournalArticle findByC_NotST_Last(long companyId, int status,
18227                    OrderByComparator orderByComparator)
18228                    throws NoSuchArticleException, SystemException {
18229                    JournalArticle journalArticle = fetchByC_NotST_Last(companyId, status,
18230                                    orderByComparator);
18231    
18232                    if (journalArticle != null) {
18233                            return journalArticle;
18234                    }
18235    
18236                    StringBundler msg = new StringBundler(6);
18237    
18238                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
18239    
18240                    msg.append("companyId=");
18241                    msg.append(companyId);
18242    
18243                    msg.append(", status=");
18244                    msg.append(status);
18245    
18246                    msg.append(StringPool.CLOSE_CURLY_BRACE);
18247    
18248                    throw new NoSuchArticleException(msg.toString());
18249            }
18250    
18251            /**
18252             * Returns the last journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
18253             *
18254             * @param companyId the company ID
18255             * @param status the status
18256             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18257             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
18258             * @throws SystemException if a system exception occurred
18259             */
18260            @Override
18261            public JournalArticle fetchByC_NotST_Last(long companyId, int status,
18262                    OrderByComparator orderByComparator) throws SystemException {
18263                    int count = countByC_NotST(companyId, status);
18264    
18265                    if (count == 0) {
18266                            return null;
18267                    }
18268    
18269                    List<JournalArticle> list = findByC_NotST(companyId, status, count - 1,
18270                                    count, orderByComparator);
18271    
18272                    if (!list.isEmpty()) {
18273                            return list.get(0);
18274                    }
18275    
18276                    return null;
18277            }
18278    
18279            /**
18280             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
18281             *
18282             * @param id the primary key of the current journal article
18283             * @param companyId the company ID
18284             * @param status the status
18285             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18286             * @return the previous, current, and next journal article
18287             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
18288             * @throws SystemException if a system exception occurred
18289             */
18290            @Override
18291            public JournalArticle[] findByC_NotST_PrevAndNext(long id, long companyId,
18292                    int status, OrderByComparator orderByComparator)
18293                    throws NoSuchArticleException, SystemException {
18294                    JournalArticle journalArticle = findByPrimaryKey(id);
18295    
18296                    Session session = null;
18297    
18298                    try {
18299                            session = openSession();
18300    
18301                            JournalArticle[] array = new JournalArticleImpl[3];
18302    
18303                            array[0] = getByC_NotST_PrevAndNext(session, journalArticle,
18304                                            companyId, status, orderByComparator, true);
18305    
18306                            array[1] = journalArticle;
18307    
18308                            array[2] = getByC_NotST_PrevAndNext(session, journalArticle,
18309                                            companyId, status, orderByComparator, false);
18310    
18311                            return array;
18312                    }
18313                    catch (Exception e) {
18314                            throw processException(e);
18315                    }
18316                    finally {
18317                            closeSession(session);
18318                    }
18319            }
18320    
18321            protected JournalArticle getByC_NotST_PrevAndNext(Session session,
18322                    JournalArticle journalArticle, long companyId, int status,
18323                    OrderByComparator orderByComparator, boolean previous) {
18324                    StringBundler query = null;
18325    
18326                    if (orderByComparator != null) {
18327                            query = new StringBundler(6 +
18328                                            (orderByComparator.getOrderByFields().length * 6));
18329                    }
18330                    else {
18331                            query = new StringBundler(3);
18332                    }
18333    
18334                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18335    
18336                    query.append(_FINDER_COLUMN_C_NOTST_COMPANYID_2);
18337    
18338                    query.append(_FINDER_COLUMN_C_NOTST_STATUS_2);
18339    
18340                    if (orderByComparator != null) {
18341                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
18342    
18343                            if (orderByConditionFields.length > 0) {
18344                                    query.append(WHERE_AND);
18345                            }
18346    
18347                            for (int i = 0; i < orderByConditionFields.length; i++) {
18348                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18349                                    query.append(orderByConditionFields[i]);
18350    
18351                                    if ((i + 1) < orderByConditionFields.length) {
18352                                            if (orderByComparator.isAscending() ^ previous) {
18353                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
18354                                            }
18355                                            else {
18356                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
18357                                            }
18358                                    }
18359                                    else {
18360                                            if (orderByComparator.isAscending() ^ previous) {
18361                                                    query.append(WHERE_GREATER_THAN);
18362                                            }
18363                                            else {
18364                                                    query.append(WHERE_LESSER_THAN);
18365                                            }
18366                                    }
18367                            }
18368    
18369                            query.append(ORDER_BY_CLAUSE);
18370    
18371                            String[] orderByFields = orderByComparator.getOrderByFields();
18372    
18373                            for (int i = 0; i < orderByFields.length; i++) {
18374                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18375                                    query.append(orderByFields[i]);
18376    
18377                                    if ((i + 1) < orderByFields.length) {
18378                                            if (orderByComparator.isAscending() ^ previous) {
18379                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
18380                                            }
18381                                            else {
18382                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
18383                                            }
18384                                    }
18385                                    else {
18386                                            if (orderByComparator.isAscending() ^ previous) {
18387                                                    query.append(ORDER_BY_ASC);
18388                                            }
18389                                            else {
18390                                                    query.append(ORDER_BY_DESC);
18391                                            }
18392                                    }
18393                            }
18394                    }
18395                    else {
18396                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18397                    }
18398    
18399                    String sql = query.toString();
18400    
18401                    Query q = session.createQuery(sql);
18402    
18403                    q.setFirstResult(0);
18404                    q.setMaxResults(2);
18405    
18406                    QueryPos qPos = QueryPos.getInstance(q);
18407    
18408                    qPos.add(companyId);
18409    
18410                    qPos.add(status);
18411    
18412                    if (orderByComparator != null) {
18413                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
18414    
18415                            for (Object value : values) {
18416                                    qPos.add(value);
18417                            }
18418                    }
18419    
18420                    List<JournalArticle> list = q.list();
18421    
18422                    if (list.size() == 2) {
18423                            return list.get(1);
18424                    }
18425                    else {
18426                            return null;
18427                    }
18428            }
18429    
18430            /**
18431             * Removes all the journal articles where companyId = &#63; and status &ne; &#63; from the database.
18432             *
18433             * @param companyId the company ID
18434             * @param status the status
18435             * @throws SystemException if a system exception occurred
18436             */
18437            @Override
18438            public void removeByC_NotST(long companyId, int status)
18439                    throws SystemException {
18440                    for (JournalArticle journalArticle : findByC_NotST(companyId, status,
18441                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
18442                            remove(journalArticle);
18443                    }
18444            }
18445    
18446            /**
18447             * Returns the number of journal articles where companyId = &#63; and status &ne; &#63;.
18448             *
18449             * @param companyId the company ID
18450             * @param status the status
18451             * @return the number of matching journal articles
18452             * @throws SystemException if a system exception occurred
18453             */
18454            @Override
18455            public int countByC_NotST(long companyId, int status)
18456                    throws SystemException {
18457                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTST;
18458    
18459                    Object[] finderArgs = new Object[] { companyId, status };
18460    
18461                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
18462                                    this);
18463    
18464                    if (count == null) {
18465                            StringBundler query = new StringBundler(3);
18466    
18467                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18468    
18469                            query.append(_FINDER_COLUMN_C_NOTST_COMPANYID_2);
18470    
18471                            query.append(_FINDER_COLUMN_C_NOTST_STATUS_2);
18472    
18473                            String sql = query.toString();
18474    
18475                            Session session = null;
18476    
18477                            try {
18478                                    session = openSession();
18479    
18480                                    Query q = session.createQuery(sql);
18481    
18482                                    QueryPos qPos = QueryPos.getInstance(q);
18483    
18484                                    qPos.add(companyId);
18485    
18486                                    qPos.add(status);
18487    
18488                                    count = (Long)q.uniqueResult();
18489    
18490                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
18491                            }
18492                            catch (Exception e) {
18493                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18494    
18495                                    throw processException(e);
18496                            }
18497                            finally {
18498                                    closeSession(session);
18499                            }
18500                    }
18501    
18502                    return count.intValue();
18503            }
18504    
18505            private static final String _FINDER_COLUMN_C_NOTST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
18506            private static final String _FINDER_COLUMN_C_NOTST_STATUS_2 = "journalArticle.status != ?";
18507            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18508                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
18509                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
18510                            "findByC_T",
18511                            new String[] {
18512                                    Long.class.getName(), String.class.getName(),
18513                                    
18514                            Integer.class.getName(), Integer.class.getName(),
18515                                    OrderByComparator.class.getName()
18516                            });
18517            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18518                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
18519                            JournalArticleImpl.class,
18520                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_T",
18521                            new String[] { Long.class.getName(), String.class.getName() },
18522                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
18523                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
18524                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
18525                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
18526            public static final FinderPath FINDER_PATH_COUNT_BY_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18527                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
18528                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_T",
18529                            new String[] { Long.class.getName(), String.class.getName() });
18530    
18531            /**
18532             * Returns all the journal articles where classNameId = &#63; and templateId = &#63;.
18533             *
18534             * @param classNameId the class name ID
18535             * @param templateId the template ID
18536             * @return the matching journal articles
18537             * @throws SystemException if a system exception occurred
18538             */
18539            @Override
18540            public List<JournalArticle> findByC_T(long classNameId, String templateId)
18541                    throws SystemException {
18542                    return findByC_T(classNameId, templateId, QueryUtil.ALL_POS,
18543                            QueryUtil.ALL_POS, null);
18544            }
18545    
18546            /**
18547             * Returns a range of all the journal articles where classNameId = &#63; and templateId = &#63;.
18548             *
18549             * <p>
18550             * 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.
18551             * </p>
18552             *
18553             * @param classNameId the class name ID
18554             * @param templateId the template ID
18555             * @param start the lower bound of the range of journal articles
18556             * @param end the upper bound of the range of journal articles (not inclusive)
18557             * @return the range of matching journal articles
18558             * @throws SystemException if a system exception occurred
18559             */
18560            @Override
18561            public List<JournalArticle> findByC_T(long classNameId, String templateId,
18562                    int start, int end) throws SystemException {
18563                    return findByC_T(classNameId, templateId, start, end, null);
18564            }
18565    
18566            /**
18567             * Returns an ordered range of all the journal articles where classNameId = &#63; and templateId = &#63;.
18568             *
18569             * <p>
18570             * 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.
18571             * </p>
18572             *
18573             * @param classNameId the class name ID
18574             * @param templateId the template ID
18575             * @param start the lower bound of the range of journal articles
18576             * @param end the upper bound of the range of journal articles (not inclusive)
18577             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18578             * @return the ordered range of matching journal articles
18579             * @throws SystemException if a system exception occurred
18580             */
18581            @Override
18582            public List<JournalArticle> findByC_T(long classNameId, String templateId,
18583                    int start, int end, OrderByComparator orderByComparator)
18584                    throws SystemException {
18585                    boolean pagination = true;
18586                    FinderPath finderPath = null;
18587                    Object[] finderArgs = null;
18588    
18589                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
18590                                    (orderByComparator == null)) {
18591                            pagination = false;
18592                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T;
18593                            finderArgs = new Object[] { classNameId, templateId };
18594                    }
18595                    else {
18596                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_T;
18597                            finderArgs = new Object[] {
18598                                            classNameId, templateId,
18599                                            
18600                                            start, end, orderByComparator
18601                                    };
18602                    }
18603    
18604                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
18605                                    finderArgs, this);
18606    
18607                    if ((list != null) && !list.isEmpty()) {
18608                            for (JournalArticle journalArticle : list) {
18609                                    if ((classNameId != journalArticle.getClassNameId()) ||
18610                                                    !Validator.equals(templateId,
18611                                                            journalArticle.getTemplateId())) {
18612                                            list = null;
18613    
18614                                            break;
18615                                    }
18616                            }
18617                    }
18618    
18619                    if (list == null) {
18620                            StringBundler query = null;
18621    
18622                            if (orderByComparator != null) {
18623                                    query = new StringBundler(4 +
18624                                                    (orderByComparator.getOrderByFields().length * 3));
18625                            }
18626                            else {
18627                                    query = new StringBundler(4);
18628                            }
18629    
18630                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18631    
18632                            query.append(_FINDER_COLUMN_C_T_CLASSNAMEID_2);
18633    
18634                            boolean bindTemplateId = false;
18635    
18636                            if (templateId == null) {
18637                                    query.append(_FINDER_COLUMN_C_T_TEMPLATEID_1);
18638                            }
18639                            else if (templateId.equals(StringPool.BLANK)) {
18640                                    query.append(_FINDER_COLUMN_C_T_TEMPLATEID_3);
18641                            }
18642                            else {
18643                                    bindTemplateId = true;
18644    
18645                                    query.append(_FINDER_COLUMN_C_T_TEMPLATEID_2);
18646                            }
18647    
18648                            if (orderByComparator != null) {
18649                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18650                                            orderByComparator);
18651                            }
18652                            else
18653                             if (pagination) {
18654                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18655                            }
18656    
18657                            String sql = query.toString();
18658    
18659                            Session session = null;
18660    
18661                            try {
18662                                    session = openSession();
18663    
18664                                    Query q = session.createQuery(sql);
18665    
18666                                    QueryPos qPos = QueryPos.getInstance(q);
18667    
18668                                    qPos.add(classNameId);
18669    
18670                                    if (bindTemplateId) {
18671                                            qPos.add(templateId);
18672                                    }
18673    
18674                                    if (!pagination) {
18675                                            list = (List<JournalArticle>)QueryUtil.list(q,
18676                                                            getDialect(), start, end, false);
18677    
18678                                            Collections.sort(list);
18679    
18680                                            list = new UnmodifiableList<JournalArticle>(list);
18681                                    }
18682                                    else {
18683                                            list = (List<JournalArticle>)QueryUtil.list(q,
18684                                                            getDialect(), start, end);
18685                                    }
18686    
18687                                    cacheResult(list);
18688    
18689                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
18690                            }
18691                            catch (Exception e) {
18692                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18693    
18694                                    throw processException(e);
18695                            }
18696                            finally {
18697                                    closeSession(session);
18698                            }
18699                    }
18700    
18701                    return list;
18702            }
18703    
18704            /**
18705             * Returns the first journal article in the ordered set where classNameId = &#63; and templateId = &#63;.
18706             *
18707             * @param classNameId the class name ID
18708             * @param templateId the template ID
18709             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18710             * @return the first matching journal article
18711             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
18712             * @throws SystemException if a system exception occurred
18713             */
18714            @Override
18715            public JournalArticle findByC_T_First(long classNameId, String templateId,
18716                    OrderByComparator orderByComparator)
18717                    throws NoSuchArticleException, SystemException {
18718                    JournalArticle journalArticle = fetchByC_T_First(classNameId,
18719                                    templateId, orderByComparator);
18720    
18721                    if (journalArticle != null) {
18722                            return journalArticle;
18723                    }
18724    
18725                    StringBundler msg = new StringBundler(6);
18726    
18727                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
18728    
18729                    msg.append("classNameId=");
18730                    msg.append(classNameId);
18731    
18732                    msg.append(", templateId=");
18733                    msg.append(templateId);
18734    
18735                    msg.append(StringPool.CLOSE_CURLY_BRACE);
18736    
18737                    throw new NoSuchArticleException(msg.toString());
18738            }
18739    
18740            /**
18741             * Returns the first journal article in the ordered set where classNameId = &#63; and templateId = &#63;.
18742             *
18743             * @param classNameId the class name ID
18744             * @param templateId the template ID
18745             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18746             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
18747             * @throws SystemException if a system exception occurred
18748             */
18749            @Override
18750            public JournalArticle fetchByC_T_First(long classNameId, String templateId,
18751                    OrderByComparator orderByComparator) throws SystemException {
18752                    List<JournalArticle> list = findByC_T(classNameId, templateId, 0, 1,
18753                                    orderByComparator);
18754    
18755                    if (!list.isEmpty()) {
18756                            return list.get(0);
18757                    }
18758    
18759                    return null;
18760            }
18761    
18762            /**
18763             * Returns the last journal article in the ordered set where classNameId = &#63; and templateId = &#63;.
18764             *
18765             * @param classNameId the class name ID
18766             * @param templateId the template ID
18767             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18768             * @return the last matching journal article
18769             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
18770             * @throws SystemException if a system exception occurred
18771             */
18772            @Override
18773            public JournalArticle findByC_T_Last(long classNameId, String templateId,
18774                    OrderByComparator orderByComparator)
18775                    throws NoSuchArticleException, SystemException {
18776                    JournalArticle journalArticle = fetchByC_T_Last(classNameId,
18777                                    templateId, orderByComparator);
18778    
18779                    if (journalArticle != null) {
18780                            return journalArticle;
18781                    }
18782    
18783                    StringBundler msg = new StringBundler(6);
18784    
18785                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
18786    
18787                    msg.append("classNameId=");
18788                    msg.append(classNameId);
18789    
18790                    msg.append(", templateId=");
18791                    msg.append(templateId);
18792    
18793                    msg.append(StringPool.CLOSE_CURLY_BRACE);
18794    
18795                    throw new NoSuchArticleException(msg.toString());
18796            }
18797    
18798            /**
18799             * Returns the last journal article in the ordered set where classNameId = &#63; and templateId = &#63;.
18800             *
18801             * @param classNameId the class name ID
18802             * @param templateId the template ID
18803             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18804             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
18805             * @throws SystemException if a system exception occurred
18806             */
18807            @Override
18808            public JournalArticle fetchByC_T_Last(long classNameId, String templateId,
18809                    OrderByComparator orderByComparator) throws SystemException {
18810                    int count = countByC_T(classNameId, templateId);
18811    
18812                    if (count == 0) {
18813                            return null;
18814                    }
18815    
18816                    List<JournalArticle> list = findByC_T(classNameId, templateId,
18817                                    count - 1, count, orderByComparator);
18818    
18819                    if (!list.isEmpty()) {
18820                            return list.get(0);
18821                    }
18822    
18823                    return null;
18824            }
18825    
18826            /**
18827             * Returns the journal articles before and after the current journal article in the ordered set where classNameId = &#63; and templateId = &#63;.
18828             *
18829             * @param id the primary key of the current journal article
18830             * @param classNameId the class name ID
18831             * @param templateId the template ID
18832             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18833             * @return the previous, current, and next journal article
18834             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
18835             * @throws SystemException if a system exception occurred
18836             */
18837            @Override
18838            public JournalArticle[] findByC_T_PrevAndNext(long id, long classNameId,
18839                    String templateId, OrderByComparator orderByComparator)
18840                    throws NoSuchArticleException, SystemException {
18841                    JournalArticle journalArticle = findByPrimaryKey(id);
18842    
18843                    Session session = null;
18844    
18845                    try {
18846                            session = openSession();
18847    
18848                            JournalArticle[] array = new JournalArticleImpl[3];
18849    
18850                            array[0] = getByC_T_PrevAndNext(session, journalArticle,
18851                                            classNameId, templateId, orderByComparator, true);
18852    
18853                            array[1] = journalArticle;
18854    
18855                            array[2] = getByC_T_PrevAndNext(session, journalArticle,
18856                                            classNameId, templateId, orderByComparator, false);
18857    
18858                            return array;
18859                    }
18860                    catch (Exception e) {
18861                            throw processException(e);
18862                    }
18863                    finally {
18864                            closeSession(session);
18865                    }
18866            }
18867    
18868            protected JournalArticle getByC_T_PrevAndNext(Session session,
18869                    JournalArticle journalArticle, long classNameId, String templateId,
18870                    OrderByComparator orderByComparator, boolean previous) {
18871                    StringBundler query = null;
18872    
18873                    if (orderByComparator != null) {
18874                            query = new StringBundler(6 +
18875                                            (orderByComparator.getOrderByFields().length * 6));
18876                    }
18877                    else {
18878                            query = new StringBundler(3);
18879                    }
18880    
18881                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18882    
18883                    query.append(_FINDER_COLUMN_C_T_CLASSNAMEID_2);
18884    
18885                    boolean bindTemplateId = false;
18886    
18887                    if (templateId == null) {
18888                            query.append(_FINDER_COLUMN_C_T_TEMPLATEID_1);
18889                    }
18890                    else if (templateId.equals(StringPool.BLANK)) {
18891                            query.append(_FINDER_COLUMN_C_T_TEMPLATEID_3);
18892                    }
18893                    else {
18894                            bindTemplateId = true;
18895    
18896                            query.append(_FINDER_COLUMN_C_T_TEMPLATEID_2);
18897                    }
18898    
18899                    if (orderByComparator != null) {
18900                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
18901    
18902                            if (orderByConditionFields.length > 0) {
18903                                    query.append(WHERE_AND);
18904                            }
18905    
18906                            for (int i = 0; i < orderByConditionFields.length; i++) {
18907                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18908                                    query.append(orderByConditionFields[i]);
18909    
18910                                    if ((i + 1) < orderByConditionFields.length) {
18911                                            if (orderByComparator.isAscending() ^ previous) {
18912                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
18913                                            }
18914                                            else {
18915                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
18916                                            }
18917                                    }
18918                                    else {
18919                                            if (orderByComparator.isAscending() ^ previous) {
18920                                                    query.append(WHERE_GREATER_THAN);
18921                                            }
18922                                            else {
18923                                                    query.append(WHERE_LESSER_THAN);
18924                                            }
18925                                    }
18926                            }
18927    
18928                            query.append(ORDER_BY_CLAUSE);
18929    
18930                            String[] orderByFields = orderByComparator.getOrderByFields();
18931    
18932                            for (int i = 0; i < orderByFields.length; i++) {
18933                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18934                                    query.append(orderByFields[i]);
18935    
18936                                    if ((i + 1) < orderByFields.length) {
18937                                            if (orderByComparator.isAscending() ^ previous) {
18938                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
18939                                            }
18940                                            else {
18941                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
18942                                            }
18943                                    }
18944                                    else {
18945                                            if (orderByComparator.isAscending() ^ previous) {
18946                                                    query.append(ORDER_BY_ASC);
18947                                            }
18948                                            else {
18949                                                    query.append(ORDER_BY_DESC);
18950                                            }
18951                                    }
18952                            }
18953                    }
18954                    else {
18955                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18956                    }
18957    
18958                    String sql = query.toString();
18959    
18960                    Query q = session.createQuery(sql);
18961    
18962                    q.setFirstResult(0);
18963                    q.setMaxResults(2);
18964    
18965                    QueryPos qPos = QueryPos.getInstance(q);
18966    
18967                    qPos.add(classNameId);
18968    
18969                    if (bindTemplateId) {
18970                            qPos.add(templateId);
18971                    }
18972    
18973                    if (orderByComparator != null) {
18974                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
18975    
18976                            for (Object value : values) {
18977                                    qPos.add(value);
18978                            }
18979                    }
18980    
18981                    List<JournalArticle> list = q.list();
18982    
18983                    if (list.size() == 2) {
18984                            return list.get(1);
18985                    }
18986                    else {
18987                            return null;
18988                    }
18989            }
18990    
18991            /**
18992             * Removes all the journal articles where classNameId = &#63; and templateId = &#63; from the database.
18993             *
18994             * @param classNameId the class name ID
18995             * @param templateId the template ID
18996             * @throws SystemException if a system exception occurred
18997             */
18998            @Override
18999            public void removeByC_T(long classNameId, String templateId)
19000                    throws SystemException {
19001                    for (JournalArticle journalArticle : findByC_T(classNameId, templateId,
19002                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
19003                            remove(journalArticle);
19004                    }
19005            }
19006    
19007            /**
19008             * Returns the number of journal articles where classNameId = &#63; and templateId = &#63;.
19009             *
19010             * @param classNameId the class name ID
19011             * @param templateId the template ID
19012             * @return the number of matching journal articles
19013             * @throws SystemException if a system exception occurred
19014             */
19015            @Override
19016            public int countByC_T(long classNameId, String templateId)
19017                    throws SystemException {
19018                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_T;
19019    
19020                    Object[] finderArgs = new Object[] { classNameId, templateId };
19021    
19022                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
19023                                    this);
19024    
19025                    if (count == null) {
19026                            StringBundler query = new StringBundler(3);
19027    
19028                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
19029    
19030                            query.append(_FINDER_COLUMN_C_T_CLASSNAMEID_2);
19031    
19032                            boolean bindTemplateId = false;
19033    
19034                            if (templateId == null) {
19035                                    query.append(_FINDER_COLUMN_C_T_TEMPLATEID_1);
19036                            }
19037                            else if (templateId.equals(StringPool.BLANK)) {
19038                                    query.append(_FINDER_COLUMN_C_T_TEMPLATEID_3);
19039                            }
19040                            else {
19041                                    bindTemplateId = true;
19042    
19043                                    query.append(_FINDER_COLUMN_C_T_TEMPLATEID_2);
19044                            }
19045    
19046                            String sql = query.toString();
19047    
19048                            Session session = null;
19049    
19050                            try {
19051                                    session = openSession();
19052    
19053                                    Query q = session.createQuery(sql);
19054    
19055                                    QueryPos qPos = QueryPos.getInstance(q);
19056    
19057                                    qPos.add(classNameId);
19058    
19059                                    if (bindTemplateId) {
19060                                            qPos.add(templateId);
19061                                    }
19062    
19063                                    count = (Long)q.uniqueResult();
19064    
19065                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
19066                            }
19067                            catch (Exception e) {
19068                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
19069    
19070                                    throw processException(e);
19071                            }
19072                            finally {
19073                                    closeSession(session);
19074                            }
19075                    }
19076    
19077                    return count.intValue();
19078            }
19079    
19080            private static final String _FINDER_COLUMN_C_T_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
19081            private static final String _FINDER_COLUMN_C_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
19082            private static final String _FINDER_COLUMN_C_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
19083            private static final String _FINDER_COLUMN_C_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = '')";
19084            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19085                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
19086                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
19087                            "findByLtD_S",
19088                            new String[] {
19089                                    Date.class.getName(), Integer.class.getName(),
19090                                    
19091                            Integer.class.getName(), Integer.class.getName(),
19092                                    OrderByComparator.class.getName()
19093                            });
19094            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19095                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
19096                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByLtD_S",
19097                            new String[] { Date.class.getName(), Integer.class.getName() });
19098    
19099            /**
19100             * Returns all the journal articles where displayDate &lt; &#63; and status = &#63;.
19101             *
19102             * @param displayDate the display date
19103             * @param status the status
19104             * @return the matching journal articles
19105             * @throws SystemException if a system exception occurred
19106             */
19107            @Override
19108            public List<JournalArticle> findByLtD_S(Date displayDate, int status)
19109                    throws SystemException {
19110                    return findByLtD_S(displayDate, status, QueryUtil.ALL_POS,
19111                            QueryUtil.ALL_POS, null);
19112            }
19113    
19114            /**
19115             * Returns a range of all the journal articles where displayDate &lt; &#63; and status = &#63;.
19116             *
19117             * <p>
19118             * 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.
19119             * </p>
19120             *
19121             * @param displayDate the display date
19122             * @param status the status
19123             * @param start the lower bound of the range of journal articles
19124             * @param end the upper bound of the range of journal articles (not inclusive)
19125             * @return the range of matching journal articles
19126             * @throws SystemException if a system exception occurred
19127             */
19128            @Override
19129            public List<JournalArticle> findByLtD_S(Date displayDate, int status,
19130                    int start, int end) throws SystemException {
19131                    return findByLtD_S(displayDate, status, start, end, null);
19132            }
19133    
19134            /**
19135             * Returns an ordered range of all the journal articles where displayDate &lt; &#63; and status = &#63;.
19136             *
19137             * <p>
19138             * 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.
19139             * </p>
19140             *
19141             * @param displayDate the display date
19142             * @param status the status
19143             * @param start the lower bound of the range of journal articles
19144             * @param end the upper bound of the range of journal articles (not inclusive)
19145             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19146             * @return the ordered range of matching journal articles
19147             * @throws SystemException if a system exception occurred
19148             */
19149            @Override
19150            public List<JournalArticle> findByLtD_S(Date displayDate, int status,
19151                    int start, int end, OrderByComparator orderByComparator)
19152                    throws SystemException {
19153                    boolean pagination = true;
19154                    FinderPath finderPath = null;
19155                    Object[] finderArgs = null;
19156    
19157                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S;
19158                    finderArgs = new Object[] {
19159                                    displayDate, status,
19160                                    
19161                                    start, end, orderByComparator
19162                            };
19163    
19164                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
19165                                    finderArgs, this);
19166    
19167                    if ((list != null) && !list.isEmpty()) {
19168                            for (JournalArticle journalArticle : list) {
19169                                    if ((displayDate.getTime() <= journalArticle.getDisplayDate()
19170                                                                                                                                    .getTime()) ||
19171                                                    (status != journalArticle.getStatus())) {
19172                                            list = null;
19173    
19174                                            break;
19175                                    }
19176                            }
19177                    }
19178    
19179                    if (list == null) {
19180                            StringBundler query = null;
19181    
19182                            if (orderByComparator != null) {
19183                                    query = new StringBundler(4 +
19184                                                    (orderByComparator.getOrderByFields().length * 3));
19185                            }
19186                            else {
19187                                    query = new StringBundler(4);
19188                            }
19189    
19190                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
19191    
19192                            boolean bindDisplayDate = false;
19193    
19194                            if (displayDate == null) {
19195                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
19196                            }
19197                            else {
19198                                    bindDisplayDate = true;
19199    
19200                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
19201                            }
19202    
19203                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
19204    
19205                            if (orderByComparator != null) {
19206                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
19207                                            orderByComparator);
19208                            }
19209                            else
19210                             if (pagination) {
19211                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19212                            }
19213    
19214                            String sql = query.toString();
19215    
19216                            Session session = null;
19217    
19218                            try {
19219                                    session = openSession();
19220    
19221                                    Query q = session.createQuery(sql);
19222    
19223                                    QueryPos qPos = QueryPos.getInstance(q);
19224    
19225                                    if (bindDisplayDate) {
19226                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
19227                                    }
19228    
19229                                    qPos.add(status);
19230    
19231                                    if (!pagination) {
19232                                            list = (List<JournalArticle>)QueryUtil.list(q,
19233                                                            getDialect(), start, end, false);
19234    
19235                                            Collections.sort(list);
19236    
19237                                            list = new UnmodifiableList<JournalArticle>(list);
19238                                    }
19239                                    else {
19240                                            list = (List<JournalArticle>)QueryUtil.list(q,
19241                                                            getDialect(), start, end);
19242                                    }
19243    
19244                                    cacheResult(list);
19245    
19246                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
19247                            }
19248                            catch (Exception e) {
19249                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
19250    
19251                                    throw processException(e);
19252                            }
19253                            finally {
19254                                    closeSession(session);
19255                            }
19256                    }
19257    
19258                    return list;
19259            }
19260    
19261            /**
19262             * Returns the first journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
19263             *
19264             * @param displayDate the display date
19265             * @param status the status
19266             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19267             * @return the first matching journal article
19268             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
19269             * @throws SystemException if a system exception occurred
19270             */
19271            @Override
19272            public JournalArticle findByLtD_S_First(Date displayDate, int status,
19273                    OrderByComparator orderByComparator)
19274                    throws NoSuchArticleException, SystemException {
19275                    JournalArticle journalArticle = fetchByLtD_S_First(displayDate, status,
19276                                    orderByComparator);
19277    
19278                    if (journalArticle != null) {
19279                            return journalArticle;
19280                    }
19281    
19282                    StringBundler msg = new StringBundler(6);
19283    
19284                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
19285    
19286                    msg.append("displayDate=");
19287                    msg.append(displayDate);
19288    
19289                    msg.append(", status=");
19290                    msg.append(status);
19291    
19292                    msg.append(StringPool.CLOSE_CURLY_BRACE);
19293    
19294                    throw new NoSuchArticleException(msg.toString());
19295            }
19296    
19297            /**
19298             * Returns the first journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
19299             *
19300             * @param displayDate the display date
19301             * @param status the status
19302             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19303             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
19304             * @throws SystemException if a system exception occurred
19305             */
19306            @Override
19307            public JournalArticle fetchByLtD_S_First(Date displayDate, int status,
19308                    OrderByComparator orderByComparator) throws SystemException {
19309                    List<JournalArticle> list = findByLtD_S(displayDate, status, 0, 1,
19310                                    orderByComparator);
19311    
19312                    if (!list.isEmpty()) {
19313                            return list.get(0);
19314                    }
19315    
19316                    return null;
19317            }
19318    
19319            /**
19320             * Returns the last journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
19321             *
19322             * @param displayDate the display date
19323             * @param status the status
19324             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19325             * @return the last matching journal article
19326             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
19327             * @throws SystemException if a system exception occurred
19328             */
19329            @Override
19330            public JournalArticle findByLtD_S_Last(Date displayDate, int status,
19331                    OrderByComparator orderByComparator)
19332                    throws NoSuchArticleException, SystemException {
19333                    JournalArticle journalArticle = fetchByLtD_S_Last(displayDate, status,
19334                                    orderByComparator);
19335    
19336                    if (journalArticle != null) {
19337                            return journalArticle;
19338                    }
19339    
19340                    StringBundler msg = new StringBundler(6);
19341    
19342                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
19343    
19344                    msg.append("displayDate=");
19345                    msg.append(displayDate);
19346    
19347                    msg.append(", status=");
19348                    msg.append(status);
19349    
19350                    msg.append(StringPool.CLOSE_CURLY_BRACE);
19351    
19352                    throw new NoSuchArticleException(msg.toString());
19353            }
19354    
19355            /**
19356             * Returns the last journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
19357             *
19358             * @param displayDate the display date
19359             * @param status the status
19360             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19361             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
19362             * @throws SystemException if a system exception occurred
19363             */
19364            @Override
19365            public JournalArticle fetchByLtD_S_Last(Date displayDate, int status,
19366                    OrderByComparator orderByComparator) throws SystemException {
19367                    int count = countByLtD_S(displayDate, status);
19368    
19369                    if (count == 0) {
19370                            return null;
19371                    }
19372    
19373                    List<JournalArticle> list = findByLtD_S(displayDate, status, count - 1,
19374                                    count, orderByComparator);
19375    
19376                    if (!list.isEmpty()) {
19377                            return list.get(0);
19378                    }
19379    
19380                    return null;
19381            }
19382    
19383            /**
19384             * Returns the journal articles before and after the current journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
19385             *
19386             * @param id the primary key of the current journal article
19387             * @param displayDate the display date
19388             * @param status the status
19389             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19390             * @return the previous, current, and next journal article
19391             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
19392             * @throws SystemException if a system exception occurred
19393             */
19394            @Override
19395            public JournalArticle[] findByLtD_S_PrevAndNext(long id, Date displayDate,
19396                    int status, OrderByComparator orderByComparator)
19397                    throws NoSuchArticleException, SystemException {
19398                    JournalArticle journalArticle = findByPrimaryKey(id);
19399    
19400                    Session session = null;
19401    
19402                    try {
19403                            session = openSession();
19404    
19405                            JournalArticle[] array = new JournalArticleImpl[3];
19406    
19407                            array[0] = getByLtD_S_PrevAndNext(session, journalArticle,
19408                                            displayDate, status, orderByComparator, true);
19409    
19410                            array[1] = journalArticle;
19411    
19412                            array[2] = getByLtD_S_PrevAndNext(session, journalArticle,
19413                                            displayDate, status, orderByComparator, false);
19414    
19415                            return array;
19416                    }
19417                    catch (Exception e) {
19418                            throw processException(e);
19419                    }
19420                    finally {
19421                            closeSession(session);
19422                    }
19423            }
19424    
19425            protected JournalArticle getByLtD_S_PrevAndNext(Session session,
19426                    JournalArticle journalArticle, Date displayDate, int status,
19427                    OrderByComparator orderByComparator, boolean previous) {
19428                    StringBundler query = null;
19429    
19430                    if (orderByComparator != null) {
19431                            query = new StringBundler(6 +
19432                                            (orderByComparator.getOrderByFields().length * 6));
19433                    }
19434                    else {
19435                            query = new StringBundler(3);
19436                    }
19437    
19438                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
19439    
19440                    boolean bindDisplayDate = false;
19441    
19442                    if (displayDate == null) {
19443                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
19444                    }
19445                    else {
19446                            bindDisplayDate = true;
19447    
19448                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
19449                    }
19450    
19451                    query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
19452    
19453                    if (orderByComparator != null) {
19454                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
19455    
19456                            if (orderByConditionFields.length > 0) {
19457                                    query.append(WHERE_AND);
19458                            }
19459    
19460                            for (int i = 0; i < orderByConditionFields.length; i++) {
19461                                    query.append(_ORDER_BY_ENTITY_ALIAS);
19462                                    query.append(orderByConditionFields[i]);
19463    
19464                                    if ((i + 1) < orderByConditionFields.length) {
19465                                            if (orderByComparator.isAscending() ^ previous) {
19466                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
19467                                            }
19468                                            else {
19469                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
19470                                            }
19471                                    }
19472                                    else {
19473                                            if (orderByComparator.isAscending() ^ previous) {
19474                                                    query.append(WHERE_GREATER_THAN);
19475                                            }
19476                                            else {
19477                                                    query.append(WHERE_LESSER_THAN);
19478                                            }
19479                                    }
19480                            }
19481    
19482                            query.append(ORDER_BY_CLAUSE);
19483    
19484                            String[] orderByFields = orderByComparator.getOrderByFields();
19485    
19486                            for (int i = 0; i < orderByFields.length; i++) {
19487                                    query.append(_ORDER_BY_ENTITY_ALIAS);
19488                                    query.append(orderByFields[i]);
19489    
19490                                    if ((i + 1) < orderByFields.length) {
19491                                            if (orderByComparator.isAscending() ^ previous) {
19492                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
19493                                            }
19494                                            else {
19495                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
19496                                            }
19497                                    }
19498                                    else {
19499                                            if (orderByComparator.isAscending() ^ previous) {
19500                                                    query.append(ORDER_BY_ASC);
19501                                            }
19502                                            else {
19503                                                    query.append(ORDER_BY_DESC);
19504                                            }
19505                                    }
19506                            }
19507                    }
19508                    else {
19509                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19510                    }
19511    
19512                    String sql = query.toString();
19513    
19514                    Query q = session.createQuery(sql);
19515    
19516                    q.setFirstResult(0);
19517                    q.setMaxResults(2);
19518    
19519                    QueryPos qPos = QueryPos.getInstance(q);
19520    
19521                    if (bindDisplayDate) {
19522                            qPos.add(CalendarUtil.getTimestamp(displayDate));
19523                    }
19524    
19525                    qPos.add(status);
19526    
19527                    if (orderByComparator != null) {
19528                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
19529    
19530                            for (Object value : values) {
19531                                    qPos.add(value);
19532                            }
19533                    }
19534    
19535                    List<JournalArticle> list = q.list();
19536    
19537                    if (list.size() == 2) {
19538                            return list.get(1);
19539                    }
19540                    else {
19541                            return null;
19542                    }
19543            }
19544    
19545            /**
19546             * Removes all the journal articles where displayDate &lt; &#63; and status = &#63; from the database.
19547             *
19548             * @param displayDate the display date
19549             * @param status the status
19550             * @throws SystemException if a system exception occurred
19551             */
19552            @Override
19553            public void removeByLtD_S(Date displayDate, int status)
19554                    throws SystemException {
19555                    for (JournalArticle journalArticle : findByLtD_S(displayDate, status,
19556                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
19557                            remove(journalArticle);
19558                    }
19559            }
19560    
19561            /**
19562             * Returns the number of journal articles where displayDate &lt; &#63; and status = &#63;.
19563             *
19564             * @param displayDate the display date
19565             * @param status the status
19566             * @return the number of matching journal articles
19567             * @throws SystemException if a system exception occurred
19568             */
19569            @Override
19570            public int countByLtD_S(Date displayDate, int status)
19571                    throws SystemException {
19572                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S;
19573    
19574                    Object[] finderArgs = new Object[] { displayDate, status };
19575    
19576                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
19577                                    this);
19578    
19579                    if (count == null) {
19580                            StringBundler query = new StringBundler(3);
19581    
19582                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
19583    
19584                            boolean bindDisplayDate = false;
19585    
19586                            if (displayDate == null) {
19587                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
19588                            }
19589                            else {
19590                                    bindDisplayDate = true;
19591    
19592                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
19593                            }
19594    
19595                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
19596    
19597                            String sql = query.toString();
19598    
19599                            Session session = null;
19600    
19601                            try {
19602                                    session = openSession();
19603    
19604                                    Query q = session.createQuery(sql);
19605    
19606                                    QueryPos qPos = QueryPos.getInstance(q);
19607    
19608                                    if (bindDisplayDate) {
19609                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
19610                                    }
19611    
19612                                    qPos.add(status);
19613    
19614                                    count = (Long)q.uniqueResult();
19615    
19616                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
19617                            }
19618                            catch (Exception e) {
19619                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
19620    
19621                                    throw processException(e);
19622                            }
19623                            finally {
19624                                    closeSession(session);
19625                            }
19626                    }
19627    
19628                    return count.intValue();
19629            }
19630    
19631            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_1 = "journalArticle.displayDate < NULL AND ";
19632            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_2 = "journalArticle.displayDate < ? AND ";
19633            private static final String _FINDER_COLUMN_LTD_S_STATUS_2 = "journalArticle.status = ?";
19634            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19635                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
19636                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
19637                            "findByR_I_S",
19638                            new String[] {
19639                                    Long.class.getName(), Boolean.class.getName(),
19640                                    Integer.class.getName(),
19641                                    
19642                            Integer.class.getName(), Integer.class.getName(),
19643                                    OrderByComparator.class.getName()
19644                            });
19645            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19646                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
19647                            JournalArticleImpl.class,
19648                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_I_S",
19649                            new String[] {
19650                                    Long.class.getName(), Boolean.class.getName(),
19651                                    Integer.class.getName()
19652                            },
19653                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
19654                            JournalArticleModelImpl.INDEXABLE_COLUMN_BITMASK |
19655                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
19656                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
19657                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
19658            public static final FinderPath FINDER_PATH_COUNT_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19659                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
19660                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_I_S",
19661                            new String[] {
19662                                    Long.class.getName(), Boolean.class.getName(),
19663                                    Integer.class.getName()
19664                            });
19665            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19666                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
19667                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByR_I_S",
19668                            new String[] {
19669                                    Long.class.getName(), Boolean.class.getName(),
19670                                    Integer.class.getName()
19671                            });
19672    
19673            /**
19674             * Returns all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
19675             *
19676             * @param resourcePrimKey the resource prim key
19677             * @param indexable the indexable
19678             * @param status the status
19679             * @return the matching journal articles
19680             * @throws SystemException if a system exception occurred
19681             */
19682            @Override
19683            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
19684                    boolean indexable, int status) throws SystemException {
19685                    return findByR_I_S(resourcePrimKey, indexable, status,
19686                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
19687            }
19688    
19689            /**
19690             * Returns a range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
19691             *
19692             * <p>
19693             * 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.
19694             * </p>
19695             *
19696             * @param resourcePrimKey the resource prim key
19697             * @param indexable the indexable
19698             * @param status the status
19699             * @param start the lower bound of the range of journal articles
19700             * @param end the upper bound of the range of journal articles (not inclusive)
19701             * @return the range of matching journal articles
19702             * @throws SystemException if a system exception occurred
19703             */
19704            @Override
19705            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
19706                    boolean indexable, int status, int start, int end)
19707                    throws SystemException {
19708                    return findByR_I_S(resourcePrimKey, indexable, status, start, end, null);
19709            }
19710    
19711            /**
19712             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
19713             *
19714             * <p>
19715             * 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.
19716             * </p>
19717             *
19718             * @param resourcePrimKey the resource prim key
19719             * @param indexable the indexable
19720             * @param status the status
19721             * @param start the lower bound of the range of journal articles
19722             * @param end the upper bound of the range of journal articles (not inclusive)
19723             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19724             * @return the ordered range of matching journal articles
19725             * @throws SystemException if a system exception occurred
19726             */
19727            @Override
19728            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
19729                    boolean indexable, int status, int start, int end,
19730                    OrderByComparator orderByComparator) throws SystemException {
19731                    boolean pagination = true;
19732                    FinderPath finderPath = null;
19733                    Object[] finderArgs = null;
19734    
19735                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
19736                                    (orderByComparator == null)) {
19737                            pagination = false;
19738                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S;
19739                            finderArgs = new Object[] { resourcePrimKey, indexable, status };
19740                    }
19741                    else {
19742                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S;
19743                            finderArgs = new Object[] {
19744                                            resourcePrimKey, indexable, status,
19745                                            
19746                                            start, end, orderByComparator
19747                                    };
19748                    }
19749    
19750                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
19751                                    finderArgs, this);
19752    
19753                    if ((list != null) && !list.isEmpty()) {
19754                            for (JournalArticle journalArticle : list) {
19755                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
19756                                                    (indexable != journalArticle.getIndexable()) ||
19757                                                    (status != journalArticle.getStatus())) {
19758                                            list = null;
19759    
19760                                            break;
19761                                    }
19762                            }
19763                    }
19764    
19765                    if (list == null) {
19766                            StringBundler query = null;
19767    
19768                            if (orderByComparator != null) {
19769                                    query = new StringBundler(5 +
19770                                                    (orderByComparator.getOrderByFields().length * 3));
19771                            }
19772                            else {
19773                                    query = new StringBundler(5);
19774                            }
19775    
19776                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
19777    
19778                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2);
19779    
19780                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_2);
19781    
19782                            query.append(_FINDER_COLUMN_R_I_S_STATUS_2);
19783    
19784                            if (orderByComparator != null) {
19785                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
19786                                            orderByComparator);
19787                            }
19788                            else
19789                             if (pagination) {
19790                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19791                            }
19792    
19793                            String sql = query.toString();
19794    
19795                            Session session = null;
19796    
19797                            try {
19798                                    session = openSession();
19799    
19800                                    Query q = session.createQuery(sql);
19801    
19802                                    QueryPos qPos = QueryPos.getInstance(q);
19803    
19804                                    qPos.add(resourcePrimKey);
19805    
19806                                    qPos.add(indexable);
19807    
19808                                    qPos.add(status);
19809    
19810                                    if (!pagination) {
19811                                            list = (List<JournalArticle>)QueryUtil.list(q,
19812                                                            getDialect(), start, end, false);
19813    
19814                                            Collections.sort(list);
19815    
19816                                            list = new UnmodifiableList<JournalArticle>(list);
19817                                    }
19818                                    else {
19819                                            list = (List<JournalArticle>)QueryUtil.list(q,
19820                                                            getDialect(), start, end);
19821                                    }
19822    
19823                                    cacheResult(list);
19824    
19825                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
19826                            }
19827                            catch (Exception e) {
19828                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
19829    
19830                                    throw processException(e);
19831                            }
19832                            finally {
19833                                    closeSession(session);
19834                            }
19835                    }
19836    
19837                    return list;
19838            }
19839    
19840            /**
19841             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
19842             *
19843             * @param resourcePrimKey the resource prim key
19844             * @param indexable the indexable
19845             * @param status the status
19846             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19847             * @return the first matching journal article
19848             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
19849             * @throws SystemException if a system exception occurred
19850             */
19851            @Override
19852            public JournalArticle findByR_I_S_First(long resourcePrimKey,
19853                    boolean indexable, int status, OrderByComparator orderByComparator)
19854                    throws NoSuchArticleException, SystemException {
19855                    JournalArticle journalArticle = fetchByR_I_S_First(resourcePrimKey,
19856                                    indexable, status, orderByComparator);
19857    
19858                    if (journalArticle != null) {
19859                            return journalArticle;
19860                    }
19861    
19862                    StringBundler msg = new StringBundler(8);
19863    
19864                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
19865    
19866                    msg.append("resourcePrimKey=");
19867                    msg.append(resourcePrimKey);
19868    
19869                    msg.append(", indexable=");
19870                    msg.append(indexable);
19871    
19872                    msg.append(", status=");
19873                    msg.append(status);
19874    
19875                    msg.append(StringPool.CLOSE_CURLY_BRACE);
19876    
19877                    throw new NoSuchArticleException(msg.toString());
19878            }
19879    
19880            /**
19881             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
19882             *
19883             * @param resourcePrimKey the resource prim key
19884             * @param indexable the indexable
19885             * @param status the status
19886             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19887             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
19888             * @throws SystemException if a system exception occurred
19889             */
19890            @Override
19891            public JournalArticle fetchByR_I_S_First(long resourcePrimKey,
19892                    boolean indexable, int status, OrderByComparator orderByComparator)
19893                    throws SystemException {
19894                    List<JournalArticle> list = findByR_I_S(resourcePrimKey, indexable,
19895                                    status, 0, 1, orderByComparator);
19896    
19897                    if (!list.isEmpty()) {
19898                            return list.get(0);
19899                    }
19900    
19901                    return null;
19902            }
19903    
19904            /**
19905             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
19906             *
19907             * @param resourcePrimKey the resource prim key
19908             * @param indexable the indexable
19909             * @param status the status
19910             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19911             * @return the last matching journal article
19912             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
19913             * @throws SystemException if a system exception occurred
19914             */
19915            @Override
19916            public JournalArticle findByR_I_S_Last(long resourcePrimKey,
19917                    boolean indexable, int status, OrderByComparator orderByComparator)
19918                    throws NoSuchArticleException, SystemException {
19919                    JournalArticle journalArticle = fetchByR_I_S_Last(resourcePrimKey,
19920                                    indexable, status, orderByComparator);
19921    
19922                    if (journalArticle != null) {
19923                            return journalArticle;
19924                    }
19925    
19926                    StringBundler msg = new StringBundler(8);
19927    
19928                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
19929    
19930                    msg.append("resourcePrimKey=");
19931                    msg.append(resourcePrimKey);
19932    
19933                    msg.append(", indexable=");
19934                    msg.append(indexable);
19935    
19936                    msg.append(", status=");
19937                    msg.append(status);
19938    
19939                    msg.append(StringPool.CLOSE_CURLY_BRACE);
19940    
19941                    throw new NoSuchArticleException(msg.toString());
19942            }
19943    
19944            /**
19945             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
19946             *
19947             * @param resourcePrimKey the resource prim key
19948             * @param indexable the indexable
19949             * @param status the status
19950             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19951             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
19952             * @throws SystemException if a system exception occurred
19953             */
19954            @Override
19955            public JournalArticle fetchByR_I_S_Last(long resourcePrimKey,
19956                    boolean indexable, int status, OrderByComparator orderByComparator)
19957                    throws SystemException {
19958                    int count = countByR_I_S(resourcePrimKey, indexable, status);
19959    
19960                    if (count == 0) {
19961                            return null;
19962                    }
19963    
19964                    List<JournalArticle> list = findByR_I_S(resourcePrimKey, indexable,
19965                                    status, count - 1, count, orderByComparator);
19966    
19967                    if (!list.isEmpty()) {
19968                            return list.get(0);
19969                    }
19970    
19971                    return null;
19972            }
19973    
19974            /**
19975             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
19976             *
19977             * @param id the primary key of the current journal article
19978             * @param resourcePrimKey the resource prim key
19979             * @param indexable the indexable
19980             * @param status the status
19981             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19982             * @return the previous, current, and next journal article
19983             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
19984             * @throws SystemException if a system exception occurred
19985             */
19986            @Override
19987            public JournalArticle[] findByR_I_S_PrevAndNext(long id,
19988                    long resourcePrimKey, boolean indexable, int status,
19989                    OrderByComparator orderByComparator)
19990                    throws NoSuchArticleException, SystemException {
19991                    JournalArticle journalArticle = findByPrimaryKey(id);
19992    
19993                    Session session = null;
19994    
19995                    try {
19996                            session = openSession();
19997    
19998                            JournalArticle[] array = new JournalArticleImpl[3];
19999    
20000                            array[0] = getByR_I_S_PrevAndNext(session, journalArticle,
20001                                            resourcePrimKey, indexable, status, orderByComparator, true);
20002    
20003                            array[1] = journalArticle;
20004    
20005                            array[2] = getByR_I_S_PrevAndNext(session, journalArticle,
20006                                            resourcePrimKey, indexable, status, orderByComparator, false);
20007    
20008                            return array;
20009                    }
20010                    catch (Exception e) {
20011                            throw processException(e);
20012                    }
20013                    finally {
20014                            closeSession(session);
20015                    }
20016            }
20017    
20018            protected JournalArticle getByR_I_S_PrevAndNext(Session session,
20019                    JournalArticle journalArticle, long resourcePrimKey, boolean indexable,
20020                    int status, OrderByComparator orderByComparator, boolean previous) {
20021                    StringBundler query = null;
20022    
20023                    if (orderByComparator != null) {
20024                            query = new StringBundler(6 +
20025                                            (orderByComparator.getOrderByFields().length * 6));
20026                    }
20027                    else {
20028                            query = new StringBundler(3);
20029                    }
20030    
20031                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
20032    
20033                    query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2);
20034    
20035                    query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_2);
20036    
20037                    query.append(_FINDER_COLUMN_R_I_S_STATUS_2);
20038    
20039                    if (orderByComparator != null) {
20040                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
20041    
20042                            if (orderByConditionFields.length > 0) {
20043                                    query.append(WHERE_AND);
20044                            }
20045    
20046                            for (int i = 0; i < orderByConditionFields.length; i++) {
20047                                    query.append(_ORDER_BY_ENTITY_ALIAS);
20048                                    query.append(orderByConditionFields[i]);
20049    
20050                                    if ((i + 1) < orderByConditionFields.length) {
20051                                            if (orderByComparator.isAscending() ^ previous) {
20052                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
20053                                            }
20054                                            else {
20055                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
20056                                            }
20057                                    }
20058                                    else {
20059                                            if (orderByComparator.isAscending() ^ previous) {
20060                                                    query.append(WHERE_GREATER_THAN);
20061                                            }
20062                                            else {
20063                                                    query.append(WHERE_LESSER_THAN);
20064                                            }
20065                                    }
20066                            }
20067    
20068                            query.append(ORDER_BY_CLAUSE);
20069    
20070                            String[] orderByFields = orderByComparator.getOrderByFields();
20071    
20072                            for (int i = 0; i < orderByFields.length; i++) {
20073                                    query.append(_ORDER_BY_ENTITY_ALIAS);
20074                                    query.append(orderByFields[i]);
20075    
20076                                    if ((i + 1) < orderByFields.length) {
20077                                            if (orderByComparator.isAscending() ^ previous) {
20078                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
20079                                            }
20080                                            else {
20081                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
20082                                            }
20083                                    }
20084                                    else {
20085                                            if (orderByComparator.isAscending() ^ previous) {
20086                                                    query.append(ORDER_BY_ASC);
20087                                            }
20088                                            else {
20089                                                    query.append(ORDER_BY_DESC);
20090                                            }
20091                                    }
20092                            }
20093                    }
20094                    else {
20095                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20096                    }
20097    
20098                    String sql = query.toString();
20099    
20100                    Query q = session.createQuery(sql);
20101    
20102                    q.setFirstResult(0);
20103                    q.setMaxResults(2);
20104    
20105                    QueryPos qPos = QueryPos.getInstance(q);
20106    
20107                    qPos.add(resourcePrimKey);
20108    
20109                    qPos.add(indexable);
20110    
20111                    qPos.add(status);
20112    
20113                    if (orderByComparator != null) {
20114                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
20115    
20116                            for (Object value : values) {
20117                                    qPos.add(value);
20118                            }
20119                    }
20120    
20121                    List<JournalArticle> list = q.list();
20122    
20123                    if (list.size() == 2) {
20124                            return list.get(1);
20125                    }
20126                    else {
20127                            return null;
20128                    }
20129            }
20130    
20131            /**
20132             * Returns all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
20133             *
20134             * <p>
20135             * 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.
20136             * </p>
20137             *
20138             * @param resourcePrimKey the resource prim key
20139             * @param indexable the indexable
20140             * @param statuses the statuses
20141             * @return the matching journal articles
20142             * @throws SystemException if a system exception occurred
20143             */
20144            @Override
20145            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
20146                    boolean indexable, int[] statuses) throws SystemException {
20147                    return findByR_I_S(resourcePrimKey, indexable, statuses,
20148                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
20149            }
20150    
20151            /**
20152             * Returns a range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
20153             *
20154             * <p>
20155             * 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.
20156             * </p>
20157             *
20158             * @param resourcePrimKey the resource prim key
20159             * @param indexable the indexable
20160             * @param statuses the statuses
20161             * @param start the lower bound of the range of journal articles
20162             * @param end the upper bound of the range of journal articles (not inclusive)
20163             * @return the range of matching journal articles
20164             * @throws SystemException if a system exception occurred
20165             */
20166            @Override
20167            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
20168                    boolean indexable, int[] statuses, int start, int end)
20169                    throws SystemException {
20170                    return findByR_I_S(resourcePrimKey, indexable, statuses, start, end,
20171                            null);
20172            }
20173    
20174            /**
20175             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
20176             *
20177             * <p>
20178             * 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.
20179             * </p>
20180             *
20181             * @param resourcePrimKey the resource prim key
20182             * @param indexable the indexable
20183             * @param statuses the statuses
20184             * @param start the lower bound of the range of journal articles
20185             * @param end the upper bound of the range of journal articles (not inclusive)
20186             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
20187             * @return the ordered range of matching journal articles
20188             * @throws SystemException if a system exception occurred
20189             */
20190            @Override
20191            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
20192                    boolean indexable, int[] statuses, int start, int end,
20193                    OrderByComparator orderByComparator) throws SystemException {
20194                    if ((statuses != null) && (statuses.length == 1)) {
20195                            return findByR_I_S(resourcePrimKey, indexable, statuses[0], start,
20196                                    end, orderByComparator);
20197                    }
20198    
20199                    boolean pagination = true;
20200                    Object[] finderArgs = null;
20201    
20202                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
20203                                    (orderByComparator == null)) {
20204                            pagination = false;
20205                            finderArgs = new Object[] {
20206                                            resourcePrimKey, indexable, StringUtil.merge(statuses)
20207                                    };
20208                    }
20209                    else {
20210                            finderArgs = new Object[] {
20211                                            resourcePrimKey, indexable, StringUtil.merge(statuses),
20212                                            
20213                                            start, end, orderByComparator
20214                                    };
20215                    }
20216    
20217                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S,
20218                                    finderArgs, this);
20219    
20220                    if ((list != null) && !list.isEmpty()) {
20221                            for (JournalArticle journalArticle : list) {
20222                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
20223                                                    (indexable != journalArticle.getIndexable()) ||
20224                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
20225                                            list = null;
20226    
20227                                            break;
20228                                    }
20229                            }
20230                    }
20231    
20232                    if (list == null) {
20233                            StringBundler query = new StringBundler();
20234    
20235                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
20236    
20237                            boolean conjunctionable = false;
20238    
20239                            if (conjunctionable) {
20240                                    query.append(WHERE_AND);
20241                            }
20242    
20243                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_5);
20244    
20245                            conjunctionable = true;
20246    
20247                            if (conjunctionable) {
20248                                    query.append(WHERE_AND);
20249                            }
20250    
20251                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_5);
20252    
20253                            conjunctionable = true;
20254    
20255                            if ((statuses == null) || (statuses.length > 0)) {
20256                                    if (conjunctionable) {
20257                                            query.append(WHERE_AND);
20258                                    }
20259    
20260                                    query.append(StringPool.OPEN_PARENTHESIS);
20261    
20262                                    for (int i = 0; i < statuses.length; i++) {
20263                                            query.append(_FINDER_COLUMN_R_I_S_STATUS_5);
20264    
20265                                            if ((i + 1) < statuses.length) {
20266                                                    query.append(WHERE_OR);
20267                                            }
20268                                    }
20269    
20270                                    query.append(StringPool.CLOSE_PARENTHESIS);
20271    
20272                                    conjunctionable = true;
20273                            }
20274    
20275                            if (orderByComparator != null) {
20276                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
20277                                            orderByComparator);
20278                            }
20279                            else
20280                             if (pagination) {
20281                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20282                            }
20283    
20284                            String sql = query.toString();
20285    
20286                            Session session = null;
20287    
20288                            try {
20289                                    session = openSession();
20290    
20291                                    Query q = session.createQuery(sql);
20292    
20293                                    QueryPos qPos = QueryPos.getInstance(q);
20294    
20295                                    qPos.add(resourcePrimKey);
20296    
20297                                    qPos.add(indexable);
20298    
20299                                    if (statuses != null) {
20300                                            qPos.add(statuses);
20301                                    }
20302    
20303                                    if (!pagination) {
20304                                            list = (List<JournalArticle>)QueryUtil.list(q,
20305                                                            getDialect(), start, end, false);
20306    
20307                                            Collections.sort(list);
20308    
20309                                            list = new UnmodifiableList<JournalArticle>(list);
20310                                    }
20311                                    else {
20312                                            list = (List<JournalArticle>)QueryUtil.list(q,
20313                                                            getDialect(), start, end);
20314                                    }
20315    
20316                                    cacheResult(list);
20317    
20318                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S,
20319                                            finderArgs, list);
20320                            }
20321                            catch (Exception e) {
20322                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S,
20323                                            finderArgs);
20324    
20325                                    throw processException(e);
20326                            }
20327                            finally {
20328                                    closeSession(session);
20329                            }
20330                    }
20331    
20332                    return list;
20333            }
20334    
20335            /**
20336             * Removes all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63; from the database.
20337             *
20338             * @param resourcePrimKey the resource prim key
20339             * @param indexable the indexable
20340             * @param status the status
20341             * @throws SystemException if a system exception occurred
20342             */
20343            @Override
20344            public void removeByR_I_S(long resourcePrimKey, boolean indexable,
20345                    int status) throws SystemException {
20346                    for (JournalArticle journalArticle : findByR_I_S(resourcePrimKey,
20347                                    indexable, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
20348                            remove(journalArticle);
20349                    }
20350            }
20351    
20352            /**
20353             * Returns the number of journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
20354             *
20355             * @param resourcePrimKey the resource prim key
20356             * @param indexable the indexable
20357             * @param status the status
20358             * @return the number of matching journal articles
20359             * @throws SystemException if a system exception occurred
20360             */
20361            @Override
20362            public int countByR_I_S(long resourcePrimKey, boolean indexable, int status)
20363                    throws SystemException {
20364                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_I_S;
20365    
20366                    Object[] finderArgs = new Object[] { resourcePrimKey, indexable, status };
20367    
20368                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
20369                                    this);
20370    
20371                    if (count == null) {
20372                            StringBundler query = new StringBundler(4);
20373    
20374                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
20375    
20376                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2);
20377    
20378                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_2);
20379    
20380                            query.append(_FINDER_COLUMN_R_I_S_STATUS_2);
20381    
20382                            String sql = query.toString();
20383    
20384                            Session session = null;
20385    
20386                            try {
20387                                    session = openSession();
20388    
20389                                    Query q = session.createQuery(sql);
20390    
20391                                    QueryPos qPos = QueryPos.getInstance(q);
20392    
20393                                    qPos.add(resourcePrimKey);
20394    
20395                                    qPos.add(indexable);
20396    
20397                                    qPos.add(status);
20398    
20399                                    count = (Long)q.uniqueResult();
20400    
20401                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
20402                            }
20403                            catch (Exception e) {
20404                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
20405    
20406                                    throw processException(e);
20407                            }
20408                            finally {
20409                                    closeSession(session);
20410                            }
20411                    }
20412    
20413                    return count.intValue();
20414            }
20415    
20416            /**
20417             * Returns the number of journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
20418             *
20419             * @param resourcePrimKey the resource prim key
20420             * @param indexable the indexable
20421             * @param statuses the statuses
20422             * @return the number of matching journal articles
20423             * @throws SystemException if a system exception occurred
20424             */
20425            @Override
20426            public int countByR_I_S(long resourcePrimKey, boolean indexable,
20427                    int[] statuses) throws SystemException {
20428                    Object[] finderArgs = new Object[] {
20429                                    resourcePrimKey, indexable, StringUtil.merge(statuses)
20430                            };
20431    
20432                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S,
20433                                    finderArgs, this);
20434    
20435                    if (count == null) {
20436                            StringBundler query = new StringBundler();
20437    
20438                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
20439    
20440                            boolean conjunctionable = false;
20441    
20442                            if (conjunctionable) {
20443                                    query.append(WHERE_AND);
20444                            }
20445    
20446                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_5);
20447    
20448                            conjunctionable = true;
20449    
20450                            if (conjunctionable) {
20451                                    query.append(WHERE_AND);
20452                            }
20453    
20454                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_5);
20455    
20456                            conjunctionable = true;
20457    
20458                            if ((statuses == null) || (statuses.length > 0)) {
20459                                    if (conjunctionable) {
20460                                            query.append(WHERE_AND);
20461                                    }
20462    
20463                                    query.append(StringPool.OPEN_PARENTHESIS);
20464    
20465                                    for (int i = 0; i < statuses.length; i++) {
20466                                            query.append(_FINDER_COLUMN_R_I_S_STATUS_5);
20467    
20468                                            if ((i + 1) < statuses.length) {
20469                                                    query.append(WHERE_OR);
20470                                            }
20471                                    }
20472    
20473                                    query.append(StringPool.CLOSE_PARENTHESIS);
20474    
20475                                    conjunctionable = true;
20476                            }
20477    
20478                            String sql = query.toString();
20479    
20480                            Session session = null;
20481    
20482                            try {
20483                                    session = openSession();
20484    
20485                                    Query q = session.createQuery(sql);
20486    
20487                                    QueryPos qPos = QueryPos.getInstance(q);
20488    
20489                                    qPos.add(resourcePrimKey);
20490    
20491                                    qPos.add(indexable);
20492    
20493                                    if (statuses != null) {
20494                                            qPos.add(statuses);
20495                                    }
20496    
20497                                    count = (Long)q.uniqueResult();
20498    
20499                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S,
20500                                            finderArgs, count);
20501                            }
20502                            catch (Exception e) {
20503                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S,
20504                                            finderArgs);
20505    
20506                                    throw processException(e);
20507                            }
20508                            finally {
20509                                    closeSession(session);
20510                            }
20511                    }
20512    
20513                    return count.intValue();
20514            }
20515    
20516            private static final String _FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
20517            private static final String _FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_5 = "(" +
20518                    removeConjunction(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2) + ")";
20519            private static final String _FINDER_COLUMN_R_I_S_INDEXABLE_2 = "journalArticle.indexable = ? AND ";
20520            private static final String _FINDER_COLUMN_R_I_S_INDEXABLE_5 = "(" +
20521                    removeConjunction(_FINDER_COLUMN_R_I_S_INDEXABLE_2) + ")";
20522            private static final String _FINDER_COLUMN_R_I_S_STATUS_2 = "journalArticle.status = ?";
20523            private static final String _FINDER_COLUMN_R_I_S_STATUS_5 = "(" +
20524                    removeConjunction(_FINDER_COLUMN_R_I_S_STATUS_2) + ")";
20525            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20526                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
20527                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
20528                            "findByG_U_C",
20529                            new String[] {
20530                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
20531                                    
20532                            Integer.class.getName(), Integer.class.getName(),
20533                                    OrderByComparator.class.getName()
20534                            });
20535            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20536                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
20537                            JournalArticleImpl.class,
20538                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_C",
20539                            new String[] {
20540                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
20541                            },
20542                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
20543                            JournalArticleModelImpl.USERID_COLUMN_BITMASK |
20544                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
20545                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
20546                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
20547            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20548                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
20549                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_C",
20550                            new String[] {
20551                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
20552                            });
20553    
20554            /**
20555             * Returns all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
20556             *
20557             * @param groupId the group ID
20558             * @param userId the user ID
20559             * @param classNameId the class name ID
20560             * @return the matching journal articles
20561             * @throws SystemException if a system exception occurred
20562             */
20563            @Override
20564            public List<JournalArticle> findByG_U_C(long groupId, long userId,
20565                    long classNameId) throws SystemException {
20566                    return findByG_U_C(groupId, userId, classNameId, QueryUtil.ALL_POS,
20567                            QueryUtil.ALL_POS, null);
20568            }
20569    
20570            /**
20571             * Returns a range of all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
20572             *
20573             * <p>
20574             * 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.
20575             * </p>
20576             *
20577             * @param groupId the group ID
20578             * @param userId the user ID
20579             * @param classNameId the class name ID
20580             * @param start the lower bound of the range of journal articles
20581             * @param end the upper bound of the range of journal articles (not inclusive)
20582             * @return the range of matching journal articles
20583             * @throws SystemException if a system exception occurred
20584             */
20585            @Override
20586            public List<JournalArticle> findByG_U_C(long groupId, long userId,
20587                    long classNameId, int start, int end) throws SystemException {
20588                    return findByG_U_C(groupId, userId, classNameId, start, end, null);
20589            }
20590    
20591            /**
20592             * Returns an ordered range of all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
20593             *
20594             * <p>
20595             * 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.
20596             * </p>
20597             *
20598             * @param groupId the group ID
20599             * @param userId the user ID
20600             * @param classNameId the class name ID
20601             * @param start the lower bound of the range of journal articles
20602             * @param end the upper bound of the range of journal articles (not inclusive)
20603             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
20604             * @return the ordered range of matching journal articles
20605             * @throws SystemException if a system exception occurred
20606             */
20607            @Override
20608            public List<JournalArticle> findByG_U_C(long groupId, long userId,
20609                    long classNameId, int start, int end,
20610                    OrderByComparator orderByComparator) throws SystemException {
20611                    boolean pagination = true;
20612                    FinderPath finderPath = null;
20613                    Object[] finderArgs = null;
20614    
20615                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
20616                                    (orderByComparator == null)) {
20617                            pagination = false;
20618                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C;
20619                            finderArgs = new Object[] { groupId, userId, classNameId };
20620                    }
20621                    else {
20622                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_C;
20623                            finderArgs = new Object[] {
20624                                            groupId, userId, classNameId,
20625                                            
20626                                            start, end, orderByComparator
20627                                    };
20628                    }
20629    
20630                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
20631                                    finderArgs, this);
20632    
20633                    if ((list != null) && !list.isEmpty()) {
20634                            for (JournalArticle journalArticle : list) {
20635                                    if ((groupId != journalArticle.getGroupId()) ||
20636                                                    (userId != journalArticle.getUserId()) ||
20637                                                    (classNameId != journalArticle.getClassNameId())) {
20638                                            list = null;
20639    
20640                                            break;
20641                                    }
20642                            }
20643                    }
20644    
20645                    if (list == null) {
20646                            StringBundler query = null;
20647    
20648                            if (orderByComparator != null) {
20649                                    query = new StringBundler(5 +
20650                                                    (orderByComparator.getOrderByFields().length * 3));
20651                            }
20652                            else {
20653                                    query = new StringBundler(5);
20654                            }
20655    
20656                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
20657    
20658                            query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
20659    
20660                            query.append(_FINDER_COLUMN_G_U_C_USERID_2);
20661    
20662                            query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
20663    
20664                            if (orderByComparator != null) {
20665                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
20666                                            orderByComparator);
20667                            }
20668                            else
20669                             if (pagination) {
20670                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20671                            }
20672    
20673                            String sql = query.toString();
20674    
20675                            Session session = null;
20676    
20677                            try {
20678                                    session = openSession();
20679    
20680                                    Query q = session.createQuery(sql);
20681    
20682                                    QueryPos qPos = QueryPos.getInstance(q);
20683    
20684                                    qPos.add(groupId);
20685    
20686                                    qPos.add(userId);
20687    
20688                                    qPos.add(classNameId);
20689    
20690                                    if (!pagination) {
20691                                            list = (List<JournalArticle>)QueryUtil.list(q,
20692                                                            getDialect(), start, end, false);
20693    
20694                                            Collections.sort(list);
20695    
20696                                            list = new UnmodifiableList<JournalArticle>(list);
20697                                    }
20698                                    else {
20699                                            list = (List<JournalArticle>)QueryUtil.list(q,
20700                                                            getDialect(), start, end);
20701                                    }
20702    
20703                                    cacheResult(list);
20704    
20705                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
20706                            }
20707                            catch (Exception e) {
20708                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
20709    
20710                                    throw processException(e);
20711                            }
20712                            finally {
20713                                    closeSession(session);
20714                            }
20715                    }
20716    
20717                    return list;
20718            }
20719    
20720            /**
20721             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
20722             *
20723             * @param groupId the group ID
20724             * @param userId the user ID
20725             * @param classNameId the class name ID
20726             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20727             * @return the first matching journal article
20728             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
20729             * @throws SystemException if a system exception occurred
20730             */
20731            @Override
20732            public JournalArticle findByG_U_C_First(long groupId, long userId,
20733                    long classNameId, OrderByComparator orderByComparator)
20734                    throws NoSuchArticleException, SystemException {
20735                    JournalArticle journalArticle = fetchByG_U_C_First(groupId, userId,
20736                                    classNameId, orderByComparator);
20737    
20738                    if (journalArticle != null) {
20739                            return journalArticle;
20740                    }
20741    
20742                    StringBundler msg = new StringBundler(8);
20743    
20744                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
20745    
20746                    msg.append("groupId=");
20747                    msg.append(groupId);
20748    
20749                    msg.append(", userId=");
20750                    msg.append(userId);
20751    
20752                    msg.append(", classNameId=");
20753                    msg.append(classNameId);
20754    
20755                    msg.append(StringPool.CLOSE_CURLY_BRACE);
20756    
20757                    throw new NoSuchArticleException(msg.toString());
20758            }
20759    
20760            /**
20761             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
20762             *
20763             * @param groupId the group ID
20764             * @param userId the user ID
20765             * @param classNameId the class name ID
20766             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20767             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
20768             * @throws SystemException if a system exception occurred
20769             */
20770            @Override
20771            public JournalArticle fetchByG_U_C_First(long groupId, long userId,
20772                    long classNameId, OrderByComparator orderByComparator)
20773                    throws SystemException {
20774                    List<JournalArticle> list = findByG_U_C(groupId, userId, classNameId,
20775                                    0, 1, orderByComparator);
20776    
20777                    if (!list.isEmpty()) {
20778                            return list.get(0);
20779                    }
20780    
20781                    return null;
20782            }
20783    
20784            /**
20785             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
20786             *
20787             * @param groupId the group ID
20788             * @param userId the user ID
20789             * @param classNameId the class name ID
20790             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20791             * @return the last matching journal article
20792             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
20793             * @throws SystemException if a system exception occurred
20794             */
20795            @Override
20796            public JournalArticle findByG_U_C_Last(long groupId, long userId,
20797                    long classNameId, OrderByComparator orderByComparator)
20798                    throws NoSuchArticleException, SystemException {
20799                    JournalArticle journalArticle = fetchByG_U_C_Last(groupId, userId,
20800                                    classNameId, orderByComparator);
20801    
20802                    if (journalArticle != null) {
20803                            return journalArticle;
20804                    }
20805    
20806                    StringBundler msg = new StringBundler(8);
20807    
20808                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
20809    
20810                    msg.append("groupId=");
20811                    msg.append(groupId);
20812    
20813                    msg.append(", userId=");
20814                    msg.append(userId);
20815    
20816                    msg.append(", classNameId=");
20817                    msg.append(classNameId);
20818    
20819                    msg.append(StringPool.CLOSE_CURLY_BRACE);
20820    
20821                    throw new NoSuchArticleException(msg.toString());
20822            }
20823    
20824            /**
20825             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
20826             *
20827             * @param groupId the group ID
20828             * @param userId the user ID
20829             * @param classNameId the class name ID
20830             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20831             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
20832             * @throws SystemException if a system exception occurred
20833             */
20834            @Override
20835            public JournalArticle fetchByG_U_C_Last(long groupId, long userId,
20836                    long classNameId, OrderByComparator orderByComparator)
20837                    throws SystemException {
20838                    int count = countByG_U_C(groupId, userId, classNameId);
20839    
20840                    if (count == 0) {
20841                            return null;
20842                    }
20843    
20844                    List<JournalArticle> list = findByG_U_C(groupId, userId, classNameId,
20845                                    count - 1, count, orderByComparator);
20846    
20847                    if (!list.isEmpty()) {
20848                            return list.get(0);
20849                    }
20850    
20851                    return null;
20852            }
20853    
20854            /**
20855             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
20856             *
20857             * @param id the primary key of the current journal article
20858             * @param groupId the group ID
20859             * @param userId the user ID
20860             * @param classNameId the class name ID
20861             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20862             * @return the previous, current, and next journal article
20863             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
20864             * @throws SystemException if a system exception occurred
20865             */
20866            @Override
20867            public JournalArticle[] findByG_U_C_PrevAndNext(long id, long groupId,
20868                    long userId, long classNameId, OrderByComparator orderByComparator)
20869                    throws NoSuchArticleException, SystemException {
20870                    JournalArticle journalArticle = findByPrimaryKey(id);
20871    
20872                    Session session = null;
20873    
20874                    try {
20875                            session = openSession();
20876    
20877                            JournalArticle[] array = new JournalArticleImpl[3];
20878    
20879                            array[0] = getByG_U_C_PrevAndNext(session, journalArticle, groupId,
20880                                            userId, classNameId, orderByComparator, true);
20881    
20882                            array[1] = journalArticle;
20883    
20884                            array[2] = getByG_U_C_PrevAndNext(session, journalArticle, groupId,
20885                                            userId, classNameId, orderByComparator, false);
20886    
20887                            return array;
20888                    }
20889                    catch (Exception e) {
20890                            throw processException(e);
20891                    }
20892                    finally {
20893                            closeSession(session);
20894                    }
20895            }
20896    
20897            protected JournalArticle getByG_U_C_PrevAndNext(Session session,
20898                    JournalArticle journalArticle, long groupId, long userId,
20899                    long classNameId, OrderByComparator orderByComparator, boolean previous) {
20900                    StringBundler query = null;
20901    
20902                    if (orderByComparator != null) {
20903                            query = new StringBundler(6 +
20904                                            (orderByComparator.getOrderByFields().length * 6));
20905                    }
20906                    else {
20907                            query = new StringBundler(3);
20908                    }
20909    
20910                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
20911    
20912                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
20913    
20914                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
20915    
20916                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
20917    
20918                    if (orderByComparator != null) {
20919                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
20920    
20921                            if (orderByConditionFields.length > 0) {
20922                                    query.append(WHERE_AND);
20923                            }
20924    
20925                            for (int i = 0; i < orderByConditionFields.length; i++) {
20926                                    query.append(_ORDER_BY_ENTITY_ALIAS);
20927                                    query.append(orderByConditionFields[i]);
20928    
20929                                    if ((i + 1) < orderByConditionFields.length) {
20930                                            if (orderByComparator.isAscending() ^ previous) {
20931                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
20932                                            }
20933                                            else {
20934                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
20935                                            }
20936                                    }
20937                                    else {
20938                                            if (orderByComparator.isAscending() ^ previous) {
20939                                                    query.append(WHERE_GREATER_THAN);
20940                                            }
20941                                            else {
20942                                                    query.append(WHERE_LESSER_THAN);
20943                                            }
20944                                    }
20945                            }
20946    
20947                            query.append(ORDER_BY_CLAUSE);
20948    
20949                            String[] orderByFields = orderByComparator.getOrderByFields();
20950    
20951                            for (int i = 0; i < orderByFields.length; i++) {
20952                                    query.append(_ORDER_BY_ENTITY_ALIAS);
20953                                    query.append(orderByFields[i]);
20954    
20955                                    if ((i + 1) < orderByFields.length) {
20956                                            if (orderByComparator.isAscending() ^ previous) {
20957                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
20958                                            }
20959                                            else {
20960                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
20961                                            }
20962                                    }
20963                                    else {
20964                                            if (orderByComparator.isAscending() ^ previous) {
20965                                                    query.append(ORDER_BY_ASC);
20966                                            }
20967                                            else {
20968                                                    query.append(ORDER_BY_DESC);
20969                                            }
20970                                    }
20971                            }
20972                    }
20973                    else {
20974                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20975                    }
20976    
20977                    String sql = query.toString();
20978    
20979                    Query q = session.createQuery(sql);
20980    
20981                    q.setFirstResult(0);
20982                    q.setMaxResults(2);
20983    
20984                    QueryPos qPos = QueryPos.getInstance(q);
20985    
20986                    qPos.add(groupId);
20987    
20988                    qPos.add(userId);
20989    
20990                    qPos.add(classNameId);
20991    
20992                    if (orderByComparator != null) {
20993                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
20994    
20995                            for (Object value : values) {
20996                                    qPos.add(value);
20997                            }
20998                    }
20999    
21000                    List<JournalArticle> list = q.list();
21001    
21002                    if (list.size() == 2) {
21003                            return list.get(1);
21004                    }
21005                    else {
21006                            return null;
21007                    }
21008            }
21009    
21010            /**
21011             * Returns all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
21012             *
21013             * @param groupId the group ID
21014             * @param userId the user ID
21015             * @param classNameId the class name ID
21016             * @return the matching journal articles that the user has permission to view
21017             * @throws SystemException if a system exception occurred
21018             */
21019            @Override
21020            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
21021                    long classNameId) throws SystemException {
21022                    return filterFindByG_U_C(groupId, userId, classNameId,
21023                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
21024            }
21025    
21026            /**
21027             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
21028             *
21029             * <p>
21030             * 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.
21031             * </p>
21032             *
21033             * @param groupId the group ID
21034             * @param userId the user ID
21035             * @param classNameId the class name ID
21036             * @param start the lower bound of the range of journal articles
21037             * @param end the upper bound of the range of journal articles (not inclusive)
21038             * @return the range of matching journal articles that the user has permission to view
21039             * @throws SystemException if a system exception occurred
21040             */
21041            @Override
21042            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
21043                    long classNameId, int start, int end) throws SystemException {
21044                    return filterFindByG_U_C(groupId, userId, classNameId, start, end, null);
21045            }
21046    
21047            /**
21048             * 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;.
21049             *
21050             * <p>
21051             * 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.
21052             * </p>
21053             *
21054             * @param groupId the group ID
21055             * @param userId the user ID
21056             * @param classNameId the class name ID
21057             * @param start the lower bound of the range of journal articles
21058             * @param end the upper bound of the range of journal articles (not inclusive)
21059             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
21060             * @return the ordered range of matching journal articles that the user has permission to view
21061             * @throws SystemException if a system exception occurred
21062             */
21063            @Override
21064            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
21065                    long classNameId, int start, int end,
21066                    OrderByComparator orderByComparator) throws SystemException {
21067                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21068                            return findByG_U_C(groupId, userId, classNameId, start, end,
21069                                    orderByComparator);
21070                    }
21071    
21072                    StringBundler query = null;
21073    
21074                    if (orderByComparator != null) {
21075                            query = new StringBundler(5 +
21076                                            (orderByComparator.getOrderByFields().length * 3));
21077                    }
21078                    else {
21079                            query = new StringBundler(5);
21080                    }
21081    
21082                    if (getDB().isSupportsInlineDistinct()) {
21083                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
21084                    }
21085                    else {
21086                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
21087                    }
21088    
21089                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
21090    
21091                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
21092    
21093                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
21094    
21095                    if (!getDB().isSupportsInlineDistinct()) {
21096                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
21097                    }
21098    
21099                    if (orderByComparator != null) {
21100                            if (getDB().isSupportsInlineDistinct()) {
21101                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
21102                                            orderByComparator, true);
21103                            }
21104                            else {
21105                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
21106                                            orderByComparator, true);
21107                            }
21108                    }
21109                    else {
21110                            if (getDB().isSupportsInlineDistinct()) {
21111                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21112                            }
21113                            else {
21114                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
21115                            }
21116                    }
21117    
21118                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21119                                    JournalArticle.class.getName(),
21120                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21121    
21122                    Session session = null;
21123    
21124                    try {
21125                            session = openSession();
21126    
21127                            SQLQuery q = session.createSQLQuery(sql);
21128    
21129                            if (getDB().isSupportsInlineDistinct()) {
21130                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
21131                            }
21132                            else {
21133                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
21134                            }
21135    
21136                            QueryPos qPos = QueryPos.getInstance(q);
21137    
21138                            qPos.add(groupId);
21139    
21140                            qPos.add(userId);
21141    
21142                            qPos.add(classNameId);
21143    
21144                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
21145                                    end);
21146                    }
21147                    catch (Exception e) {
21148                            throw processException(e);
21149                    }
21150                    finally {
21151                            closeSession(session);
21152                    }
21153            }
21154    
21155            /**
21156             * 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;.
21157             *
21158             * @param id the primary key of the current journal article
21159             * @param groupId the group ID
21160             * @param userId the user ID
21161             * @param classNameId the class name ID
21162             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21163             * @return the previous, current, and next journal article
21164             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
21165             * @throws SystemException if a system exception occurred
21166             */
21167            @Override
21168            public JournalArticle[] filterFindByG_U_C_PrevAndNext(long id,
21169                    long groupId, long userId, long classNameId,
21170                    OrderByComparator orderByComparator)
21171                    throws NoSuchArticleException, SystemException {
21172                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21173                            return findByG_U_C_PrevAndNext(id, groupId, userId, classNameId,
21174                                    orderByComparator);
21175                    }
21176    
21177                    JournalArticle journalArticle = findByPrimaryKey(id);
21178    
21179                    Session session = null;
21180    
21181                    try {
21182                            session = openSession();
21183    
21184                            JournalArticle[] array = new JournalArticleImpl[3];
21185    
21186                            array[0] = filterGetByG_U_C_PrevAndNext(session, journalArticle,
21187                                            groupId, userId, classNameId, orderByComparator, true);
21188    
21189                            array[1] = journalArticle;
21190    
21191                            array[2] = filterGetByG_U_C_PrevAndNext(session, journalArticle,
21192                                            groupId, userId, classNameId, orderByComparator, false);
21193    
21194                            return array;
21195                    }
21196                    catch (Exception e) {
21197                            throw processException(e);
21198                    }
21199                    finally {
21200                            closeSession(session);
21201                    }
21202            }
21203    
21204            protected JournalArticle filterGetByG_U_C_PrevAndNext(Session session,
21205                    JournalArticle journalArticle, long groupId, long userId,
21206                    long classNameId, OrderByComparator orderByComparator, boolean previous) {
21207                    StringBundler query = null;
21208    
21209                    if (orderByComparator != null) {
21210                            query = new StringBundler(6 +
21211                                            (orderByComparator.getOrderByFields().length * 6));
21212                    }
21213                    else {
21214                            query = new StringBundler(3);
21215                    }
21216    
21217                    if (getDB().isSupportsInlineDistinct()) {
21218                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
21219                    }
21220                    else {
21221                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
21222                    }
21223    
21224                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
21225    
21226                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
21227    
21228                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
21229    
21230                    if (!getDB().isSupportsInlineDistinct()) {
21231                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
21232                    }
21233    
21234                    if (orderByComparator != null) {
21235                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
21236    
21237                            if (orderByConditionFields.length > 0) {
21238                                    query.append(WHERE_AND);
21239                            }
21240    
21241                            for (int i = 0; i < orderByConditionFields.length; i++) {
21242                                    if (getDB().isSupportsInlineDistinct()) {
21243                                            query.append(_ORDER_BY_ENTITY_ALIAS);
21244                                    }
21245                                    else {
21246                                            query.append(_ORDER_BY_ENTITY_TABLE);
21247                                    }
21248    
21249                                    query.append(orderByConditionFields[i]);
21250    
21251                                    if ((i + 1) < orderByConditionFields.length) {
21252                                            if (orderByComparator.isAscending() ^ previous) {
21253                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
21254                                            }
21255                                            else {
21256                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
21257                                            }
21258                                    }
21259                                    else {
21260                                            if (orderByComparator.isAscending() ^ previous) {
21261                                                    query.append(WHERE_GREATER_THAN);
21262                                            }
21263                                            else {
21264                                                    query.append(WHERE_LESSER_THAN);
21265                                            }
21266                                    }
21267                            }
21268    
21269                            query.append(ORDER_BY_CLAUSE);
21270    
21271                            String[] orderByFields = orderByComparator.getOrderByFields();
21272    
21273                            for (int i = 0; i < orderByFields.length; i++) {
21274                                    if (getDB().isSupportsInlineDistinct()) {
21275                                            query.append(_ORDER_BY_ENTITY_ALIAS);
21276                                    }
21277                                    else {
21278                                            query.append(_ORDER_BY_ENTITY_TABLE);
21279                                    }
21280    
21281                                    query.append(orderByFields[i]);
21282    
21283                                    if ((i + 1) < orderByFields.length) {
21284                                            if (orderByComparator.isAscending() ^ previous) {
21285                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
21286                                            }
21287                                            else {
21288                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
21289                                            }
21290                                    }
21291                                    else {
21292                                            if (orderByComparator.isAscending() ^ previous) {
21293                                                    query.append(ORDER_BY_ASC);
21294                                            }
21295                                            else {
21296                                                    query.append(ORDER_BY_DESC);
21297                                            }
21298                                    }
21299                            }
21300                    }
21301                    else {
21302                            if (getDB().isSupportsInlineDistinct()) {
21303                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21304                            }
21305                            else {
21306                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
21307                            }
21308                    }
21309    
21310                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21311                                    JournalArticle.class.getName(),
21312                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21313    
21314                    SQLQuery q = session.createSQLQuery(sql);
21315    
21316                    q.setFirstResult(0);
21317                    q.setMaxResults(2);
21318    
21319                    if (getDB().isSupportsInlineDistinct()) {
21320                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
21321                    }
21322                    else {
21323                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
21324                    }
21325    
21326                    QueryPos qPos = QueryPos.getInstance(q);
21327    
21328                    qPos.add(groupId);
21329    
21330                    qPos.add(userId);
21331    
21332                    qPos.add(classNameId);
21333    
21334                    if (orderByComparator != null) {
21335                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
21336    
21337                            for (Object value : values) {
21338                                    qPos.add(value);
21339                            }
21340                    }
21341    
21342                    List<JournalArticle> list = q.list();
21343    
21344                    if (list.size() == 2) {
21345                            return list.get(1);
21346                    }
21347                    else {
21348                            return null;
21349                    }
21350            }
21351    
21352            /**
21353             * Removes all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63; from the database.
21354             *
21355             * @param groupId the group ID
21356             * @param userId the user ID
21357             * @param classNameId the class name ID
21358             * @throws SystemException if a system exception occurred
21359             */
21360            @Override
21361            public void removeByG_U_C(long groupId, long userId, long classNameId)
21362                    throws SystemException {
21363                    for (JournalArticle journalArticle : findByG_U_C(groupId, userId,
21364                                    classNameId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
21365                            remove(journalArticle);
21366                    }
21367            }
21368    
21369            /**
21370             * Returns the number of journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
21371             *
21372             * @param groupId the group ID
21373             * @param userId the user ID
21374             * @param classNameId the class name ID
21375             * @return the number of matching journal articles
21376             * @throws SystemException if a system exception occurred
21377             */
21378            @Override
21379            public int countByG_U_C(long groupId, long userId, long classNameId)
21380                    throws SystemException {
21381                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_C;
21382    
21383                    Object[] finderArgs = new Object[] { groupId, userId, classNameId };
21384    
21385                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
21386                                    this);
21387    
21388                    if (count == null) {
21389                            StringBundler query = new StringBundler(4);
21390    
21391                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
21392    
21393                            query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
21394    
21395                            query.append(_FINDER_COLUMN_G_U_C_USERID_2);
21396    
21397                            query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
21398    
21399                            String sql = query.toString();
21400    
21401                            Session session = null;
21402    
21403                            try {
21404                                    session = openSession();
21405    
21406                                    Query q = session.createQuery(sql);
21407    
21408                                    QueryPos qPos = QueryPos.getInstance(q);
21409    
21410                                    qPos.add(groupId);
21411    
21412                                    qPos.add(userId);
21413    
21414                                    qPos.add(classNameId);
21415    
21416                                    count = (Long)q.uniqueResult();
21417    
21418                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
21419                            }
21420                            catch (Exception e) {
21421                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
21422    
21423                                    throw processException(e);
21424                            }
21425                            finally {
21426                                    closeSession(session);
21427                            }
21428                    }
21429    
21430                    return count.intValue();
21431            }
21432    
21433            /**
21434             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
21435             *
21436             * @param groupId the group ID
21437             * @param userId the user ID
21438             * @param classNameId the class name ID
21439             * @return the number of matching journal articles that the user has permission to view
21440             * @throws SystemException if a system exception occurred
21441             */
21442            @Override
21443            public int filterCountByG_U_C(long groupId, long userId, long classNameId)
21444                    throws SystemException {
21445                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21446                            return countByG_U_C(groupId, userId, classNameId);
21447                    }
21448    
21449                    StringBundler query = new StringBundler(4);
21450    
21451                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
21452    
21453                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
21454    
21455                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
21456    
21457                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
21458    
21459                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21460                                    JournalArticle.class.getName(),
21461                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21462    
21463                    Session session = null;
21464    
21465                    try {
21466                            session = openSession();
21467    
21468                            SQLQuery q = session.createSQLQuery(sql);
21469    
21470                            q.addScalar(COUNT_COLUMN_NAME,
21471                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
21472    
21473                            QueryPos qPos = QueryPos.getInstance(q);
21474    
21475                            qPos.add(groupId);
21476    
21477                            qPos.add(userId);
21478    
21479                            qPos.add(classNameId);
21480    
21481                            Long count = (Long)q.uniqueResult();
21482    
21483                            return count.intValue();
21484                    }
21485                    catch (Exception e) {
21486                            throw processException(e);
21487                    }
21488                    finally {
21489                            closeSession(session);
21490                    }
21491            }
21492    
21493            private static final String _FINDER_COLUMN_G_U_C_GROUPID_2 = "journalArticle.groupId = ? AND ";
21494            private static final String _FINDER_COLUMN_G_U_C_USERID_2 = "journalArticle.userId = ? AND ";
21495            private static final String _FINDER_COLUMN_G_U_C_CLASSNAMEID_2 = "journalArticle.classNameId = ?";
21496            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21497                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
21498                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
21499                            "findByG_F_ST",
21500                            new String[] {
21501                                    Long.class.getName(), Long.class.getName(),
21502                                    Integer.class.getName(),
21503                                    
21504                            Integer.class.getName(), Integer.class.getName(),
21505                                    OrderByComparator.class.getName()
21506                            });
21507            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST =
21508                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21509                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
21510                            JournalArticleImpl.class,
21511                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F_ST",
21512                            new String[] {
21513                                    Long.class.getName(), Long.class.getName(),
21514                                    Integer.class.getName()
21515                            },
21516                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
21517                            JournalArticleModelImpl.FOLDERID_COLUMN_BITMASK |
21518                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
21519                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
21520                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
21521            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21522                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
21523                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_ST",
21524                            new String[] {
21525                                    Long.class.getName(), Long.class.getName(),
21526                                    Integer.class.getName()
21527                            });
21528            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21529                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
21530                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F_ST",
21531                            new String[] {
21532                                    Long.class.getName(), Long.class.getName(),
21533                                    Integer.class.getName()
21534                            });
21535    
21536            /**
21537             * Returns all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
21538             *
21539             * @param groupId the group ID
21540             * @param folderId the folder ID
21541             * @param status the status
21542             * @return the matching journal articles
21543             * @throws SystemException if a system exception occurred
21544             */
21545            @Override
21546            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
21547                    int status) throws SystemException {
21548                    return findByG_F_ST(groupId, folderId, status, QueryUtil.ALL_POS,
21549                            QueryUtil.ALL_POS, null);
21550            }
21551    
21552            /**
21553             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
21554             *
21555             * <p>
21556             * 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.
21557             * </p>
21558             *
21559             * @param groupId the group ID
21560             * @param folderId the folder ID
21561             * @param status the status
21562             * @param start the lower bound of the range of journal articles
21563             * @param end the upper bound of the range of journal articles (not inclusive)
21564             * @return the range of matching journal articles
21565             * @throws SystemException if a system exception occurred
21566             */
21567            @Override
21568            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
21569                    int status, int start, int end) throws SystemException {
21570                    return findByG_F_ST(groupId, folderId, status, start, end, null);
21571            }
21572    
21573            /**
21574             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
21575             *
21576             * <p>
21577             * 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.
21578             * </p>
21579             *
21580             * @param groupId the group ID
21581             * @param folderId the folder ID
21582             * @param status the status
21583             * @param start the lower bound of the range of journal articles
21584             * @param end the upper bound of the range of journal articles (not inclusive)
21585             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
21586             * @return the ordered range of matching journal articles
21587             * @throws SystemException if a system exception occurred
21588             */
21589            @Override
21590            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
21591                    int status, int start, int end, OrderByComparator orderByComparator)
21592                    throws SystemException {
21593                    boolean pagination = true;
21594                    FinderPath finderPath = null;
21595                    Object[] finderArgs = null;
21596    
21597                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
21598                                    (orderByComparator == null)) {
21599                            pagination = false;
21600                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST;
21601                            finderArgs = new Object[] { groupId, folderId, status };
21602                    }
21603                    else {
21604                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST;
21605                            finderArgs = new Object[] {
21606                                            groupId, folderId, status,
21607                                            
21608                                            start, end, orderByComparator
21609                                    };
21610                    }
21611    
21612                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
21613                                    finderArgs, this);
21614    
21615                    if ((list != null) && !list.isEmpty()) {
21616                            for (JournalArticle journalArticle : list) {
21617                                    if ((groupId != journalArticle.getGroupId()) ||
21618                                                    (folderId != journalArticle.getFolderId()) ||
21619                                                    (status != journalArticle.getStatus())) {
21620                                            list = null;
21621    
21622                                            break;
21623                                    }
21624                            }
21625                    }
21626    
21627                    if (list == null) {
21628                            StringBundler query = null;
21629    
21630                            if (orderByComparator != null) {
21631                                    query = new StringBundler(5 +
21632                                                    (orderByComparator.getOrderByFields().length * 3));
21633                            }
21634                            else {
21635                                    query = new StringBundler(5);
21636                            }
21637    
21638                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
21639    
21640                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
21641    
21642                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
21643    
21644                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
21645    
21646                            if (orderByComparator != null) {
21647                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
21648                                            orderByComparator);
21649                            }
21650                            else
21651                             if (pagination) {
21652                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21653                            }
21654    
21655                            String sql = query.toString();
21656    
21657                            Session session = null;
21658    
21659                            try {
21660                                    session = openSession();
21661    
21662                                    Query q = session.createQuery(sql);
21663    
21664                                    QueryPos qPos = QueryPos.getInstance(q);
21665    
21666                                    qPos.add(groupId);
21667    
21668                                    qPos.add(folderId);
21669    
21670                                    qPos.add(status);
21671    
21672                                    if (!pagination) {
21673                                            list = (List<JournalArticle>)QueryUtil.list(q,
21674                                                            getDialect(), start, end, false);
21675    
21676                                            Collections.sort(list);
21677    
21678                                            list = new UnmodifiableList<JournalArticle>(list);
21679                                    }
21680                                    else {
21681                                            list = (List<JournalArticle>)QueryUtil.list(q,
21682                                                            getDialect(), start, end);
21683                                    }
21684    
21685                                    cacheResult(list);
21686    
21687                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
21688                            }
21689                            catch (Exception e) {
21690                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
21691    
21692                                    throw processException(e);
21693                            }
21694                            finally {
21695                                    closeSession(session);
21696                            }
21697                    }
21698    
21699                    return list;
21700            }
21701    
21702            /**
21703             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
21704             *
21705             * @param groupId the group ID
21706             * @param folderId the folder ID
21707             * @param status the status
21708             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21709             * @return the first matching journal article
21710             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
21711             * @throws SystemException if a system exception occurred
21712             */
21713            @Override
21714            public JournalArticle findByG_F_ST_First(long groupId, long folderId,
21715                    int status, OrderByComparator orderByComparator)
21716                    throws NoSuchArticleException, SystemException {
21717                    JournalArticle journalArticle = fetchByG_F_ST_First(groupId, folderId,
21718                                    status, orderByComparator);
21719    
21720                    if (journalArticle != null) {
21721                            return journalArticle;
21722                    }
21723    
21724                    StringBundler msg = new StringBundler(8);
21725    
21726                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
21727    
21728                    msg.append("groupId=");
21729                    msg.append(groupId);
21730    
21731                    msg.append(", folderId=");
21732                    msg.append(folderId);
21733    
21734                    msg.append(", status=");
21735                    msg.append(status);
21736    
21737                    msg.append(StringPool.CLOSE_CURLY_BRACE);
21738    
21739                    throw new NoSuchArticleException(msg.toString());
21740            }
21741    
21742            /**
21743             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
21744             *
21745             * @param groupId the group ID
21746             * @param folderId the folder ID
21747             * @param status the status
21748             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21749             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
21750             * @throws SystemException if a system exception occurred
21751             */
21752            @Override
21753            public JournalArticle fetchByG_F_ST_First(long groupId, long folderId,
21754                    int status, OrderByComparator orderByComparator)
21755                    throws SystemException {
21756                    List<JournalArticle> list = findByG_F_ST(groupId, folderId, status, 0,
21757                                    1, orderByComparator);
21758    
21759                    if (!list.isEmpty()) {
21760                            return list.get(0);
21761                    }
21762    
21763                    return null;
21764            }
21765    
21766            /**
21767             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
21768             *
21769             * @param groupId the group ID
21770             * @param folderId the folder ID
21771             * @param status the status
21772             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21773             * @return the last matching journal article
21774             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
21775             * @throws SystemException if a system exception occurred
21776             */
21777            @Override
21778            public JournalArticle findByG_F_ST_Last(long groupId, long folderId,
21779                    int status, OrderByComparator orderByComparator)
21780                    throws NoSuchArticleException, SystemException {
21781                    JournalArticle journalArticle = fetchByG_F_ST_Last(groupId, folderId,
21782                                    status, orderByComparator);
21783    
21784                    if (journalArticle != null) {
21785                            return journalArticle;
21786                    }
21787    
21788                    StringBundler msg = new StringBundler(8);
21789    
21790                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
21791    
21792                    msg.append("groupId=");
21793                    msg.append(groupId);
21794    
21795                    msg.append(", folderId=");
21796                    msg.append(folderId);
21797    
21798                    msg.append(", status=");
21799                    msg.append(status);
21800    
21801                    msg.append(StringPool.CLOSE_CURLY_BRACE);
21802    
21803                    throw new NoSuchArticleException(msg.toString());
21804            }
21805    
21806            /**
21807             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
21808             *
21809             * @param groupId the group ID
21810             * @param folderId the folder ID
21811             * @param status the status
21812             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21813             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
21814             * @throws SystemException if a system exception occurred
21815             */
21816            @Override
21817            public JournalArticle fetchByG_F_ST_Last(long groupId, long folderId,
21818                    int status, OrderByComparator orderByComparator)
21819                    throws SystemException {
21820                    int count = countByG_F_ST(groupId, folderId, status);
21821    
21822                    if (count == 0) {
21823                            return null;
21824                    }
21825    
21826                    List<JournalArticle> list = findByG_F_ST(groupId, folderId, status,
21827                                    count - 1, count, orderByComparator);
21828    
21829                    if (!list.isEmpty()) {
21830                            return list.get(0);
21831                    }
21832    
21833                    return null;
21834            }
21835    
21836            /**
21837             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
21838             *
21839             * @param id the primary key of the current journal article
21840             * @param groupId the group ID
21841             * @param folderId the folder ID
21842             * @param status the status
21843             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21844             * @return the previous, current, and next journal article
21845             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
21846             * @throws SystemException if a system exception occurred
21847             */
21848            @Override
21849            public JournalArticle[] findByG_F_ST_PrevAndNext(long id, long groupId,
21850                    long folderId, int status, OrderByComparator orderByComparator)
21851                    throws NoSuchArticleException, SystemException {
21852                    JournalArticle journalArticle = findByPrimaryKey(id);
21853    
21854                    Session session = null;
21855    
21856                    try {
21857                            session = openSession();
21858    
21859                            JournalArticle[] array = new JournalArticleImpl[3];
21860    
21861                            array[0] = getByG_F_ST_PrevAndNext(session, journalArticle,
21862                                            groupId, folderId, status, orderByComparator, true);
21863    
21864                            array[1] = journalArticle;
21865    
21866                            array[2] = getByG_F_ST_PrevAndNext(session, journalArticle,
21867                                            groupId, folderId, status, orderByComparator, false);
21868    
21869                            return array;
21870                    }
21871                    catch (Exception e) {
21872                            throw processException(e);
21873                    }
21874                    finally {
21875                            closeSession(session);
21876                    }
21877            }
21878    
21879            protected JournalArticle getByG_F_ST_PrevAndNext(Session session,
21880                    JournalArticle journalArticle, long groupId, long folderId, int status,
21881                    OrderByComparator orderByComparator, boolean previous) {
21882                    StringBundler query = null;
21883    
21884                    if (orderByComparator != null) {
21885                            query = new StringBundler(6 +
21886                                            (orderByComparator.getOrderByFields().length * 6));
21887                    }
21888                    else {
21889                            query = new StringBundler(3);
21890                    }
21891    
21892                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
21893    
21894                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
21895    
21896                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
21897    
21898                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
21899    
21900                    if (orderByComparator != null) {
21901                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
21902    
21903                            if (orderByConditionFields.length > 0) {
21904                                    query.append(WHERE_AND);
21905                            }
21906    
21907                            for (int i = 0; i < orderByConditionFields.length; i++) {
21908                                    query.append(_ORDER_BY_ENTITY_ALIAS);
21909                                    query.append(orderByConditionFields[i]);
21910    
21911                                    if ((i + 1) < orderByConditionFields.length) {
21912                                            if (orderByComparator.isAscending() ^ previous) {
21913                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
21914                                            }
21915                                            else {
21916                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
21917                                            }
21918                                    }
21919                                    else {
21920                                            if (orderByComparator.isAscending() ^ previous) {
21921                                                    query.append(WHERE_GREATER_THAN);
21922                                            }
21923                                            else {
21924                                                    query.append(WHERE_LESSER_THAN);
21925                                            }
21926                                    }
21927                            }
21928    
21929                            query.append(ORDER_BY_CLAUSE);
21930    
21931                            String[] orderByFields = orderByComparator.getOrderByFields();
21932    
21933                            for (int i = 0; i < orderByFields.length; i++) {
21934                                    query.append(_ORDER_BY_ENTITY_ALIAS);
21935                                    query.append(orderByFields[i]);
21936    
21937                                    if ((i + 1) < orderByFields.length) {
21938                                            if (orderByComparator.isAscending() ^ previous) {
21939                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
21940                                            }
21941                                            else {
21942                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
21943                                            }
21944                                    }
21945                                    else {
21946                                            if (orderByComparator.isAscending() ^ previous) {
21947                                                    query.append(ORDER_BY_ASC);
21948                                            }
21949                                            else {
21950                                                    query.append(ORDER_BY_DESC);
21951                                            }
21952                                    }
21953                            }
21954                    }
21955                    else {
21956                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21957                    }
21958    
21959                    String sql = query.toString();
21960    
21961                    Query q = session.createQuery(sql);
21962    
21963                    q.setFirstResult(0);
21964                    q.setMaxResults(2);
21965    
21966                    QueryPos qPos = QueryPos.getInstance(q);
21967    
21968                    qPos.add(groupId);
21969    
21970                    qPos.add(folderId);
21971    
21972                    qPos.add(status);
21973    
21974                    if (orderByComparator != null) {
21975                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
21976    
21977                            for (Object value : values) {
21978                                    qPos.add(value);
21979                            }
21980                    }
21981    
21982                    List<JournalArticle> list = q.list();
21983    
21984                    if (list.size() == 2) {
21985                            return list.get(1);
21986                    }
21987                    else {
21988                            return null;
21989                    }
21990            }
21991    
21992            /**
21993             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
21994             *
21995             * @param groupId the group ID
21996             * @param folderId the folder ID
21997             * @param status the status
21998             * @return the matching journal articles that the user has permission to view
21999             * @throws SystemException if a system exception occurred
22000             */
22001            @Override
22002            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
22003                    int status) throws SystemException {
22004                    return filterFindByG_F_ST(groupId, folderId, status, QueryUtil.ALL_POS,
22005                            QueryUtil.ALL_POS, null);
22006            }
22007    
22008            /**
22009             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
22010             *
22011             * <p>
22012             * 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.
22013             * </p>
22014             *
22015             * @param groupId the group ID
22016             * @param folderId the folder ID
22017             * @param status the status
22018             * @param start the lower bound of the range of journal articles
22019             * @param end the upper bound of the range of journal articles (not inclusive)
22020             * @return the range of matching journal articles that the user has permission to view
22021             * @throws SystemException if a system exception occurred
22022             */
22023            @Override
22024            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
22025                    int status, int start, int end) throws SystemException {
22026                    return filterFindByG_F_ST(groupId, folderId, status, start, end, null);
22027            }
22028    
22029            /**
22030             * 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;.
22031             *
22032             * <p>
22033             * 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.
22034             * </p>
22035             *
22036             * @param groupId the group ID
22037             * @param folderId the folder ID
22038             * @param status the status
22039             * @param start the lower bound of the range of journal articles
22040             * @param end the upper bound of the range of journal articles (not inclusive)
22041             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
22042             * @return the ordered range of matching journal articles that the user has permission to view
22043             * @throws SystemException if a system exception occurred
22044             */
22045            @Override
22046            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
22047                    int status, int start, int end, OrderByComparator orderByComparator)
22048                    throws SystemException {
22049                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22050                            return findByG_F_ST(groupId, folderId, status, start, end,
22051                                    orderByComparator);
22052                    }
22053    
22054                    StringBundler query = null;
22055    
22056                    if (orderByComparator != null) {
22057                            query = new StringBundler(5 +
22058                                            (orderByComparator.getOrderByFields().length * 3));
22059                    }
22060                    else {
22061                            query = new StringBundler(5);
22062                    }
22063    
22064                    if (getDB().isSupportsInlineDistinct()) {
22065                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
22066                    }
22067                    else {
22068                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
22069                    }
22070    
22071                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
22072    
22073                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
22074    
22075                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
22076    
22077                    if (!getDB().isSupportsInlineDistinct()) {
22078                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
22079                    }
22080    
22081                    if (orderByComparator != null) {
22082                            if (getDB().isSupportsInlineDistinct()) {
22083                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
22084                                            orderByComparator, true);
22085                            }
22086                            else {
22087                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
22088                                            orderByComparator, true);
22089                            }
22090                    }
22091                    else {
22092                            if (getDB().isSupportsInlineDistinct()) {
22093                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22094                            }
22095                            else {
22096                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
22097                            }
22098                    }
22099    
22100                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22101                                    JournalArticle.class.getName(),
22102                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22103    
22104                    Session session = null;
22105    
22106                    try {
22107                            session = openSession();
22108    
22109                            SQLQuery q = session.createSQLQuery(sql);
22110    
22111                            if (getDB().isSupportsInlineDistinct()) {
22112                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
22113                            }
22114                            else {
22115                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
22116                            }
22117    
22118                            QueryPos qPos = QueryPos.getInstance(q);
22119    
22120                            qPos.add(groupId);
22121    
22122                            qPos.add(folderId);
22123    
22124                            qPos.add(status);
22125    
22126                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
22127                                    end);
22128                    }
22129                    catch (Exception e) {
22130                            throw processException(e);
22131                    }
22132                    finally {
22133                            closeSession(session);
22134                    }
22135            }
22136    
22137            /**
22138             * 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;.
22139             *
22140             * @param id the primary key of the current journal article
22141             * @param groupId the group ID
22142             * @param folderId the folder ID
22143             * @param status the status
22144             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22145             * @return the previous, current, and next journal article
22146             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
22147             * @throws SystemException if a system exception occurred
22148             */
22149            @Override
22150            public JournalArticle[] filterFindByG_F_ST_PrevAndNext(long id,
22151                    long groupId, long folderId, int status,
22152                    OrderByComparator orderByComparator)
22153                    throws NoSuchArticleException, SystemException {
22154                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22155                            return findByG_F_ST_PrevAndNext(id, groupId, folderId, status,
22156                                    orderByComparator);
22157                    }
22158    
22159                    JournalArticle journalArticle = findByPrimaryKey(id);
22160    
22161                    Session session = null;
22162    
22163                    try {
22164                            session = openSession();
22165    
22166                            JournalArticle[] array = new JournalArticleImpl[3];
22167    
22168                            array[0] = filterGetByG_F_ST_PrevAndNext(session, journalArticle,
22169                                            groupId, folderId, status, orderByComparator, true);
22170    
22171                            array[1] = journalArticle;
22172    
22173                            array[2] = filterGetByG_F_ST_PrevAndNext(session, journalArticle,
22174                                            groupId, folderId, status, orderByComparator, false);
22175    
22176                            return array;
22177                    }
22178                    catch (Exception e) {
22179                            throw processException(e);
22180                    }
22181                    finally {
22182                            closeSession(session);
22183                    }
22184            }
22185    
22186            protected JournalArticle filterGetByG_F_ST_PrevAndNext(Session session,
22187                    JournalArticle journalArticle, long groupId, long folderId, int status,
22188                    OrderByComparator orderByComparator, boolean previous) {
22189                    StringBundler query = null;
22190    
22191                    if (orderByComparator != null) {
22192                            query = new StringBundler(6 +
22193                                            (orderByComparator.getOrderByFields().length * 6));
22194                    }
22195                    else {
22196                            query = new StringBundler(3);
22197                    }
22198    
22199                    if (getDB().isSupportsInlineDistinct()) {
22200                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
22201                    }
22202                    else {
22203                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
22204                    }
22205    
22206                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
22207    
22208                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
22209    
22210                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
22211    
22212                    if (!getDB().isSupportsInlineDistinct()) {
22213                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
22214                    }
22215    
22216                    if (orderByComparator != null) {
22217                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
22218    
22219                            if (orderByConditionFields.length > 0) {
22220                                    query.append(WHERE_AND);
22221                            }
22222    
22223                            for (int i = 0; i < orderByConditionFields.length; i++) {
22224                                    if (getDB().isSupportsInlineDistinct()) {
22225                                            query.append(_ORDER_BY_ENTITY_ALIAS);
22226                                    }
22227                                    else {
22228                                            query.append(_ORDER_BY_ENTITY_TABLE);
22229                                    }
22230    
22231                                    query.append(orderByConditionFields[i]);
22232    
22233                                    if ((i + 1) < orderByConditionFields.length) {
22234                                            if (orderByComparator.isAscending() ^ previous) {
22235                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
22236                                            }
22237                                            else {
22238                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
22239                                            }
22240                                    }
22241                                    else {
22242                                            if (orderByComparator.isAscending() ^ previous) {
22243                                                    query.append(WHERE_GREATER_THAN);
22244                                            }
22245                                            else {
22246                                                    query.append(WHERE_LESSER_THAN);
22247                                            }
22248                                    }
22249                            }
22250    
22251                            query.append(ORDER_BY_CLAUSE);
22252    
22253                            String[] orderByFields = orderByComparator.getOrderByFields();
22254    
22255                            for (int i = 0; i < orderByFields.length; i++) {
22256                                    if (getDB().isSupportsInlineDistinct()) {
22257                                            query.append(_ORDER_BY_ENTITY_ALIAS);
22258                                    }
22259                                    else {
22260                                            query.append(_ORDER_BY_ENTITY_TABLE);
22261                                    }
22262    
22263                                    query.append(orderByFields[i]);
22264    
22265                                    if ((i + 1) < orderByFields.length) {
22266                                            if (orderByComparator.isAscending() ^ previous) {
22267                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
22268                                            }
22269                                            else {
22270                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
22271                                            }
22272                                    }
22273                                    else {
22274                                            if (orderByComparator.isAscending() ^ previous) {
22275                                                    query.append(ORDER_BY_ASC);
22276                                            }
22277                                            else {
22278                                                    query.append(ORDER_BY_DESC);
22279                                            }
22280                                    }
22281                            }
22282                    }
22283                    else {
22284                            if (getDB().isSupportsInlineDistinct()) {
22285                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22286                            }
22287                            else {
22288                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
22289                            }
22290                    }
22291    
22292                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22293                                    JournalArticle.class.getName(),
22294                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22295    
22296                    SQLQuery q = session.createSQLQuery(sql);
22297    
22298                    q.setFirstResult(0);
22299                    q.setMaxResults(2);
22300    
22301                    if (getDB().isSupportsInlineDistinct()) {
22302                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
22303                    }
22304                    else {
22305                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
22306                    }
22307    
22308                    QueryPos qPos = QueryPos.getInstance(q);
22309    
22310                    qPos.add(groupId);
22311    
22312                    qPos.add(folderId);
22313    
22314                    qPos.add(status);
22315    
22316                    if (orderByComparator != null) {
22317                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
22318    
22319                            for (Object value : values) {
22320                                    qPos.add(value);
22321                            }
22322                    }
22323    
22324                    List<JournalArticle> list = q.list();
22325    
22326                    if (list.size() == 2) {
22327                            return list.get(1);
22328                    }
22329                    else {
22330                            return null;
22331                    }
22332            }
22333    
22334            /**
22335             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = any &#63;.
22336             *
22337             * @param groupId the group ID
22338             * @param folderId the folder ID
22339             * @param statuses the statuses
22340             * @return the matching journal articles that the user has permission to view
22341             * @throws SystemException if a system exception occurred
22342             */
22343            @Override
22344            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
22345                    int[] statuses) throws SystemException {
22346                    return filterFindByG_F_ST(groupId, folderId, statuses,
22347                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
22348            }
22349    
22350            /**
22351             * 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;.
22352             *
22353             * <p>
22354             * 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.
22355             * </p>
22356             *
22357             * @param groupId the group ID
22358             * @param folderId the folder ID
22359             * @param statuses the statuses
22360             * @param start the lower bound of the range of journal articles
22361             * @param end the upper bound of the range of journal articles (not inclusive)
22362             * @return the range of matching journal articles that the user has permission to view
22363             * @throws SystemException if a system exception occurred
22364             */
22365            @Override
22366            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
22367                    int[] statuses, int start, int end) throws SystemException {
22368                    return filterFindByG_F_ST(groupId, folderId, statuses, start, end, null);
22369            }
22370    
22371            /**
22372             * 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;.
22373             *
22374             * <p>
22375             * 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.
22376             * </p>
22377             *
22378             * @param groupId the group ID
22379             * @param folderId the folder ID
22380             * @param statuses the statuses
22381             * @param start the lower bound of the range of journal articles
22382             * @param end the upper bound of the range of journal articles (not inclusive)
22383             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
22384             * @return the ordered range of matching journal articles that the user has permission to view
22385             * @throws SystemException if a system exception occurred
22386             */
22387            @Override
22388            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
22389                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
22390                    throws SystemException {
22391                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22392                            return findByG_F_ST(groupId, folderId, statuses, start, end,
22393                                    orderByComparator);
22394                    }
22395    
22396                    StringBundler query = new StringBundler();
22397    
22398                    if (getDB().isSupportsInlineDistinct()) {
22399                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
22400                    }
22401                    else {
22402                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
22403                    }
22404    
22405                    boolean conjunctionable = false;
22406    
22407                    if (conjunctionable) {
22408                            query.append(WHERE_AND);
22409                    }
22410    
22411                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
22412    
22413                    conjunctionable = true;
22414    
22415                    if (conjunctionable) {
22416                            query.append(WHERE_AND);
22417                    }
22418    
22419                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
22420    
22421                    conjunctionable = true;
22422    
22423                    if ((statuses == null) || (statuses.length > 0)) {
22424                            if (conjunctionable) {
22425                                    query.append(WHERE_AND);
22426                            }
22427    
22428                            query.append(StringPool.OPEN_PARENTHESIS);
22429    
22430                            for (int i = 0; i < statuses.length; i++) {
22431                                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
22432    
22433                                    if ((i + 1) < statuses.length) {
22434                                            query.append(WHERE_OR);
22435                                    }
22436                            }
22437    
22438                            query.append(StringPool.CLOSE_PARENTHESIS);
22439    
22440                            conjunctionable = true;
22441                    }
22442    
22443                    if (!getDB().isSupportsInlineDistinct()) {
22444                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
22445                    }
22446    
22447                    if (orderByComparator != null) {
22448                            if (getDB().isSupportsInlineDistinct()) {
22449                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
22450                                            orderByComparator, true);
22451                            }
22452                            else {
22453                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
22454                                            orderByComparator, true);
22455                            }
22456                    }
22457                    else {
22458                            if (getDB().isSupportsInlineDistinct()) {
22459                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22460                            }
22461                            else {
22462                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
22463                            }
22464                    }
22465    
22466                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22467                                    JournalArticle.class.getName(),
22468                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22469    
22470                    Session session = null;
22471    
22472                    try {
22473                            session = openSession();
22474    
22475                            SQLQuery q = session.createSQLQuery(sql);
22476    
22477                            if (getDB().isSupportsInlineDistinct()) {
22478                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
22479                            }
22480                            else {
22481                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
22482                            }
22483    
22484                            QueryPos qPos = QueryPos.getInstance(q);
22485    
22486                            qPos.add(groupId);
22487    
22488                            qPos.add(folderId);
22489    
22490                            if (statuses != null) {
22491                                    qPos.add(statuses);
22492                            }
22493    
22494                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
22495                                    end);
22496                    }
22497                    catch (Exception e) {
22498                            throw processException(e);
22499                    }
22500                    finally {
22501                            closeSession(session);
22502                    }
22503            }
22504    
22505            /**
22506             * Returns all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
22507             *
22508             * <p>
22509             * 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.
22510             * </p>
22511             *
22512             * @param groupId the group ID
22513             * @param folderId the folder ID
22514             * @param statuses the statuses
22515             * @return the matching journal articles
22516             * @throws SystemException if a system exception occurred
22517             */
22518            @Override
22519            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
22520                    int[] statuses) throws SystemException {
22521                    return findByG_F_ST(groupId, folderId, statuses, QueryUtil.ALL_POS,
22522                            QueryUtil.ALL_POS, null);
22523            }
22524    
22525            /**
22526             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
22527             *
22528             * <p>
22529             * 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.
22530             * </p>
22531             *
22532             * @param groupId the group ID
22533             * @param folderId the folder ID
22534             * @param statuses the statuses
22535             * @param start the lower bound of the range of journal articles
22536             * @param end the upper bound of the range of journal articles (not inclusive)
22537             * @return the range of matching journal articles
22538             * @throws SystemException if a system exception occurred
22539             */
22540            @Override
22541            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
22542                    int[] statuses, int start, int end) throws SystemException {
22543                    return findByG_F_ST(groupId, folderId, statuses, start, end, null);
22544            }
22545    
22546            /**
22547             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
22548             *
22549             * <p>
22550             * 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.
22551             * </p>
22552             *
22553             * @param groupId the group ID
22554             * @param folderId the folder ID
22555             * @param statuses the statuses
22556             * @param start the lower bound of the range of journal articles
22557             * @param end the upper bound of the range of journal articles (not inclusive)
22558             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
22559             * @return the ordered range of matching journal articles
22560             * @throws SystemException if a system exception occurred
22561             */
22562            @Override
22563            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
22564                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
22565                    throws SystemException {
22566                    if ((statuses != null) && (statuses.length == 1)) {
22567                            return findByG_F_ST(groupId, folderId, statuses[0], start, end,
22568                                    orderByComparator);
22569                    }
22570    
22571                    boolean pagination = true;
22572                    Object[] finderArgs = null;
22573    
22574                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
22575                                    (orderByComparator == null)) {
22576                            pagination = false;
22577                            finderArgs = new Object[] {
22578                                            groupId, folderId, StringUtil.merge(statuses)
22579                                    };
22580                    }
22581                    else {
22582                            finderArgs = new Object[] {
22583                                            groupId, folderId, StringUtil.merge(statuses),
22584                                            
22585                                            start, end, orderByComparator
22586                                    };
22587                    }
22588    
22589                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
22590                                    finderArgs, this);
22591    
22592                    if ((list != null) && !list.isEmpty()) {
22593                            for (JournalArticle journalArticle : list) {
22594                                    if ((groupId != journalArticle.getGroupId()) ||
22595                                                    (folderId != journalArticle.getFolderId()) ||
22596                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
22597                                            list = null;
22598    
22599                                            break;
22600                                    }
22601                            }
22602                    }
22603    
22604                    if (list == null) {
22605                            StringBundler query = new StringBundler();
22606    
22607                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
22608    
22609                            boolean conjunctionable = false;
22610    
22611                            if (conjunctionable) {
22612                                    query.append(WHERE_AND);
22613                            }
22614    
22615                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
22616    
22617                            conjunctionable = true;
22618    
22619                            if (conjunctionable) {
22620                                    query.append(WHERE_AND);
22621                            }
22622    
22623                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
22624    
22625                            conjunctionable = true;
22626    
22627                            if ((statuses == null) || (statuses.length > 0)) {
22628                                    if (conjunctionable) {
22629                                            query.append(WHERE_AND);
22630                                    }
22631    
22632                                    query.append(StringPool.OPEN_PARENTHESIS);
22633    
22634                                    for (int i = 0; i < statuses.length; i++) {
22635                                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
22636    
22637                                            if ((i + 1) < statuses.length) {
22638                                                    query.append(WHERE_OR);
22639                                            }
22640                                    }
22641    
22642                                    query.append(StringPool.CLOSE_PARENTHESIS);
22643    
22644                                    conjunctionable = true;
22645                            }
22646    
22647                            if (orderByComparator != null) {
22648                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
22649                                            orderByComparator);
22650                            }
22651                            else
22652                             if (pagination) {
22653                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22654                            }
22655    
22656                            String sql = query.toString();
22657    
22658                            Session session = null;
22659    
22660                            try {
22661                                    session = openSession();
22662    
22663                                    Query q = session.createQuery(sql);
22664    
22665                                    QueryPos qPos = QueryPos.getInstance(q);
22666    
22667                                    qPos.add(groupId);
22668    
22669                                    qPos.add(folderId);
22670    
22671                                    if (statuses != null) {
22672                                            qPos.add(statuses);
22673                                    }
22674    
22675                                    if (!pagination) {
22676                                            list = (List<JournalArticle>)QueryUtil.list(q,
22677                                                            getDialect(), start, end, false);
22678    
22679                                            Collections.sort(list);
22680    
22681                                            list = new UnmodifiableList<JournalArticle>(list);
22682                                    }
22683                                    else {
22684                                            list = (List<JournalArticle>)QueryUtil.list(q,
22685                                                            getDialect(), start, end);
22686                                    }
22687    
22688                                    cacheResult(list);
22689    
22690                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
22691                                            finderArgs, list);
22692                            }
22693                            catch (Exception e) {
22694                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
22695                                            finderArgs);
22696    
22697                                    throw processException(e);
22698                            }
22699                            finally {
22700                                    closeSession(session);
22701                            }
22702                    }
22703    
22704                    return list;
22705            }
22706    
22707            /**
22708             * Removes all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63; from the database.
22709             *
22710             * @param groupId the group ID
22711             * @param folderId the folder ID
22712             * @param status the status
22713             * @throws SystemException if a system exception occurred
22714             */
22715            @Override
22716            public void removeByG_F_ST(long groupId, long folderId, int status)
22717                    throws SystemException {
22718                    for (JournalArticle journalArticle : findByG_F_ST(groupId, folderId,
22719                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
22720                            remove(journalArticle);
22721                    }
22722            }
22723    
22724            /**
22725             * Returns the number of journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
22726             *
22727             * @param groupId the group ID
22728             * @param folderId the folder ID
22729             * @param status the status
22730             * @return the number of matching journal articles
22731             * @throws SystemException if a system exception occurred
22732             */
22733            @Override
22734            public int countByG_F_ST(long groupId, long folderId, int status)
22735                    throws SystemException {
22736                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_ST;
22737    
22738                    Object[] finderArgs = new Object[] { groupId, folderId, status };
22739    
22740                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
22741                                    this);
22742    
22743                    if (count == null) {
22744                            StringBundler query = new StringBundler(4);
22745    
22746                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
22747    
22748                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
22749    
22750                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
22751    
22752                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
22753    
22754                            String sql = query.toString();
22755    
22756                            Session session = null;
22757    
22758                            try {
22759                                    session = openSession();
22760    
22761                                    Query q = session.createQuery(sql);
22762    
22763                                    QueryPos qPos = QueryPos.getInstance(q);
22764    
22765                                    qPos.add(groupId);
22766    
22767                                    qPos.add(folderId);
22768    
22769                                    qPos.add(status);
22770    
22771                                    count = (Long)q.uniqueResult();
22772    
22773                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
22774                            }
22775                            catch (Exception e) {
22776                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
22777    
22778                                    throw processException(e);
22779                            }
22780                            finally {
22781                                    closeSession(session);
22782                            }
22783                    }
22784    
22785                    return count.intValue();
22786            }
22787    
22788            /**
22789             * Returns the number of journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
22790             *
22791             * @param groupId the group ID
22792             * @param folderId the folder ID
22793             * @param statuses the statuses
22794             * @return the number of matching journal articles
22795             * @throws SystemException if a system exception occurred
22796             */
22797            @Override
22798            public int countByG_F_ST(long groupId, long folderId, int[] statuses)
22799                    throws SystemException {
22800                    Object[] finderArgs = new Object[] {
22801                                    groupId, folderId, StringUtil.merge(statuses)
22802                            };
22803    
22804                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
22805                                    finderArgs, this);
22806    
22807                    if (count == null) {
22808                            StringBundler query = new StringBundler();
22809    
22810                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
22811    
22812                            boolean conjunctionable = false;
22813    
22814                            if (conjunctionable) {
22815                                    query.append(WHERE_AND);
22816                            }
22817    
22818                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
22819    
22820                            conjunctionable = true;
22821    
22822                            if (conjunctionable) {
22823                                    query.append(WHERE_AND);
22824                            }
22825    
22826                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
22827    
22828                            conjunctionable = true;
22829    
22830                            if ((statuses == null) || (statuses.length > 0)) {
22831                                    if (conjunctionable) {
22832                                            query.append(WHERE_AND);
22833                                    }
22834    
22835                                    query.append(StringPool.OPEN_PARENTHESIS);
22836    
22837                                    for (int i = 0; i < statuses.length; i++) {
22838                                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
22839    
22840                                            if ((i + 1) < statuses.length) {
22841                                                    query.append(WHERE_OR);
22842                                            }
22843                                    }
22844    
22845                                    query.append(StringPool.CLOSE_PARENTHESIS);
22846    
22847                                    conjunctionable = true;
22848                            }
22849    
22850                            String sql = query.toString();
22851    
22852                            Session session = null;
22853    
22854                            try {
22855                                    session = openSession();
22856    
22857                                    Query q = session.createQuery(sql);
22858    
22859                                    QueryPos qPos = QueryPos.getInstance(q);
22860    
22861                                    qPos.add(groupId);
22862    
22863                                    qPos.add(folderId);
22864    
22865                                    if (statuses != null) {
22866                                            qPos.add(statuses);
22867                                    }
22868    
22869                                    count = (Long)q.uniqueResult();
22870    
22871                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
22872                                            finderArgs, count);
22873                            }
22874                            catch (Exception e) {
22875                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
22876                                            finderArgs);
22877    
22878                                    throw processException(e);
22879                            }
22880                            finally {
22881                                    closeSession(session);
22882                            }
22883                    }
22884    
22885                    return count.intValue();
22886            }
22887    
22888            /**
22889             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
22890             *
22891             * @param groupId the group ID
22892             * @param folderId the folder ID
22893             * @param status the status
22894             * @return the number of matching journal articles that the user has permission to view
22895             * @throws SystemException if a system exception occurred
22896             */
22897            @Override
22898            public int filterCountByG_F_ST(long groupId, long folderId, int status)
22899                    throws SystemException {
22900                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22901                            return countByG_F_ST(groupId, folderId, status);
22902                    }
22903    
22904                    StringBundler query = new StringBundler(4);
22905    
22906                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
22907    
22908                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
22909    
22910                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
22911    
22912                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
22913    
22914                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22915                                    JournalArticle.class.getName(),
22916                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22917    
22918                    Session session = null;
22919    
22920                    try {
22921                            session = openSession();
22922    
22923                            SQLQuery q = session.createSQLQuery(sql);
22924    
22925                            q.addScalar(COUNT_COLUMN_NAME,
22926                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
22927    
22928                            QueryPos qPos = QueryPos.getInstance(q);
22929    
22930                            qPos.add(groupId);
22931    
22932                            qPos.add(folderId);
22933    
22934                            qPos.add(status);
22935    
22936                            Long count = (Long)q.uniqueResult();
22937    
22938                            return count.intValue();
22939                    }
22940                    catch (Exception e) {
22941                            throw processException(e);
22942                    }
22943                    finally {
22944                            closeSession(session);
22945                    }
22946            }
22947    
22948            /**
22949             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = any &#63;.
22950             *
22951             * @param groupId the group ID
22952             * @param folderId the folder ID
22953             * @param statuses the statuses
22954             * @return the number of matching journal articles that the user has permission to view
22955             * @throws SystemException if a system exception occurred
22956             */
22957            @Override
22958            public int filterCountByG_F_ST(long groupId, long folderId, int[] statuses)
22959                    throws SystemException {
22960                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22961                            return countByG_F_ST(groupId, folderId, statuses);
22962                    }
22963    
22964                    StringBundler query = new StringBundler();
22965    
22966                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
22967    
22968                    boolean conjunctionable = false;
22969    
22970                    if (conjunctionable) {
22971                            query.append(WHERE_AND);
22972                    }
22973    
22974                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
22975    
22976                    conjunctionable = true;
22977    
22978                    if (conjunctionable) {
22979                            query.append(WHERE_AND);
22980                    }
22981    
22982                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
22983    
22984                    conjunctionable = true;
22985    
22986                    if ((statuses == null) || (statuses.length > 0)) {
22987                            if (conjunctionable) {
22988                                    query.append(WHERE_AND);
22989                            }
22990    
22991                            query.append(StringPool.OPEN_PARENTHESIS);
22992    
22993                            for (int i = 0; i < statuses.length; i++) {
22994                                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
22995    
22996                                    if ((i + 1) < statuses.length) {
22997                                            query.append(WHERE_OR);
22998                                    }
22999                            }
23000    
23001                            query.append(StringPool.CLOSE_PARENTHESIS);
23002    
23003                            conjunctionable = true;
23004                    }
23005    
23006                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23007                                    JournalArticle.class.getName(),
23008                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23009    
23010                    Session session = null;
23011    
23012                    try {
23013                            session = openSession();
23014    
23015                            SQLQuery q = session.createSQLQuery(sql);
23016    
23017                            q.addScalar(COUNT_COLUMN_NAME,
23018                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
23019    
23020                            QueryPos qPos = QueryPos.getInstance(q);
23021    
23022                            qPos.add(groupId);
23023    
23024                            qPos.add(folderId);
23025    
23026                            if (statuses != null) {
23027                                    qPos.add(statuses);
23028                            }
23029    
23030                            Long count = (Long)q.uniqueResult();
23031    
23032                            return count.intValue();
23033                    }
23034                    catch (Exception e) {
23035                            throw processException(e);
23036                    }
23037                    finally {
23038                            closeSession(session);
23039                    }
23040            }
23041    
23042            private static final String _FINDER_COLUMN_G_F_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
23043            private static final String _FINDER_COLUMN_G_F_ST_GROUPID_5 = "(" +
23044                    removeConjunction(_FINDER_COLUMN_G_F_ST_GROUPID_2) + ")";
23045            private static final String _FINDER_COLUMN_G_F_ST_FOLDERID_2 = "journalArticle.folderId = ? AND ";
23046            private static final String _FINDER_COLUMN_G_F_ST_FOLDERID_5 = "(" +
23047                    removeConjunction(_FINDER_COLUMN_G_F_ST_FOLDERID_2) + ")";
23048            private static final String _FINDER_COLUMN_G_F_ST_STATUS_2 = "journalArticle.status = ?";
23049            private static final String _FINDER_COLUMN_G_F_ST_STATUS_5 = "(" +
23050                    removeConjunction(_FINDER_COLUMN_G_F_ST_STATUS_2) + ")";
23051            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23052                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
23053                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
23054                            "findByG_C_C",
23055                            new String[] {
23056                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
23057                                    
23058                            Integer.class.getName(), Integer.class.getName(),
23059                                    OrderByComparator.class.getName()
23060                            });
23061            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23062                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
23063                            JournalArticleImpl.class,
23064                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_C",
23065                            new String[] {
23066                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
23067                            },
23068                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
23069                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
23070                            JournalArticleModelImpl.CLASSPK_COLUMN_BITMASK |
23071                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
23072                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
23073            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23074                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
23075                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_C",
23076                            new String[] {
23077                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
23078                            });
23079    
23080            /**
23081             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
23082             *
23083             * @param groupId the group ID
23084             * @param classNameId the class name ID
23085             * @param classPK the class p k
23086             * @return the matching journal articles
23087             * @throws SystemException if a system exception occurred
23088             */
23089            @Override
23090            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
23091                    long classPK) throws SystemException {
23092                    return findByG_C_C(groupId, classNameId, classPK, QueryUtil.ALL_POS,
23093                            QueryUtil.ALL_POS, null);
23094            }
23095    
23096            /**
23097             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
23098             *
23099             * <p>
23100             * 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.
23101             * </p>
23102             *
23103             * @param groupId the group ID
23104             * @param classNameId the class name ID
23105             * @param classPK the class p k
23106             * @param start the lower bound of the range of journal articles
23107             * @param end the upper bound of the range of journal articles (not inclusive)
23108             * @return the range of matching journal articles
23109             * @throws SystemException if a system exception occurred
23110             */
23111            @Override
23112            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
23113                    long classPK, int start, int end) throws SystemException {
23114                    return findByG_C_C(groupId, classNameId, classPK, start, end, null);
23115            }
23116    
23117            /**
23118             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
23119             *
23120             * <p>
23121             * 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.
23122             * </p>
23123             *
23124             * @param groupId the group ID
23125             * @param classNameId the class name ID
23126             * @param classPK the class p k
23127             * @param start the lower bound of the range of journal articles
23128             * @param end the upper bound of the range of journal articles (not inclusive)
23129             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
23130             * @return the ordered range of matching journal articles
23131             * @throws SystemException if a system exception occurred
23132             */
23133            @Override
23134            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
23135                    long classPK, int start, int end, OrderByComparator orderByComparator)
23136                    throws SystemException {
23137                    boolean pagination = true;
23138                    FinderPath finderPath = null;
23139                    Object[] finderArgs = null;
23140    
23141                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
23142                                    (orderByComparator == null)) {
23143                            pagination = false;
23144                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C;
23145                            finderArgs = new Object[] { groupId, classNameId, classPK };
23146                    }
23147                    else {
23148                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C;
23149                            finderArgs = new Object[] {
23150                                            groupId, classNameId, classPK,
23151                                            
23152                                            start, end, orderByComparator
23153                                    };
23154                    }
23155    
23156                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
23157                                    finderArgs, this);
23158    
23159                    if ((list != null) && !list.isEmpty()) {
23160                            for (JournalArticle journalArticle : list) {
23161                                    if ((groupId != journalArticle.getGroupId()) ||
23162                                                    (classNameId != journalArticle.getClassNameId()) ||
23163                                                    (classPK != journalArticle.getClassPK())) {
23164                                            list = null;
23165    
23166                                            break;
23167                                    }
23168                            }
23169                    }
23170    
23171                    if (list == null) {
23172                            StringBundler query = null;
23173    
23174                            if (orderByComparator != null) {
23175                                    query = new StringBundler(5 +
23176                                                    (orderByComparator.getOrderByFields().length * 3));
23177                            }
23178                            else {
23179                                    query = new StringBundler(5);
23180                            }
23181    
23182                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
23183    
23184                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
23185    
23186                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
23187    
23188                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
23189    
23190                            if (orderByComparator != null) {
23191                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
23192                                            orderByComparator);
23193                            }
23194                            else
23195                             if (pagination) {
23196                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23197                            }
23198    
23199                            String sql = query.toString();
23200    
23201                            Session session = null;
23202    
23203                            try {
23204                                    session = openSession();
23205    
23206                                    Query q = session.createQuery(sql);
23207    
23208                                    QueryPos qPos = QueryPos.getInstance(q);
23209    
23210                                    qPos.add(groupId);
23211    
23212                                    qPos.add(classNameId);
23213    
23214                                    qPos.add(classPK);
23215    
23216                                    if (!pagination) {
23217                                            list = (List<JournalArticle>)QueryUtil.list(q,
23218                                                            getDialect(), start, end, false);
23219    
23220                                            Collections.sort(list);
23221    
23222                                            list = new UnmodifiableList<JournalArticle>(list);
23223                                    }
23224                                    else {
23225                                            list = (List<JournalArticle>)QueryUtil.list(q,
23226                                                            getDialect(), start, end);
23227                                    }
23228    
23229                                    cacheResult(list);
23230    
23231                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
23232                            }
23233                            catch (Exception e) {
23234                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
23235    
23236                                    throw processException(e);
23237                            }
23238                            finally {
23239                                    closeSession(session);
23240                            }
23241                    }
23242    
23243                    return list;
23244            }
23245    
23246            /**
23247             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
23248             *
23249             * @param groupId the group ID
23250             * @param classNameId the class name ID
23251             * @param classPK the class p k
23252             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23253             * @return the first matching journal article
23254             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
23255             * @throws SystemException if a system exception occurred
23256             */
23257            @Override
23258            public JournalArticle findByG_C_C_First(long groupId, long classNameId,
23259                    long classPK, OrderByComparator orderByComparator)
23260                    throws NoSuchArticleException, SystemException {
23261                    JournalArticle journalArticle = fetchByG_C_C_First(groupId,
23262                                    classNameId, classPK, orderByComparator);
23263    
23264                    if (journalArticle != null) {
23265                            return journalArticle;
23266                    }
23267    
23268                    StringBundler msg = new StringBundler(8);
23269    
23270                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
23271    
23272                    msg.append("groupId=");
23273                    msg.append(groupId);
23274    
23275                    msg.append(", classNameId=");
23276                    msg.append(classNameId);
23277    
23278                    msg.append(", classPK=");
23279                    msg.append(classPK);
23280    
23281                    msg.append(StringPool.CLOSE_CURLY_BRACE);
23282    
23283                    throw new NoSuchArticleException(msg.toString());
23284            }
23285    
23286            /**
23287             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
23288             *
23289             * @param groupId the group ID
23290             * @param classNameId the class name ID
23291             * @param classPK the class p k
23292             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23293             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
23294             * @throws SystemException if a system exception occurred
23295             */
23296            @Override
23297            public JournalArticle fetchByG_C_C_First(long groupId, long classNameId,
23298                    long classPK, OrderByComparator orderByComparator)
23299                    throws SystemException {
23300                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
23301                                    0, 1, orderByComparator);
23302    
23303                    if (!list.isEmpty()) {
23304                            return list.get(0);
23305                    }
23306    
23307                    return null;
23308            }
23309    
23310            /**
23311             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
23312             *
23313             * @param groupId the group ID
23314             * @param classNameId the class name ID
23315             * @param classPK the class p k
23316             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23317             * @return the last matching journal article
23318             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
23319             * @throws SystemException if a system exception occurred
23320             */
23321            @Override
23322            public JournalArticle findByG_C_C_Last(long groupId, long classNameId,
23323                    long classPK, OrderByComparator orderByComparator)
23324                    throws NoSuchArticleException, SystemException {
23325                    JournalArticle journalArticle = fetchByG_C_C_Last(groupId, classNameId,
23326                                    classPK, orderByComparator);
23327    
23328                    if (journalArticle != null) {
23329                            return journalArticle;
23330                    }
23331    
23332                    StringBundler msg = new StringBundler(8);
23333    
23334                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
23335    
23336                    msg.append("groupId=");
23337                    msg.append(groupId);
23338    
23339                    msg.append(", classNameId=");
23340                    msg.append(classNameId);
23341    
23342                    msg.append(", classPK=");
23343                    msg.append(classPK);
23344    
23345                    msg.append(StringPool.CLOSE_CURLY_BRACE);
23346    
23347                    throw new NoSuchArticleException(msg.toString());
23348            }
23349    
23350            /**
23351             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
23352             *
23353             * @param groupId the group ID
23354             * @param classNameId the class name ID
23355             * @param classPK the class p k
23356             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23357             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
23358             * @throws SystemException if a system exception occurred
23359             */
23360            @Override
23361            public JournalArticle fetchByG_C_C_Last(long groupId, long classNameId,
23362                    long classPK, OrderByComparator orderByComparator)
23363                    throws SystemException {
23364                    int count = countByG_C_C(groupId, classNameId, classPK);
23365    
23366                    if (count == 0) {
23367                            return null;
23368                    }
23369    
23370                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
23371                                    count - 1, count, orderByComparator);
23372    
23373                    if (!list.isEmpty()) {
23374                            return list.get(0);
23375                    }
23376    
23377                    return null;
23378            }
23379    
23380            /**
23381             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
23382             *
23383             * @param id the primary key of the current journal article
23384             * @param groupId the group ID
23385             * @param classNameId the class name ID
23386             * @param classPK the class p k
23387             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23388             * @return the previous, current, and next journal article
23389             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
23390             * @throws SystemException if a system exception occurred
23391             */
23392            @Override
23393            public JournalArticle[] findByG_C_C_PrevAndNext(long id, long groupId,
23394                    long classNameId, long classPK, OrderByComparator orderByComparator)
23395                    throws NoSuchArticleException, SystemException {
23396                    JournalArticle journalArticle = findByPrimaryKey(id);
23397    
23398                    Session session = null;
23399    
23400                    try {
23401                            session = openSession();
23402    
23403                            JournalArticle[] array = new JournalArticleImpl[3];
23404    
23405                            array[0] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
23406                                            classNameId, classPK, orderByComparator, true);
23407    
23408                            array[1] = journalArticle;
23409    
23410                            array[2] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
23411                                            classNameId, classPK, orderByComparator, false);
23412    
23413                            return array;
23414                    }
23415                    catch (Exception e) {
23416                            throw processException(e);
23417                    }
23418                    finally {
23419                            closeSession(session);
23420                    }
23421            }
23422    
23423            protected JournalArticle getByG_C_C_PrevAndNext(Session session,
23424                    JournalArticle journalArticle, long groupId, long classNameId,
23425                    long classPK, OrderByComparator orderByComparator, boolean previous) {
23426                    StringBundler query = null;
23427    
23428                    if (orderByComparator != null) {
23429                            query = new StringBundler(6 +
23430                                            (orderByComparator.getOrderByFields().length * 6));
23431                    }
23432                    else {
23433                            query = new StringBundler(3);
23434                    }
23435    
23436                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
23437    
23438                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
23439    
23440                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
23441    
23442                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
23443    
23444                    if (orderByComparator != null) {
23445                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
23446    
23447                            if (orderByConditionFields.length > 0) {
23448                                    query.append(WHERE_AND);
23449                            }
23450    
23451                            for (int i = 0; i < orderByConditionFields.length; i++) {
23452                                    query.append(_ORDER_BY_ENTITY_ALIAS);
23453                                    query.append(orderByConditionFields[i]);
23454    
23455                                    if ((i + 1) < orderByConditionFields.length) {
23456                                            if (orderByComparator.isAscending() ^ previous) {
23457                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
23458                                            }
23459                                            else {
23460                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
23461                                            }
23462                                    }
23463                                    else {
23464                                            if (orderByComparator.isAscending() ^ previous) {
23465                                                    query.append(WHERE_GREATER_THAN);
23466                                            }
23467                                            else {
23468                                                    query.append(WHERE_LESSER_THAN);
23469                                            }
23470                                    }
23471                            }
23472    
23473                            query.append(ORDER_BY_CLAUSE);
23474    
23475                            String[] orderByFields = orderByComparator.getOrderByFields();
23476    
23477                            for (int i = 0; i < orderByFields.length; i++) {
23478                                    query.append(_ORDER_BY_ENTITY_ALIAS);
23479                                    query.append(orderByFields[i]);
23480    
23481                                    if ((i + 1) < orderByFields.length) {
23482                                            if (orderByComparator.isAscending() ^ previous) {
23483                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
23484                                            }
23485                                            else {
23486                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
23487                                            }
23488                                    }
23489                                    else {
23490                                            if (orderByComparator.isAscending() ^ previous) {
23491                                                    query.append(ORDER_BY_ASC);
23492                                            }
23493                                            else {
23494                                                    query.append(ORDER_BY_DESC);
23495                                            }
23496                                    }
23497                            }
23498                    }
23499                    else {
23500                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23501                    }
23502    
23503                    String sql = query.toString();
23504    
23505                    Query q = session.createQuery(sql);
23506    
23507                    q.setFirstResult(0);
23508                    q.setMaxResults(2);
23509    
23510                    QueryPos qPos = QueryPos.getInstance(q);
23511    
23512                    qPos.add(groupId);
23513    
23514                    qPos.add(classNameId);
23515    
23516                    qPos.add(classPK);
23517    
23518                    if (orderByComparator != null) {
23519                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
23520    
23521                            for (Object value : values) {
23522                                    qPos.add(value);
23523                            }
23524                    }
23525    
23526                    List<JournalArticle> list = q.list();
23527    
23528                    if (list.size() == 2) {
23529                            return list.get(1);
23530                    }
23531                    else {
23532                            return null;
23533                    }
23534            }
23535    
23536            /**
23537             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
23538             *
23539             * @param groupId the group ID
23540             * @param classNameId the class name ID
23541             * @param classPK the class p k
23542             * @return the matching journal articles that the user has permission to view
23543             * @throws SystemException if a system exception occurred
23544             */
23545            @Override
23546            public List<JournalArticle> filterFindByG_C_C(long groupId,
23547                    long classNameId, long classPK) throws SystemException {
23548                    return filterFindByG_C_C(groupId, classNameId, classPK,
23549                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
23550            }
23551    
23552            /**
23553             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
23554             *
23555             * <p>
23556             * 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.
23557             * </p>
23558             *
23559             * @param groupId the group ID
23560             * @param classNameId the class name ID
23561             * @param classPK the class p k
23562             * @param start the lower bound of the range of journal articles
23563             * @param end the upper bound of the range of journal articles (not inclusive)
23564             * @return the range of matching journal articles that the user has permission to view
23565             * @throws SystemException if a system exception occurred
23566             */
23567            @Override
23568            public List<JournalArticle> filterFindByG_C_C(long groupId,
23569                    long classNameId, long classPK, int start, int end)
23570                    throws SystemException {
23571                    return filterFindByG_C_C(groupId, classNameId, classPK, start, end, null);
23572            }
23573    
23574            /**
23575             * 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;.
23576             *
23577             * <p>
23578             * 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.
23579             * </p>
23580             *
23581             * @param groupId the group ID
23582             * @param classNameId the class name ID
23583             * @param classPK the class p k
23584             * @param start the lower bound of the range of journal articles
23585             * @param end the upper bound of the range of journal articles (not inclusive)
23586             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
23587             * @return the ordered range of matching journal articles that the user has permission to view
23588             * @throws SystemException if a system exception occurred
23589             */
23590            @Override
23591            public List<JournalArticle> filterFindByG_C_C(long groupId,
23592                    long classNameId, long classPK, int start, int end,
23593                    OrderByComparator orderByComparator) throws SystemException {
23594                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23595                            return findByG_C_C(groupId, classNameId, classPK, start, end,
23596                                    orderByComparator);
23597                    }
23598    
23599                    StringBundler query = null;
23600    
23601                    if (orderByComparator != null) {
23602                            query = new StringBundler(5 +
23603                                            (orderByComparator.getOrderByFields().length * 3));
23604                    }
23605                    else {
23606                            query = new StringBundler(5);
23607                    }
23608    
23609                    if (getDB().isSupportsInlineDistinct()) {
23610                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
23611                    }
23612                    else {
23613                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
23614                    }
23615    
23616                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
23617    
23618                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
23619    
23620                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
23621    
23622                    if (!getDB().isSupportsInlineDistinct()) {
23623                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
23624                    }
23625    
23626                    if (orderByComparator != null) {
23627                            if (getDB().isSupportsInlineDistinct()) {
23628                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
23629                                            orderByComparator, true);
23630                            }
23631                            else {
23632                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
23633                                            orderByComparator, true);
23634                            }
23635                    }
23636                    else {
23637                            if (getDB().isSupportsInlineDistinct()) {
23638                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23639                            }
23640                            else {
23641                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
23642                            }
23643                    }
23644    
23645                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23646                                    JournalArticle.class.getName(),
23647                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23648    
23649                    Session session = null;
23650    
23651                    try {
23652                            session = openSession();
23653    
23654                            SQLQuery q = session.createSQLQuery(sql);
23655    
23656                            if (getDB().isSupportsInlineDistinct()) {
23657                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
23658                            }
23659                            else {
23660                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
23661                            }
23662    
23663                            QueryPos qPos = QueryPos.getInstance(q);
23664    
23665                            qPos.add(groupId);
23666    
23667                            qPos.add(classNameId);
23668    
23669                            qPos.add(classPK);
23670    
23671                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
23672                                    end);
23673                    }
23674                    catch (Exception e) {
23675                            throw processException(e);
23676                    }
23677                    finally {
23678                            closeSession(session);
23679                    }
23680            }
23681    
23682            /**
23683             * 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;.
23684             *
23685             * @param id the primary key of the current journal article
23686             * @param groupId the group ID
23687             * @param classNameId the class name ID
23688             * @param classPK the class p k
23689             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23690             * @return the previous, current, and next journal article
23691             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
23692             * @throws SystemException if a system exception occurred
23693             */
23694            @Override
23695            public JournalArticle[] filterFindByG_C_C_PrevAndNext(long id,
23696                    long groupId, long classNameId, long classPK,
23697                    OrderByComparator orderByComparator)
23698                    throws NoSuchArticleException, SystemException {
23699                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23700                            return findByG_C_C_PrevAndNext(id, groupId, classNameId, classPK,
23701                                    orderByComparator);
23702                    }
23703    
23704                    JournalArticle journalArticle = findByPrimaryKey(id);
23705    
23706                    Session session = null;
23707    
23708                    try {
23709                            session = openSession();
23710    
23711                            JournalArticle[] array = new JournalArticleImpl[3];
23712    
23713                            array[0] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
23714                                            groupId, classNameId, classPK, orderByComparator, true);
23715    
23716                            array[1] = journalArticle;
23717    
23718                            array[2] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
23719                                            groupId, classNameId, classPK, orderByComparator, false);
23720    
23721                            return array;
23722                    }
23723                    catch (Exception e) {
23724                            throw processException(e);
23725                    }
23726                    finally {
23727                            closeSession(session);
23728                    }
23729            }
23730    
23731            protected JournalArticle filterGetByG_C_C_PrevAndNext(Session session,
23732                    JournalArticle journalArticle, long groupId, long classNameId,
23733                    long classPK, OrderByComparator orderByComparator, boolean previous) {
23734                    StringBundler query = null;
23735    
23736                    if (orderByComparator != null) {
23737                            query = new StringBundler(6 +
23738                                            (orderByComparator.getOrderByFields().length * 6));
23739                    }
23740                    else {
23741                            query = new StringBundler(3);
23742                    }
23743    
23744                    if (getDB().isSupportsInlineDistinct()) {
23745                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
23746                    }
23747                    else {
23748                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
23749                    }
23750    
23751                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
23752    
23753                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
23754    
23755                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
23756    
23757                    if (!getDB().isSupportsInlineDistinct()) {
23758                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
23759                    }
23760    
23761                    if (orderByComparator != null) {
23762                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
23763    
23764                            if (orderByConditionFields.length > 0) {
23765                                    query.append(WHERE_AND);
23766                            }
23767    
23768                            for (int i = 0; i < orderByConditionFields.length; i++) {
23769                                    if (getDB().isSupportsInlineDistinct()) {
23770                                            query.append(_ORDER_BY_ENTITY_ALIAS);
23771                                    }
23772                                    else {
23773                                            query.append(_ORDER_BY_ENTITY_TABLE);
23774                                    }
23775    
23776                                    query.append(orderByConditionFields[i]);
23777    
23778                                    if ((i + 1) < orderByConditionFields.length) {
23779                                            if (orderByComparator.isAscending() ^ previous) {
23780                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
23781                                            }
23782                                            else {
23783                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
23784                                            }
23785                                    }
23786                                    else {
23787                                            if (orderByComparator.isAscending() ^ previous) {
23788                                                    query.append(WHERE_GREATER_THAN);
23789                                            }
23790                                            else {
23791                                                    query.append(WHERE_LESSER_THAN);
23792                                            }
23793                                    }
23794                            }
23795    
23796                            query.append(ORDER_BY_CLAUSE);
23797    
23798                            String[] orderByFields = orderByComparator.getOrderByFields();
23799    
23800                            for (int i = 0; i < orderByFields.length; i++) {
23801                                    if (getDB().isSupportsInlineDistinct()) {
23802                                            query.append(_ORDER_BY_ENTITY_ALIAS);
23803                                    }
23804                                    else {
23805                                            query.append(_ORDER_BY_ENTITY_TABLE);
23806                                    }
23807    
23808                                    query.append(orderByFields[i]);
23809    
23810                                    if ((i + 1) < orderByFields.length) {
23811                                            if (orderByComparator.isAscending() ^ previous) {
23812                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
23813                                            }
23814                                            else {
23815                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
23816                                            }
23817                                    }
23818                                    else {
23819                                            if (orderByComparator.isAscending() ^ previous) {
23820                                                    query.append(ORDER_BY_ASC);
23821                                            }
23822                                            else {
23823                                                    query.append(ORDER_BY_DESC);
23824                                            }
23825                                    }
23826                            }
23827                    }
23828                    else {
23829                            if (getDB().isSupportsInlineDistinct()) {
23830                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23831                            }
23832                            else {
23833                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
23834                            }
23835                    }
23836    
23837                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23838                                    JournalArticle.class.getName(),
23839                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23840    
23841                    SQLQuery q = session.createSQLQuery(sql);
23842    
23843                    q.setFirstResult(0);
23844                    q.setMaxResults(2);
23845    
23846                    if (getDB().isSupportsInlineDistinct()) {
23847                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
23848                    }
23849                    else {
23850                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
23851                    }
23852    
23853                    QueryPos qPos = QueryPos.getInstance(q);
23854    
23855                    qPos.add(groupId);
23856    
23857                    qPos.add(classNameId);
23858    
23859                    qPos.add(classPK);
23860    
23861                    if (orderByComparator != null) {
23862                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
23863    
23864                            for (Object value : values) {
23865                                    qPos.add(value);
23866                            }
23867                    }
23868    
23869                    List<JournalArticle> list = q.list();
23870    
23871                    if (list.size() == 2) {
23872                            return list.get(1);
23873                    }
23874                    else {
23875                            return null;
23876                    }
23877            }
23878    
23879            /**
23880             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
23881             *
23882             * @param groupId the group ID
23883             * @param classNameId the class name ID
23884             * @param classPK the class p k
23885             * @throws SystemException if a system exception occurred
23886             */
23887            @Override
23888            public void removeByG_C_C(long groupId, long classNameId, long classPK)
23889                    throws SystemException {
23890                    for (JournalArticle journalArticle : findByG_C_C(groupId, classNameId,
23891                                    classPK, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
23892                            remove(journalArticle);
23893                    }
23894            }
23895    
23896            /**
23897             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
23898             *
23899             * @param groupId the group ID
23900             * @param classNameId the class name ID
23901             * @param classPK the class p k
23902             * @return the number of matching journal articles
23903             * @throws SystemException if a system exception occurred
23904             */
23905            @Override
23906            public int countByG_C_C(long groupId, long classNameId, long classPK)
23907                    throws SystemException {
23908                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_C;
23909    
23910                    Object[] finderArgs = new Object[] { groupId, classNameId, classPK };
23911    
23912                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
23913                                    this);
23914    
23915                    if (count == null) {
23916                            StringBundler query = new StringBundler(4);
23917    
23918                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
23919    
23920                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
23921    
23922                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
23923    
23924                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
23925    
23926                            String sql = query.toString();
23927    
23928                            Session session = null;
23929    
23930                            try {
23931                                    session = openSession();
23932    
23933                                    Query q = session.createQuery(sql);
23934    
23935                                    QueryPos qPos = QueryPos.getInstance(q);
23936    
23937                                    qPos.add(groupId);
23938    
23939                                    qPos.add(classNameId);
23940    
23941                                    qPos.add(classPK);
23942    
23943                                    count = (Long)q.uniqueResult();
23944    
23945                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
23946                            }
23947                            catch (Exception e) {
23948                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
23949    
23950                                    throw processException(e);
23951                            }
23952                            finally {
23953                                    closeSession(session);
23954                            }
23955                    }
23956    
23957                    return count.intValue();
23958            }
23959    
23960            /**
23961             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
23962             *
23963             * @param groupId the group ID
23964             * @param classNameId the class name ID
23965             * @param classPK the class p k
23966             * @return the number of matching journal articles that the user has permission to view
23967             * @throws SystemException if a system exception occurred
23968             */
23969            @Override
23970            public int filterCountByG_C_C(long groupId, long classNameId, long classPK)
23971                    throws SystemException {
23972                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23973                            return countByG_C_C(groupId, classNameId, classPK);
23974                    }
23975    
23976                    StringBundler query = new StringBundler(4);
23977    
23978                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
23979    
23980                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
23981    
23982                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
23983    
23984                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
23985    
23986                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23987                                    JournalArticle.class.getName(),
23988                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23989    
23990                    Session session = null;
23991    
23992                    try {
23993                            session = openSession();
23994    
23995                            SQLQuery q = session.createSQLQuery(sql);
23996    
23997                            q.addScalar(COUNT_COLUMN_NAME,
23998                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
23999    
24000                            QueryPos qPos = QueryPos.getInstance(q);
24001    
24002                            qPos.add(groupId);
24003    
24004                            qPos.add(classNameId);
24005    
24006                            qPos.add(classPK);
24007    
24008                            Long count = (Long)q.uniqueResult();
24009    
24010                            return count.intValue();
24011                    }
24012                    catch (Exception e) {
24013                            throw processException(e);
24014                    }
24015                    finally {
24016                            closeSession(session);
24017                    }
24018            }
24019    
24020            private static final String _FINDER_COLUMN_G_C_C_GROUPID_2 = "journalArticle.groupId = ? AND ";
24021            private static final String _FINDER_COLUMN_G_C_C_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
24022            private static final String _FINDER_COLUMN_G_C_C_CLASSPK_2 = "journalArticle.classPK = ?";
24023            public static final FinderPath FINDER_PATH_FETCH_BY_G_C_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24024                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
24025                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_C_S",
24026                            new String[] {
24027                                    Long.class.getName(), Long.class.getName(),
24028                                    String.class.getName()
24029                            },
24030                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
24031                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
24032                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK);
24033            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24034                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
24035                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_S",
24036                            new String[] {
24037                                    Long.class.getName(), Long.class.getName(),
24038                                    String.class.getName()
24039                            });
24040    
24041            /**
24042             * 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.
24043             *
24044             * @param groupId the group ID
24045             * @param classNameId the class name ID
24046             * @param structureId the structure ID
24047             * @return the matching journal article
24048             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
24049             * @throws SystemException if a system exception occurred
24050             */
24051            @Override
24052            public JournalArticle findByG_C_S(long groupId, long classNameId,
24053                    String structureId) throws NoSuchArticleException, SystemException {
24054                    JournalArticle journalArticle = fetchByG_C_S(groupId, classNameId,
24055                                    structureId);
24056    
24057                    if (journalArticle == null) {
24058                            StringBundler msg = new StringBundler(8);
24059    
24060                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
24061    
24062                            msg.append("groupId=");
24063                            msg.append(groupId);
24064    
24065                            msg.append(", classNameId=");
24066                            msg.append(classNameId);
24067    
24068                            msg.append(", structureId=");
24069                            msg.append(structureId);
24070    
24071                            msg.append(StringPool.CLOSE_CURLY_BRACE);
24072    
24073                            if (_log.isWarnEnabled()) {
24074                                    _log.warn(msg.toString());
24075                            }
24076    
24077                            throw new NoSuchArticleException(msg.toString());
24078                    }
24079    
24080                    return journalArticle;
24081            }
24082    
24083            /**
24084             * 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.
24085             *
24086             * @param groupId the group ID
24087             * @param classNameId the class name ID
24088             * @param structureId the structure ID
24089             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
24090             * @throws SystemException if a system exception occurred
24091             */
24092            @Override
24093            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
24094                    String structureId) throws SystemException {
24095                    return fetchByG_C_S(groupId, classNameId, structureId, true);
24096            }
24097    
24098            /**
24099             * 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.
24100             *
24101             * @param groupId the group ID
24102             * @param classNameId the class name ID
24103             * @param structureId the structure ID
24104             * @param retrieveFromCache whether to use the finder cache
24105             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
24106             * @throws SystemException if a system exception occurred
24107             */
24108            @Override
24109            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
24110                    String structureId, boolean retrieveFromCache)
24111                    throws SystemException {
24112                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
24113    
24114                    Object result = null;
24115    
24116                    if (retrieveFromCache) {
24117                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_C_S,
24118                                            finderArgs, this);
24119                    }
24120    
24121                    if (result instanceof JournalArticle) {
24122                            JournalArticle journalArticle = (JournalArticle)result;
24123    
24124                            if ((groupId != journalArticle.getGroupId()) ||
24125                                            (classNameId != journalArticle.getClassNameId()) ||
24126                                            !Validator.equals(structureId,
24127                                                    journalArticle.getStructureId())) {
24128                                    result = null;
24129                            }
24130                    }
24131    
24132                    if (result == null) {
24133                            StringBundler query = new StringBundler(5);
24134    
24135                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
24136    
24137                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
24138    
24139                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
24140    
24141                            boolean bindStructureId = false;
24142    
24143                            if (structureId == null) {
24144                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
24145                            }
24146                            else if (structureId.equals(StringPool.BLANK)) {
24147                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
24148                            }
24149                            else {
24150                                    bindStructureId = true;
24151    
24152                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
24153                            }
24154    
24155                            String sql = query.toString();
24156    
24157                            Session session = null;
24158    
24159                            try {
24160                                    session = openSession();
24161    
24162                                    Query q = session.createQuery(sql);
24163    
24164                                    QueryPos qPos = QueryPos.getInstance(q);
24165    
24166                                    qPos.add(groupId);
24167    
24168                                    qPos.add(classNameId);
24169    
24170                                    if (bindStructureId) {
24171                                            qPos.add(structureId);
24172                                    }
24173    
24174                                    List<JournalArticle> list = q.list();
24175    
24176                                    if (list.isEmpty()) {
24177                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
24178                                                    finderArgs, list);
24179                                    }
24180                                    else {
24181                                            if ((list.size() > 1) && _log.isWarnEnabled()) {
24182                                                    _log.warn(
24183                                                            "JournalArticlePersistenceImpl.fetchByG_C_S(long, long, String, boolean) with parameters (" +
24184                                                            StringUtil.merge(finderArgs) +
24185                                                            ") 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.");
24186                                            }
24187    
24188                                            JournalArticle journalArticle = list.get(0);
24189    
24190                                            result = journalArticle;
24191    
24192                                            cacheResult(journalArticle);
24193    
24194                                            if ((journalArticle.getGroupId() != groupId) ||
24195                                                            (journalArticle.getClassNameId() != classNameId) ||
24196                                                            (journalArticle.getStructureId() == null) ||
24197                                                            !journalArticle.getStructureId().equals(structureId)) {
24198                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
24199                                                            finderArgs, journalArticle);
24200                                            }
24201                                    }
24202                            }
24203                            catch (Exception e) {
24204                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S,
24205                                            finderArgs);
24206    
24207                                    throw processException(e);
24208                            }
24209                            finally {
24210                                    closeSession(session);
24211                            }
24212                    }
24213    
24214                    if (result instanceof List<?>) {
24215                            return null;
24216                    }
24217                    else {
24218                            return (JournalArticle)result;
24219                    }
24220            }
24221    
24222            /**
24223             * Removes the journal article where groupId = &#63; and classNameId = &#63; and structureId = &#63; from the database.
24224             *
24225             * @param groupId the group ID
24226             * @param classNameId the class name ID
24227             * @param structureId the structure ID
24228             * @return the journal article that was removed
24229             * @throws SystemException if a system exception occurred
24230             */
24231            @Override
24232            public JournalArticle removeByG_C_S(long groupId, long classNameId,
24233                    String structureId) throws NoSuchArticleException, SystemException {
24234                    JournalArticle journalArticle = findByG_C_S(groupId, classNameId,
24235                                    structureId);
24236    
24237                    return remove(journalArticle);
24238            }
24239    
24240            /**
24241             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and structureId = &#63;.
24242             *
24243             * @param groupId the group ID
24244             * @param classNameId the class name ID
24245             * @param structureId the structure ID
24246             * @return the number of matching journal articles
24247             * @throws SystemException if a system exception occurred
24248             */
24249            @Override
24250            public int countByG_C_S(long groupId, long classNameId, String structureId)
24251                    throws SystemException {
24252                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_S;
24253    
24254                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
24255    
24256                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
24257                                    this);
24258    
24259                    if (count == null) {
24260                            StringBundler query = new StringBundler(4);
24261    
24262                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
24263    
24264                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
24265    
24266                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
24267    
24268                            boolean bindStructureId = false;
24269    
24270                            if (structureId == null) {
24271                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
24272                            }
24273                            else if (structureId.equals(StringPool.BLANK)) {
24274                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
24275                            }
24276                            else {
24277                                    bindStructureId = true;
24278    
24279                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
24280                            }
24281    
24282                            String sql = query.toString();
24283    
24284                            Session session = null;
24285    
24286                            try {
24287                                    session = openSession();
24288    
24289                                    Query q = session.createQuery(sql);
24290    
24291                                    QueryPos qPos = QueryPos.getInstance(q);
24292    
24293                                    qPos.add(groupId);
24294    
24295                                    qPos.add(classNameId);
24296    
24297                                    if (bindStructureId) {
24298                                            qPos.add(structureId);
24299                                    }
24300    
24301                                    count = (Long)q.uniqueResult();
24302    
24303                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
24304                            }
24305                            catch (Exception e) {
24306                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
24307    
24308                                    throw processException(e);
24309                            }
24310                            finally {
24311                                    closeSession(session);
24312                            }
24313                    }
24314    
24315                    return count.intValue();
24316            }
24317    
24318            private static final String _FINDER_COLUMN_G_C_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
24319            private static final String _FINDER_COLUMN_G_C_S_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
24320            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
24321            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
24322            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = '')";
24323            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24324                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
24325                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
24326                            "findByG_C_T",
24327                            new String[] {
24328                                    Long.class.getName(), Long.class.getName(),
24329                                    String.class.getName(),
24330                                    
24331                            Integer.class.getName(), Integer.class.getName(),
24332                                    OrderByComparator.class.getName()
24333                            });
24334            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24335                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
24336                            JournalArticleImpl.class,
24337                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_T",
24338                            new String[] {
24339                                    Long.class.getName(), Long.class.getName(),
24340                                    String.class.getName()
24341                            },
24342                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
24343                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
24344                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
24345                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
24346                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
24347            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24348                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
24349                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_T",
24350                            new String[] {
24351                                    Long.class.getName(), Long.class.getName(),
24352                                    String.class.getName()
24353                            });
24354    
24355            /**
24356             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
24357             *
24358             * @param groupId the group ID
24359             * @param classNameId the class name ID
24360             * @param templateId the template ID
24361             * @return the matching journal articles
24362             * @throws SystemException if a system exception occurred
24363             */
24364            @Override
24365            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
24366                    String templateId) throws SystemException {
24367                    return findByG_C_T(groupId, classNameId, templateId, QueryUtil.ALL_POS,
24368                            QueryUtil.ALL_POS, null);
24369            }
24370    
24371            /**
24372             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
24373             *
24374             * <p>
24375             * 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.
24376             * </p>
24377             *
24378             * @param groupId the group ID
24379             * @param classNameId the class name ID
24380             * @param templateId the template ID
24381             * @param start the lower bound of the range of journal articles
24382             * @param end the upper bound of the range of journal articles (not inclusive)
24383             * @return the range of matching journal articles
24384             * @throws SystemException if a system exception occurred
24385             */
24386            @Override
24387            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
24388                    String templateId, int start, int end) throws SystemException {
24389                    return findByG_C_T(groupId, classNameId, templateId, start, end, null);
24390            }
24391    
24392            /**
24393             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
24394             *
24395             * <p>
24396             * 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.
24397             * </p>
24398             *
24399             * @param groupId the group ID
24400             * @param classNameId the class name ID
24401             * @param templateId the template ID
24402             * @param start the lower bound of the range of journal articles
24403             * @param end the upper bound of the range of journal articles (not inclusive)
24404             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
24405             * @return the ordered range of matching journal articles
24406             * @throws SystemException if a system exception occurred
24407             */
24408            @Override
24409            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
24410                    String templateId, int start, int end,
24411                    OrderByComparator orderByComparator) throws SystemException {
24412                    boolean pagination = true;
24413                    FinderPath finderPath = null;
24414                    Object[] finderArgs = null;
24415    
24416                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
24417                                    (orderByComparator == null)) {
24418                            pagination = false;
24419                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T;
24420                            finderArgs = new Object[] { groupId, classNameId, templateId };
24421                    }
24422                    else {
24423                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T;
24424                            finderArgs = new Object[] {
24425                                            groupId, classNameId, templateId,
24426                                            
24427                                            start, end, orderByComparator
24428                                    };
24429                    }
24430    
24431                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
24432                                    finderArgs, this);
24433    
24434                    if ((list != null) && !list.isEmpty()) {
24435                            for (JournalArticle journalArticle : list) {
24436                                    if ((groupId != journalArticle.getGroupId()) ||
24437                                                    (classNameId != journalArticle.getClassNameId()) ||
24438                                                    !Validator.equals(templateId,
24439                                                            journalArticle.getTemplateId())) {
24440                                            list = null;
24441    
24442                                            break;
24443                                    }
24444                            }
24445                    }
24446    
24447                    if (list == null) {
24448                            StringBundler query = null;
24449    
24450                            if (orderByComparator != null) {
24451                                    query = new StringBundler(5 +
24452                                                    (orderByComparator.getOrderByFields().length * 3));
24453                            }
24454                            else {
24455                                    query = new StringBundler(5);
24456                            }
24457    
24458                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
24459    
24460                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
24461    
24462                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
24463    
24464                            boolean bindTemplateId = false;
24465    
24466                            if (templateId == null) {
24467                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
24468                            }
24469                            else if (templateId.equals(StringPool.BLANK)) {
24470                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
24471                            }
24472                            else {
24473                                    bindTemplateId = true;
24474    
24475                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
24476                            }
24477    
24478                            if (orderByComparator != null) {
24479                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
24480                                            orderByComparator);
24481                            }
24482                            else
24483                             if (pagination) {
24484                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24485                            }
24486    
24487                            String sql = query.toString();
24488    
24489                            Session session = null;
24490    
24491                            try {
24492                                    session = openSession();
24493    
24494                                    Query q = session.createQuery(sql);
24495    
24496                                    QueryPos qPos = QueryPos.getInstance(q);
24497    
24498                                    qPos.add(groupId);
24499    
24500                                    qPos.add(classNameId);
24501    
24502                                    if (bindTemplateId) {
24503                                            qPos.add(templateId);
24504                                    }
24505    
24506                                    if (!pagination) {
24507                                            list = (List<JournalArticle>)QueryUtil.list(q,
24508                                                            getDialect(), start, end, false);
24509    
24510                                            Collections.sort(list);
24511    
24512                                            list = new UnmodifiableList<JournalArticle>(list);
24513                                    }
24514                                    else {
24515                                            list = (List<JournalArticle>)QueryUtil.list(q,
24516                                                            getDialect(), start, end);
24517                                    }
24518    
24519                                    cacheResult(list);
24520    
24521                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
24522                            }
24523                            catch (Exception e) {
24524                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
24525    
24526                                    throw processException(e);
24527                            }
24528                            finally {
24529                                    closeSession(session);
24530                            }
24531                    }
24532    
24533                    return list;
24534            }
24535    
24536            /**
24537             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
24538             *
24539             * @param groupId the group ID
24540             * @param classNameId the class name ID
24541             * @param templateId the template ID
24542             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24543             * @return the first matching journal article
24544             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
24545             * @throws SystemException if a system exception occurred
24546             */
24547            @Override
24548            public JournalArticle findByG_C_T_First(long groupId, long classNameId,
24549                    String templateId, OrderByComparator orderByComparator)
24550                    throws NoSuchArticleException, SystemException {
24551                    JournalArticle journalArticle = fetchByG_C_T_First(groupId,
24552                                    classNameId, templateId, orderByComparator);
24553    
24554                    if (journalArticle != null) {
24555                            return journalArticle;
24556                    }
24557    
24558                    StringBundler msg = new StringBundler(8);
24559    
24560                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
24561    
24562                    msg.append("groupId=");
24563                    msg.append(groupId);
24564    
24565                    msg.append(", classNameId=");
24566                    msg.append(classNameId);
24567    
24568                    msg.append(", templateId=");
24569                    msg.append(templateId);
24570    
24571                    msg.append(StringPool.CLOSE_CURLY_BRACE);
24572    
24573                    throw new NoSuchArticleException(msg.toString());
24574            }
24575    
24576            /**
24577             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
24578             *
24579             * @param groupId the group ID
24580             * @param classNameId the class name ID
24581             * @param templateId the template ID
24582             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24583             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
24584             * @throws SystemException if a system exception occurred
24585             */
24586            @Override
24587            public JournalArticle fetchByG_C_T_First(long groupId, long classNameId,
24588                    String templateId, OrderByComparator orderByComparator)
24589                    throws SystemException {
24590                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
24591                                    templateId, 0, 1, orderByComparator);
24592    
24593                    if (!list.isEmpty()) {
24594                            return list.get(0);
24595                    }
24596    
24597                    return null;
24598            }
24599    
24600            /**
24601             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
24602             *
24603             * @param groupId the group ID
24604             * @param classNameId the class name ID
24605             * @param templateId the template ID
24606             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24607             * @return the last matching journal article
24608             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
24609             * @throws SystemException if a system exception occurred
24610             */
24611            @Override
24612            public JournalArticle findByG_C_T_Last(long groupId, long classNameId,
24613                    String templateId, OrderByComparator orderByComparator)
24614                    throws NoSuchArticleException, SystemException {
24615                    JournalArticle journalArticle = fetchByG_C_T_Last(groupId, classNameId,
24616                                    templateId, orderByComparator);
24617    
24618                    if (journalArticle != null) {
24619                            return journalArticle;
24620                    }
24621    
24622                    StringBundler msg = new StringBundler(8);
24623    
24624                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
24625    
24626                    msg.append("groupId=");
24627                    msg.append(groupId);
24628    
24629                    msg.append(", classNameId=");
24630                    msg.append(classNameId);
24631    
24632                    msg.append(", templateId=");
24633                    msg.append(templateId);
24634    
24635                    msg.append(StringPool.CLOSE_CURLY_BRACE);
24636    
24637                    throw new NoSuchArticleException(msg.toString());
24638            }
24639    
24640            /**
24641             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
24642             *
24643             * @param groupId the group ID
24644             * @param classNameId the class name ID
24645             * @param templateId the template ID
24646             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24647             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
24648             * @throws SystemException if a system exception occurred
24649             */
24650            @Override
24651            public JournalArticle fetchByG_C_T_Last(long groupId, long classNameId,
24652                    String templateId, OrderByComparator orderByComparator)
24653                    throws SystemException {
24654                    int count = countByG_C_T(groupId, classNameId, templateId);
24655    
24656                    if (count == 0) {
24657                            return null;
24658                    }
24659    
24660                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
24661                                    templateId, count - 1, count, orderByComparator);
24662    
24663                    if (!list.isEmpty()) {
24664                            return list.get(0);
24665                    }
24666    
24667                    return null;
24668            }
24669    
24670            /**
24671             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
24672             *
24673             * @param id the primary key of the current journal article
24674             * @param groupId the group ID
24675             * @param classNameId the class name ID
24676             * @param templateId the template ID
24677             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24678             * @return the previous, current, and next journal article
24679             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
24680             * @throws SystemException if a system exception occurred
24681             */
24682            @Override
24683            public JournalArticle[] findByG_C_T_PrevAndNext(long id, long groupId,
24684                    long classNameId, String templateId, OrderByComparator orderByComparator)
24685                    throws NoSuchArticleException, SystemException {
24686                    JournalArticle journalArticle = findByPrimaryKey(id);
24687    
24688                    Session session = null;
24689    
24690                    try {
24691                            session = openSession();
24692    
24693                            JournalArticle[] array = new JournalArticleImpl[3];
24694    
24695                            array[0] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
24696                                            classNameId, templateId, orderByComparator, true);
24697    
24698                            array[1] = journalArticle;
24699    
24700                            array[2] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
24701                                            classNameId, templateId, orderByComparator, false);
24702    
24703                            return array;
24704                    }
24705                    catch (Exception e) {
24706                            throw processException(e);
24707                    }
24708                    finally {
24709                            closeSession(session);
24710                    }
24711            }
24712    
24713            protected JournalArticle getByG_C_T_PrevAndNext(Session session,
24714                    JournalArticle journalArticle, long groupId, long classNameId,
24715                    String templateId, OrderByComparator orderByComparator, boolean previous) {
24716                    StringBundler query = null;
24717    
24718                    if (orderByComparator != null) {
24719                            query = new StringBundler(6 +
24720                                            (orderByComparator.getOrderByFields().length * 6));
24721                    }
24722                    else {
24723                            query = new StringBundler(3);
24724                    }
24725    
24726                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
24727    
24728                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
24729    
24730                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
24731    
24732                    boolean bindTemplateId = false;
24733    
24734                    if (templateId == null) {
24735                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
24736                    }
24737                    else if (templateId.equals(StringPool.BLANK)) {
24738                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
24739                    }
24740                    else {
24741                            bindTemplateId = true;
24742    
24743                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
24744                    }
24745    
24746                    if (orderByComparator != null) {
24747                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
24748    
24749                            if (orderByConditionFields.length > 0) {
24750                                    query.append(WHERE_AND);
24751                            }
24752    
24753                            for (int i = 0; i < orderByConditionFields.length; i++) {
24754                                    query.append(_ORDER_BY_ENTITY_ALIAS);
24755                                    query.append(orderByConditionFields[i]);
24756    
24757                                    if ((i + 1) < orderByConditionFields.length) {
24758                                            if (orderByComparator.isAscending() ^ previous) {
24759                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
24760                                            }
24761                                            else {
24762                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
24763                                            }
24764                                    }
24765                                    else {
24766                                            if (orderByComparator.isAscending() ^ previous) {
24767                                                    query.append(WHERE_GREATER_THAN);
24768                                            }
24769                                            else {
24770                                                    query.append(WHERE_LESSER_THAN);
24771                                            }
24772                                    }
24773                            }
24774    
24775                            query.append(ORDER_BY_CLAUSE);
24776    
24777                            String[] orderByFields = orderByComparator.getOrderByFields();
24778    
24779                            for (int i = 0; i < orderByFields.length; i++) {
24780                                    query.append(_ORDER_BY_ENTITY_ALIAS);
24781                                    query.append(orderByFields[i]);
24782    
24783                                    if ((i + 1) < orderByFields.length) {
24784                                            if (orderByComparator.isAscending() ^ previous) {
24785                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
24786                                            }
24787                                            else {
24788                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
24789                                            }
24790                                    }
24791                                    else {
24792                                            if (orderByComparator.isAscending() ^ previous) {
24793                                                    query.append(ORDER_BY_ASC);
24794                                            }
24795                                            else {
24796                                                    query.append(ORDER_BY_DESC);
24797                                            }
24798                                    }
24799                            }
24800                    }
24801                    else {
24802                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24803                    }
24804    
24805                    String sql = query.toString();
24806    
24807                    Query q = session.createQuery(sql);
24808    
24809                    q.setFirstResult(0);
24810                    q.setMaxResults(2);
24811    
24812                    QueryPos qPos = QueryPos.getInstance(q);
24813    
24814                    qPos.add(groupId);
24815    
24816                    qPos.add(classNameId);
24817    
24818                    if (bindTemplateId) {
24819                            qPos.add(templateId);
24820                    }
24821    
24822                    if (orderByComparator != null) {
24823                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
24824    
24825                            for (Object value : values) {
24826                                    qPos.add(value);
24827                            }
24828                    }
24829    
24830                    List<JournalArticle> list = q.list();
24831    
24832                    if (list.size() == 2) {
24833                            return list.get(1);
24834                    }
24835                    else {
24836                            return null;
24837                    }
24838            }
24839    
24840            /**
24841             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
24842             *
24843             * @param groupId the group ID
24844             * @param classNameId the class name ID
24845             * @param templateId the template ID
24846             * @return the matching journal articles that the user has permission to view
24847             * @throws SystemException if a system exception occurred
24848             */
24849            @Override
24850            public List<JournalArticle> filterFindByG_C_T(long groupId,
24851                    long classNameId, String templateId) throws SystemException {
24852                    return filterFindByG_C_T(groupId, classNameId, templateId,
24853                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
24854            }
24855    
24856            /**
24857             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
24858             *
24859             * <p>
24860             * 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.
24861             * </p>
24862             *
24863             * @param groupId the group ID
24864             * @param classNameId the class name ID
24865             * @param templateId the template ID
24866             * @param start the lower bound of the range of journal articles
24867             * @param end the upper bound of the range of journal articles (not inclusive)
24868             * @return the range of matching journal articles that the user has permission to view
24869             * @throws SystemException if a system exception occurred
24870             */
24871            @Override
24872            public List<JournalArticle> filterFindByG_C_T(long groupId,
24873                    long classNameId, String templateId, int start, int end)
24874                    throws SystemException {
24875                    return filterFindByG_C_T(groupId, classNameId, templateId, start, end,
24876                            null);
24877            }
24878    
24879            /**
24880             * 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;.
24881             *
24882             * <p>
24883             * 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.
24884             * </p>
24885             *
24886             * @param groupId the group ID
24887             * @param classNameId the class name ID
24888             * @param templateId the template ID
24889             * @param start the lower bound of the range of journal articles
24890             * @param end the upper bound of the range of journal articles (not inclusive)
24891             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
24892             * @return the ordered range of matching journal articles that the user has permission to view
24893             * @throws SystemException if a system exception occurred
24894             */
24895            @Override
24896            public List<JournalArticle> filterFindByG_C_T(long groupId,
24897                    long classNameId, String templateId, int start, int end,
24898                    OrderByComparator orderByComparator) throws SystemException {
24899                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
24900                            return findByG_C_T(groupId, classNameId, templateId, start, end,
24901                                    orderByComparator);
24902                    }
24903    
24904                    StringBundler query = null;
24905    
24906                    if (orderByComparator != null) {
24907                            query = new StringBundler(5 +
24908                                            (orderByComparator.getOrderByFields().length * 3));
24909                    }
24910                    else {
24911                            query = new StringBundler(5);
24912                    }
24913    
24914                    if (getDB().isSupportsInlineDistinct()) {
24915                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
24916                    }
24917                    else {
24918                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
24919                    }
24920    
24921                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
24922    
24923                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
24924    
24925                    boolean bindTemplateId = false;
24926    
24927                    if (templateId == null) {
24928                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
24929                    }
24930                    else if (templateId.equals(StringPool.BLANK)) {
24931                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
24932                    }
24933                    else {
24934                            bindTemplateId = true;
24935    
24936                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
24937                    }
24938    
24939                    if (!getDB().isSupportsInlineDistinct()) {
24940                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
24941                    }
24942    
24943                    if (orderByComparator != null) {
24944                            if (getDB().isSupportsInlineDistinct()) {
24945                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
24946                                            orderByComparator, true);
24947                            }
24948                            else {
24949                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
24950                                            orderByComparator, true);
24951                            }
24952                    }
24953                    else {
24954                            if (getDB().isSupportsInlineDistinct()) {
24955                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24956                            }
24957                            else {
24958                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
24959                            }
24960                    }
24961    
24962                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
24963                                    JournalArticle.class.getName(),
24964                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
24965    
24966                    Session session = null;
24967    
24968                    try {
24969                            session = openSession();
24970    
24971                            SQLQuery q = session.createSQLQuery(sql);
24972    
24973                            if (getDB().isSupportsInlineDistinct()) {
24974                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
24975                            }
24976                            else {
24977                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
24978                            }
24979    
24980                            QueryPos qPos = QueryPos.getInstance(q);
24981    
24982                            qPos.add(groupId);
24983    
24984                            qPos.add(classNameId);
24985    
24986                            if (bindTemplateId) {
24987                                    qPos.add(templateId);
24988                            }
24989    
24990                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
24991                                    end);
24992                    }
24993                    catch (Exception e) {
24994                            throw processException(e);
24995                    }
24996                    finally {
24997                            closeSession(session);
24998                    }
24999            }
25000    
25001            /**
25002             * 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;.
25003             *
25004             * @param id the primary key of the current journal article
25005             * @param groupId the group ID
25006             * @param classNameId the class name ID
25007             * @param templateId the template ID
25008             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25009             * @return the previous, current, and next journal article
25010             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
25011             * @throws SystemException if a system exception occurred
25012             */
25013            @Override
25014            public JournalArticle[] filterFindByG_C_T_PrevAndNext(long id,
25015                    long groupId, long classNameId, String templateId,
25016                    OrderByComparator orderByComparator)
25017                    throws NoSuchArticleException, SystemException {
25018                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
25019                            return findByG_C_T_PrevAndNext(id, groupId, classNameId,
25020                                    templateId, orderByComparator);
25021                    }
25022    
25023                    JournalArticle journalArticle = findByPrimaryKey(id);
25024    
25025                    Session session = null;
25026    
25027                    try {
25028                            session = openSession();
25029    
25030                            JournalArticle[] array = new JournalArticleImpl[3];
25031    
25032                            array[0] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
25033                                            groupId, classNameId, templateId, orderByComparator, true);
25034    
25035                            array[1] = journalArticle;
25036    
25037                            array[2] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
25038                                            groupId, classNameId, templateId, orderByComparator, false);
25039    
25040                            return array;
25041                    }
25042                    catch (Exception e) {
25043                            throw processException(e);
25044                    }
25045                    finally {
25046                            closeSession(session);
25047                    }
25048            }
25049    
25050            protected JournalArticle filterGetByG_C_T_PrevAndNext(Session session,
25051                    JournalArticle journalArticle, long groupId, long classNameId,
25052                    String templateId, OrderByComparator orderByComparator, boolean previous) {
25053                    StringBundler query = null;
25054    
25055                    if (orderByComparator != null) {
25056                            query = new StringBundler(6 +
25057                                            (orderByComparator.getOrderByFields().length * 6));
25058                    }
25059                    else {
25060                            query = new StringBundler(3);
25061                    }
25062    
25063                    if (getDB().isSupportsInlineDistinct()) {
25064                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
25065                    }
25066                    else {
25067                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
25068                    }
25069    
25070                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
25071    
25072                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
25073    
25074                    boolean bindTemplateId = false;
25075    
25076                    if (templateId == null) {
25077                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
25078                    }
25079                    else if (templateId.equals(StringPool.BLANK)) {
25080                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
25081                    }
25082                    else {
25083                            bindTemplateId = true;
25084    
25085                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
25086                    }
25087    
25088                    if (!getDB().isSupportsInlineDistinct()) {
25089                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
25090                    }
25091    
25092                    if (orderByComparator != null) {
25093                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
25094    
25095                            if (orderByConditionFields.length > 0) {
25096                                    query.append(WHERE_AND);
25097                            }
25098    
25099                            for (int i = 0; i < orderByConditionFields.length; i++) {
25100                                    if (getDB().isSupportsInlineDistinct()) {
25101                                            query.append(_ORDER_BY_ENTITY_ALIAS);
25102                                    }
25103                                    else {
25104                                            query.append(_ORDER_BY_ENTITY_TABLE);
25105                                    }
25106    
25107                                    query.append(orderByConditionFields[i]);
25108    
25109                                    if ((i + 1) < orderByConditionFields.length) {
25110                                            if (orderByComparator.isAscending() ^ previous) {
25111                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
25112                                            }
25113                                            else {
25114                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
25115                                            }
25116                                    }
25117                                    else {
25118                                            if (orderByComparator.isAscending() ^ previous) {
25119                                                    query.append(WHERE_GREATER_THAN);
25120                                            }
25121                                            else {
25122                                                    query.append(WHERE_LESSER_THAN);
25123                                            }
25124                                    }
25125                            }
25126    
25127                            query.append(ORDER_BY_CLAUSE);
25128    
25129                            String[] orderByFields = orderByComparator.getOrderByFields();
25130    
25131                            for (int i = 0; i < orderByFields.length; i++) {
25132                                    if (getDB().isSupportsInlineDistinct()) {
25133                                            query.append(_ORDER_BY_ENTITY_ALIAS);
25134                                    }
25135                                    else {
25136                                            query.append(_ORDER_BY_ENTITY_TABLE);
25137                                    }
25138    
25139                                    query.append(orderByFields[i]);
25140    
25141                                    if ((i + 1) < orderByFields.length) {
25142                                            if (orderByComparator.isAscending() ^ previous) {
25143                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
25144                                            }
25145                                            else {
25146                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
25147                                            }
25148                                    }
25149                                    else {
25150                                            if (orderByComparator.isAscending() ^ previous) {
25151                                                    query.append(ORDER_BY_ASC);
25152                                            }
25153                                            else {
25154                                                    query.append(ORDER_BY_DESC);
25155                                            }
25156                                    }
25157                            }
25158                    }
25159                    else {
25160                            if (getDB().isSupportsInlineDistinct()) {
25161                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
25162                            }
25163                            else {
25164                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
25165                            }
25166                    }
25167    
25168                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
25169                                    JournalArticle.class.getName(),
25170                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
25171    
25172                    SQLQuery q = session.createSQLQuery(sql);
25173    
25174                    q.setFirstResult(0);
25175                    q.setMaxResults(2);
25176    
25177                    if (getDB().isSupportsInlineDistinct()) {
25178                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
25179                    }
25180                    else {
25181                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
25182                    }
25183    
25184                    QueryPos qPos = QueryPos.getInstance(q);
25185    
25186                    qPos.add(groupId);
25187    
25188                    qPos.add(classNameId);
25189    
25190                    if (bindTemplateId) {
25191                            qPos.add(templateId);
25192                    }
25193    
25194                    if (orderByComparator != null) {
25195                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
25196    
25197                            for (Object value : values) {
25198                                    qPos.add(value);
25199                            }
25200                    }
25201    
25202                    List<JournalArticle> list = q.list();
25203    
25204                    if (list.size() == 2) {
25205                            return list.get(1);
25206                    }
25207                    else {
25208                            return null;
25209                    }
25210            }
25211    
25212            /**
25213             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63; from the database.
25214             *
25215             * @param groupId the group ID
25216             * @param classNameId the class name ID
25217             * @param templateId the template ID
25218             * @throws SystemException if a system exception occurred
25219             */
25220            @Override
25221            public void removeByG_C_T(long groupId, long classNameId, String templateId)
25222                    throws SystemException {
25223                    for (JournalArticle journalArticle : findByG_C_T(groupId, classNameId,
25224                                    templateId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
25225                            remove(journalArticle);
25226                    }
25227            }
25228    
25229            /**
25230             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
25231             *
25232             * @param groupId the group ID
25233             * @param classNameId the class name ID
25234             * @param templateId the template ID
25235             * @return the number of matching journal articles
25236             * @throws SystemException if a system exception occurred
25237             */
25238            @Override
25239            public int countByG_C_T(long groupId, long classNameId, String templateId)
25240                    throws SystemException {
25241                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_T;
25242    
25243                    Object[] finderArgs = new Object[] { groupId, classNameId, templateId };
25244    
25245                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
25246                                    this);
25247    
25248                    if (count == null) {
25249                            StringBundler query = new StringBundler(4);
25250    
25251                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
25252    
25253                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
25254    
25255                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
25256    
25257                            boolean bindTemplateId = false;
25258    
25259                            if (templateId == null) {
25260                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
25261                            }
25262                            else if (templateId.equals(StringPool.BLANK)) {
25263                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
25264                            }
25265                            else {
25266                                    bindTemplateId = true;
25267    
25268                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
25269                            }
25270    
25271                            String sql = query.toString();
25272    
25273                            Session session = null;
25274    
25275                            try {
25276                                    session = openSession();
25277    
25278                                    Query q = session.createQuery(sql);
25279    
25280                                    QueryPos qPos = QueryPos.getInstance(q);
25281    
25282                                    qPos.add(groupId);
25283    
25284                                    qPos.add(classNameId);
25285    
25286                                    if (bindTemplateId) {
25287                                            qPos.add(templateId);
25288                                    }
25289    
25290                                    count = (Long)q.uniqueResult();
25291    
25292                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
25293                            }
25294                            catch (Exception e) {
25295                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
25296    
25297                                    throw processException(e);
25298                            }
25299                            finally {
25300                                    closeSession(session);
25301                            }
25302                    }
25303    
25304                    return count.intValue();
25305            }
25306    
25307            /**
25308             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
25309             *
25310             * @param groupId the group ID
25311             * @param classNameId the class name ID
25312             * @param templateId the template ID
25313             * @return the number of matching journal articles that the user has permission to view
25314             * @throws SystemException if a system exception occurred
25315             */
25316            @Override
25317            public int filterCountByG_C_T(long groupId, long classNameId,
25318                    String templateId) throws SystemException {
25319                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
25320                            return countByG_C_T(groupId, classNameId, templateId);
25321                    }
25322    
25323                    StringBundler query = new StringBundler(4);
25324    
25325                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
25326    
25327                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
25328    
25329                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
25330    
25331                    boolean bindTemplateId = false;
25332    
25333                    if (templateId == null) {
25334                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
25335                    }
25336                    else if (templateId.equals(StringPool.BLANK)) {
25337                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
25338                    }
25339                    else {
25340                            bindTemplateId = true;
25341    
25342                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
25343                    }
25344    
25345                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
25346                                    JournalArticle.class.getName(),
25347                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
25348    
25349                    Session session = null;
25350    
25351                    try {
25352                            session = openSession();
25353    
25354                            SQLQuery q = session.createSQLQuery(sql);
25355    
25356                            q.addScalar(COUNT_COLUMN_NAME,
25357                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
25358    
25359                            QueryPos qPos = QueryPos.getInstance(q);
25360    
25361                            qPos.add(groupId);
25362    
25363                            qPos.add(classNameId);
25364    
25365                            if (bindTemplateId) {
25366                                    qPos.add(templateId);
25367                            }
25368    
25369                            Long count = (Long)q.uniqueResult();
25370    
25371                            return count.intValue();
25372                    }
25373                    catch (Exception e) {
25374                            throw processException(e);
25375                    }
25376                    finally {
25377                            closeSession(session);
25378                    }
25379            }
25380    
25381            private static final String _FINDER_COLUMN_G_C_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
25382            private static final String _FINDER_COLUMN_G_C_T_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
25383            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
25384            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
25385            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = '')";
25386            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
25387                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
25388                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
25389                            "findByG_C_L",
25390                            new String[] {
25391                                    Long.class.getName(), Long.class.getName(),
25392                                    String.class.getName(),
25393                                    
25394                            Integer.class.getName(), Integer.class.getName(),
25395                                    OrderByComparator.class.getName()
25396                            });
25397            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
25398                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
25399                            JournalArticleImpl.class,
25400                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_L",
25401                            new String[] {
25402                                    Long.class.getName(), Long.class.getName(),
25403                                    String.class.getName()
25404                            },
25405                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
25406                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
25407                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
25408                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
25409                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
25410            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
25411                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
25412                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_L",
25413                            new String[] {
25414                                    Long.class.getName(), Long.class.getName(),
25415                                    String.class.getName()
25416                            });
25417    
25418            /**
25419             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
25420             *
25421             * @param groupId the group ID
25422             * @param classNameId the class name ID
25423             * @param layoutUuid the layout uuid
25424             * @return the matching journal articles
25425             * @throws SystemException if a system exception occurred
25426             */
25427            @Override
25428            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
25429                    String layoutUuid) throws SystemException {
25430                    return findByG_C_L(groupId, classNameId, layoutUuid, QueryUtil.ALL_POS,
25431                            QueryUtil.ALL_POS, null);
25432            }
25433    
25434            /**
25435             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
25436             *
25437             * <p>
25438             * 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.
25439             * </p>
25440             *
25441             * @param groupId the group ID
25442             * @param classNameId the class name ID
25443             * @param layoutUuid the layout uuid
25444             * @param start the lower bound of the range of journal articles
25445             * @param end the upper bound of the range of journal articles (not inclusive)
25446             * @return the range of matching journal articles
25447             * @throws SystemException if a system exception occurred
25448             */
25449            @Override
25450            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
25451                    String layoutUuid, int start, int end) throws SystemException {
25452                    return findByG_C_L(groupId, classNameId, layoutUuid, start, end, null);
25453            }
25454    
25455            /**
25456             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
25457             *
25458             * <p>
25459             * 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.
25460             * </p>
25461             *
25462             * @param groupId the group ID
25463             * @param classNameId the class name ID
25464             * @param layoutUuid the layout uuid
25465             * @param start the lower bound of the range of journal articles
25466             * @param end the upper bound of the range of journal articles (not inclusive)
25467             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
25468             * @return the ordered range of matching journal articles
25469             * @throws SystemException if a system exception occurred
25470             */
25471            @Override
25472            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
25473                    String layoutUuid, int start, int end,
25474                    OrderByComparator orderByComparator) throws SystemException {
25475                    boolean pagination = true;
25476                    FinderPath finderPath = null;
25477                    Object[] finderArgs = null;
25478    
25479                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
25480                                    (orderByComparator == null)) {
25481                            pagination = false;
25482                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L;
25483                            finderArgs = new Object[] { groupId, classNameId, layoutUuid };
25484                    }
25485                    else {
25486                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L;
25487                            finderArgs = new Object[] {
25488                                            groupId, classNameId, layoutUuid,
25489                                            
25490                                            start, end, orderByComparator
25491                                    };
25492                    }
25493    
25494                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
25495                                    finderArgs, this);
25496    
25497                    if ((list != null) && !list.isEmpty()) {
25498                            for (JournalArticle journalArticle : list) {
25499                                    if ((groupId != journalArticle.getGroupId()) ||
25500                                                    (classNameId != journalArticle.getClassNameId()) ||
25501                                                    !Validator.equals(layoutUuid,
25502                                                            journalArticle.getLayoutUuid())) {
25503                                            list = null;
25504    
25505                                            break;
25506                                    }
25507                            }
25508                    }
25509    
25510                    if (list == null) {
25511                            StringBundler query = null;
25512    
25513                            if (orderByComparator != null) {
25514                                    query = new StringBundler(5 +
25515                                                    (orderByComparator.getOrderByFields().length * 3));
25516                            }
25517                            else {
25518                                    query = new StringBundler(5);
25519                            }
25520    
25521                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
25522    
25523                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
25524    
25525                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
25526    
25527                            boolean bindLayoutUuid = false;
25528    
25529                            if (layoutUuid == null) {
25530                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
25531                            }
25532                            else if (layoutUuid.equals(StringPool.BLANK)) {
25533                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
25534                            }
25535                            else {
25536                                    bindLayoutUuid = true;
25537    
25538                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
25539                            }
25540    
25541                            if (orderByComparator != null) {
25542                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
25543                                            orderByComparator);
25544                            }
25545                            else
25546                             if (pagination) {
25547                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
25548                            }
25549    
25550                            String sql = query.toString();
25551    
25552                            Session session = null;
25553    
25554                            try {
25555                                    session = openSession();
25556    
25557                                    Query q = session.createQuery(sql);
25558    
25559                                    QueryPos qPos = QueryPos.getInstance(q);
25560    
25561                                    qPos.add(groupId);
25562    
25563                                    qPos.add(classNameId);
25564    
25565                                    if (bindLayoutUuid) {
25566                                            qPos.add(layoutUuid);
25567                                    }
25568    
25569                                    if (!pagination) {
25570                                            list = (List<JournalArticle>)QueryUtil.list(q,
25571                                                            getDialect(), start, end, false);
25572    
25573                                            Collections.sort(list);
25574    
25575                                            list = new UnmodifiableList<JournalArticle>(list);
25576                                    }
25577                                    else {
25578                                            list = (List<JournalArticle>)QueryUtil.list(q,
25579                                                            getDialect(), start, end);
25580                                    }
25581    
25582                                    cacheResult(list);
25583    
25584                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
25585                            }
25586                            catch (Exception e) {
25587                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
25588    
25589                                    throw processException(e);
25590                            }
25591                            finally {
25592                                    closeSession(session);
25593                            }
25594                    }
25595    
25596                    return list;
25597            }
25598    
25599            /**
25600             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
25601             *
25602             * @param groupId the group ID
25603             * @param classNameId the class name ID
25604             * @param layoutUuid the layout uuid
25605             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25606             * @return the first matching journal article
25607             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
25608             * @throws SystemException if a system exception occurred
25609             */
25610            @Override
25611            public JournalArticle findByG_C_L_First(long groupId, long classNameId,
25612                    String layoutUuid, OrderByComparator orderByComparator)
25613                    throws NoSuchArticleException, SystemException {
25614                    JournalArticle journalArticle = fetchByG_C_L_First(groupId,
25615                                    classNameId, layoutUuid, orderByComparator);
25616    
25617                    if (journalArticle != null) {
25618                            return journalArticle;
25619                    }
25620    
25621                    StringBundler msg = new StringBundler(8);
25622    
25623                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
25624    
25625                    msg.append("groupId=");
25626                    msg.append(groupId);
25627    
25628                    msg.append(", classNameId=");
25629                    msg.append(classNameId);
25630    
25631                    msg.append(", layoutUuid=");
25632                    msg.append(layoutUuid);
25633    
25634                    msg.append(StringPool.CLOSE_CURLY_BRACE);
25635    
25636                    throw new NoSuchArticleException(msg.toString());
25637            }
25638    
25639            /**
25640             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
25641             *
25642             * @param groupId the group ID
25643             * @param classNameId the class name ID
25644             * @param layoutUuid the layout uuid
25645             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25646             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
25647             * @throws SystemException if a system exception occurred
25648             */
25649            @Override
25650            public JournalArticle fetchByG_C_L_First(long groupId, long classNameId,
25651                    String layoutUuid, OrderByComparator orderByComparator)
25652                    throws SystemException {
25653                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
25654                                    layoutUuid, 0, 1, orderByComparator);
25655    
25656                    if (!list.isEmpty()) {
25657                            return list.get(0);
25658                    }
25659    
25660                    return null;
25661            }
25662    
25663            /**
25664             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
25665             *
25666             * @param groupId the group ID
25667             * @param classNameId the class name ID
25668             * @param layoutUuid the layout uuid
25669             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25670             * @return the last matching journal article
25671             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
25672             * @throws SystemException if a system exception occurred
25673             */
25674            @Override
25675            public JournalArticle findByG_C_L_Last(long groupId, long classNameId,
25676                    String layoutUuid, OrderByComparator orderByComparator)
25677                    throws NoSuchArticleException, SystemException {
25678                    JournalArticle journalArticle = fetchByG_C_L_Last(groupId, classNameId,
25679                                    layoutUuid, orderByComparator);
25680    
25681                    if (journalArticle != null) {
25682                            return journalArticle;
25683                    }
25684    
25685                    StringBundler msg = new StringBundler(8);
25686    
25687                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
25688    
25689                    msg.append("groupId=");
25690                    msg.append(groupId);
25691    
25692                    msg.append(", classNameId=");
25693                    msg.append(classNameId);
25694    
25695                    msg.append(", layoutUuid=");
25696                    msg.append(layoutUuid);
25697    
25698                    msg.append(StringPool.CLOSE_CURLY_BRACE);
25699    
25700                    throw new NoSuchArticleException(msg.toString());
25701            }
25702    
25703            /**
25704             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
25705             *
25706             * @param groupId the group ID
25707             * @param classNameId the class name ID
25708             * @param layoutUuid the layout uuid
25709             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25710             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
25711             * @throws SystemException if a system exception occurred
25712             */
25713            @Override
25714            public JournalArticle fetchByG_C_L_Last(long groupId, long classNameId,
25715                    String layoutUuid, OrderByComparator orderByComparator)
25716                    throws SystemException {
25717                    int count = countByG_C_L(groupId, classNameId, layoutUuid);
25718    
25719                    if (count == 0) {
25720                            return null;
25721                    }
25722    
25723                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
25724                                    layoutUuid, count - 1, count, orderByComparator);
25725    
25726                    if (!list.isEmpty()) {
25727                            return list.get(0);
25728                    }
25729    
25730                    return null;
25731            }
25732    
25733            /**
25734             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
25735             *
25736             * @param id the primary key of the current journal article
25737             * @param groupId the group ID
25738             * @param classNameId the class name ID
25739             * @param layoutUuid the layout uuid
25740             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25741             * @return the previous, current, and next journal article
25742             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
25743             * @throws SystemException if a system exception occurred
25744             */
25745            @Override
25746            public JournalArticle[] findByG_C_L_PrevAndNext(long id, long groupId,
25747                    long classNameId, String layoutUuid, OrderByComparator orderByComparator)
25748                    throws NoSuchArticleException, SystemException {
25749                    JournalArticle journalArticle = findByPrimaryKey(id);
25750    
25751                    Session session = null;
25752    
25753                    try {
25754                            session = openSession();
25755    
25756                            JournalArticle[] array = new JournalArticleImpl[3];
25757    
25758                            array[0] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
25759                                            classNameId, layoutUuid, orderByComparator, true);
25760    
25761                            array[1] = journalArticle;
25762    
25763                            array[2] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
25764                                            classNameId, layoutUuid, orderByComparator, false);
25765    
25766                            return array;
25767                    }
25768                    catch (Exception e) {
25769                            throw processException(e);
25770                    }
25771                    finally {
25772                            closeSession(session);
25773                    }
25774            }
25775    
25776            protected JournalArticle getByG_C_L_PrevAndNext(Session session,
25777                    JournalArticle journalArticle, long groupId, long classNameId,
25778                    String layoutUuid, OrderByComparator orderByComparator, boolean previous) {
25779                    StringBundler query = null;
25780    
25781                    if (orderByComparator != null) {
25782                            query = new StringBundler(6 +
25783                                            (orderByComparator.getOrderByFields().length * 6));
25784                    }
25785                    else {
25786                            query = new StringBundler(3);
25787                    }
25788    
25789                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
25790    
25791                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
25792    
25793                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
25794    
25795                    boolean bindLayoutUuid = false;
25796    
25797                    if (layoutUuid == null) {
25798                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
25799                    }
25800                    else if (layoutUuid.equals(StringPool.BLANK)) {
25801                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
25802                    }
25803                    else {
25804                            bindLayoutUuid = true;
25805    
25806                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
25807                    }
25808    
25809                    if (orderByComparator != null) {
25810                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
25811    
25812                            if (orderByConditionFields.length > 0) {
25813                                    query.append(WHERE_AND);
25814                            }
25815    
25816                            for (int i = 0; i < orderByConditionFields.length; i++) {
25817                                    query.append(_ORDER_BY_ENTITY_ALIAS);
25818                                    query.append(orderByConditionFields[i]);
25819    
25820                                    if ((i + 1) < orderByConditionFields.length) {
25821                                            if (orderByComparator.isAscending() ^ previous) {
25822                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
25823                                            }
25824                                            else {
25825                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
25826                                            }
25827                                    }
25828                                    else {
25829                                            if (orderByComparator.isAscending() ^ previous) {
25830                                                    query.append(WHERE_GREATER_THAN);
25831                                            }
25832                                            else {
25833                                                    query.append(WHERE_LESSER_THAN);
25834                                            }
25835                                    }
25836                            }
25837    
25838                            query.append(ORDER_BY_CLAUSE);
25839    
25840                            String[] orderByFields = orderByComparator.getOrderByFields();
25841    
25842                            for (int i = 0; i < orderByFields.length; i++) {
25843                                    query.append(_ORDER_BY_ENTITY_ALIAS);
25844                                    query.append(orderByFields[i]);
25845    
25846                                    if ((i + 1) < orderByFields.length) {
25847                                            if (orderByComparator.isAscending() ^ previous) {
25848                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
25849                                            }
25850                                            else {
25851                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
25852                                            }
25853                                    }
25854                                    else {
25855                                            if (orderByComparator.isAscending() ^ previous) {
25856                                                    query.append(ORDER_BY_ASC);
25857                                            }
25858                                            else {
25859                                                    query.append(ORDER_BY_DESC);
25860                                            }
25861                                    }
25862                            }
25863                    }
25864                    else {
25865                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
25866                    }
25867    
25868                    String sql = query.toString();
25869    
25870                    Query q = session.createQuery(sql);
25871    
25872                    q.setFirstResult(0);
25873                    q.setMaxResults(2);
25874    
25875                    QueryPos qPos = QueryPos.getInstance(q);
25876    
25877                    qPos.add(groupId);
25878    
25879                    qPos.add(classNameId);
25880    
25881                    if (bindLayoutUuid) {
25882                            qPos.add(layoutUuid);
25883                    }
25884    
25885                    if (orderByComparator != null) {
25886                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
25887    
25888                            for (Object value : values) {
25889                                    qPos.add(value);
25890                            }
25891                    }
25892    
25893                    List<JournalArticle> list = q.list();
25894    
25895                    if (list.size() == 2) {
25896                            return list.get(1);
25897                    }
25898                    else {
25899                            return null;
25900                    }
25901            }
25902    
25903            /**
25904             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
25905             *
25906             * @param groupId the group ID
25907             * @param classNameId the class name ID
25908             * @param layoutUuid the layout uuid
25909             * @return the matching journal articles that the user has permission to view
25910             * @throws SystemException if a system exception occurred
25911             */
25912            @Override
25913            public List<JournalArticle> filterFindByG_C_L(long groupId,
25914                    long classNameId, String layoutUuid) throws SystemException {
25915                    return filterFindByG_C_L(groupId, classNameId, layoutUuid,
25916                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
25917            }
25918    
25919            /**
25920             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
25921             *
25922             * <p>
25923             * 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.
25924             * </p>
25925             *
25926             * @param groupId the group ID
25927             * @param classNameId the class name ID
25928             * @param layoutUuid the layout uuid
25929             * @param start the lower bound of the range of journal articles
25930             * @param end the upper bound of the range of journal articles (not inclusive)
25931             * @return the range of matching journal articles that the user has permission to view
25932             * @throws SystemException if a system exception occurred
25933             */
25934            @Override
25935            public List<JournalArticle> filterFindByG_C_L(long groupId,
25936                    long classNameId, String layoutUuid, int start, int end)
25937                    throws SystemException {
25938                    return filterFindByG_C_L(groupId, classNameId, layoutUuid, start, end,
25939                            null);
25940            }
25941    
25942            /**
25943             * 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;.
25944             *
25945             * <p>
25946             * 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.
25947             * </p>
25948             *
25949             * @param groupId the group ID
25950             * @param classNameId the class name ID
25951             * @param layoutUuid the layout uuid
25952             * @param start the lower bound of the range of journal articles
25953             * @param end the upper bound of the range of journal articles (not inclusive)
25954             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
25955             * @return the ordered range of matching journal articles that the user has permission to view
25956             * @throws SystemException if a system exception occurred
25957             */
25958            @Override
25959            public List<JournalArticle> filterFindByG_C_L(long groupId,
25960                    long classNameId, String layoutUuid, int start, int end,
25961                    OrderByComparator orderByComparator) throws SystemException {
25962                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
25963                            return findByG_C_L(groupId, classNameId, layoutUuid, start, end,
25964                                    orderByComparator);
25965                    }
25966    
25967                    StringBundler query = null;
25968    
25969                    if (orderByComparator != null) {
25970                            query = new StringBundler(5 +
25971                                            (orderByComparator.getOrderByFields().length * 3));
25972                    }
25973                    else {
25974                            query = new StringBundler(5);
25975                    }
25976    
25977                    if (getDB().isSupportsInlineDistinct()) {
25978                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
25979                    }
25980                    else {
25981                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
25982                    }
25983    
25984                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
25985    
25986                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
25987    
25988                    boolean bindLayoutUuid = false;
25989    
25990                    if (layoutUuid == null) {
25991                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
25992                    }
25993                    else if (layoutUuid.equals(StringPool.BLANK)) {
25994                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
25995                    }
25996                    else {
25997                            bindLayoutUuid = true;
25998    
25999                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
26000                    }
26001    
26002                    if (!getDB().isSupportsInlineDistinct()) {
26003                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
26004                    }
26005    
26006                    if (orderByComparator != null) {
26007                            if (getDB().isSupportsInlineDistinct()) {
26008                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
26009                                            orderByComparator, true);
26010                            }
26011                            else {
26012                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
26013                                            orderByComparator, true);
26014                            }
26015                    }
26016                    else {
26017                            if (getDB().isSupportsInlineDistinct()) {
26018                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
26019                            }
26020                            else {
26021                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
26022                            }
26023                    }
26024    
26025                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
26026                                    JournalArticle.class.getName(),
26027                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
26028    
26029                    Session session = null;
26030    
26031                    try {
26032                            session = openSession();
26033    
26034                            SQLQuery q = session.createSQLQuery(sql);
26035    
26036                            if (getDB().isSupportsInlineDistinct()) {
26037                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
26038                            }
26039                            else {
26040                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
26041                            }
26042    
26043                            QueryPos qPos = QueryPos.getInstance(q);
26044    
26045                            qPos.add(groupId);
26046    
26047                            qPos.add(classNameId);
26048    
26049                            if (bindLayoutUuid) {
26050                                    qPos.add(layoutUuid);
26051                            }
26052    
26053                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
26054                                    end);
26055                    }
26056                    catch (Exception e) {
26057                            throw processException(e);
26058                    }
26059                    finally {
26060                            closeSession(session);
26061                    }
26062            }
26063    
26064            /**
26065             * 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;.
26066             *
26067             * @param id the primary key of the current journal article
26068             * @param groupId the group ID
26069             * @param classNameId the class name ID
26070             * @param layoutUuid the layout uuid
26071             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26072             * @return the previous, current, and next journal article
26073             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
26074             * @throws SystemException if a system exception occurred
26075             */
26076            @Override
26077            public JournalArticle[] filterFindByG_C_L_PrevAndNext(long id,
26078                    long groupId, long classNameId, String layoutUuid,
26079                    OrderByComparator orderByComparator)
26080                    throws NoSuchArticleException, SystemException {
26081                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
26082                            return findByG_C_L_PrevAndNext(id, groupId, classNameId,
26083                                    layoutUuid, orderByComparator);
26084                    }
26085    
26086                    JournalArticle journalArticle = findByPrimaryKey(id);
26087    
26088                    Session session = null;
26089    
26090                    try {
26091                            session = openSession();
26092    
26093                            JournalArticle[] array = new JournalArticleImpl[3];
26094    
26095                            array[0] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
26096                                            groupId, classNameId, layoutUuid, orderByComparator, true);
26097    
26098                            array[1] = journalArticle;
26099    
26100                            array[2] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
26101                                            groupId, classNameId, layoutUuid, orderByComparator, false);
26102    
26103                            return array;
26104                    }
26105                    catch (Exception e) {
26106                            throw processException(e);
26107                    }
26108                    finally {
26109                            closeSession(session);
26110                    }
26111            }
26112    
26113            protected JournalArticle filterGetByG_C_L_PrevAndNext(Session session,
26114                    JournalArticle journalArticle, long groupId, long classNameId,
26115                    String layoutUuid, OrderByComparator orderByComparator, boolean previous) {
26116                    StringBundler query = null;
26117    
26118                    if (orderByComparator != null) {
26119                            query = new StringBundler(6 +
26120                                            (orderByComparator.getOrderByFields().length * 6));
26121                    }
26122                    else {
26123                            query = new StringBundler(3);
26124                    }
26125    
26126                    if (getDB().isSupportsInlineDistinct()) {
26127                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
26128                    }
26129                    else {
26130                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
26131                    }
26132    
26133                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
26134    
26135                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
26136    
26137                    boolean bindLayoutUuid = false;
26138    
26139                    if (layoutUuid == null) {
26140                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
26141                    }
26142                    else if (layoutUuid.equals(StringPool.BLANK)) {
26143                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
26144                    }
26145                    else {
26146                            bindLayoutUuid = true;
26147    
26148                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
26149                    }
26150    
26151                    if (!getDB().isSupportsInlineDistinct()) {
26152                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
26153                    }
26154    
26155                    if (orderByComparator != null) {
26156                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
26157    
26158                            if (orderByConditionFields.length > 0) {
26159                                    query.append(WHERE_AND);
26160                            }
26161    
26162                            for (int i = 0; i < orderByConditionFields.length; i++) {
26163                                    if (getDB().isSupportsInlineDistinct()) {
26164                                            query.append(_ORDER_BY_ENTITY_ALIAS);
26165                                    }
26166                                    else {
26167                                            query.append(_ORDER_BY_ENTITY_TABLE);
26168                                    }
26169    
26170                                    query.append(orderByConditionFields[i]);
26171    
26172                                    if ((i + 1) < orderByConditionFields.length) {
26173                                            if (orderByComparator.isAscending() ^ previous) {
26174                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
26175                                            }
26176                                            else {
26177                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
26178                                            }
26179                                    }
26180                                    else {
26181                                            if (orderByComparator.isAscending() ^ previous) {
26182                                                    query.append(WHERE_GREATER_THAN);
26183                                            }
26184                                            else {
26185                                                    query.append(WHERE_LESSER_THAN);
26186                                            }
26187                                    }
26188                            }
26189    
26190                            query.append(ORDER_BY_CLAUSE);
26191    
26192                            String[] orderByFields = orderByComparator.getOrderByFields();
26193    
26194                            for (int i = 0; i < orderByFields.length; i++) {
26195                                    if (getDB().isSupportsInlineDistinct()) {
26196                                            query.append(_ORDER_BY_ENTITY_ALIAS);
26197                                    }
26198                                    else {
26199                                            query.append(_ORDER_BY_ENTITY_TABLE);
26200                                    }
26201    
26202                                    query.append(orderByFields[i]);
26203    
26204                                    if ((i + 1) < orderByFields.length) {
26205                                            if (orderByComparator.isAscending() ^ previous) {
26206                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
26207                                            }
26208                                            else {
26209                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
26210                                            }
26211                                    }
26212                                    else {
26213                                            if (orderByComparator.isAscending() ^ previous) {
26214                                                    query.append(ORDER_BY_ASC);
26215                                            }
26216                                            else {
26217                                                    query.append(ORDER_BY_DESC);
26218                                            }
26219                                    }
26220                            }
26221                    }
26222                    else {
26223                            if (getDB().isSupportsInlineDistinct()) {
26224                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
26225                            }
26226                            else {
26227                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
26228                            }
26229                    }
26230    
26231                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
26232                                    JournalArticle.class.getName(),
26233                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
26234    
26235                    SQLQuery q = session.createSQLQuery(sql);
26236    
26237                    q.setFirstResult(0);
26238                    q.setMaxResults(2);
26239    
26240                    if (getDB().isSupportsInlineDistinct()) {
26241                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
26242                    }
26243                    else {
26244                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
26245                    }
26246    
26247                    QueryPos qPos = QueryPos.getInstance(q);
26248    
26249                    qPos.add(groupId);
26250    
26251                    qPos.add(classNameId);
26252    
26253                    if (bindLayoutUuid) {
26254                            qPos.add(layoutUuid);
26255                    }
26256    
26257                    if (orderByComparator != null) {
26258                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
26259    
26260                            for (Object value : values) {
26261                                    qPos.add(value);
26262                            }
26263                    }
26264    
26265                    List<JournalArticle> list = q.list();
26266    
26267                    if (list.size() == 2) {
26268                            return list.get(1);
26269                    }
26270                    else {
26271                            return null;
26272                    }
26273            }
26274    
26275            /**
26276             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63; from the database.
26277             *
26278             * @param groupId the group ID
26279             * @param classNameId the class name ID
26280             * @param layoutUuid the layout uuid
26281             * @throws SystemException if a system exception occurred
26282             */
26283            @Override
26284            public void removeByG_C_L(long groupId, long classNameId, String layoutUuid)
26285                    throws SystemException {
26286                    for (JournalArticle journalArticle : findByG_C_L(groupId, classNameId,
26287                                    layoutUuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
26288                            remove(journalArticle);
26289                    }
26290            }
26291    
26292            /**
26293             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
26294             *
26295             * @param groupId the group ID
26296             * @param classNameId the class name ID
26297             * @param layoutUuid the layout uuid
26298             * @return the number of matching journal articles
26299             * @throws SystemException if a system exception occurred
26300             */
26301            @Override
26302            public int countByG_C_L(long groupId, long classNameId, String layoutUuid)
26303                    throws SystemException {
26304                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_L;
26305    
26306                    Object[] finderArgs = new Object[] { groupId, classNameId, layoutUuid };
26307    
26308                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
26309                                    this);
26310    
26311                    if (count == null) {
26312                            StringBundler query = new StringBundler(4);
26313    
26314                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
26315    
26316                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
26317    
26318                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
26319    
26320                            boolean bindLayoutUuid = false;
26321    
26322                            if (layoutUuid == null) {
26323                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
26324                            }
26325                            else if (layoutUuid.equals(StringPool.BLANK)) {
26326                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
26327                            }
26328                            else {
26329                                    bindLayoutUuid = true;
26330    
26331                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
26332                            }
26333    
26334                            String sql = query.toString();
26335    
26336                            Session session = null;
26337    
26338                            try {
26339                                    session = openSession();
26340    
26341                                    Query q = session.createQuery(sql);
26342    
26343                                    QueryPos qPos = QueryPos.getInstance(q);
26344    
26345                                    qPos.add(groupId);
26346    
26347                                    qPos.add(classNameId);
26348    
26349                                    if (bindLayoutUuid) {
26350                                            qPos.add(layoutUuid);
26351                                    }
26352    
26353                                    count = (Long)q.uniqueResult();
26354    
26355                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
26356                            }
26357                            catch (Exception e) {
26358                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
26359    
26360                                    throw processException(e);
26361                            }
26362                            finally {
26363                                    closeSession(session);
26364                            }
26365                    }
26366    
26367                    return count.intValue();
26368            }
26369    
26370            /**
26371             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
26372             *
26373             * @param groupId the group ID
26374             * @param classNameId the class name ID
26375             * @param layoutUuid the layout uuid
26376             * @return the number of matching journal articles that the user has permission to view
26377             * @throws SystemException if a system exception occurred
26378             */
26379            @Override
26380            public int filterCountByG_C_L(long groupId, long classNameId,
26381                    String layoutUuid) throws SystemException {
26382                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
26383                            return countByG_C_L(groupId, classNameId, layoutUuid);
26384                    }
26385    
26386                    StringBundler query = new StringBundler(4);
26387    
26388                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
26389    
26390                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
26391    
26392                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
26393    
26394                    boolean bindLayoutUuid = false;
26395    
26396                    if (layoutUuid == null) {
26397                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
26398                    }
26399                    else if (layoutUuid.equals(StringPool.BLANK)) {
26400                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
26401                    }
26402                    else {
26403                            bindLayoutUuid = true;
26404    
26405                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
26406                    }
26407    
26408                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
26409                                    JournalArticle.class.getName(),
26410                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
26411    
26412                    Session session = null;
26413    
26414                    try {
26415                            session = openSession();
26416    
26417                            SQLQuery q = session.createSQLQuery(sql);
26418    
26419                            q.addScalar(COUNT_COLUMN_NAME,
26420                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
26421    
26422                            QueryPos qPos = QueryPos.getInstance(q);
26423    
26424                            qPos.add(groupId);
26425    
26426                            qPos.add(classNameId);
26427    
26428                            if (bindLayoutUuid) {
26429                                    qPos.add(layoutUuid);
26430                            }
26431    
26432                            Long count = (Long)q.uniqueResult();
26433    
26434                            return count.intValue();
26435                    }
26436                    catch (Exception e) {
26437                            throw processException(e);
26438                    }
26439                    finally {
26440                            closeSession(session);
26441                    }
26442            }
26443    
26444            private static final String _FINDER_COLUMN_G_C_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
26445            private static final String _FINDER_COLUMN_G_C_L_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
26446            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
26447            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
26448            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = '')";
26449            public static final FinderPath FINDER_PATH_FETCH_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
26450                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
26451                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_A_V",
26452                            new String[] {
26453                                    Long.class.getName(), String.class.getName(),
26454                                    Double.class.getName()
26455                            },
26456                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
26457                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
26458                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
26459            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
26460                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
26461                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_V",
26462                            new String[] {
26463                                    Long.class.getName(), String.class.getName(),
26464                                    Double.class.getName()
26465                            });
26466    
26467            /**
26468             * 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.
26469             *
26470             * @param groupId the group ID
26471             * @param articleId the article ID
26472             * @param version the version
26473             * @return the matching journal article
26474             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
26475             * @throws SystemException if a system exception occurred
26476             */
26477            @Override
26478            public JournalArticle findByG_A_V(long groupId, String articleId,
26479                    double version) throws NoSuchArticleException, SystemException {
26480                    JournalArticle journalArticle = fetchByG_A_V(groupId, articleId, version);
26481    
26482                    if (journalArticle == null) {
26483                            StringBundler msg = new StringBundler(8);
26484    
26485                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
26486    
26487                            msg.append("groupId=");
26488                            msg.append(groupId);
26489    
26490                            msg.append(", articleId=");
26491                            msg.append(articleId);
26492    
26493                            msg.append(", version=");
26494                            msg.append(version);
26495    
26496                            msg.append(StringPool.CLOSE_CURLY_BRACE);
26497    
26498                            if (_log.isWarnEnabled()) {
26499                                    _log.warn(msg.toString());
26500                            }
26501    
26502                            throw new NoSuchArticleException(msg.toString());
26503                    }
26504    
26505                    return journalArticle;
26506            }
26507    
26508            /**
26509             * 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.
26510             *
26511             * @param groupId the group ID
26512             * @param articleId the article ID
26513             * @param version the version
26514             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
26515             * @throws SystemException if a system exception occurred
26516             */
26517            @Override
26518            public JournalArticle fetchByG_A_V(long groupId, String articleId,
26519                    double version) throws SystemException {
26520                    return fetchByG_A_V(groupId, articleId, version, true);
26521            }
26522    
26523            /**
26524             * 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.
26525             *
26526             * @param groupId the group ID
26527             * @param articleId the article ID
26528             * @param version the version
26529             * @param retrieveFromCache whether to use the finder cache
26530             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
26531             * @throws SystemException if a system exception occurred
26532             */
26533            @Override
26534            public JournalArticle fetchByG_A_V(long groupId, String articleId,
26535                    double version, boolean retrieveFromCache) throws SystemException {
26536                    Object[] finderArgs = new Object[] { groupId, articleId, version };
26537    
26538                    Object result = null;
26539    
26540                    if (retrieveFromCache) {
26541                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_A_V,
26542                                            finderArgs, this);
26543                    }
26544    
26545                    if (result instanceof JournalArticle) {
26546                            JournalArticle journalArticle = (JournalArticle)result;
26547    
26548                            if ((groupId != journalArticle.getGroupId()) ||
26549                                            !Validator.equals(articleId, journalArticle.getArticleId()) ||
26550                                            (version != journalArticle.getVersion())) {
26551                                    result = null;
26552                            }
26553                    }
26554    
26555                    if (result == null) {
26556                            StringBundler query = new StringBundler(5);
26557    
26558                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
26559    
26560                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
26561    
26562                            boolean bindArticleId = false;
26563    
26564                            if (articleId == null) {
26565                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
26566                            }
26567                            else if (articleId.equals(StringPool.BLANK)) {
26568                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
26569                            }
26570                            else {
26571                                    bindArticleId = true;
26572    
26573                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
26574                            }
26575    
26576                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
26577    
26578                            String sql = query.toString();
26579    
26580                            Session session = null;
26581    
26582                            try {
26583                                    session = openSession();
26584    
26585                                    Query q = session.createQuery(sql);
26586    
26587                                    QueryPos qPos = QueryPos.getInstance(q);
26588    
26589                                    qPos.add(groupId);
26590    
26591                                    if (bindArticleId) {
26592                                            qPos.add(articleId);
26593                                    }
26594    
26595                                    qPos.add(version);
26596    
26597                                    List<JournalArticle> list = q.list();
26598    
26599                                    if (list.isEmpty()) {
26600                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
26601                                                    finderArgs, list);
26602                                    }
26603                                    else {
26604                                            JournalArticle journalArticle = list.get(0);
26605    
26606                                            result = journalArticle;
26607    
26608                                            cacheResult(journalArticle);
26609    
26610                                            if ((journalArticle.getGroupId() != groupId) ||
26611                                                            (journalArticle.getArticleId() == null) ||
26612                                                            !journalArticle.getArticleId().equals(articleId) ||
26613                                                            (journalArticle.getVersion() != version)) {
26614                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
26615                                                            finderArgs, journalArticle);
26616                                            }
26617                                    }
26618                            }
26619                            catch (Exception e) {
26620                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V,
26621                                            finderArgs);
26622    
26623                                    throw processException(e);
26624                            }
26625                            finally {
26626                                    closeSession(session);
26627                            }
26628                    }
26629    
26630                    if (result instanceof List<?>) {
26631                            return null;
26632                    }
26633                    else {
26634                            return (JournalArticle)result;
26635                    }
26636            }
26637    
26638            /**
26639             * Removes the journal article where groupId = &#63; and articleId = &#63; and version = &#63; from the database.
26640             *
26641             * @param groupId the group ID
26642             * @param articleId the article ID
26643             * @param version the version
26644             * @return the journal article that was removed
26645             * @throws SystemException if a system exception occurred
26646             */
26647            @Override
26648            public JournalArticle removeByG_A_V(long groupId, String articleId,
26649                    double version) throws NoSuchArticleException, SystemException {
26650                    JournalArticle journalArticle = findByG_A_V(groupId, articleId, version);
26651    
26652                    return remove(journalArticle);
26653            }
26654    
26655            /**
26656             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and version = &#63;.
26657             *
26658             * @param groupId the group ID
26659             * @param articleId the article ID
26660             * @param version the version
26661             * @return the number of matching journal articles
26662             * @throws SystemException if a system exception occurred
26663             */
26664            @Override
26665            public int countByG_A_V(long groupId, String articleId, double version)
26666                    throws SystemException {
26667                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A_V;
26668    
26669                    Object[] finderArgs = new Object[] { groupId, articleId, version };
26670    
26671                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
26672                                    this);
26673    
26674                    if (count == null) {
26675                            StringBundler query = new StringBundler(4);
26676    
26677                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
26678    
26679                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
26680    
26681                            boolean bindArticleId = false;
26682    
26683                            if (articleId == null) {
26684                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
26685                            }
26686                            else if (articleId.equals(StringPool.BLANK)) {
26687                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
26688                            }
26689                            else {
26690                                    bindArticleId = true;
26691    
26692                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
26693                            }
26694    
26695                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
26696    
26697                            String sql = query.toString();
26698    
26699                            Session session = null;
26700    
26701                            try {
26702                                    session = openSession();
26703    
26704                                    Query q = session.createQuery(sql);
26705    
26706                                    QueryPos qPos = QueryPos.getInstance(q);
26707    
26708                                    qPos.add(groupId);
26709    
26710                                    if (bindArticleId) {
26711                                            qPos.add(articleId);
26712                                    }
26713    
26714                                    qPos.add(version);
26715    
26716                                    count = (Long)q.uniqueResult();
26717    
26718                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
26719                            }
26720                            catch (Exception e) {
26721                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
26722    
26723                                    throw processException(e);
26724                            }
26725                            finally {
26726                                    closeSession(session);
26727                            }
26728                    }
26729    
26730                    return count.intValue();
26731            }
26732    
26733            private static final String _FINDER_COLUMN_G_A_V_GROUPID_2 = "journalArticle.groupId = ? AND ";
26734            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
26735            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
26736            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '') AND ";
26737            private static final String _FINDER_COLUMN_G_A_V_VERSION_2 = "journalArticle.version = ?";
26738            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
26739                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
26740                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
26741                            "findByG_A_ST",
26742                            new String[] {
26743                                    Long.class.getName(), String.class.getName(),
26744                                    Integer.class.getName(),
26745                                    
26746                            Integer.class.getName(), Integer.class.getName(),
26747                                    OrderByComparator.class.getName()
26748                            });
26749            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST =
26750                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
26751                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
26752                            JournalArticleImpl.class,
26753                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A_ST",
26754                            new String[] {
26755                                    Long.class.getName(), String.class.getName(),
26756                                    Integer.class.getName()
26757                            },
26758                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
26759                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
26760                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
26761                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
26762            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
26763                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
26764                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_ST",
26765                            new String[] {
26766                                    Long.class.getName(), String.class.getName(),
26767                                    Integer.class.getName()
26768                            });
26769            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
26770                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
26771                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_A_ST",
26772                            new String[] {
26773                                    Long.class.getName(), String.class.getName(),
26774                                    Integer.class.getName()
26775                            });
26776    
26777            /**
26778             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
26779             *
26780             * @param groupId the group ID
26781             * @param articleId the article ID
26782             * @param status the status
26783             * @return the matching journal articles
26784             * @throws SystemException if a system exception occurred
26785             */
26786            @Override
26787            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
26788                    int status) throws SystemException {
26789                    return findByG_A_ST(groupId, articleId, status, QueryUtil.ALL_POS,
26790                            QueryUtil.ALL_POS, null);
26791            }
26792    
26793            /**
26794             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
26795             *
26796             * <p>
26797             * 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.
26798             * </p>
26799             *
26800             * @param groupId the group ID
26801             * @param articleId the article ID
26802             * @param status the status
26803             * @param start the lower bound of the range of journal articles
26804             * @param end the upper bound of the range of journal articles (not inclusive)
26805             * @return the range of matching journal articles
26806             * @throws SystemException if a system exception occurred
26807             */
26808            @Override
26809            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
26810                    int status, int start, int end) throws SystemException {
26811                    return findByG_A_ST(groupId, articleId, status, start, end, null);
26812            }
26813    
26814            /**
26815             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
26816             *
26817             * <p>
26818             * 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.
26819             * </p>
26820             *
26821             * @param groupId the group ID
26822             * @param articleId the article ID
26823             * @param status the status
26824             * @param start the lower bound of the range of journal articles
26825             * @param end the upper bound of the range of journal articles (not inclusive)
26826             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
26827             * @return the ordered range of matching journal articles
26828             * @throws SystemException if a system exception occurred
26829             */
26830            @Override
26831            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
26832                    int status, int start, int end, OrderByComparator orderByComparator)
26833                    throws SystemException {
26834                    boolean pagination = true;
26835                    FinderPath finderPath = null;
26836                    Object[] finderArgs = null;
26837    
26838                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
26839                                    (orderByComparator == null)) {
26840                            pagination = false;
26841                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST;
26842                            finderArgs = new Object[] { groupId, articleId, status };
26843                    }
26844                    else {
26845                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST;
26846                            finderArgs = new Object[] {
26847                                            groupId, articleId, status,
26848                                            
26849                                            start, end, orderByComparator
26850                                    };
26851                    }
26852    
26853                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
26854                                    finderArgs, this);
26855    
26856                    if ((list != null) && !list.isEmpty()) {
26857                            for (JournalArticle journalArticle : list) {
26858                                    if ((groupId != journalArticle.getGroupId()) ||
26859                                                    !Validator.equals(articleId,
26860                                                            journalArticle.getArticleId()) ||
26861                                                    (status != journalArticle.getStatus())) {
26862                                            list = null;
26863    
26864                                            break;
26865                                    }
26866                            }
26867                    }
26868    
26869                    if (list == null) {
26870                            StringBundler query = null;
26871    
26872                            if (orderByComparator != null) {
26873                                    query = new StringBundler(5 +
26874                                                    (orderByComparator.getOrderByFields().length * 3));
26875                            }
26876                            else {
26877                                    query = new StringBundler(5);
26878                            }
26879    
26880                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
26881    
26882                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
26883    
26884                            boolean bindArticleId = false;
26885    
26886                            if (articleId == null) {
26887                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
26888                            }
26889                            else if (articleId.equals(StringPool.BLANK)) {
26890                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
26891                            }
26892                            else {
26893                                    bindArticleId = true;
26894    
26895                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
26896                            }
26897    
26898                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
26899    
26900                            if (orderByComparator != null) {
26901                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
26902                                            orderByComparator);
26903                            }
26904                            else
26905                             if (pagination) {
26906                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
26907                            }
26908    
26909                            String sql = query.toString();
26910    
26911                            Session session = null;
26912    
26913                            try {
26914                                    session = openSession();
26915    
26916                                    Query q = session.createQuery(sql);
26917    
26918                                    QueryPos qPos = QueryPos.getInstance(q);
26919    
26920                                    qPos.add(groupId);
26921    
26922                                    if (bindArticleId) {
26923                                            qPos.add(articleId);
26924                                    }
26925    
26926                                    qPos.add(status);
26927    
26928                                    if (!pagination) {
26929                                            list = (List<JournalArticle>)QueryUtil.list(q,
26930                                                            getDialect(), start, end, false);
26931    
26932                                            Collections.sort(list);
26933    
26934                                            list = new UnmodifiableList<JournalArticle>(list);
26935                                    }
26936                                    else {
26937                                            list = (List<JournalArticle>)QueryUtil.list(q,
26938                                                            getDialect(), start, end);
26939                                    }
26940    
26941                                    cacheResult(list);
26942    
26943                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
26944                            }
26945                            catch (Exception e) {
26946                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
26947    
26948                                    throw processException(e);
26949                            }
26950                            finally {
26951                                    closeSession(session);
26952                            }
26953                    }
26954    
26955                    return list;
26956            }
26957    
26958            /**
26959             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
26960             *
26961             * @param groupId the group ID
26962             * @param articleId the article ID
26963             * @param status the status
26964             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26965             * @return the first matching journal article
26966             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
26967             * @throws SystemException if a system exception occurred
26968             */
26969            @Override
26970            public JournalArticle findByG_A_ST_First(long groupId, String articleId,
26971                    int status, OrderByComparator orderByComparator)
26972                    throws NoSuchArticleException, SystemException {
26973                    JournalArticle journalArticle = fetchByG_A_ST_First(groupId, articleId,
26974                                    status, orderByComparator);
26975    
26976                    if (journalArticle != null) {
26977                            return journalArticle;
26978                    }
26979    
26980                    StringBundler msg = new StringBundler(8);
26981    
26982                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
26983    
26984                    msg.append("groupId=");
26985                    msg.append(groupId);
26986    
26987                    msg.append(", articleId=");
26988                    msg.append(articleId);
26989    
26990                    msg.append(", status=");
26991                    msg.append(status);
26992    
26993                    msg.append(StringPool.CLOSE_CURLY_BRACE);
26994    
26995                    throw new NoSuchArticleException(msg.toString());
26996            }
26997    
26998            /**
26999             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
27000             *
27001             * @param groupId the group ID
27002             * @param articleId the article ID
27003             * @param status the status
27004             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27005             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
27006             * @throws SystemException if a system exception occurred
27007             */
27008            @Override
27009            public JournalArticle fetchByG_A_ST_First(long groupId, String articleId,
27010                    int status, OrderByComparator orderByComparator)
27011                    throws SystemException {
27012                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status, 0,
27013                                    1, orderByComparator);
27014    
27015                    if (!list.isEmpty()) {
27016                            return list.get(0);
27017                    }
27018    
27019                    return null;
27020            }
27021    
27022            /**
27023             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
27024             *
27025             * @param groupId the group ID
27026             * @param articleId the article ID
27027             * @param status the status
27028             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27029             * @return the last matching journal article
27030             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
27031             * @throws SystemException if a system exception occurred
27032             */
27033            @Override
27034            public JournalArticle findByG_A_ST_Last(long groupId, String articleId,
27035                    int status, OrderByComparator orderByComparator)
27036                    throws NoSuchArticleException, SystemException {
27037                    JournalArticle journalArticle = fetchByG_A_ST_Last(groupId, articleId,
27038                                    status, orderByComparator);
27039    
27040                    if (journalArticle != null) {
27041                            return journalArticle;
27042                    }
27043    
27044                    StringBundler msg = new StringBundler(8);
27045    
27046                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
27047    
27048                    msg.append("groupId=");
27049                    msg.append(groupId);
27050    
27051                    msg.append(", articleId=");
27052                    msg.append(articleId);
27053    
27054                    msg.append(", status=");
27055                    msg.append(status);
27056    
27057                    msg.append(StringPool.CLOSE_CURLY_BRACE);
27058    
27059                    throw new NoSuchArticleException(msg.toString());
27060            }
27061    
27062            /**
27063             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
27064             *
27065             * @param groupId the group ID
27066             * @param articleId the article ID
27067             * @param status the status
27068             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27069             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
27070             * @throws SystemException if a system exception occurred
27071             */
27072            @Override
27073            public JournalArticle fetchByG_A_ST_Last(long groupId, String articleId,
27074                    int status, OrderByComparator orderByComparator)
27075                    throws SystemException {
27076                    int count = countByG_A_ST(groupId, articleId, status);
27077    
27078                    if (count == 0) {
27079                            return null;
27080                    }
27081    
27082                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status,
27083                                    count - 1, count, orderByComparator);
27084    
27085                    if (!list.isEmpty()) {
27086                            return list.get(0);
27087                    }
27088    
27089                    return null;
27090            }
27091    
27092            /**
27093             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
27094             *
27095             * @param id the primary key of the current journal article
27096             * @param groupId the group ID
27097             * @param articleId the article ID
27098             * @param status the status
27099             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27100             * @return the previous, current, and next journal article
27101             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
27102             * @throws SystemException if a system exception occurred
27103             */
27104            @Override
27105            public JournalArticle[] findByG_A_ST_PrevAndNext(long id, long groupId,
27106                    String articleId, int status, OrderByComparator orderByComparator)
27107                    throws NoSuchArticleException, SystemException {
27108                    JournalArticle journalArticle = findByPrimaryKey(id);
27109    
27110                    Session session = null;
27111    
27112                    try {
27113                            session = openSession();
27114    
27115                            JournalArticle[] array = new JournalArticleImpl[3];
27116    
27117                            array[0] = getByG_A_ST_PrevAndNext(session, journalArticle,
27118                                            groupId, articleId, status, orderByComparator, true);
27119    
27120                            array[1] = journalArticle;
27121    
27122                            array[2] = getByG_A_ST_PrevAndNext(session, journalArticle,
27123                                            groupId, articleId, status, orderByComparator, false);
27124    
27125                            return array;
27126                    }
27127                    catch (Exception e) {
27128                            throw processException(e);
27129                    }
27130                    finally {
27131                            closeSession(session);
27132                    }
27133            }
27134    
27135            protected JournalArticle getByG_A_ST_PrevAndNext(Session session,
27136                    JournalArticle journalArticle, long groupId, String articleId,
27137                    int status, OrderByComparator orderByComparator, boolean previous) {
27138                    StringBundler query = null;
27139    
27140                    if (orderByComparator != null) {
27141                            query = new StringBundler(6 +
27142                                            (orderByComparator.getOrderByFields().length * 6));
27143                    }
27144                    else {
27145                            query = new StringBundler(3);
27146                    }
27147    
27148                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
27149    
27150                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
27151    
27152                    boolean bindArticleId = false;
27153    
27154                    if (articleId == null) {
27155                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
27156                    }
27157                    else if (articleId.equals(StringPool.BLANK)) {
27158                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
27159                    }
27160                    else {
27161                            bindArticleId = true;
27162    
27163                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
27164                    }
27165    
27166                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
27167    
27168                    if (orderByComparator != null) {
27169                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
27170    
27171                            if (orderByConditionFields.length > 0) {
27172                                    query.append(WHERE_AND);
27173                            }
27174    
27175                            for (int i = 0; i < orderByConditionFields.length; i++) {
27176                                    query.append(_ORDER_BY_ENTITY_ALIAS);
27177                                    query.append(orderByConditionFields[i]);
27178    
27179                                    if ((i + 1) < orderByConditionFields.length) {
27180                                            if (orderByComparator.isAscending() ^ previous) {
27181                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
27182                                            }
27183                                            else {
27184                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
27185                                            }
27186                                    }
27187                                    else {
27188                                            if (orderByComparator.isAscending() ^ previous) {
27189                                                    query.append(WHERE_GREATER_THAN);
27190                                            }
27191                                            else {
27192                                                    query.append(WHERE_LESSER_THAN);
27193                                            }
27194                                    }
27195                            }
27196    
27197                            query.append(ORDER_BY_CLAUSE);
27198    
27199                            String[] orderByFields = orderByComparator.getOrderByFields();
27200    
27201                            for (int i = 0; i < orderByFields.length; i++) {
27202                                    query.append(_ORDER_BY_ENTITY_ALIAS);
27203                                    query.append(orderByFields[i]);
27204    
27205                                    if ((i + 1) < orderByFields.length) {
27206                                            if (orderByComparator.isAscending() ^ previous) {
27207                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
27208                                            }
27209                                            else {
27210                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
27211                                            }
27212                                    }
27213                                    else {
27214                                            if (orderByComparator.isAscending() ^ previous) {
27215                                                    query.append(ORDER_BY_ASC);
27216                                            }
27217                                            else {
27218                                                    query.append(ORDER_BY_DESC);
27219                                            }
27220                                    }
27221                            }
27222                    }
27223                    else {
27224                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
27225                    }
27226    
27227                    String sql = query.toString();
27228    
27229                    Query q = session.createQuery(sql);
27230    
27231                    q.setFirstResult(0);
27232                    q.setMaxResults(2);
27233    
27234                    QueryPos qPos = QueryPos.getInstance(q);
27235    
27236                    qPos.add(groupId);
27237    
27238                    if (bindArticleId) {
27239                            qPos.add(articleId);
27240                    }
27241    
27242                    qPos.add(status);
27243    
27244                    if (orderByComparator != null) {
27245                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
27246    
27247                            for (Object value : values) {
27248                                    qPos.add(value);
27249                            }
27250                    }
27251    
27252                    List<JournalArticle> list = q.list();
27253    
27254                    if (list.size() == 2) {
27255                            return list.get(1);
27256                    }
27257                    else {
27258                            return null;
27259                    }
27260            }
27261    
27262            /**
27263             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
27264             *
27265             * @param groupId the group ID
27266             * @param articleId the article ID
27267             * @param status the status
27268             * @return the matching journal articles that the user has permission to view
27269             * @throws SystemException if a system exception occurred
27270             */
27271            @Override
27272            public List<JournalArticle> filterFindByG_A_ST(long groupId,
27273                    String articleId, int status) throws SystemException {
27274                    return filterFindByG_A_ST(groupId, articleId, status,
27275                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
27276            }
27277    
27278            /**
27279             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
27280             *
27281             * <p>
27282             * 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.
27283             * </p>
27284             *
27285             * @param groupId the group ID
27286             * @param articleId the article ID
27287             * @param status the status
27288             * @param start the lower bound of the range of journal articles
27289             * @param end the upper bound of the range of journal articles (not inclusive)
27290             * @return the range of matching journal articles that the user has permission to view
27291             * @throws SystemException if a system exception occurred
27292             */
27293            @Override
27294            public List<JournalArticle> filterFindByG_A_ST(long groupId,
27295                    String articleId, int status, int start, int end)
27296                    throws SystemException {
27297                    return filterFindByG_A_ST(groupId, articleId, status, start, end, null);
27298            }
27299    
27300            /**
27301             * 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;.
27302             *
27303             * <p>
27304             * 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.
27305             * </p>
27306             *
27307             * @param groupId the group ID
27308             * @param articleId the article ID
27309             * @param status the status
27310             * @param start the lower bound of the range of journal articles
27311             * @param end the upper bound of the range of journal articles (not inclusive)
27312             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
27313             * @return the ordered range of matching journal articles that the user has permission to view
27314             * @throws SystemException if a system exception occurred
27315             */
27316            @Override
27317            public List<JournalArticle> filterFindByG_A_ST(long groupId,
27318                    String articleId, int status, int start, int end,
27319                    OrderByComparator orderByComparator) throws SystemException {
27320                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
27321                            return findByG_A_ST(groupId, articleId, status, start, end,
27322                                    orderByComparator);
27323                    }
27324    
27325                    StringBundler query = null;
27326    
27327                    if (orderByComparator != null) {
27328                            query = new StringBundler(5 +
27329                                            (orderByComparator.getOrderByFields().length * 3));
27330                    }
27331                    else {
27332                            query = new StringBundler(5);
27333                    }
27334    
27335                    if (getDB().isSupportsInlineDistinct()) {
27336                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
27337                    }
27338                    else {
27339                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
27340                    }
27341    
27342                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
27343    
27344                    boolean bindArticleId = false;
27345    
27346                    if (articleId == null) {
27347                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
27348                    }
27349                    else if (articleId.equals(StringPool.BLANK)) {
27350                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
27351                    }
27352                    else {
27353                            bindArticleId = true;
27354    
27355                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
27356                    }
27357    
27358                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
27359    
27360                    if (!getDB().isSupportsInlineDistinct()) {
27361                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
27362                    }
27363    
27364                    if (orderByComparator != null) {
27365                            if (getDB().isSupportsInlineDistinct()) {
27366                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
27367                                            orderByComparator, true);
27368                            }
27369                            else {
27370                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
27371                                            orderByComparator, true);
27372                            }
27373                    }
27374                    else {
27375                            if (getDB().isSupportsInlineDistinct()) {
27376                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
27377                            }
27378                            else {
27379                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
27380                            }
27381                    }
27382    
27383                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
27384                                    JournalArticle.class.getName(),
27385                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
27386    
27387                    Session session = null;
27388    
27389                    try {
27390                            session = openSession();
27391    
27392                            SQLQuery q = session.createSQLQuery(sql);
27393    
27394                            if (getDB().isSupportsInlineDistinct()) {
27395                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
27396                            }
27397                            else {
27398                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
27399                            }
27400    
27401                            QueryPos qPos = QueryPos.getInstance(q);
27402    
27403                            qPos.add(groupId);
27404    
27405                            if (bindArticleId) {
27406                                    qPos.add(articleId);
27407                            }
27408    
27409                            qPos.add(status);
27410    
27411                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
27412                                    end);
27413                    }
27414                    catch (Exception e) {
27415                            throw processException(e);
27416                    }
27417                    finally {
27418                            closeSession(session);
27419                    }
27420            }
27421    
27422            /**
27423             * 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;.
27424             *
27425             * @param id the primary key of the current journal article
27426             * @param groupId the group ID
27427             * @param articleId the article ID
27428             * @param status the status
27429             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27430             * @return the previous, current, and next journal article
27431             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
27432             * @throws SystemException if a system exception occurred
27433             */
27434            @Override
27435            public JournalArticle[] filterFindByG_A_ST_PrevAndNext(long id,
27436                    long groupId, String articleId, int status,
27437                    OrderByComparator orderByComparator)
27438                    throws NoSuchArticleException, SystemException {
27439                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
27440                            return findByG_A_ST_PrevAndNext(id, groupId, articleId, status,
27441                                    orderByComparator);
27442                    }
27443    
27444                    JournalArticle journalArticle = findByPrimaryKey(id);
27445    
27446                    Session session = null;
27447    
27448                    try {
27449                            session = openSession();
27450    
27451                            JournalArticle[] array = new JournalArticleImpl[3];
27452    
27453                            array[0] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
27454                                            groupId, articleId, status, orderByComparator, true);
27455    
27456                            array[1] = journalArticle;
27457    
27458                            array[2] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
27459                                            groupId, articleId, status, orderByComparator, false);
27460    
27461                            return array;
27462                    }
27463                    catch (Exception e) {
27464                            throw processException(e);
27465                    }
27466                    finally {
27467                            closeSession(session);
27468                    }
27469            }
27470    
27471            protected JournalArticle filterGetByG_A_ST_PrevAndNext(Session session,
27472                    JournalArticle journalArticle, long groupId, String articleId,
27473                    int status, OrderByComparator orderByComparator, boolean previous) {
27474                    StringBundler query = null;
27475    
27476                    if (orderByComparator != null) {
27477                            query = new StringBundler(6 +
27478                                            (orderByComparator.getOrderByFields().length * 6));
27479                    }
27480                    else {
27481                            query = new StringBundler(3);
27482                    }
27483    
27484                    if (getDB().isSupportsInlineDistinct()) {
27485                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
27486                    }
27487                    else {
27488                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
27489                    }
27490    
27491                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
27492    
27493                    boolean bindArticleId = false;
27494    
27495                    if (articleId == null) {
27496                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
27497                    }
27498                    else if (articleId.equals(StringPool.BLANK)) {
27499                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
27500                    }
27501                    else {
27502                            bindArticleId = true;
27503    
27504                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
27505                    }
27506    
27507                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
27508    
27509                    if (!getDB().isSupportsInlineDistinct()) {
27510                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
27511                    }
27512    
27513                    if (orderByComparator != null) {
27514                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
27515    
27516                            if (orderByConditionFields.length > 0) {
27517                                    query.append(WHERE_AND);
27518                            }
27519    
27520                            for (int i = 0; i < orderByConditionFields.length; i++) {
27521                                    if (getDB().isSupportsInlineDistinct()) {
27522                                            query.append(_ORDER_BY_ENTITY_ALIAS);
27523                                    }
27524                                    else {
27525                                            query.append(_ORDER_BY_ENTITY_TABLE);
27526                                    }
27527    
27528                                    query.append(orderByConditionFields[i]);
27529    
27530                                    if ((i + 1) < orderByConditionFields.length) {
27531                                            if (orderByComparator.isAscending() ^ previous) {
27532                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
27533                                            }
27534                                            else {
27535                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
27536                                            }
27537                                    }
27538                                    else {
27539                                            if (orderByComparator.isAscending() ^ previous) {
27540                                                    query.append(WHERE_GREATER_THAN);
27541                                            }
27542                                            else {
27543                                                    query.append(WHERE_LESSER_THAN);
27544                                            }
27545                                    }
27546                            }
27547    
27548                            query.append(ORDER_BY_CLAUSE);
27549    
27550                            String[] orderByFields = orderByComparator.getOrderByFields();
27551    
27552                            for (int i = 0; i < orderByFields.length; i++) {
27553                                    if (getDB().isSupportsInlineDistinct()) {
27554                                            query.append(_ORDER_BY_ENTITY_ALIAS);
27555                                    }
27556                                    else {
27557                                            query.append(_ORDER_BY_ENTITY_TABLE);
27558                                    }
27559    
27560                                    query.append(orderByFields[i]);
27561    
27562                                    if ((i + 1) < orderByFields.length) {
27563                                            if (orderByComparator.isAscending() ^ previous) {
27564                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
27565                                            }
27566                                            else {
27567                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
27568                                            }
27569                                    }
27570                                    else {
27571                                            if (orderByComparator.isAscending() ^ previous) {
27572                                                    query.append(ORDER_BY_ASC);
27573                                            }
27574                                            else {
27575                                                    query.append(ORDER_BY_DESC);
27576                                            }
27577                                    }
27578                            }
27579                    }
27580                    else {
27581                            if (getDB().isSupportsInlineDistinct()) {
27582                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
27583                            }
27584                            else {
27585                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
27586                            }
27587                    }
27588    
27589                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
27590                                    JournalArticle.class.getName(),
27591                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
27592    
27593                    SQLQuery q = session.createSQLQuery(sql);
27594    
27595                    q.setFirstResult(0);
27596                    q.setMaxResults(2);
27597    
27598                    if (getDB().isSupportsInlineDistinct()) {
27599                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
27600                    }
27601                    else {
27602                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
27603                    }
27604    
27605                    QueryPos qPos = QueryPos.getInstance(q);
27606    
27607                    qPos.add(groupId);
27608    
27609                    if (bindArticleId) {
27610                            qPos.add(articleId);
27611                    }
27612    
27613                    qPos.add(status);
27614    
27615                    if (orderByComparator != null) {
27616                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
27617    
27618                            for (Object value : values) {
27619                                    qPos.add(value);
27620                            }
27621                    }
27622    
27623                    List<JournalArticle> list = q.list();
27624    
27625                    if (list.size() == 2) {
27626                            return list.get(1);
27627                    }
27628                    else {
27629                            return null;
27630                    }
27631            }
27632    
27633            /**
27634             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
27635             *
27636             * @param groupId the group ID
27637             * @param articleId the article ID
27638             * @param statuses the statuses
27639             * @return the matching journal articles that the user has permission to view
27640             * @throws SystemException if a system exception occurred
27641             */
27642            @Override
27643            public List<JournalArticle> filterFindByG_A_ST(long groupId,
27644                    String articleId, int[] statuses) throws SystemException {
27645                    return filterFindByG_A_ST(groupId, articleId, statuses,
27646                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
27647            }
27648    
27649            /**
27650             * 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;.
27651             *
27652             * <p>
27653             * 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.
27654             * </p>
27655             *
27656             * @param groupId the group ID
27657             * @param articleId the article ID
27658             * @param statuses the statuses
27659             * @param start the lower bound of the range of journal articles
27660             * @param end the upper bound of the range of journal articles (not inclusive)
27661             * @return the range of matching journal articles that the user has permission to view
27662             * @throws SystemException if a system exception occurred
27663             */
27664            @Override
27665            public List<JournalArticle> filterFindByG_A_ST(long groupId,
27666                    String articleId, int[] statuses, int start, int end)
27667                    throws SystemException {
27668                    return filterFindByG_A_ST(groupId, articleId, statuses, start, end, null);
27669            }
27670    
27671            /**
27672             * 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;.
27673             *
27674             * <p>
27675             * 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.
27676             * </p>
27677             *
27678             * @param groupId the group ID
27679             * @param articleId the article ID
27680             * @param statuses the statuses
27681             * @param start the lower bound of the range of journal articles
27682             * @param end the upper bound of the range of journal articles (not inclusive)
27683             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
27684             * @return the ordered range of matching journal articles that the user has permission to view
27685             * @throws SystemException if a system exception occurred
27686             */
27687            @Override
27688            public List<JournalArticle> filterFindByG_A_ST(long groupId,
27689                    String articleId, int[] statuses, int start, int end,
27690                    OrderByComparator orderByComparator) throws SystemException {
27691                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
27692                            return findByG_A_ST(groupId, articleId, statuses, start, end,
27693                                    orderByComparator);
27694                    }
27695    
27696                    StringBundler query = new StringBundler();
27697    
27698                    if (getDB().isSupportsInlineDistinct()) {
27699                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
27700                    }
27701                    else {
27702                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
27703                    }
27704    
27705                    boolean conjunctionable = false;
27706    
27707                    if (conjunctionable) {
27708                            query.append(WHERE_AND);
27709                    }
27710    
27711                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
27712    
27713                    conjunctionable = true;
27714    
27715                    if (conjunctionable) {
27716                            query.append(WHERE_AND);
27717                    }
27718    
27719                    boolean bindArticleId = false;
27720    
27721                    if (articleId == null) {
27722                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
27723                    }
27724                    else if (articleId.equals(StringPool.BLANK)) {
27725                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
27726                    }
27727                    else {
27728                            bindArticleId = true;
27729    
27730                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
27731                    }
27732    
27733                    conjunctionable = true;
27734    
27735                    if ((statuses == null) || (statuses.length > 0)) {
27736                            if (conjunctionable) {
27737                                    query.append(WHERE_AND);
27738                            }
27739    
27740                            query.append(StringPool.OPEN_PARENTHESIS);
27741    
27742                            for (int i = 0; i < statuses.length; i++) {
27743                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
27744    
27745                                    if ((i + 1) < statuses.length) {
27746                                            query.append(WHERE_OR);
27747                                    }
27748                            }
27749    
27750                            query.append(StringPool.CLOSE_PARENTHESIS);
27751    
27752                            conjunctionable = true;
27753                    }
27754    
27755                    if (!getDB().isSupportsInlineDistinct()) {
27756                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
27757                    }
27758    
27759                    if (orderByComparator != null) {
27760                            if (getDB().isSupportsInlineDistinct()) {
27761                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
27762                                            orderByComparator, true);
27763                            }
27764                            else {
27765                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
27766                                            orderByComparator, true);
27767                            }
27768                    }
27769                    else {
27770                            if (getDB().isSupportsInlineDistinct()) {
27771                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
27772                            }
27773                            else {
27774                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
27775                            }
27776                    }
27777    
27778                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
27779                                    JournalArticle.class.getName(),
27780                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
27781    
27782                    Session session = null;
27783    
27784                    try {
27785                            session = openSession();
27786    
27787                            SQLQuery q = session.createSQLQuery(sql);
27788    
27789                            if (getDB().isSupportsInlineDistinct()) {
27790                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
27791                            }
27792                            else {
27793                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
27794                            }
27795    
27796                            QueryPos qPos = QueryPos.getInstance(q);
27797    
27798                            qPos.add(groupId);
27799    
27800                            if (bindArticleId) {
27801                                    qPos.add(articleId);
27802                            }
27803    
27804                            if (statuses != null) {
27805                                    qPos.add(statuses);
27806                            }
27807    
27808                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
27809                                    end);
27810                    }
27811                    catch (Exception e) {
27812                            throw processException(e);
27813                    }
27814                    finally {
27815                            closeSession(session);
27816                    }
27817            }
27818    
27819            /**
27820             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
27821             *
27822             * <p>
27823             * 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.
27824             * </p>
27825             *
27826             * @param groupId the group ID
27827             * @param articleId the article ID
27828             * @param statuses the statuses
27829             * @return the matching journal articles
27830             * @throws SystemException if a system exception occurred
27831             */
27832            @Override
27833            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
27834                    int[] statuses) throws SystemException {
27835                    return findByG_A_ST(groupId, articleId, statuses, QueryUtil.ALL_POS,
27836                            QueryUtil.ALL_POS, null);
27837            }
27838    
27839            /**
27840             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
27841             *
27842             * <p>
27843             * 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.
27844             * </p>
27845             *
27846             * @param groupId the group ID
27847             * @param articleId the article ID
27848             * @param statuses the statuses
27849             * @param start the lower bound of the range of journal articles
27850             * @param end the upper bound of the range of journal articles (not inclusive)
27851             * @return the range of matching journal articles
27852             * @throws SystemException if a system exception occurred
27853             */
27854            @Override
27855            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
27856                    int[] statuses, int start, int end) throws SystemException {
27857                    return findByG_A_ST(groupId, articleId, statuses, start, end, null);
27858            }
27859    
27860            /**
27861             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
27862             *
27863             * <p>
27864             * 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.
27865             * </p>
27866             *
27867             * @param groupId the group ID
27868             * @param articleId the article ID
27869             * @param statuses the statuses
27870             * @param start the lower bound of the range of journal articles
27871             * @param end the upper bound of the range of journal articles (not inclusive)
27872             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
27873             * @return the ordered range of matching journal articles
27874             * @throws SystemException if a system exception occurred
27875             */
27876            @Override
27877            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
27878                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
27879                    throws SystemException {
27880                    if ((statuses != null) && (statuses.length == 1)) {
27881                            return findByG_A_ST(groupId, articleId, statuses[0], start, end,
27882                                    orderByComparator);
27883                    }
27884    
27885                    boolean pagination = true;
27886                    Object[] finderArgs = null;
27887    
27888                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
27889                                    (orderByComparator == null)) {
27890                            pagination = false;
27891                            finderArgs = new Object[] {
27892                                            groupId, articleId, StringUtil.merge(statuses)
27893                                    };
27894                    }
27895                    else {
27896                            finderArgs = new Object[] {
27897                                            groupId, articleId, StringUtil.merge(statuses),
27898                                            
27899                                            start, end, orderByComparator
27900                                    };
27901                    }
27902    
27903                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
27904                                    finderArgs, this);
27905    
27906                    if ((list != null) && !list.isEmpty()) {
27907                            for (JournalArticle journalArticle : list) {
27908                                    if ((groupId != journalArticle.getGroupId()) ||
27909                                                    !Validator.equals(articleId,
27910                                                            journalArticle.getArticleId()) ||
27911                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
27912                                            list = null;
27913    
27914                                            break;
27915                                    }
27916                            }
27917                    }
27918    
27919                    if (list == null) {
27920                            StringBundler query = new StringBundler();
27921    
27922                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
27923    
27924                            boolean conjunctionable = false;
27925    
27926                            if (conjunctionable) {
27927                                    query.append(WHERE_AND);
27928                            }
27929    
27930                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
27931    
27932                            conjunctionable = true;
27933    
27934                            if (conjunctionable) {
27935                                    query.append(WHERE_AND);
27936                            }
27937    
27938                            boolean bindArticleId = false;
27939    
27940                            if (articleId == null) {
27941                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
27942                            }
27943                            else if (articleId.equals(StringPool.BLANK)) {
27944                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
27945                            }
27946                            else {
27947                                    bindArticleId = true;
27948    
27949                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
27950                            }
27951    
27952                            conjunctionable = true;
27953    
27954                            if ((statuses == null) || (statuses.length > 0)) {
27955                                    if (conjunctionable) {
27956                                            query.append(WHERE_AND);
27957                                    }
27958    
27959                                    query.append(StringPool.OPEN_PARENTHESIS);
27960    
27961                                    for (int i = 0; i < statuses.length; i++) {
27962                                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
27963    
27964                                            if ((i + 1) < statuses.length) {
27965                                                    query.append(WHERE_OR);
27966                                            }
27967                                    }
27968    
27969                                    query.append(StringPool.CLOSE_PARENTHESIS);
27970    
27971                                    conjunctionable = true;
27972                            }
27973    
27974                            if (orderByComparator != null) {
27975                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
27976                                            orderByComparator);
27977                            }
27978                            else
27979                             if (pagination) {
27980                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
27981                            }
27982    
27983                            String sql = query.toString();
27984    
27985                            Session session = null;
27986    
27987                            try {
27988                                    session = openSession();
27989    
27990                                    Query q = session.createQuery(sql);
27991    
27992                                    QueryPos qPos = QueryPos.getInstance(q);
27993    
27994                                    qPos.add(groupId);
27995    
27996                                    if (bindArticleId) {
27997                                            qPos.add(articleId);
27998                                    }
27999    
28000                                    if (statuses != null) {
28001                                            qPos.add(statuses);
28002                                    }
28003    
28004                                    if (!pagination) {
28005                                            list = (List<JournalArticle>)QueryUtil.list(q,
28006                                                            getDialect(), start, end, false);
28007    
28008                                            Collections.sort(list);
28009    
28010                                            list = new UnmodifiableList<JournalArticle>(list);
28011                                    }
28012                                    else {
28013                                            list = (List<JournalArticle>)QueryUtil.list(q,
28014                                                            getDialect(), start, end);
28015                                    }
28016    
28017                                    cacheResult(list);
28018    
28019                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
28020                                            finderArgs, list);
28021                            }
28022                            catch (Exception e) {
28023                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
28024                                            finderArgs);
28025    
28026                                    throw processException(e);
28027                            }
28028                            finally {
28029                                    closeSession(session);
28030                            }
28031                    }
28032    
28033                    return list;
28034            }
28035    
28036            /**
28037             * Removes all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63; from the database.
28038             *
28039             * @param groupId the group ID
28040             * @param articleId the article ID
28041             * @param status the status
28042             * @throws SystemException if a system exception occurred
28043             */
28044            @Override
28045            public void removeByG_A_ST(long groupId, String articleId, int status)
28046                    throws SystemException {
28047                    for (JournalArticle journalArticle : findByG_A_ST(groupId, articleId,
28048                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
28049                            remove(journalArticle);
28050                    }
28051            }
28052    
28053            /**
28054             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
28055             *
28056             * @param groupId the group ID
28057             * @param articleId the article ID
28058             * @param status the status
28059             * @return the number of matching journal articles
28060             * @throws SystemException if a system exception occurred
28061             */
28062            @Override
28063            public int countByG_A_ST(long groupId, String articleId, int status)
28064                    throws SystemException {
28065                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A_ST;
28066    
28067                    Object[] finderArgs = new Object[] { groupId, articleId, status };
28068    
28069                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
28070                                    this);
28071    
28072                    if (count == null) {
28073                            StringBundler query = new StringBundler(4);
28074    
28075                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
28076    
28077                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
28078    
28079                            boolean bindArticleId = false;
28080    
28081                            if (articleId == null) {
28082                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
28083                            }
28084                            else if (articleId.equals(StringPool.BLANK)) {
28085                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
28086                            }
28087                            else {
28088                                    bindArticleId = true;
28089    
28090                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
28091                            }
28092    
28093                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
28094    
28095                            String sql = query.toString();
28096    
28097                            Session session = null;
28098    
28099                            try {
28100                                    session = openSession();
28101    
28102                                    Query q = session.createQuery(sql);
28103    
28104                                    QueryPos qPos = QueryPos.getInstance(q);
28105    
28106                                    qPos.add(groupId);
28107    
28108                                    if (bindArticleId) {
28109                                            qPos.add(articleId);
28110                                    }
28111    
28112                                    qPos.add(status);
28113    
28114                                    count = (Long)q.uniqueResult();
28115    
28116                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
28117                            }
28118                            catch (Exception e) {
28119                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
28120    
28121                                    throw processException(e);
28122                            }
28123                            finally {
28124                                    closeSession(session);
28125                            }
28126                    }
28127    
28128                    return count.intValue();
28129            }
28130    
28131            /**
28132             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
28133             *
28134             * @param groupId the group ID
28135             * @param articleId the article ID
28136             * @param statuses the statuses
28137             * @return the number of matching journal articles
28138             * @throws SystemException if a system exception occurred
28139             */
28140            @Override
28141            public int countByG_A_ST(long groupId, String articleId, int[] statuses)
28142                    throws SystemException {
28143                    Object[] finderArgs = new Object[] {
28144                                    groupId, articleId, StringUtil.merge(statuses)
28145                            };
28146    
28147                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
28148                                    finderArgs, this);
28149    
28150                    if (count == null) {
28151                            StringBundler query = new StringBundler();
28152    
28153                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
28154    
28155                            boolean conjunctionable = false;
28156    
28157                            if (conjunctionable) {
28158                                    query.append(WHERE_AND);
28159                            }
28160    
28161                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
28162    
28163                            conjunctionable = true;
28164    
28165                            if (conjunctionable) {
28166                                    query.append(WHERE_AND);
28167                            }
28168    
28169                            boolean bindArticleId = false;
28170    
28171                            if (articleId == null) {
28172                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
28173                            }
28174                            else if (articleId.equals(StringPool.BLANK)) {
28175                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
28176                            }
28177                            else {
28178                                    bindArticleId = true;
28179    
28180                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
28181                            }
28182    
28183                            conjunctionable = true;
28184    
28185                            if ((statuses == null) || (statuses.length > 0)) {
28186                                    if (conjunctionable) {
28187                                            query.append(WHERE_AND);
28188                                    }
28189    
28190                                    query.append(StringPool.OPEN_PARENTHESIS);
28191    
28192                                    for (int i = 0; i < statuses.length; i++) {
28193                                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
28194    
28195                                            if ((i + 1) < statuses.length) {
28196                                                    query.append(WHERE_OR);
28197                                            }
28198                                    }
28199    
28200                                    query.append(StringPool.CLOSE_PARENTHESIS);
28201    
28202                                    conjunctionable = true;
28203                            }
28204    
28205                            String sql = query.toString();
28206    
28207                            Session session = null;
28208    
28209                            try {
28210                                    session = openSession();
28211    
28212                                    Query q = session.createQuery(sql);
28213    
28214                                    QueryPos qPos = QueryPos.getInstance(q);
28215    
28216                                    qPos.add(groupId);
28217    
28218                                    if (bindArticleId) {
28219                                            qPos.add(articleId);
28220                                    }
28221    
28222                                    if (statuses != null) {
28223                                            qPos.add(statuses);
28224                                    }
28225    
28226                                    count = (Long)q.uniqueResult();
28227    
28228                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
28229                                            finderArgs, count);
28230                            }
28231                            catch (Exception e) {
28232                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
28233                                            finderArgs);
28234    
28235                                    throw processException(e);
28236                            }
28237                            finally {
28238                                    closeSession(session);
28239                            }
28240                    }
28241    
28242                    return count.intValue();
28243            }
28244    
28245            /**
28246             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
28247             *
28248             * @param groupId the group ID
28249             * @param articleId the article ID
28250             * @param status the status
28251             * @return the number of matching journal articles that the user has permission to view
28252             * @throws SystemException if a system exception occurred
28253             */
28254            @Override
28255            public int filterCountByG_A_ST(long groupId, String articleId, int status)
28256                    throws SystemException {
28257                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
28258                            return countByG_A_ST(groupId, articleId, status);
28259                    }
28260    
28261                    StringBundler query = new StringBundler(4);
28262    
28263                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
28264    
28265                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
28266    
28267                    boolean bindArticleId = false;
28268    
28269                    if (articleId == null) {
28270                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
28271                    }
28272                    else if (articleId.equals(StringPool.BLANK)) {
28273                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
28274                    }
28275                    else {
28276                            bindArticleId = true;
28277    
28278                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
28279                    }
28280    
28281                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
28282    
28283                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
28284                                    JournalArticle.class.getName(),
28285                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
28286    
28287                    Session session = null;
28288    
28289                    try {
28290                            session = openSession();
28291    
28292                            SQLQuery q = session.createSQLQuery(sql);
28293    
28294                            q.addScalar(COUNT_COLUMN_NAME,
28295                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
28296    
28297                            QueryPos qPos = QueryPos.getInstance(q);
28298    
28299                            qPos.add(groupId);
28300    
28301                            if (bindArticleId) {
28302                                    qPos.add(articleId);
28303                            }
28304    
28305                            qPos.add(status);
28306    
28307                            Long count = (Long)q.uniqueResult();
28308    
28309                            return count.intValue();
28310                    }
28311                    catch (Exception e) {
28312                            throw processException(e);
28313                    }
28314                    finally {
28315                            closeSession(session);
28316                    }
28317            }
28318    
28319            /**
28320             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
28321             *
28322             * @param groupId the group ID
28323             * @param articleId the article ID
28324             * @param statuses the statuses
28325             * @return the number of matching journal articles that the user has permission to view
28326             * @throws SystemException if a system exception occurred
28327             */
28328            @Override
28329            public int filterCountByG_A_ST(long groupId, String articleId,
28330                    int[] statuses) throws SystemException {
28331                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
28332                            return countByG_A_ST(groupId, articleId, statuses);
28333                    }
28334    
28335                    StringBundler query = new StringBundler();
28336    
28337                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
28338    
28339                    boolean conjunctionable = false;
28340    
28341                    if (conjunctionable) {
28342                            query.append(WHERE_AND);
28343                    }
28344    
28345                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
28346    
28347                    conjunctionable = true;
28348    
28349                    if (conjunctionable) {
28350                            query.append(WHERE_AND);
28351                    }
28352    
28353                    boolean bindArticleId = false;
28354    
28355                    if (articleId == null) {
28356                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
28357                    }
28358                    else if (articleId.equals(StringPool.BLANK)) {
28359                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
28360                    }
28361                    else {
28362                            bindArticleId = true;
28363    
28364                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
28365                    }
28366    
28367                    conjunctionable = true;
28368    
28369                    if ((statuses == null) || (statuses.length > 0)) {
28370                            if (conjunctionable) {
28371                                    query.append(WHERE_AND);
28372                            }
28373    
28374                            query.append(StringPool.OPEN_PARENTHESIS);
28375    
28376                            for (int i = 0; i < statuses.length; i++) {
28377                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
28378    
28379                                    if ((i + 1) < statuses.length) {
28380                                            query.append(WHERE_OR);
28381                                    }
28382                            }
28383    
28384                            query.append(StringPool.CLOSE_PARENTHESIS);
28385    
28386                            conjunctionable = true;
28387                    }
28388    
28389                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
28390                                    JournalArticle.class.getName(),
28391                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
28392    
28393                    Session session = null;
28394    
28395                    try {
28396                            session = openSession();
28397    
28398                            SQLQuery q = session.createSQLQuery(sql);
28399    
28400                            q.addScalar(COUNT_COLUMN_NAME,
28401                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
28402    
28403                            QueryPos qPos = QueryPos.getInstance(q);
28404    
28405                            qPos.add(groupId);
28406    
28407                            if (bindArticleId) {
28408                                    qPos.add(articleId);
28409                            }
28410    
28411                            if (statuses != null) {
28412                                    qPos.add(statuses);
28413                            }
28414    
28415                            Long count = (Long)q.uniqueResult();
28416    
28417                            return count.intValue();
28418                    }
28419                    catch (Exception e) {
28420                            throw processException(e);
28421                    }
28422                    finally {
28423                            closeSession(session);
28424                    }
28425            }
28426    
28427            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
28428            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_5 = "(" +
28429                    removeConjunction(_FINDER_COLUMN_G_A_ST_GROUPID_2) + ")";
28430            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
28431            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
28432            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '') AND ";
28433            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_4 = "(" +
28434                    removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_1) + ")";
28435            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_5 = "(" +
28436                    removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_2) + ")";
28437            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_6 = "(" +
28438                    removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_3) + ")";
28439            private static final String _FINDER_COLUMN_G_A_ST_STATUS_2 = "journalArticle.status = ?";
28440            private static final String _FINDER_COLUMN_G_A_ST_STATUS_5 = "(" +
28441                    removeConjunction(_FINDER_COLUMN_G_A_ST_STATUS_2) + ")";
28442            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_NOTST =
28443                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28444                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
28445                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
28446                            "findByG_A_NotST",
28447                            new String[] {
28448                                    Long.class.getName(), String.class.getName(),
28449                                    Integer.class.getName(),
28450                                    
28451                            Integer.class.getName(), Integer.class.getName(),
28452                                    OrderByComparator.class.getName()
28453                            });
28454            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_NOTST =
28455                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28456                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
28457                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_A_NotST",
28458                            new String[] {
28459                                    Long.class.getName(), String.class.getName(),
28460                                    Integer.class.getName()
28461                            });
28462    
28463            /**
28464             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
28465             *
28466             * @param groupId the group ID
28467             * @param articleId the article ID
28468             * @param status the status
28469             * @return the matching journal articles
28470             * @throws SystemException if a system exception occurred
28471             */
28472            @Override
28473            public List<JournalArticle> findByG_A_NotST(long groupId, String articleId,
28474                    int status) throws SystemException {
28475                    return findByG_A_NotST(groupId, articleId, status, QueryUtil.ALL_POS,
28476                            QueryUtil.ALL_POS, null);
28477            }
28478    
28479            /**
28480             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
28481             *
28482             * <p>
28483             * 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.
28484             * </p>
28485             *
28486             * @param groupId the group ID
28487             * @param articleId the article ID
28488             * @param status the status
28489             * @param start the lower bound of the range of journal articles
28490             * @param end the upper bound of the range of journal articles (not inclusive)
28491             * @return the range of matching journal articles
28492             * @throws SystemException if a system exception occurred
28493             */
28494            @Override
28495            public List<JournalArticle> findByG_A_NotST(long groupId, String articleId,
28496                    int status, int start, int end) throws SystemException {
28497                    return findByG_A_NotST(groupId, articleId, status, start, end, null);
28498            }
28499    
28500            /**
28501             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
28502             *
28503             * <p>
28504             * 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.
28505             * </p>
28506             *
28507             * @param groupId the group ID
28508             * @param articleId the article ID
28509             * @param status the status
28510             * @param start the lower bound of the range of journal articles
28511             * @param end the upper bound of the range of journal articles (not inclusive)
28512             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
28513             * @return the ordered range of matching journal articles
28514             * @throws SystemException if a system exception occurred
28515             */
28516            @Override
28517            public List<JournalArticle> findByG_A_NotST(long groupId, String articleId,
28518                    int status, int start, int end, OrderByComparator orderByComparator)
28519                    throws SystemException {
28520                    boolean pagination = true;
28521                    FinderPath finderPath = null;
28522                    Object[] finderArgs = null;
28523    
28524                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_NOTST;
28525                    finderArgs = new Object[] {
28526                                    groupId, articleId, status,
28527                                    
28528                                    start, end, orderByComparator
28529                            };
28530    
28531                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
28532                                    finderArgs, this);
28533    
28534                    if ((list != null) && !list.isEmpty()) {
28535                            for (JournalArticle journalArticle : list) {
28536                                    if ((groupId != journalArticle.getGroupId()) ||
28537                                                    !Validator.equals(articleId,
28538                                                            journalArticle.getArticleId()) ||
28539                                                    (status == journalArticle.getStatus())) {
28540                                            list = null;
28541    
28542                                            break;
28543                                    }
28544                            }
28545                    }
28546    
28547                    if (list == null) {
28548                            StringBundler query = null;
28549    
28550                            if (orderByComparator != null) {
28551                                    query = new StringBundler(5 +
28552                                                    (orderByComparator.getOrderByFields().length * 3));
28553                            }
28554                            else {
28555                                    query = new StringBundler(5);
28556                            }
28557    
28558                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
28559    
28560                            query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
28561    
28562                            boolean bindArticleId = false;
28563    
28564                            if (articleId == null) {
28565                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
28566                            }
28567                            else if (articleId.equals(StringPool.BLANK)) {
28568                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
28569                            }
28570                            else {
28571                                    bindArticleId = true;
28572    
28573                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
28574                            }
28575    
28576                            query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
28577    
28578                            if (orderByComparator != null) {
28579                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
28580                                            orderByComparator);
28581                            }
28582                            else
28583                             if (pagination) {
28584                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
28585                            }
28586    
28587                            String sql = query.toString();
28588    
28589                            Session session = null;
28590    
28591                            try {
28592                                    session = openSession();
28593    
28594                                    Query q = session.createQuery(sql);
28595    
28596                                    QueryPos qPos = QueryPos.getInstance(q);
28597    
28598                                    qPos.add(groupId);
28599    
28600                                    if (bindArticleId) {
28601                                            qPos.add(articleId);
28602                                    }
28603    
28604                                    qPos.add(status);
28605    
28606                                    if (!pagination) {
28607                                            list = (List<JournalArticle>)QueryUtil.list(q,
28608                                                            getDialect(), start, end, false);
28609    
28610                                            Collections.sort(list);
28611    
28612                                            list = new UnmodifiableList<JournalArticle>(list);
28613                                    }
28614                                    else {
28615                                            list = (List<JournalArticle>)QueryUtil.list(q,
28616                                                            getDialect(), start, end);
28617                                    }
28618    
28619                                    cacheResult(list);
28620    
28621                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
28622                            }
28623                            catch (Exception e) {
28624                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
28625    
28626                                    throw processException(e);
28627                            }
28628                            finally {
28629                                    closeSession(session);
28630                            }
28631                    }
28632    
28633                    return list;
28634            }
28635    
28636            /**
28637             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
28638             *
28639             * @param groupId the group ID
28640             * @param articleId the article ID
28641             * @param status the status
28642             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28643             * @return the first matching journal article
28644             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
28645             * @throws SystemException if a system exception occurred
28646             */
28647            @Override
28648            public JournalArticle findByG_A_NotST_First(long groupId, String articleId,
28649                    int status, OrderByComparator orderByComparator)
28650                    throws NoSuchArticleException, SystemException {
28651                    JournalArticle journalArticle = fetchByG_A_NotST_First(groupId,
28652                                    articleId, status, orderByComparator);
28653    
28654                    if (journalArticle != null) {
28655                            return journalArticle;
28656                    }
28657    
28658                    StringBundler msg = new StringBundler(8);
28659    
28660                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
28661    
28662                    msg.append("groupId=");
28663                    msg.append(groupId);
28664    
28665                    msg.append(", articleId=");
28666                    msg.append(articleId);
28667    
28668                    msg.append(", status=");
28669                    msg.append(status);
28670    
28671                    msg.append(StringPool.CLOSE_CURLY_BRACE);
28672    
28673                    throw new NoSuchArticleException(msg.toString());
28674            }
28675    
28676            /**
28677             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
28678             *
28679             * @param groupId the group ID
28680             * @param articleId the article ID
28681             * @param status the status
28682             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28683             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
28684             * @throws SystemException if a system exception occurred
28685             */
28686            @Override
28687            public JournalArticle fetchByG_A_NotST_First(long groupId,
28688                    String articleId, int status, OrderByComparator orderByComparator)
28689                    throws SystemException {
28690                    List<JournalArticle> list = findByG_A_NotST(groupId, articleId, status,
28691                                    0, 1, orderByComparator);
28692    
28693                    if (!list.isEmpty()) {
28694                            return list.get(0);
28695                    }
28696    
28697                    return null;
28698            }
28699    
28700            /**
28701             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
28702             *
28703             * @param groupId the group ID
28704             * @param articleId the article ID
28705             * @param status the status
28706             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28707             * @return the last matching journal article
28708             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
28709             * @throws SystemException if a system exception occurred
28710             */
28711            @Override
28712            public JournalArticle findByG_A_NotST_Last(long groupId, String articleId,
28713                    int status, OrderByComparator orderByComparator)
28714                    throws NoSuchArticleException, SystemException {
28715                    JournalArticle journalArticle = fetchByG_A_NotST_Last(groupId,
28716                                    articleId, status, orderByComparator);
28717    
28718                    if (journalArticle != null) {
28719                            return journalArticle;
28720                    }
28721    
28722                    StringBundler msg = new StringBundler(8);
28723    
28724                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
28725    
28726                    msg.append("groupId=");
28727                    msg.append(groupId);
28728    
28729                    msg.append(", articleId=");
28730                    msg.append(articleId);
28731    
28732                    msg.append(", status=");
28733                    msg.append(status);
28734    
28735                    msg.append(StringPool.CLOSE_CURLY_BRACE);
28736    
28737                    throw new NoSuchArticleException(msg.toString());
28738            }
28739    
28740            /**
28741             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
28742             *
28743             * @param groupId the group ID
28744             * @param articleId the article ID
28745             * @param status the status
28746             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28747             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
28748             * @throws SystemException if a system exception occurred
28749             */
28750            @Override
28751            public JournalArticle fetchByG_A_NotST_Last(long groupId, String articleId,
28752                    int status, OrderByComparator orderByComparator)
28753                    throws SystemException {
28754                    int count = countByG_A_NotST(groupId, articleId, status);
28755    
28756                    if (count == 0) {
28757                            return null;
28758                    }
28759    
28760                    List<JournalArticle> list = findByG_A_NotST(groupId, articleId, status,
28761                                    count - 1, count, orderByComparator);
28762    
28763                    if (!list.isEmpty()) {
28764                            return list.get(0);
28765                    }
28766    
28767                    return null;
28768            }
28769    
28770            /**
28771             * 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;.
28772             *
28773             * @param id the primary key of the current journal article
28774             * @param groupId the group ID
28775             * @param articleId the article ID
28776             * @param status the status
28777             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28778             * @return the previous, current, and next journal article
28779             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
28780             * @throws SystemException if a system exception occurred
28781             */
28782            @Override
28783            public JournalArticle[] findByG_A_NotST_PrevAndNext(long id, long groupId,
28784                    String articleId, int status, OrderByComparator orderByComparator)
28785                    throws NoSuchArticleException, SystemException {
28786                    JournalArticle journalArticle = findByPrimaryKey(id);
28787    
28788                    Session session = null;
28789    
28790                    try {
28791                            session = openSession();
28792    
28793                            JournalArticle[] array = new JournalArticleImpl[3];
28794    
28795                            array[0] = getByG_A_NotST_PrevAndNext(session, journalArticle,
28796                                            groupId, articleId, status, orderByComparator, true);
28797    
28798                            array[1] = journalArticle;
28799    
28800                            array[2] = getByG_A_NotST_PrevAndNext(session, journalArticle,
28801                                            groupId, articleId, status, orderByComparator, false);
28802    
28803                            return array;
28804                    }
28805                    catch (Exception e) {
28806                            throw processException(e);
28807                    }
28808                    finally {
28809                            closeSession(session);
28810                    }
28811            }
28812    
28813            protected JournalArticle getByG_A_NotST_PrevAndNext(Session session,
28814                    JournalArticle journalArticle, long groupId, String articleId,
28815                    int status, OrderByComparator orderByComparator, boolean previous) {
28816                    StringBundler query = null;
28817    
28818                    if (orderByComparator != null) {
28819                            query = new StringBundler(6 +
28820                                            (orderByComparator.getOrderByFields().length * 6));
28821                    }
28822                    else {
28823                            query = new StringBundler(3);
28824                    }
28825    
28826                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
28827    
28828                    query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
28829    
28830                    boolean bindArticleId = false;
28831    
28832                    if (articleId == null) {
28833                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
28834                    }
28835                    else if (articleId.equals(StringPool.BLANK)) {
28836                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
28837                    }
28838                    else {
28839                            bindArticleId = true;
28840    
28841                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
28842                    }
28843    
28844                    query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
28845    
28846                    if (orderByComparator != null) {
28847                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
28848    
28849                            if (orderByConditionFields.length > 0) {
28850                                    query.append(WHERE_AND);
28851                            }
28852    
28853                            for (int i = 0; i < orderByConditionFields.length; i++) {
28854                                    query.append(_ORDER_BY_ENTITY_ALIAS);
28855                                    query.append(orderByConditionFields[i]);
28856    
28857                                    if ((i + 1) < orderByConditionFields.length) {
28858                                            if (orderByComparator.isAscending() ^ previous) {
28859                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
28860                                            }
28861                                            else {
28862                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
28863                                            }
28864                                    }
28865                                    else {
28866                                            if (orderByComparator.isAscending() ^ previous) {
28867                                                    query.append(WHERE_GREATER_THAN);
28868                                            }
28869                                            else {
28870                                                    query.append(WHERE_LESSER_THAN);
28871                                            }
28872                                    }
28873                            }
28874    
28875                            query.append(ORDER_BY_CLAUSE);
28876    
28877                            String[] orderByFields = orderByComparator.getOrderByFields();
28878    
28879                            for (int i = 0; i < orderByFields.length; i++) {
28880                                    query.append(_ORDER_BY_ENTITY_ALIAS);
28881                                    query.append(orderByFields[i]);
28882    
28883                                    if ((i + 1) < orderByFields.length) {
28884                                            if (orderByComparator.isAscending() ^ previous) {
28885                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
28886                                            }
28887                                            else {
28888                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
28889                                            }
28890                                    }
28891                                    else {
28892                                            if (orderByComparator.isAscending() ^ previous) {
28893                                                    query.append(ORDER_BY_ASC);
28894                                            }
28895                                            else {
28896                                                    query.append(ORDER_BY_DESC);
28897                                            }
28898                                    }
28899                            }
28900                    }
28901                    else {
28902                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
28903                    }
28904    
28905                    String sql = query.toString();
28906    
28907                    Query q = session.createQuery(sql);
28908    
28909                    q.setFirstResult(0);
28910                    q.setMaxResults(2);
28911    
28912                    QueryPos qPos = QueryPos.getInstance(q);
28913    
28914                    qPos.add(groupId);
28915    
28916                    if (bindArticleId) {
28917                            qPos.add(articleId);
28918                    }
28919    
28920                    qPos.add(status);
28921    
28922                    if (orderByComparator != null) {
28923                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
28924    
28925                            for (Object value : values) {
28926                                    qPos.add(value);
28927                            }
28928                    }
28929    
28930                    List<JournalArticle> list = q.list();
28931    
28932                    if (list.size() == 2) {
28933                            return list.get(1);
28934                    }
28935                    else {
28936                            return null;
28937                    }
28938            }
28939    
28940            /**
28941             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
28942             *
28943             * @param groupId the group ID
28944             * @param articleId the article ID
28945             * @param status the status
28946             * @return the matching journal articles that the user has permission to view
28947             * @throws SystemException if a system exception occurred
28948             */
28949            @Override
28950            public List<JournalArticle> filterFindByG_A_NotST(long groupId,
28951                    String articleId, int status) throws SystemException {
28952                    return filterFindByG_A_NotST(groupId, articleId, status,
28953                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
28954            }
28955    
28956            /**
28957             * 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;.
28958             *
28959             * <p>
28960             * 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.
28961             * </p>
28962             *
28963             * @param groupId the group ID
28964             * @param articleId the article ID
28965             * @param status the status
28966             * @param start the lower bound of the range of journal articles
28967             * @param end the upper bound of the range of journal articles (not inclusive)
28968             * @return the range of matching journal articles that the user has permission to view
28969             * @throws SystemException if a system exception occurred
28970             */
28971            @Override
28972            public List<JournalArticle> filterFindByG_A_NotST(long groupId,
28973                    String articleId, int status, int start, int end)
28974                    throws SystemException {
28975                    return filterFindByG_A_NotST(groupId, articleId, status, start, end,
28976                            null);
28977            }
28978    
28979            /**
28980             * 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;.
28981             *
28982             * <p>
28983             * 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.
28984             * </p>
28985             *
28986             * @param groupId the group ID
28987             * @param articleId the article ID
28988             * @param status the status
28989             * @param start the lower bound of the range of journal articles
28990             * @param end the upper bound of the range of journal articles (not inclusive)
28991             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
28992             * @return the ordered range of matching journal articles that the user has permission to view
28993             * @throws SystemException if a system exception occurred
28994             */
28995            @Override
28996            public List<JournalArticle> filterFindByG_A_NotST(long groupId,
28997                    String articleId, int status, int start, int end,
28998                    OrderByComparator orderByComparator) throws SystemException {
28999                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
29000                            return findByG_A_NotST(groupId, articleId, status, start, end,
29001                                    orderByComparator);
29002                    }
29003    
29004                    StringBundler query = null;
29005    
29006                    if (orderByComparator != null) {
29007                            query = new StringBundler(5 +
29008                                            (orderByComparator.getOrderByFields().length * 3));
29009                    }
29010                    else {
29011                            query = new StringBundler(5);
29012                    }
29013    
29014                    if (getDB().isSupportsInlineDistinct()) {
29015                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
29016                    }
29017                    else {
29018                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
29019                    }
29020    
29021                    query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
29022    
29023                    boolean bindArticleId = false;
29024    
29025                    if (articleId == null) {
29026                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
29027                    }
29028                    else if (articleId.equals(StringPool.BLANK)) {
29029                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
29030                    }
29031                    else {
29032                            bindArticleId = true;
29033    
29034                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
29035                    }
29036    
29037                    query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
29038    
29039                    if (!getDB().isSupportsInlineDistinct()) {
29040                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
29041                    }
29042    
29043                    if (orderByComparator != null) {
29044                            if (getDB().isSupportsInlineDistinct()) {
29045                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
29046                                            orderByComparator, true);
29047                            }
29048                            else {
29049                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
29050                                            orderByComparator, true);
29051                            }
29052                    }
29053                    else {
29054                            if (getDB().isSupportsInlineDistinct()) {
29055                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
29056                            }
29057                            else {
29058                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
29059                            }
29060                    }
29061    
29062                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
29063                                    JournalArticle.class.getName(),
29064                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
29065    
29066                    Session session = null;
29067    
29068                    try {
29069                            session = openSession();
29070    
29071                            SQLQuery q = session.createSQLQuery(sql);
29072    
29073                            if (getDB().isSupportsInlineDistinct()) {
29074                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
29075                            }
29076                            else {
29077                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
29078                            }
29079    
29080                            QueryPos qPos = QueryPos.getInstance(q);
29081    
29082                            qPos.add(groupId);
29083    
29084                            if (bindArticleId) {
29085                                    qPos.add(articleId);
29086                            }
29087    
29088                            qPos.add(status);
29089    
29090                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
29091                                    end);
29092                    }
29093                    catch (Exception e) {
29094                            throw processException(e);
29095                    }
29096                    finally {
29097                            closeSession(session);
29098                    }
29099            }
29100    
29101            /**
29102             * 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;.
29103             *
29104             * @param id the primary key of the current journal article
29105             * @param groupId the group ID
29106             * @param articleId the article ID
29107             * @param status the status
29108             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
29109             * @return the previous, current, and next journal article
29110             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
29111             * @throws SystemException if a system exception occurred
29112             */
29113            @Override
29114            public JournalArticle[] filterFindByG_A_NotST_PrevAndNext(long id,
29115                    long groupId, String articleId, int status,
29116                    OrderByComparator orderByComparator)
29117                    throws NoSuchArticleException, SystemException {
29118                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
29119                            return findByG_A_NotST_PrevAndNext(id, groupId, articleId, status,
29120                                    orderByComparator);
29121                    }
29122    
29123                    JournalArticle journalArticle = findByPrimaryKey(id);
29124    
29125                    Session session = null;
29126    
29127                    try {
29128                            session = openSession();
29129    
29130                            JournalArticle[] array = new JournalArticleImpl[3];
29131    
29132                            array[0] = filterGetByG_A_NotST_PrevAndNext(session,
29133                                            journalArticle, groupId, articleId, status,
29134                                            orderByComparator, true);
29135    
29136                            array[1] = journalArticle;
29137    
29138                            array[2] = filterGetByG_A_NotST_PrevAndNext(session,
29139                                            journalArticle, groupId, articleId, status,
29140                                            orderByComparator, false);
29141    
29142                            return array;
29143                    }
29144                    catch (Exception e) {
29145                            throw processException(e);
29146                    }
29147                    finally {
29148                            closeSession(session);
29149                    }
29150            }
29151    
29152            protected JournalArticle filterGetByG_A_NotST_PrevAndNext(Session session,
29153                    JournalArticle journalArticle, long groupId, String articleId,
29154                    int status, OrderByComparator orderByComparator, boolean previous) {
29155                    StringBundler query = null;
29156    
29157                    if (orderByComparator != null) {
29158                            query = new StringBundler(6 +
29159                                            (orderByComparator.getOrderByFields().length * 6));
29160                    }
29161                    else {
29162                            query = new StringBundler(3);
29163                    }
29164    
29165                    if (getDB().isSupportsInlineDistinct()) {
29166                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
29167                    }
29168                    else {
29169                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
29170                    }
29171    
29172                    query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
29173    
29174                    boolean bindArticleId = false;
29175    
29176                    if (articleId == null) {
29177                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
29178                    }
29179                    else if (articleId.equals(StringPool.BLANK)) {
29180                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
29181                    }
29182                    else {
29183                            bindArticleId = true;
29184    
29185                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
29186                    }
29187    
29188                    query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
29189    
29190                    if (!getDB().isSupportsInlineDistinct()) {
29191                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
29192                    }
29193    
29194                    if (orderByComparator != null) {
29195                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
29196    
29197                            if (orderByConditionFields.length > 0) {
29198                                    query.append(WHERE_AND);
29199                            }
29200    
29201                            for (int i = 0; i < orderByConditionFields.length; i++) {
29202                                    if (getDB().isSupportsInlineDistinct()) {
29203                                            query.append(_ORDER_BY_ENTITY_ALIAS);
29204                                    }
29205                                    else {
29206                                            query.append(_ORDER_BY_ENTITY_TABLE);
29207                                    }
29208    
29209                                    query.append(orderByConditionFields[i]);
29210    
29211                                    if ((i + 1) < orderByConditionFields.length) {
29212                                            if (orderByComparator.isAscending() ^ previous) {
29213                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
29214                                            }
29215                                            else {
29216                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
29217                                            }
29218                                    }
29219                                    else {
29220                                            if (orderByComparator.isAscending() ^ previous) {
29221                                                    query.append(WHERE_GREATER_THAN);
29222                                            }
29223                                            else {
29224                                                    query.append(WHERE_LESSER_THAN);
29225                                            }
29226                                    }
29227                            }
29228    
29229                            query.append(ORDER_BY_CLAUSE);
29230    
29231                            String[] orderByFields = orderByComparator.getOrderByFields();
29232    
29233                            for (int i = 0; i < orderByFields.length; i++) {
29234                                    if (getDB().isSupportsInlineDistinct()) {
29235                                            query.append(_ORDER_BY_ENTITY_ALIAS);
29236                                    }
29237                                    else {
29238                                            query.append(_ORDER_BY_ENTITY_TABLE);
29239                                    }
29240    
29241                                    query.append(orderByFields[i]);
29242    
29243                                    if ((i + 1) < orderByFields.length) {
29244                                            if (orderByComparator.isAscending() ^ previous) {
29245                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
29246                                            }
29247                                            else {
29248                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
29249                                            }
29250                                    }
29251                                    else {
29252                                            if (orderByComparator.isAscending() ^ previous) {
29253                                                    query.append(ORDER_BY_ASC);
29254                                            }
29255                                            else {
29256                                                    query.append(ORDER_BY_DESC);
29257                                            }
29258                                    }
29259                            }
29260                    }
29261                    else {
29262                            if (getDB().isSupportsInlineDistinct()) {
29263                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
29264                            }
29265                            else {
29266                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
29267                            }
29268                    }
29269    
29270                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
29271                                    JournalArticle.class.getName(),
29272                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
29273    
29274                    SQLQuery q = session.createSQLQuery(sql);
29275    
29276                    q.setFirstResult(0);
29277                    q.setMaxResults(2);
29278    
29279                    if (getDB().isSupportsInlineDistinct()) {
29280                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
29281                    }
29282                    else {
29283                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
29284                    }
29285    
29286                    QueryPos qPos = QueryPos.getInstance(q);
29287    
29288                    qPos.add(groupId);
29289    
29290                    if (bindArticleId) {
29291                            qPos.add(articleId);
29292                    }
29293    
29294                    qPos.add(status);
29295    
29296                    if (orderByComparator != null) {
29297                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
29298    
29299                            for (Object value : values) {
29300                                    qPos.add(value);
29301                            }
29302                    }
29303    
29304                    List<JournalArticle> list = q.list();
29305    
29306                    if (list.size() == 2) {
29307                            return list.get(1);
29308                    }
29309                    else {
29310                            return null;
29311                    }
29312            }
29313    
29314            /**
29315             * Removes all the journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63; from the database.
29316             *
29317             * @param groupId the group ID
29318             * @param articleId the article ID
29319             * @param status the status
29320             * @throws SystemException if a system exception occurred
29321             */
29322            @Override
29323            public void removeByG_A_NotST(long groupId, String articleId, int status)
29324                    throws SystemException {
29325                    for (JournalArticle journalArticle : findByG_A_NotST(groupId,
29326                                    articleId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
29327                            remove(journalArticle);
29328                    }
29329            }
29330    
29331            /**
29332             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
29333             *
29334             * @param groupId the group ID
29335             * @param articleId the article ID
29336             * @param status the status
29337             * @return the number of matching journal articles
29338             * @throws SystemException if a system exception occurred
29339             */
29340            @Override
29341            public int countByG_A_NotST(long groupId, String articleId, int status)
29342                    throws SystemException {
29343                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_NOTST;
29344    
29345                    Object[] finderArgs = new Object[] { groupId, articleId, status };
29346    
29347                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
29348                                    this);
29349    
29350                    if (count == null) {
29351                            StringBundler query = new StringBundler(4);
29352    
29353                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
29354    
29355                            query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
29356    
29357                            boolean bindArticleId = false;
29358    
29359                            if (articleId == null) {
29360                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
29361                            }
29362                            else if (articleId.equals(StringPool.BLANK)) {
29363                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
29364                            }
29365                            else {
29366                                    bindArticleId = true;
29367    
29368                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
29369                            }
29370    
29371                            query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
29372    
29373                            String sql = query.toString();
29374    
29375                            Session session = null;
29376    
29377                            try {
29378                                    session = openSession();
29379    
29380                                    Query q = session.createQuery(sql);
29381    
29382                                    QueryPos qPos = QueryPos.getInstance(q);
29383    
29384                                    qPos.add(groupId);
29385    
29386                                    if (bindArticleId) {
29387                                            qPos.add(articleId);
29388                                    }
29389    
29390                                    qPos.add(status);
29391    
29392                                    count = (Long)q.uniqueResult();
29393    
29394                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
29395                            }
29396                            catch (Exception e) {
29397                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
29398    
29399                                    throw processException(e);
29400                            }
29401                            finally {
29402                                    closeSession(session);
29403                            }
29404                    }
29405    
29406                    return count.intValue();
29407            }
29408    
29409            /**
29410             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
29411             *
29412             * @param groupId the group ID
29413             * @param articleId the article ID
29414             * @param status the status
29415             * @return the number of matching journal articles that the user has permission to view
29416             * @throws SystemException if a system exception occurred
29417             */
29418            @Override
29419            public int filterCountByG_A_NotST(long groupId, String articleId, int status)
29420                    throws SystemException {
29421                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
29422                            return countByG_A_NotST(groupId, articleId, status);
29423                    }
29424    
29425                    StringBundler query = new StringBundler(4);
29426    
29427                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
29428    
29429                    query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
29430    
29431                    boolean bindArticleId = false;
29432    
29433                    if (articleId == null) {
29434                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
29435                    }
29436                    else if (articleId.equals(StringPool.BLANK)) {
29437                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
29438                    }
29439                    else {
29440                            bindArticleId = true;
29441    
29442                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
29443                    }
29444    
29445                    query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
29446    
29447                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
29448                                    JournalArticle.class.getName(),
29449                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
29450    
29451                    Session session = null;
29452    
29453                    try {
29454                            session = openSession();
29455    
29456                            SQLQuery q = session.createSQLQuery(sql);
29457    
29458                            q.addScalar(COUNT_COLUMN_NAME,
29459                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
29460    
29461                            QueryPos qPos = QueryPos.getInstance(q);
29462    
29463                            qPos.add(groupId);
29464    
29465                            if (bindArticleId) {
29466                                    qPos.add(articleId);
29467                            }
29468    
29469                            qPos.add(status);
29470    
29471                            Long count = (Long)q.uniqueResult();
29472    
29473                            return count.intValue();
29474                    }
29475                    catch (Exception e) {
29476                            throw processException(e);
29477                    }
29478                    finally {
29479                            closeSession(session);
29480                    }
29481            }
29482    
29483            private static final String _FINDER_COLUMN_G_A_NOTST_GROUPID_2 = "journalArticle.groupId = ? AND ";
29484            private static final String _FINDER_COLUMN_G_A_NOTST_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
29485            private static final String _FINDER_COLUMN_G_A_NOTST_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
29486            private static final String _FINDER_COLUMN_G_A_NOTST_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '') AND ";
29487            private static final String _FINDER_COLUMN_G_A_NOTST_STATUS_2 = "journalArticle.status != ?";
29488            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
29489                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
29490                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
29491                            "findByG_UT_ST",
29492                            new String[] {
29493                                    Long.class.getName(), String.class.getName(),
29494                                    Integer.class.getName(),
29495                                    
29496                            Integer.class.getName(), Integer.class.getName(),
29497                                    OrderByComparator.class.getName()
29498                            });
29499            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST =
29500                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
29501                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
29502                            JournalArticleImpl.class,
29503                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_UT_ST",
29504                            new String[] {
29505                                    Long.class.getName(), String.class.getName(),
29506                                    Integer.class.getName()
29507                            },
29508                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
29509                            JournalArticleModelImpl.URLTITLE_COLUMN_BITMASK |
29510                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
29511                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
29512                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
29513            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
29514                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
29515                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT_ST",
29516                            new String[] {
29517                                    Long.class.getName(), String.class.getName(),
29518                                    Integer.class.getName()
29519                            });
29520    
29521            /**
29522             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
29523             *
29524             * @param groupId the group ID
29525             * @param urlTitle the url title
29526             * @param status the status
29527             * @return the matching journal articles
29528             * @throws SystemException if a system exception occurred
29529             */
29530            @Override
29531            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
29532                    int status) throws SystemException {
29533                    return findByG_UT_ST(groupId, urlTitle, status, QueryUtil.ALL_POS,
29534                            QueryUtil.ALL_POS, null);
29535            }
29536    
29537            /**
29538             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
29539             *
29540             * <p>
29541             * 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.
29542             * </p>
29543             *
29544             * @param groupId the group ID
29545             * @param urlTitle the url title
29546             * @param status the status
29547             * @param start the lower bound of the range of journal articles
29548             * @param end the upper bound of the range of journal articles (not inclusive)
29549             * @return the range of matching journal articles
29550             * @throws SystemException if a system exception occurred
29551             */
29552            @Override
29553            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
29554                    int status, int start, int end) throws SystemException {
29555                    return findByG_UT_ST(groupId, urlTitle, status, start, end, null);
29556            }
29557    
29558            /**
29559             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
29560             *
29561             * <p>
29562             * 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.
29563             * </p>
29564             *
29565             * @param groupId the group ID
29566             * @param urlTitle the url title
29567             * @param status the status
29568             * @param start the lower bound of the range of journal articles
29569             * @param end the upper bound of the range of journal articles (not inclusive)
29570             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
29571             * @return the ordered range of matching journal articles
29572             * @throws SystemException if a system exception occurred
29573             */
29574            @Override
29575            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
29576                    int status, int start, int end, OrderByComparator orderByComparator)
29577                    throws SystemException {
29578                    boolean pagination = true;
29579                    FinderPath finderPath = null;
29580                    Object[] finderArgs = null;
29581    
29582                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
29583                                    (orderByComparator == null)) {
29584                            pagination = false;
29585                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST;
29586                            finderArgs = new Object[] { groupId, urlTitle, status };
29587                    }
29588                    else {
29589                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST;
29590                            finderArgs = new Object[] {
29591                                            groupId, urlTitle, status,
29592                                            
29593                                            start, end, orderByComparator
29594                                    };
29595                    }
29596    
29597                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
29598                                    finderArgs, this);
29599    
29600                    if ((list != null) && !list.isEmpty()) {
29601                            for (JournalArticle journalArticle : list) {
29602                                    if ((groupId != journalArticle.getGroupId()) ||
29603                                                    !Validator.equals(urlTitle, journalArticle.getUrlTitle()) ||
29604                                                    (status != journalArticle.getStatus())) {
29605                                            list = null;
29606    
29607                                            break;
29608                                    }
29609                            }
29610                    }
29611    
29612                    if (list == null) {
29613                            StringBundler query = null;
29614    
29615                            if (orderByComparator != null) {
29616                                    query = new StringBundler(5 +
29617                                                    (orderByComparator.getOrderByFields().length * 3));
29618                            }
29619                            else {
29620                                    query = new StringBundler(5);
29621                            }
29622    
29623                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
29624    
29625                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
29626    
29627                            boolean bindUrlTitle = false;
29628    
29629                            if (urlTitle == null) {
29630                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
29631                            }
29632                            else if (urlTitle.equals(StringPool.BLANK)) {
29633                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
29634                            }
29635                            else {
29636                                    bindUrlTitle = true;
29637    
29638                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
29639                            }
29640    
29641                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
29642    
29643                            if (orderByComparator != null) {
29644                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
29645                                            orderByComparator);
29646                            }
29647                            else
29648                             if (pagination) {
29649                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
29650                            }
29651    
29652                            String sql = query.toString();
29653    
29654                            Session session = null;
29655    
29656                            try {
29657                                    session = openSession();
29658    
29659                                    Query q = session.createQuery(sql);
29660    
29661                                    QueryPos qPos = QueryPos.getInstance(q);
29662    
29663                                    qPos.add(groupId);
29664    
29665                                    if (bindUrlTitle) {
29666                                            qPos.add(urlTitle);
29667                                    }
29668    
29669                                    qPos.add(status);
29670    
29671                                    if (!pagination) {
29672                                            list = (List<JournalArticle>)QueryUtil.list(q,
29673                                                            getDialect(), start, end, false);
29674    
29675                                            Collections.sort(list);
29676    
29677                                            list = new UnmodifiableList<JournalArticle>(list);
29678                                    }
29679                                    else {
29680                                            list = (List<JournalArticle>)QueryUtil.list(q,
29681                                                            getDialect(), start, end);
29682                                    }
29683    
29684                                    cacheResult(list);
29685    
29686                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
29687                            }
29688                            catch (Exception e) {
29689                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
29690    
29691                                    throw processException(e);
29692                            }
29693                            finally {
29694                                    closeSession(session);
29695                            }
29696                    }
29697    
29698                    return list;
29699            }
29700    
29701            /**
29702             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
29703             *
29704             * @param groupId the group ID
29705             * @param urlTitle the url title
29706             * @param status the status
29707             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
29708             * @return the first matching journal article
29709             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
29710             * @throws SystemException if a system exception occurred
29711             */
29712            @Override
29713            public JournalArticle findByG_UT_ST_First(long groupId, String urlTitle,
29714                    int status, OrderByComparator orderByComparator)
29715                    throws NoSuchArticleException, SystemException {
29716                    JournalArticle journalArticle = fetchByG_UT_ST_First(groupId, urlTitle,
29717                                    status, orderByComparator);
29718    
29719                    if (journalArticle != null) {
29720                            return journalArticle;
29721                    }
29722    
29723                    StringBundler msg = new StringBundler(8);
29724    
29725                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
29726    
29727                    msg.append("groupId=");
29728                    msg.append(groupId);
29729    
29730                    msg.append(", urlTitle=");
29731                    msg.append(urlTitle);
29732    
29733                    msg.append(", status=");
29734                    msg.append(status);
29735    
29736                    msg.append(StringPool.CLOSE_CURLY_BRACE);
29737    
29738                    throw new NoSuchArticleException(msg.toString());
29739            }
29740    
29741            /**
29742             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
29743             *
29744             * @param groupId the group ID
29745             * @param urlTitle the url title
29746             * @param status the status
29747             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
29748             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
29749             * @throws SystemException if a system exception occurred
29750             */
29751            @Override
29752            public JournalArticle fetchByG_UT_ST_First(long groupId, String urlTitle,
29753                    int status, OrderByComparator orderByComparator)
29754                    throws SystemException {
29755                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status, 0,
29756                                    1, orderByComparator);
29757    
29758                    if (!list.isEmpty()) {
29759                            return list.get(0);
29760                    }
29761    
29762                    return null;
29763            }
29764    
29765            /**
29766             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
29767             *
29768             * @param groupId the group ID
29769             * @param urlTitle the url title
29770             * @param status the status
29771             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
29772             * @return the last matching journal article
29773             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
29774             * @throws SystemException if a system exception occurred
29775             */
29776            @Override
29777            public JournalArticle findByG_UT_ST_Last(long groupId, String urlTitle,
29778                    int status, OrderByComparator orderByComparator)
29779                    throws NoSuchArticleException, SystemException {
29780                    JournalArticle journalArticle = fetchByG_UT_ST_Last(groupId, urlTitle,
29781                                    status, orderByComparator);
29782    
29783                    if (journalArticle != null) {
29784                            return journalArticle;
29785                    }
29786    
29787                    StringBundler msg = new StringBundler(8);
29788    
29789                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
29790    
29791                    msg.append("groupId=");
29792                    msg.append(groupId);
29793    
29794                    msg.append(", urlTitle=");
29795                    msg.append(urlTitle);
29796    
29797                    msg.append(", status=");
29798                    msg.append(status);
29799    
29800                    msg.append(StringPool.CLOSE_CURLY_BRACE);
29801    
29802                    throw new NoSuchArticleException(msg.toString());
29803            }
29804    
29805            /**
29806             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
29807             *
29808             * @param groupId the group ID
29809             * @param urlTitle the url title
29810             * @param status the status
29811             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
29812             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
29813             * @throws SystemException if a system exception occurred
29814             */
29815            @Override
29816            public JournalArticle fetchByG_UT_ST_Last(long groupId, String urlTitle,
29817                    int status, OrderByComparator orderByComparator)
29818                    throws SystemException {
29819                    int count = countByG_UT_ST(groupId, urlTitle, status);
29820    
29821                    if (count == 0) {
29822                            return null;
29823                    }
29824    
29825                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status,
29826                                    count - 1, count, orderByComparator);
29827    
29828                    if (!list.isEmpty()) {
29829                            return list.get(0);
29830                    }
29831    
29832                    return null;
29833            }
29834    
29835            /**
29836             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
29837             *
29838             * @param id the primary key of the current journal article
29839             * @param groupId the group ID
29840             * @param urlTitle the url title
29841             * @param status the status
29842             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
29843             * @return the previous, current, and next journal article
29844             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
29845             * @throws SystemException if a system exception occurred
29846             */
29847            @Override
29848            public JournalArticle[] findByG_UT_ST_PrevAndNext(long id, long groupId,
29849                    String urlTitle, int status, OrderByComparator orderByComparator)
29850                    throws NoSuchArticleException, SystemException {
29851                    JournalArticle journalArticle = findByPrimaryKey(id);
29852    
29853                    Session session = null;
29854    
29855                    try {
29856                            session = openSession();
29857    
29858                            JournalArticle[] array = new JournalArticleImpl[3];
29859    
29860                            array[0] = getByG_UT_ST_PrevAndNext(session, journalArticle,
29861                                            groupId, urlTitle, status, orderByComparator, true);
29862    
29863                            array[1] = journalArticle;
29864    
29865                            array[2] = getByG_UT_ST_PrevAndNext(session, journalArticle,
29866                                            groupId, urlTitle, status, orderByComparator, false);
29867    
29868                            return array;
29869                    }
29870                    catch (Exception e) {
29871                            throw processException(e);
29872                    }
29873                    finally {
29874                            closeSession(session);
29875                    }
29876            }
29877    
29878            protected JournalArticle getByG_UT_ST_PrevAndNext(Session session,
29879                    JournalArticle journalArticle, long groupId, String urlTitle,
29880                    int status, OrderByComparator orderByComparator, boolean previous) {
29881                    StringBundler query = null;
29882    
29883                    if (orderByComparator != null) {
29884                            query = new StringBundler(6 +
29885                                            (orderByComparator.getOrderByFields().length * 6));
29886                    }
29887                    else {
29888                            query = new StringBundler(3);
29889                    }
29890    
29891                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
29892    
29893                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
29894    
29895                    boolean bindUrlTitle = false;
29896    
29897                    if (urlTitle == null) {
29898                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
29899                    }
29900                    else if (urlTitle.equals(StringPool.BLANK)) {
29901                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
29902                    }
29903                    else {
29904                            bindUrlTitle = true;
29905    
29906                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
29907                    }
29908    
29909                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
29910    
29911                    if (orderByComparator != null) {
29912                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
29913    
29914                            if (orderByConditionFields.length > 0) {
29915                                    query.append(WHERE_AND);
29916                            }
29917    
29918                            for (int i = 0; i < orderByConditionFields.length; i++) {
29919                                    query.append(_ORDER_BY_ENTITY_ALIAS);
29920                                    query.append(orderByConditionFields[i]);
29921    
29922                                    if ((i + 1) < orderByConditionFields.length) {
29923                                            if (orderByComparator.isAscending() ^ previous) {
29924                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
29925                                            }
29926                                            else {
29927                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
29928                                            }
29929                                    }
29930                                    else {
29931                                            if (orderByComparator.isAscending() ^ previous) {
29932                                                    query.append(WHERE_GREATER_THAN);
29933                                            }
29934                                            else {
29935                                                    query.append(WHERE_LESSER_THAN);
29936                                            }
29937                                    }
29938                            }
29939    
29940                            query.append(ORDER_BY_CLAUSE);
29941    
29942                            String[] orderByFields = orderByComparator.getOrderByFields();
29943    
29944                            for (int i = 0; i < orderByFields.length; i++) {
29945                                    query.append(_ORDER_BY_ENTITY_ALIAS);
29946                                    query.append(orderByFields[i]);
29947    
29948                                    if ((i + 1) < orderByFields.length) {
29949                                            if (orderByComparator.isAscending() ^ previous) {
29950                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
29951                                            }
29952                                            else {
29953                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
29954                                            }
29955                                    }
29956                                    else {
29957                                            if (orderByComparator.isAscending() ^ previous) {
29958                                                    query.append(ORDER_BY_ASC);
29959                                            }
29960                                            else {
29961                                                    query.append(ORDER_BY_DESC);
29962                                            }
29963                                    }
29964                            }
29965                    }
29966                    else {
29967                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
29968                    }
29969    
29970                    String sql = query.toString();
29971    
29972                    Query q = session.createQuery(sql);
29973    
29974                    q.setFirstResult(0);
29975                    q.setMaxResults(2);
29976    
29977                    QueryPos qPos = QueryPos.getInstance(q);
29978    
29979                    qPos.add(groupId);
29980    
29981                    if (bindUrlTitle) {
29982                            qPos.add(urlTitle);
29983                    }
29984    
29985                    qPos.add(status);
29986    
29987                    if (orderByComparator != null) {
29988                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
29989    
29990                            for (Object value : values) {
29991                                    qPos.add(value);
29992                            }
29993                    }
29994    
29995                    List<JournalArticle> list = q.list();
29996    
29997                    if (list.size() == 2) {
29998                            return list.get(1);
29999                    }
30000                    else {
30001                            return null;
30002                    }
30003            }
30004    
30005            /**
30006             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
30007             *
30008             * @param groupId the group ID
30009             * @param urlTitle the url title
30010             * @param status the status
30011             * @return the matching journal articles that the user has permission to view
30012             * @throws SystemException if a system exception occurred
30013             */
30014            @Override
30015            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
30016                    String urlTitle, int status) throws SystemException {
30017                    return filterFindByG_UT_ST(groupId, urlTitle, status,
30018                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
30019            }
30020    
30021            /**
30022             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
30023             *
30024             * <p>
30025             * 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.
30026             * </p>
30027             *
30028             * @param groupId the group ID
30029             * @param urlTitle the url title
30030             * @param status the status
30031             * @param start the lower bound of the range of journal articles
30032             * @param end the upper bound of the range of journal articles (not inclusive)
30033             * @return the range of matching journal articles that the user has permission to view
30034             * @throws SystemException if a system exception occurred
30035             */
30036            @Override
30037            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
30038                    String urlTitle, int status, int start, int end)
30039                    throws SystemException {
30040                    return filterFindByG_UT_ST(groupId, urlTitle, status, start, end, null);
30041            }
30042    
30043            /**
30044             * 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;.
30045             *
30046             * <p>
30047             * 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.
30048             * </p>
30049             *
30050             * @param groupId the group ID
30051             * @param urlTitle the url title
30052             * @param status the status
30053             * @param start the lower bound of the range of journal articles
30054             * @param end the upper bound of the range of journal articles (not inclusive)
30055             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
30056             * @return the ordered range of matching journal articles that the user has permission to view
30057             * @throws SystemException if a system exception occurred
30058             */
30059            @Override
30060            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
30061                    String urlTitle, int status, int start, int end,
30062                    OrderByComparator orderByComparator) throws SystemException {
30063                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
30064                            return findByG_UT_ST(groupId, urlTitle, status, start, end,
30065                                    orderByComparator);
30066                    }
30067    
30068                    StringBundler query = null;
30069    
30070                    if (orderByComparator != null) {
30071                            query = new StringBundler(5 +
30072                                            (orderByComparator.getOrderByFields().length * 3));
30073                    }
30074                    else {
30075                            query = new StringBundler(5);
30076                    }
30077    
30078                    if (getDB().isSupportsInlineDistinct()) {
30079                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
30080                    }
30081                    else {
30082                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
30083                    }
30084    
30085                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
30086    
30087                    boolean bindUrlTitle = false;
30088    
30089                    if (urlTitle == null) {
30090                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
30091                    }
30092                    else if (urlTitle.equals(StringPool.BLANK)) {
30093                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
30094                    }
30095                    else {
30096                            bindUrlTitle = true;
30097    
30098                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
30099                    }
30100    
30101                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
30102    
30103                    if (!getDB().isSupportsInlineDistinct()) {
30104                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
30105                    }
30106    
30107                    if (orderByComparator != null) {
30108                            if (getDB().isSupportsInlineDistinct()) {
30109                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
30110                                            orderByComparator, true);
30111                            }
30112                            else {
30113                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
30114                                            orderByComparator, true);
30115                            }
30116                    }
30117                    else {
30118                            if (getDB().isSupportsInlineDistinct()) {
30119                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
30120                            }
30121                            else {
30122                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
30123                            }
30124                    }
30125    
30126                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
30127                                    JournalArticle.class.getName(),
30128                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
30129    
30130                    Session session = null;
30131    
30132                    try {
30133                            session = openSession();
30134    
30135                            SQLQuery q = session.createSQLQuery(sql);
30136    
30137                            if (getDB().isSupportsInlineDistinct()) {
30138                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
30139                            }
30140                            else {
30141                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
30142                            }
30143    
30144                            QueryPos qPos = QueryPos.getInstance(q);
30145    
30146                            qPos.add(groupId);
30147    
30148                            if (bindUrlTitle) {
30149                                    qPos.add(urlTitle);
30150                            }
30151    
30152                            qPos.add(status);
30153    
30154                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
30155                                    end);
30156                    }
30157                    catch (Exception e) {
30158                            throw processException(e);
30159                    }
30160                    finally {
30161                            closeSession(session);
30162                    }
30163            }
30164    
30165            /**
30166             * 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;.
30167             *
30168             * @param id the primary key of the current journal article
30169             * @param groupId the group ID
30170             * @param urlTitle the url title
30171             * @param status the status
30172             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
30173             * @return the previous, current, and next journal article
30174             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
30175             * @throws SystemException if a system exception occurred
30176             */
30177            @Override
30178            public JournalArticle[] filterFindByG_UT_ST_PrevAndNext(long id,
30179                    long groupId, String urlTitle, int status,
30180                    OrderByComparator orderByComparator)
30181                    throws NoSuchArticleException, SystemException {
30182                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
30183                            return findByG_UT_ST_PrevAndNext(id, groupId, urlTitle, status,
30184                                    orderByComparator);
30185                    }
30186    
30187                    JournalArticle journalArticle = findByPrimaryKey(id);
30188    
30189                    Session session = null;
30190    
30191                    try {
30192                            session = openSession();
30193    
30194                            JournalArticle[] array = new JournalArticleImpl[3];
30195    
30196                            array[0] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
30197                                            groupId, urlTitle, status, orderByComparator, true);
30198    
30199                            array[1] = journalArticle;
30200    
30201                            array[2] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
30202                                            groupId, urlTitle, status, orderByComparator, false);
30203    
30204                            return array;
30205                    }
30206                    catch (Exception e) {
30207                            throw processException(e);
30208                    }
30209                    finally {
30210                            closeSession(session);
30211                    }
30212            }
30213    
30214            protected JournalArticle filterGetByG_UT_ST_PrevAndNext(Session session,
30215                    JournalArticle journalArticle, long groupId, String urlTitle,
30216                    int status, OrderByComparator orderByComparator, boolean previous) {
30217                    StringBundler query = null;
30218    
30219                    if (orderByComparator != null) {
30220                            query = new StringBundler(6 +
30221                                            (orderByComparator.getOrderByFields().length * 6));
30222                    }
30223                    else {
30224                            query = new StringBundler(3);
30225                    }
30226    
30227                    if (getDB().isSupportsInlineDistinct()) {
30228                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
30229                    }
30230                    else {
30231                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
30232                    }
30233    
30234                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
30235    
30236                    boolean bindUrlTitle = false;
30237    
30238                    if (urlTitle == null) {
30239                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
30240                    }
30241                    else if (urlTitle.equals(StringPool.BLANK)) {
30242                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
30243                    }
30244                    else {
30245                            bindUrlTitle = true;
30246    
30247                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
30248                    }
30249    
30250                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
30251    
30252                    if (!getDB().isSupportsInlineDistinct()) {
30253                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
30254                    }
30255    
30256                    if (orderByComparator != null) {
30257                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
30258    
30259                            if (orderByConditionFields.length > 0) {
30260                                    query.append(WHERE_AND);
30261                            }
30262    
30263                            for (int i = 0; i < orderByConditionFields.length; i++) {
30264                                    if (getDB().isSupportsInlineDistinct()) {
30265                                            query.append(_ORDER_BY_ENTITY_ALIAS);
30266                                    }
30267                                    else {
30268                                            query.append(_ORDER_BY_ENTITY_TABLE);
30269                                    }
30270    
30271                                    query.append(orderByConditionFields[i]);
30272    
30273                                    if ((i + 1) < orderByConditionFields.length) {
30274                                            if (orderByComparator.isAscending() ^ previous) {
30275                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
30276                                            }
30277                                            else {
30278                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
30279                                            }
30280                                    }
30281                                    else {
30282                                            if (orderByComparator.isAscending() ^ previous) {
30283                                                    query.append(WHERE_GREATER_THAN);
30284                                            }
30285                                            else {
30286                                                    query.append(WHERE_LESSER_THAN);
30287                                            }
30288                                    }
30289                            }
30290    
30291                            query.append(ORDER_BY_CLAUSE);
30292    
30293                            String[] orderByFields = orderByComparator.getOrderByFields();
30294    
30295                            for (int i = 0; i < orderByFields.length; i++) {
30296                                    if (getDB().isSupportsInlineDistinct()) {
30297                                            query.append(_ORDER_BY_ENTITY_ALIAS);
30298                                    }
30299                                    else {
30300                                            query.append(_ORDER_BY_ENTITY_TABLE);
30301                                    }
30302    
30303                                    query.append(orderByFields[i]);
30304    
30305                                    if ((i + 1) < orderByFields.length) {
30306                                            if (orderByComparator.isAscending() ^ previous) {
30307                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
30308                                            }
30309                                            else {
30310                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
30311                                            }
30312                                    }
30313                                    else {
30314                                            if (orderByComparator.isAscending() ^ previous) {
30315                                                    query.append(ORDER_BY_ASC);
30316                                            }
30317                                            else {
30318                                                    query.append(ORDER_BY_DESC);
30319                                            }
30320                                    }
30321                            }
30322                    }
30323                    else {
30324                            if (getDB().isSupportsInlineDistinct()) {
30325                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
30326                            }
30327                            else {
30328                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
30329                            }
30330                    }
30331    
30332                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
30333                                    JournalArticle.class.getName(),
30334                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
30335    
30336                    SQLQuery q = session.createSQLQuery(sql);
30337    
30338                    q.setFirstResult(0);
30339                    q.setMaxResults(2);
30340    
30341                    if (getDB().isSupportsInlineDistinct()) {
30342                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
30343                    }
30344                    else {
30345                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
30346                    }
30347    
30348                    QueryPos qPos = QueryPos.getInstance(q);
30349    
30350                    qPos.add(groupId);
30351    
30352                    if (bindUrlTitle) {
30353                            qPos.add(urlTitle);
30354                    }
30355    
30356                    qPos.add(status);
30357    
30358                    if (orderByComparator != null) {
30359                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
30360    
30361                            for (Object value : values) {
30362                                    qPos.add(value);
30363                            }
30364                    }
30365    
30366                    List<JournalArticle> list = q.list();
30367    
30368                    if (list.size() == 2) {
30369                            return list.get(1);
30370                    }
30371                    else {
30372                            return null;
30373                    }
30374            }
30375    
30376            /**
30377             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63; from the database.
30378             *
30379             * @param groupId the group ID
30380             * @param urlTitle the url title
30381             * @param status the status
30382             * @throws SystemException if a system exception occurred
30383             */
30384            @Override
30385            public void removeByG_UT_ST(long groupId, String urlTitle, int status)
30386                    throws SystemException {
30387                    for (JournalArticle journalArticle : findByG_UT_ST(groupId, urlTitle,
30388                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
30389                            remove(journalArticle);
30390                    }
30391            }
30392    
30393            /**
30394             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
30395             *
30396             * @param groupId the group ID
30397             * @param urlTitle the url title
30398             * @param status the status
30399             * @return the number of matching journal articles
30400             * @throws SystemException if a system exception occurred
30401             */
30402            @Override
30403            public int countByG_UT_ST(long groupId, String urlTitle, int status)
30404                    throws SystemException {
30405                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT_ST;
30406    
30407                    Object[] finderArgs = new Object[] { groupId, urlTitle, status };
30408    
30409                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
30410                                    this);
30411    
30412                    if (count == null) {
30413                            StringBundler query = new StringBundler(4);
30414    
30415                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
30416    
30417                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
30418    
30419                            boolean bindUrlTitle = false;
30420    
30421                            if (urlTitle == null) {
30422                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
30423                            }
30424                            else if (urlTitle.equals(StringPool.BLANK)) {
30425                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
30426                            }
30427                            else {
30428                                    bindUrlTitle = true;
30429    
30430                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
30431                            }
30432    
30433                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
30434    
30435                            String sql = query.toString();
30436    
30437                            Session session = null;
30438    
30439                            try {
30440                                    session = openSession();
30441    
30442                                    Query q = session.createQuery(sql);
30443    
30444                                    QueryPos qPos = QueryPos.getInstance(q);
30445    
30446                                    qPos.add(groupId);
30447    
30448                                    if (bindUrlTitle) {
30449                                            qPos.add(urlTitle);
30450                                    }
30451    
30452                                    qPos.add(status);
30453    
30454                                    count = (Long)q.uniqueResult();
30455    
30456                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
30457                            }
30458                            catch (Exception e) {
30459                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
30460    
30461                                    throw processException(e);
30462                            }
30463                            finally {
30464                                    closeSession(session);
30465                            }
30466                    }
30467    
30468                    return count.intValue();
30469            }
30470    
30471            /**
30472             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
30473             *
30474             * @param groupId the group ID
30475             * @param urlTitle the url title
30476             * @param status the status
30477             * @return the number of matching journal articles that the user has permission to view
30478             * @throws SystemException if a system exception occurred
30479             */
30480            @Override
30481            public int filterCountByG_UT_ST(long groupId, String urlTitle, int status)
30482                    throws SystemException {
30483                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
30484                            return countByG_UT_ST(groupId, urlTitle, status);
30485                    }
30486    
30487                    StringBundler query = new StringBundler(4);
30488    
30489                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
30490    
30491                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
30492    
30493                    boolean bindUrlTitle = false;
30494    
30495                    if (urlTitle == null) {
30496                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
30497                    }
30498                    else if (urlTitle.equals(StringPool.BLANK)) {
30499                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
30500                    }
30501                    else {
30502                            bindUrlTitle = true;
30503    
30504                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
30505                    }
30506    
30507                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
30508    
30509                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
30510                                    JournalArticle.class.getName(),
30511                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
30512    
30513                    Session session = null;
30514    
30515                    try {
30516                            session = openSession();
30517    
30518                            SQLQuery q = session.createSQLQuery(sql);
30519    
30520                            q.addScalar(COUNT_COLUMN_NAME,
30521                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
30522    
30523                            QueryPos qPos = QueryPos.getInstance(q);
30524    
30525                            qPos.add(groupId);
30526    
30527                            if (bindUrlTitle) {
30528                                    qPos.add(urlTitle);
30529                            }
30530    
30531                            qPos.add(status);
30532    
30533                            Long count = (Long)q.uniqueResult();
30534    
30535                            return count.intValue();
30536                    }
30537                    catch (Exception e) {
30538                            throw processException(e);
30539                    }
30540                    finally {
30541                            closeSession(session);
30542                    }
30543            }
30544    
30545            private static final String _FINDER_COLUMN_G_UT_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
30546            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_1 = "journalArticle.urlTitle IS NULL AND ";
30547            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_2 = "journalArticle.urlTitle = ? AND ";
30548            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = '') AND ";
30549            private static final String _FINDER_COLUMN_G_UT_ST_STATUS_2 = "journalArticle.status = ?";
30550            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
30551                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
30552                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
30553                            "findByC_V_ST",
30554                            new String[] {
30555                                    Long.class.getName(), Double.class.getName(),
30556                                    Integer.class.getName(),
30557                                    
30558                            Integer.class.getName(), Integer.class.getName(),
30559                                    OrderByComparator.class.getName()
30560                            });
30561            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST =
30562                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
30563                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
30564                            JournalArticleImpl.class,
30565                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_V_ST",
30566                            new String[] {
30567                                    Long.class.getName(), Double.class.getName(),
30568                                    Integer.class.getName()
30569                            },
30570                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
30571                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK |
30572                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
30573                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK);
30574            public static final FinderPath FINDER_PATH_COUNT_BY_C_V_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
30575                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
30576                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_V_ST",
30577                            new String[] {
30578                                    Long.class.getName(), Double.class.getName(),
30579                                    Integer.class.getName()
30580                            });
30581    
30582            /**
30583             * Returns all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
30584             *
30585             * @param companyId the company ID
30586             * @param version the version
30587             * @param status the status
30588             * @return the matching journal articles
30589             * @throws SystemException if a system exception occurred
30590             */
30591            @Override
30592            public List<JournalArticle> findByC_V_ST(long companyId, double version,
30593                    int status) throws SystemException {
30594                    return findByC_V_ST(companyId, version, status, QueryUtil.ALL_POS,
30595                            QueryUtil.ALL_POS, null);
30596            }
30597    
30598            /**
30599             * Returns a range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
30600             *
30601             * <p>
30602             * 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.
30603             * </p>
30604             *
30605             * @param companyId the company ID
30606             * @param version the version
30607             * @param status the status
30608             * @param start the lower bound of the range of journal articles
30609             * @param end the upper bound of the range of journal articles (not inclusive)
30610             * @return the range of matching journal articles
30611             * @throws SystemException if a system exception occurred
30612             */
30613            @Override
30614            public List<JournalArticle> findByC_V_ST(long companyId, double version,
30615                    int status, int start, int end) throws SystemException {
30616                    return findByC_V_ST(companyId, version, status, start, end, null);
30617            }
30618    
30619            /**
30620             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
30621             *
30622             * <p>
30623             * 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.
30624             * </p>
30625             *
30626             * @param companyId the company ID
30627             * @param version the version
30628             * @param status the status
30629             * @param start the lower bound of the range of journal articles
30630             * @param end the upper bound of the range of journal articles (not inclusive)
30631             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
30632             * @return the ordered range of matching journal articles
30633             * @throws SystemException if a system exception occurred
30634             */
30635            @Override
30636            public List<JournalArticle> findByC_V_ST(long companyId, double version,
30637                    int status, int start, int end, OrderByComparator orderByComparator)
30638                    throws SystemException {
30639                    boolean pagination = true;
30640                    FinderPath finderPath = null;
30641                    Object[] finderArgs = null;
30642    
30643                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
30644                                    (orderByComparator == null)) {
30645                            pagination = false;
30646                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST;
30647                            finderArgs = new Object[] { companyId, version, status };
30648                    }
30649                    else {
30650                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST;
30651                            finderArgs = new Object[] {
30652                                            companyId, version, status,
30653                                            
30654                                            start, end, orderByComparator
30655                                    };
30656                    }
30657    
30658                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
30659                                    finderArgs, this);
30660    
30661                    if ((list != null) && !list.isEmpty()) {
30662                            for (JournalArticle journalArticle : list) {
30663                                    if ((companyId != journalArticle.getCompanyId()) ||
30664                                                    (version != journalArticle.getVersion()) ||
30665                                                    (status != journalArticle.getStatus())) {
30666                                            list = null;
30667    
30668                                            break;
30669                                    }
30670                            }
30671                    }
30672    
30673                    if (list == null) {
30674                            StringBundler query = null;
30675    
30676                            if (orderByComparator != null) {
30677                                    query = new StringBundler(5 +
30678                                                    (orderByComparator.getOrderByFields().length * 3));
30679                            }
30680                            else {
30681                                    query = new StringBundler(5);
30682                            }
30683    
30684                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
30685    
30686                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
30687    
30688                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
30689    
30690                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
30691    
30692                            if (orderByComparator != null) {
30693                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
30694                                            orderByComparator);
30695                            }
30696                            else
30697                             if (pagination) {
30698                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
30699                            }
30700    
30701                            String sql = query.toString();
30702    
30703                            Session session = null;
30704    
30705                            try {
30706                                    session = openSession();
30707    
30708                                    Query q = session.createQuery(sql);
30709    
30710                                    QueryPos qPos = QueryPos.getInstance(q);
30711    
30712                                    qPos.add(companyId);
30713    
30714                                    qPos.add(version);
30715    
30716                                    qPos.add(status);
30717    
30718                                    if (!pagination) {
30719                                            list = (List<JournalArticle>)QueryUtil.list(q,
30720                                                            getDialect(), start, end, false);
30721    
30722                                            Collections.sort(list);
30723    
30724                                            list = new UnmodifiableList<JournalArticle>(list);
30725                                    }
30726                                    else {
30727                                            list = (List<JournalArticle>)QueryUtil.list(q,
30728                                                            getDialect(), start, end);
30729                                    }
30730    
30731                                    cacheResult(list);
30732    
30733                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
30734                            }
30735                            catch (Exception e) {
30736                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
30737    
30738                                    throw processException(e);
30739                            }
30740                            finally {
30741                                    closeSession(session);
30742                            }
30743                    }
30744    
30745                    return list;
30746            }
30747    
30748            /**
30749             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
30750             *
30751             * @param companyId the company ID
30752             * @param version the version
30753             * @param status the status
30754             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
30755             * @return the first matching journal article
30756             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
30757             * @throws SystemException if a system exception occurred
30758             */
30759            @Override
30760            public JournalArticle findByC_V_ST_First(long companyId, double version,
30761                    int status, OrderByComparator orderByComparator)
30762                    throws NoSuchArticleException, SystemException {
30763                    JournalArticle journalArticle = fetchByC_V_ST_First(companyId, version,
30764                                    status, orderByComparator);
30765    
30766                    if (journalArticle != null) {
30767                            return journalArticle;
30768                    }
30769    
30770                    StringBundler msg = new StringBundler(8);
30771    
30772                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
30773    
30774                    msg.append("companyId=");
30775                    msg.append(companyId);
30776    
30777                    msg.append(", version=");
30778                    msg.append(version);
30779    
30780                    msg.append(", status=");
30781                    msg.append(status);
30782    
30783                    msg.append(StringPool.CLOSE_CURLY_BRACE);
30784    
30785                    throw new NoSuchArticleException(msg.toString());
30786            }
30787    
30788            /**
30789             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
30790             *
30791             * @param companyId the company ID
30792             * @param version the version
30793             * @param status the status
30794             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
30795             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
30796             * @throws SystemException if a system exception occurred
30797             */
30798            @Override
30799            public JournalArticle fetchByC_V_ST_First(long companyId, double version,
30800                    int status, OrderByComparator orderByComparator)
30801                    throws SystemException {
30802                    List<JournalArticle> list = findByC_V_ST(companyId, version, status, 0,
30803                                    1, orderByComparator);
30804    
30805                    if (!list.isEmpty()) {
30806                            return list.get(0);
30807                    }
30808    
30809                    return null;
30810            }
30811    
30812            /**
30813             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
30814             *
30815             * @param companyId the company ID
30816             * @param version the version
30817             * @param status the status
30818             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
30819             * @return the last matching journal article
30820             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
30821             * @throws SystemException if a system exception occurred
30822             */
30823            @Override
30824            public JournalArticle findByC_V_ST_Last(long companyId, double version,
30825                    int status, OrderByComparator orderByComparator)
30826                    throws NoSuchArticleException, SystemException {
30827                    JournalArticle journalArticle = fetchByC_V_ST_Last(companyId, version,
30828                                    status, orderByComparator);
30829    
30830                    if (journalArticle != null) {
30831                            return journalArticle;
30832                    }
30833    
30834                    StringBundler msg = new StringBundler(8);
30835    
30836                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
30837    
30838                    msg.append("companyId=");
30839                    msg.append(companyId);
30840    
30841                    msg.append(", version=");
30842                    msg.append(version);
30843    
30844                    msg.append(", status=");
30845                    msg.append(status);
30846    
30847                    msg.append(StringPool.CLOSE_CURLY_BRACE);
30848    
30849                    throw new NoSuchArticleException(msg.toString());
30850            }
30851    
30852            /**
30853             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
30854             *
30855             * @param companyId the company ID
30856             * @param version the version
30857             * @param status the status
30858             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
30859             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
30860             * @throws SystemException if a system exception occurred
30861             */
30862            @Override
30863            public JournalArticle fetchByC_V_ST_Last(long companyId, double version,
30864                    int status, OrderByComparator orderByComparator)
30865                    throws SystemException {
30866                    int count = countByC_V_ST(companyId, version, status);
30867    
30868                    if (count == 0) {
30869                            return null;
30870                    }
30871    
30872                    List<JournalArticle> list = findByC_V_ST(companyId, version, status,
30873                                    count - 1, count, orderByComparator);
30874    
30875                    if (!list.isEmpty()) {
30876                            return list.get(0);
30877                    }
30878    
30879                    return null;
30880            }
30881    
30882            /**
30883             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
30884             *
30885             * @param id the primary key of the current journal article
30886             * @param companyId the company ID
30887             * @param version the version
30888             * @param status the status
30889             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
30890             * @return the previous, current, and next journal article
30891             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
30892             * @throws SystemException if a system exception occurred
30893             */
30894            @Override
30895            public JournalArticle[] findByC_V_ST_PrevAndNext(long id, long companyId,
30896                    double version, int status, OrderByComparator orderByComparator)
30897                    throws NoSuchArticleException, SystemException {
30898                    JournalArticle journalArticle = findByPrimaryKey(id);
30899    
30900                    Session session = null;
30901    
30902                    try {
30903                            session = openSession();
30904    
30905                            JournalArticle[] array = new JournalArticleImpl[3];
30906    
30907                            array[0] = getByC_V_ST_PrevAndNext(session, journalArticle,
30908                                            companyId, version, status, orderByComparator, true);
30909    
30910                            array[1] = journalArticle;
30911    
30912                            array[2] = getByC_V_ST_PrevAndNext(session, journalArticle,
30913                                            companyId, version, status, orderByComparator, false);
30914    
30915                            return array;
30916                    }
30917                    catch (Exception e) {
30918                            throw processException(e);
30919                    }
30920                    finally {
30921                            closeSession(session);
30922                    }
30923            }
30924    
30925            protected JournalArticle getByC_V_ST_PrevAndNext(Session session,
30926                    JournalArticle journalArticle, long companyId, double version,
30927                    int status, OrderByComparator orderByComparator, boolean previous) {
30928                    StringBundler query = null;
30929    
30930                    if (orderByComparator != null) {
30931                            query = new StringBundler(6 +
30932                                            (orderByComparator.getOrderByFields().length * 6));
30933                    }
30934                    else {
30935                            query = new StringBundler(3);
30936                    }
30937    
30938                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
30939    
30940                    query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
30941    
30942                    query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
30943    
30944                    query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
30945    
30946                    if (orderByComparator != null) {
30947                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
30948    
30949                            if (orderByConditionFields.length > 0) {
30950                                    query.append(WHERE_AND);
30951                            }
30952    
30953                            for (int i = 0; i < orderByConditionFields.length; i++) {
30954                                    query.append(_ORDER_BY_ENTITY_ALIAS);
30955                                    query.append(orderByConditionFields[i]);
30956    
30957                                    if ((i + 1) < orderByConditionFields.length) {
30958                                            if (orderByComparator.isAscending() ^ previous) {
30959                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
30960                                            }
30961                                            else {
30962                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
30963                                            }
30964                                    }
30965                                    else {
30966                                            if (orderByComparator.isAscending() ^ previous) {
30967                                                    query.append(WHERE_GREATER_THAN);
30968                                            }
30969                                            else {
30970                                                    query.append(WHERE_LESSER_THAN);
30971                                            }
30972                                    }
30973                            }
30974    
30975                            query.append(ORDER_BY_CLAUSE);
30976    
30977                            String[] orderByFields = orderByComparator.getOrderByFields();
30978    
30979                            for (int i = 0; i < orderByFields.length; i++) {
30980                                    query.append(_ORDER_BY_ENTITY_ALIAS);
30981                                    query.append(orderByFields[i]);
30982    
30983                                    if ((i + 1) < orderByFields.length) {
30984                                            if (orderByComparator.isAscending() ^ previous) {
30985                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
30986                                            }
30987                                            else {
30988                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
30989                                            }
30990                                    }
30991                                    else {
30992                                            if (orderByComparator.isAscending() ^ previous) {
30993                                                    query.append(ORDER_BY_ASC);
30994                                            }
30995                                            else {
30996                                                    query.append(ORDER_BY_DESC);
30997                                            }
30998                                    }
30999                            }
31000                    }
31001                    else {
31002                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
31003                    }
31004    
31005                    String sql = query.toString();
31006    
31007                    Query q = session.createQuery(sql);
31008    
31009                    q.setFirstResult(0);
31010                    q.setMaxResults(2);
31011    
31012                    QueryPos qPos = QueryPos.getInstance(q);
31013    
31014                    qPos.add(companyId);
31015    
31016                    qPos.add(version);
31017    
31018                    qPos.add(status);
31019    
31020                    if (orderByComparator != null) {
31021                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
31022    
31023                            for (Object value : values) {
31024                                    qPos.add(value);
31025                            }
31026                    }
31027    
31028                    List<JournalArticle> list = q.list();
31029    
31030                    if (list.size() == 2) {
31031                            return list.get(1);
31032                    }
31033                    else {
31034                            return null;
31035                    }
31036            }
31037    
31038            /**
31039             * Removes all the journal articles where companyId = &#63; and version = &#63; and status = &#63; from the database.
31040             *
31041             * @param companyId the company ID
31042             * @param version the version
31043             * @param status the status
31044             * @throws SystemException if a system exception occurred
31045             */
31046            @Override
31047            public void removeByC_V_ST(long companyId, double version, int status)
31048                    throws SystemException {
31049                    for (JournalArticle journalArticle : findByC_V_ST(companyId, version,
31050                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
31051                            remove(journalArticle);
31052                    }
31053            }
31054    
31055            /**
31056             * Returns the number of journal articles where companyId = &#63; and version = &#63; and status = &#63;.
31057             *
31058             * @param companyId the company ID
31059             * @param version the version
31060             * @param status the status
31061             * @return the number of matching journal articles
31062             * @throws SystemException if a system exception occurred
31063             */
31064            @Override
31065            public int countByC_V_ST(long companyId, double version, int status)
31066                    throws SystemException {
31067                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_V_ST;
31068    
31069                    Object[] finderArgs = new Object[] { companyId, version, status };
31070    
31071                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
31072                                    this);
31073    
31074                    if (count == null) {
31075                            StringBundler query = new StringBundler(4);
31076    
31077                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
31078    
31079                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
31080    
31081                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
31082    
31083                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
31084    
31085                            String sql = query.toString();
31086    
31087                            Session session = null;
31088    
31089                            try {
31090                                    session = openSession();
31091    
31092                                    Query q = session.createQuery(sql);
31093    
31094                                    QueryPos qPos = QueryPos.getInstance(q);
31095    
31096                                    qPos.add(companyId);
31097    
31098                                    qPos.add(version);
31099    
31100                                    qPos.add(status);
31101    
31102                                    count = (Long)q.uniqueResult();
31103    
31104                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
31105                            }
31106                            catch (Exception e) {
31107                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
31108    
31109                                    throw processException(e);
31110                            }
31111                            finally {
31112                                    closeSession(session);
31113                            }
31114                    }
31115    
31116                    return count.intValue();
31117            }
31118    
31119            private static final String _FINDER_COLUMN_C_V_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
31120            private static final String _FINDER_COLUMN_C_V_ST_VERSION_2 = "journalArticle.version = ? AND ";
31121            private static final String _FINDER_COLUMN_C_V_ST_STATUS_2 = "journalArticle.status = ?";
31122    
31123            public JournalArticlePersistenceImpl() {
31124                    setModelClass(JournalArticle.class);
31125            }
31126    
31127            /**
31128             * Caches the journal article in the entity cache if it is enabled.
31129             *
31130             * @param journalArticle the journal article
31131             */
31132            @Override
31133            public void cacheResult(JournalArticle journalArticle) {
31134                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
31135                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
31136                            journalArticle);
31137    
31138                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
31139                            new Object[] { journalArticle.getUuid(), journalArticle.getGroupId() },
31140                            journalArticle);
31141    
31142                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
31143                            new Object[] {
31144                                    journalArticle.getGroupId(), journalArticle.getClassNameId(),
31145                                    journalArticle.getStructureId()
31146                            }, journalArticle);
31147    
31148                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
31149                            new Object[] {
31150                                    journalArticle.getGroupId(), journalArticle.getArticleId(),
31151                                    journalArticle.getVersion()
31152                            }, journalArticle);
31153    
31154                    journalArticle.resetOriginalValues();
31155            }
31156    
31157            /**
31158             * Caches the journal articles in the entity cache if it is enabled.
31159             *
31160             * @param journalArticles the journal articles
31161             */
31162            @Override
31163            public void cacheResult(List<JournalArticle> journalArticles) {
31164                    for (JournalArticle journalArticle : journalArticles) {
31165                            if (EntityCacheUtil.getResult(
31166                                                    JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
31167                                                    JournalArticleImpl.class, journalArticle.getPrimaryKey()) == null) {
31168                                    cacheResult(journalArticle);
31169                            }
31170                            else {
31171                                    journalArticle.resetOriginalValues();
31172                            }
31173                    }
31174            }
31175    
31176            /**
31177             * Clears the cache for all journal articles.
31178             *
31179             * <p>
31180             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
31181             * </p>
31182             */
31183            @Override
31184            public void clearCache() {
31185                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
31186                            CacheRegistryUtil.clear(JournalArticleImpl.class.getName());
31187                    }
31188    
31189                    EntityCacheUtil.clearCache(JournalArticleImpl.class.getName());
31190    
31191                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
31192                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
31193                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
31194            }
31195    
31196            /**
31197             * Clears the cache for the journal article.
31198             *
31199             * <p>
31200             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
31201             * </p>
31202             */
31203            @Override
31204            public void clearCache(JournalArticle journalArticle) {
31205                    EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
31206                            JournalArticleImpl.class, journalArticle.getPrimaryKey());
31207    
31208                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
31209                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
31210    
31211                    clearUniqueFindersCache(journalArticle);
31212            }
31213    
31214            @Override
31215            public void clearCache(List<JournalArticle> journalArticles) {
31216                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
31217                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
31218    
31219                    for (JournalArticle journalArticle : journalArticles) {
31220                            EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
31221                                    JournalArticleImpl.class, journalArticle.getPrimaryKey());
31222    
31223                            clearUniqueFindersCache(journalArticle);
31224                    }
31225            }
31226    
31227            protected void cacheUniqueFindersCache(JournalArticle journalArticle) {
31228                    if (journalArticle.isNew()) {
31229                            Object[] args = new Object[] {
31230                                            journalArticle.getUuid(), journalArticle.getGroupId()
31231                                    };
31232    
31233                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
31234                                    Long.valueOf(1));
31235                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
31236                                    journalArticle);
31237    
31238                            args = new Object[] {
31239                                            journalArticle.getGroupId(), journalArticle.getClassNameId(),
31240                                            journalArticle.getStructureId()
31241                                    };
31242    
31243                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S, args,
31244                                    Long.valueOf(1));
31245                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S, args,
31246                                    journalArticle);
31247    
31248                            args = new Object[] {
31249                                            journalArticle.getGroupId(), journalArticle.getArticleId(),
31250                                            journalArticle.getVersion()
31251                                    };
31252    
31253                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V, args,
31254                                    Long.valueOf(1));
31255                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V, args,
31256                                    journalArticle);
31257                    }
31258                    else {
31259                            JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
31260    
31261                            if ((journalArticleModelImpl.getColumnBitmask() &
31262                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
31263                                    Object[] args = new Object[] {
31264                                                    journalArticle.getUuid(), journalArticle.getGroupId()
31265                                            };
31266    
31267                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
31268                                            Long.valueOf(1));
31269                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
31270                                            journalArticle);
31271                            }
31272    
31273                            if ((journalArticleModelImpl.getColumnBitmask() &
31274                                            FINDER_PATH_FETCH_BY_G_C_S.getColumnBitmask()) != 0) {
31275                                    Object[] args = new Object[] {
31276                                                    journalArticle.getGroupId(),
31277                                                    journalArticle.getClassNameId(),
31278                                                    journalArticle.getStructureId()
31279                                            };
31280    
31281                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S, args,
31282                                            Long.valueOf(1));
31283                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S, args,
31284                                            journalArticle);
31285                            }
31286    
31287                            if ((journalArticleModelImpl.getColumnBitmask() &
31288                                            FINDER_PATH_FETCH_BY_G_A_V.getColumnBitmask()) != 0) {
31289                                    Object[] args = new Object[] {
31290                                                    journalArticle.getGroupId(),
31291                                                    journalArticle.getArticleId(),
31292                                                    journalArticle.getVersion()
31293                                            };
31294    
31295                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V, args,
31296                                            Long.valueOf(1));
31297                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V, args,
31298                                            journalArticle);
31299                            }
31300                    }
31301            }
31302    
31303            protected void clearUniqueFindersCache(JournalArticle journalArticle) {
31304                    JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
31305    
31306                    Object[] args = new Object[] {
31307                                    journalArticle.getUuid(), journalArticle.getGroupId()
31308                            };
31309    
31310                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
31311                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
31312    
31313                    if ((journalArticleModelImpl.getColumnBitmask() &
31314                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
31315                            args = new Object[] {
31316                                            journalArticleModelImpl.getOriginalUuid(),
31317                                            journalArticleModelImpl.getOriginalGroupId()
31318                                    };
31319    
31320                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
31321                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
31322                    }
31323    
31324                    args = new Object[] {
31325                                    journalArticle.getGroupId(), journalArticle.getClassNameId(),
31326                                    journalArticle.getStructureId()
31327                            };
31328    
31329                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
31330                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S, args);
31331    
31332                    if ((journalArticleModelImpl.getColumnBitmask() &
31333                                    FINDER_PATH_FETCH_BY_G_C_S.getColumnBitmask()) != 0) {
31334                            args = new Object[] {
31335                                            journalArticleModelImpl.getOriginalGroupId(),
31336                                            journalArticleModelImpl.getOriginalClassNameId(),
31337                                            journalArticleModelImpl.getOriginalStructureId()
31338                                    };
31339    
31340                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
31341                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S, args);
31342                    }
31343    
31344                    args = new Object[] {
31345                                    journalArticle.getGroupId(), journalArticle.getArticleId(),
31346                                    journalArticle.getVersion()
31347                            };
31348    
31349                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V, args);
31350                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V, args);
31351    
31352                    if ((journalArticleModelImpl.getColumnBitmask() &
31353                                    FINDER_PATH_FETCH_BY_G_A_V.getColumnBitmask()) != 0) {
31354                            args = new Object[] {
31355                                            journalArticleModelImpl.getOriginalGroupId(),
31356                                            journalArticleModelImpl.getOriginalArticleId(),
31357                                            journalArticleModelImpl.getOriginalVersion()
31358                                    };
31359    
31360                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V, args);
31361                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V, args);
31362                    }
31363            }
31364    
31365            /**
31366             * Creates a new journal article with the primary key. Does not add the journal article to the database.
31367             *
31368             * @param id the primary key for the new journal article
31369             * @return the new journal article
31370             */
31371            @Override
31372            public JournalArticle create(long id) {
31373                    JournalArticle journalArticle = new JournalArticleImpl();
31374    
31375                    journalArticle.setNew(true);
31376                    journalArticle.setPrimaryKey(id);
31377    
31378                    String uuid = PortalUUIDUtil.generate();
31379    
31380                    journalArticle.setUuid(uuid);
31381    
31382                    return journalArticle;
31383            }
31384    
31385            /**
31386             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
31387             *
31388             * @param id the primary key of the journal article
31389             * @return the journal article that was removed
31390             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
31391             * @throws SystemException if a system exception occurred
31392             */
31393            @Override
31394            public JournalArticle remove(long id)
31395                    throws NoSuchArticleException, SystemException {
31396                    return remove((Serializable)id);
31397            }
31398    
31399            /**
31400             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
31401             *
31402             * @param primaryKey the primary key of the journal article
31403             * @return the journal article that was removed
31404             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
31405             * @throws SystemException if a system exception occurred
31406             */
31407            @Override
31408            public JournalArticle remove(Serializable primaryKey)
31409                    throws NoSuchArticleException, SystemException {
31410                    Session session = null;
31411    
31412                    try {
31413                            session = openSession();
31414    
31415                            JournalArticle journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
31416                                            primaryKey);
31417    
31418                            if (journalArticle == null) {
31419                                    if (_log.isWarnEnabled()) {
31420                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
31421                                    }
31422    
31423                                    throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
31424                                            primaryKey);
31425                            }
31426    
31427                            return remove(journalArticle);
31428                    }
31429                    catch (NoSuchArticleException nsee) {
31430                            throw nsee;
31431                    }
31432                    catch (Exception e) {
31433                            throw processException(e);
31434                    }
31435                    finally {
31436                            closeSession(session);
31437                    }
31438            }
31439    
31440            @Override
31441            protected JournalArticle removeImpl(JournalArticle journalArticle)
31442                    throws SystemException {
31443                    journalArticle = toUnwrappedModel(journalArticle);
31444    
31445                    Session session = null;
31446    
31447                    try {
31448                            session = openSession();
31449    
31450                            if (!session.contains(journalArticle)) {
31451                                    journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
31452                                                    journalArticle.getPrimaryKeyObj());
31453                            }
31454    
31455                            if (journalArticle != null) {
31456                                    session.delete(journalArticle);
31457                            }
31458                    }
31459                    catch (Exception e) {
31460                            throw processException(e);
31461                    }
31462                    finally {
31463                            closeSession(session);
31464                    }
31465    
31466                    if (journalArticle != null) {
31467                            clearCache(journalArticle);
31468                    }
31469    
31470                    return journalArticle;
31471            }
31472    
31473            @Override
31474            public JournalArticle updateImpl(
31475                    com.liferay.portlet.journal.model.JournalArticle journalArticle)
31476                    throws SystemException {
31477                    journalArticle = toUnwrappedModel(journalArticle);
31478    
31479                    boolean isNew = journalArticle.isNew();
31480    
31481                    JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
31482    
31483                    if (Validator.isNull(journalArticle.getUuid())) {
31484                            String uuid = PortalUUIDUtil.generate();
31485    
31486                            journalArticle.setUuid(uuid);
31487                    }
31488    
31489                    Session session = null;
31490    
31491                    try {
31492                            session = openSession();
31493    
31494                            if (journalArticle.isNew()) {
31495                                    session.save(journalArticle);
31496    
31497                                    journalArticle.setNew(false);
31498                            }
31499                            else {
31500                                    session.merge(journalArticle);
31501                            }
31502                    }
31503                    catch (Exception e) {
31504                            throw processException(e);
31505                    }
31506                    finally {
31507                            closeSession(session);
31508                    }
31509    
31510                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
31511    
31512                    if (isNew || !JournalArticleModelImpl.COLUMN_BITMASK_ENABLED) {
31513                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
31514                    }
31515    
31516                    else {
31517                            if ((journalArticleModelImpl.getColumnBitmask() &
31518                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
31519                                    Object[] args = new Object[] {
31520                                                    journalArticleModelImpl.getOriginalUuid()
31521                                            };
31522    
31523                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
31524                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
31525                                            args);
31526    
31527                                    args = new Object[] { journalArticleModelImpl.getUuid() };
31528    
31529                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
31530                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
31531                                            args);
31532                            }
31533    
31534                            if ((journalArticleModelImpl.getColumnBitmask() &
31535                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
31536                                    Object[] args = new Object[] {
31537                                                    journalArticleModelImpl.getOriginalUuid(),
31538                                                    journalArticleModelImpl.getOriginalCompanyId()
31539                                            };
31540    
31541                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
31542                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
31543                                            args);
31544    
31545                                    args = new Object[] {
31546                                                    journalArticleModelImpl.getUuid(),
31547                                                    journalArticleModelImpl.getCompanyId()
31548                                            };
31549    
31550                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
31551                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
31552                                            args);
31553                            }
31554    
31555                            if ((journalArticleModelImpl.getColumnBitmask() &
31556                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY.getColumnBitmask()) != 0) {
31557                                    Object[] args = new Object[] {
31558                                                    journalArticleModelImpl.getOriginalResourcePrimKey()
31559                                            };
31560    
31561                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
31562                                            args);
31563                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
31564                                            args);
31565    
31566                                    args = new Object[] { journalArticleModelImpl.getResourcePrimKey() };
31567    
31568                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
31569                                            args);
31570                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
31571                                            args);
31572                            }
31573    
31574                            if ((journalArticleModelImpl.getColumnBitmask() &
31575                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
31576                                    Object[] args = new Object[] {
31577                                                    journalArticleModelImpl.getOriginalGroupId()
31578                                            };
31579    
31580                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
31581                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
31582                                            args);
31583    
31584                                    args = new Object[] { journalArticleModelImpl.getGroupId() };
31585    
31586                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
31587                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
31588                                            args);
31589                            }
31590    
31591                            if ((journalArticleModelImpl.getColumnBitmask() &
31592                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
31593                                    Object[] args = new Object[] {
31594                                                    journalArticleModelImpl.getOriginalCompanyId()
31595                                            };
31596    
31597                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
31598                                            args);
31599                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
31600                                            args);
31601    
31602                                    args = new Object[] { journalArticleModelImpl.getCompanyId() };
31603    
31604                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
31605                                            args);
31606                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
31607                                            args);
31608                            }
31609    
31610                            if ((journalArticleModelImpl.getColumnBitmask() &
31611                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID.getColumnBitmask()) != 0) {
31612                                    Object[] args = new Object[] {
31613                                                    journalArticleModelImpl.getOriginalStructureId()
31614                                            };
31615    
31616                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
31617                                            args);
31618                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
31619                                            args);
31620    
31621                                    args = new Object[] { journalArticleModelImpl.getStructureId() };
31622    
31623                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
31624                                            args);
31625                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
31626                                            args);
31627                            }
31628    
31629                            if ((journalArticleModelImpl.getColumnBitmask() &
31630                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID.getColumnBitmask()) != 0) {
31631                                    Object[] args = new Object[] {
31632                                                    journalArticleModelImpl.getOriginalTemplateId()
31633                                            };
31634    
31635                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
31636                                            args);
31637                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID,
31638                                            args);
31639    
31640                                    args = new Object[] { journalArticleModelImpl.getTemplateId() };
31641    
31642                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
31643                                            args);
31644                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID,
31645                                            args);
31646                            }
31647    
31648                            if ((journalArticleModelImpl.getColumnBitmask() &
31649                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID.getColumnBitmask()) != 0) {
31650                                    Object[] args = new Object[] {
31651                                                    journalArticleModelImpl.getOriginalLayoutUuid()
31652                                            };
31653    
31654                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
31655                                            args);
31656                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
31657                                            args);
31658    
31659                                    args = new Object[] { journalArticleModelImpl.getLayoutUuid() };
31660    
31661                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
31662                                            args);
31663                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
31664                                            args);
31665                            }
31666    
31667                            if ((journalArticleModelImpl.getColumnBitmask() &
31668                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID.getColumnBitmask()) != 0) {
31669                                    Object[] args = new Object[] {
31670                                                    journalArticleModelImpl.getOriginalSmallImageId()
31671                                            };
31672    
31673                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
31674                                            args);
31675                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
31676                                            args);
31677    
31678                                    args = new Object[] { journalArticleModelImpl.getSmallImageId() };
31679    
31680                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
31681                                            args);
31682                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
31683                                            args);
31684                            }
31685    
31686                            if ((journalArticleModelImpl.getColumnBitmask() &
31687                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I.getColumnBitmask()) != 0) {
31688                                    Object[] args = new Object[] {
31689                                                    journalArticleModelImpl.getOriginalResourcePrimKey(),
31690                                                    journalArticleModelImpl.getOriginalIndexable()
31691                                            };
31692    
31693                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_I, args);
31694                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I,
31695                                            args);
31696    
31697                                    args = new Object[] {
31698                                                    journalArticleModelImpl.getResourcePrimKey(),
31699                                                    journalArticleModelImpl.getIndexable()
31700                                            };
31701    
31702                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_I, args);
31703                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I,
31704                                            args);
31705                            }
31706    
31707                            if ((journalArticleModelImpl.getColumnBitmask() &
31708                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST.getColumnBitmask()) != 0) {
31709                                    Object[] args = new Object[] {
31710                                                    journalArticleModelImpl.getOriginalResourcePrimKey(),
31711                                                    journalArticleModelImpl.getOriginalStatus()
31712                                            };
31713    
31714                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
31715                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
31716                                            args);
31717    
31718                                    args = new Object[] {
31719                                                    journalArticleModelImpl.getResourcePrimKey(),
31720                                                    journalArticleModelImpl.getStatus()
31721                                            };
31722    
31723                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
31724                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
31725                                            args);
31726                            }
31727    
31728                            if ((journalArticleModelImpl.getColumnBitmask() &
31729                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) {
31730                                    Object[] args = new Object[] {
31731                                                    journalArticleModelImpl.getOriginalGroupId(),
31732                                                    journalArticleModelImpl.getOriginalUserId()
31733                                            };
31734    
31735                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
31736                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
31737                                            args);
31738    
31739                                    args = new Object[] {
31740                                                    journalArticleModelImpl.getGroupId(),
31741                                                    journalArticleModelImpl.getUserId()
31742                                            };
31743    
31744                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
31745                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
31746                                            args);
31747                            }
31748    
31749                            if ((journalArticleModelImpl.getColumnBitmask() &
31750                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F.getColumnBitmask()) != 0) {
31751                                    Object[] args = new Object[] {
31752                                                    journalArticleModelImpl.getOriginalGroupId(),
31753                                                    journalArticleModelImpl.getOriginalFolderId()
31754                                            };
31755    
31756                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
31757                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
31758                                            args);
31759    
31760                                    args = new Object[] {
31761                                                    journalArticleModelImpl.getGroupId(),
31762                                                    journalArticleModelImpl.getFolderId()
31763                                            };
31764    
31765                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
31766                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
31767                                            args);
31768                            }
31769    
31770                            if ((journalArticleModelImpl.getColumnBitmask() &
31771                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A.getColumnBitmask()) != 0) {
31772                                    Object[] args = new Object[] {
31773                                                    journalArticleModelImpl.getOriginalGroupId(),
31774                                                    journalArticleModelImpl.getOriginalArticleId()
31775                                            };
31776    
31777                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
31778                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
31779                                            args);
31780    
31781                                    args = new Object[] {
31782                                                    journalArticleModelImpl.getGroupId(),
31783                                                    journalArticleModelImpl.getArticleId()
31784                                            };
31785    
31786                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
31787                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
31788                                            args);
31789                            }
31790    
31791                            if ((journalArticleModelImpl.getColumnBitmask() &
31792                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT.getColumnBitmask()) != 0) {
31793                                    Object[] args = new Object[] {
31794                                                    journalArticleModelImpl.getOriginalGroupId(),
31795                                                    journalArticleModelImpl.getOriginalUrlTitle()
31796                                            };
31797    
31798                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
31799                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
31800                                            args);
31801    
31802                                    args = new Object[] {
31803                                                    journalArticleModelImpl.getGroupId(),
31804                                                    journalArticleModelImpl.getUrlTitle()
31805                                            };
31806    
31807                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
31808                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
31809                                            args);
31810                            }
31811    
31812                            if ((journalArticleModelImpl.getColumnBitmask() &
31813                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
31814                                    Object[] args = new Object[] {
31815                                                    journalArticleModelImpl.getOriginalGroupId(),
31816                                                    journalArticleModelImpl.getOriginalStructureId()
31817                                            };
31818    
31819                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
31820                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
31821                                            args);
31822    
31823                                    args = new Object[] {
31824                                                    journalArticleModelImpl.getGroupId(),
31825                                                    journalArticleModelImpl.getStructureId()
31826                                            };
31827    
31828                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
31829                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
31830                                            args);
31831                            }
31832    
31833                            if ((journalArticleModelImpl.getColumnBitmask() &
31834                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T.getColumnBitmask()) != 0) {
31835                                    Object[] args = new Object[] {
31836                                                    journalArticleModelImpl.getOriginalGroupId(),
31837                                                    journalArticleModelImpl.getOriginalTemplateId()
31838                                            };
31839    
31840                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
31841                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
31842                                            args);
31843    
31844                                    args = new Object[] {
31845                                                    journalArticleModelImpl.getGroupId(),
31846                                                    journalArticleModelImpl.getTemplateId()
31847                                            };
31848    
31849                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
31850                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
31851                                            args);
31852                            }
31853    
31854                            if ((journalArticleModelImpl.getColumnBitmask() &
31855                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L.getColumnBitmask()) != 0) {
31856                                    Object[] args = new Object[] {
31857                                                    journalArticleModelImpl.getOriginalGroupId(),
31858                                                    journalArticleModelImpl.getOriginalLayoutUuid()
31859                                            };
31860    
31861                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
31862                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
31863                                            args);
31864    
31865                                    args = new Object[] {
31866                                                    journalArticleModelImpl.getGroupId(),
31867                                                    journalArticleModelImpl.getLayoutUuid()
31868                                            };
31869    
31870                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
31871                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
31872                                            args);
31873                            }
31874    
31875                            if ((journalArticleModelImpl.getColumnBitmask() &
31876                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST.getColumnBitmask()) != 0) {
31877                                    Object[] args = new Object[] {
31878                                                    journalArticleModelImpl.getOriginalGroupId(),
31879                                                    journalArticleModelImpl.getOriginalStatus()
31880                                            };
31881    
31882                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
31883                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
31884                                            args);
31885    
31886                                    args = new Object[] {
31887                                                    journalArticleModelImpl.getGroupId(),
31888                                                    journalArticleModelImpl.getStatus()
31889                                            };
31890    
31891                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
31892                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
31893                                            args);
31894                            }
31895    
31896                            if ((journalArticleModelImpl.getColumnBitmask() &
31897                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V.getColumnBitmask()) != 0) {
31898                                    Object[] args = new Object[] {
31899                                                    journalArticleModelImpl.getOriginalCompanyId(),
31900                                                    journalArticleModelImpl.getOriginalVersion()
31901                                            };
31902    
31903                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
31904                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
31905                                            args);
31906    
31907                                    args = new Object[] {
31908                                                    journalArticleModelImpl.getCompanyId(),
31909                                                    journalArticleModelImpl.getVersion()
31910                                            };
31911    
31912                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
31913                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
31914                                            args);
31915                            }
31916    
31917                            if ((journalArticleModelImpl.getColumnBitmask() &
31918                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST.getColumnBitmask()) != 0) {
31919                                    Object[] args = new Object[] {
31920                                                    journalArticleModelImpl.getOriginalCompanyId(),
31921                                                    journalArticleModelImpl.getOriginalStatus()
31922                                            };
31923    
31924                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
31925                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
31926                                            args);
31927    
31928                                    args = new Object[] {
31929                                                    journalArticleModelImpl.getCompanyId(),
31930                                                    journalArticleModelImpl.getStatus()
31931                                            };
31932    
31933                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
31934                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
31935                                            args);
31936                            }
31937    
31938                            if ((journalArticleModelImpl.getColumnBitmask() &
31939                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T.getColumnBitmask()) != 0) {
31940                                    Object[] args = new Object[] {
31941                                                    journalArticleModelImpl.getOriginalClassNameId(),
31942                                                    journalArticleModelImpl.getOriginalTemplateId()
31943                                            };
31944    
31945                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_T, args);
31946                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T,
31947                                            args);
31948    
31949                                    args = new Object[] {
31950                                                    journalArticleModelImpl.getClassNameId(),
31951                                                    journalArticleModelImpl.getTemplateId()
31952                                            };
31953    
31954                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_T, args);
31955                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T,
31956                                            args);
31957                            }
31958    
31959                            if ((journalArticleModelImpl.getColumnBitmask() &
31960                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S.getColumnBitmask()) != 0) {
31961                                    Object[] args = new Object[] {
31962                                                    journalArticleModelImpl.getOriginalResourcePrimKey(),
31963                                                    journalArticleModelImpl.getOriginalIndexable(),
31964                                                    journalArticleModelImpl.getOriginalStatus()
31965                                            };
31966    
31967                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_I_S, args);
31968                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S,
31969                                            args);
31970    
31971                                    args = new Object[] {
31972                                                    journalArticleModelImpl.getResourcePrimKey(),
31973                                                    journalArticleModelImpl.getIndexable(),
31974                                                    journalArticleModelImpl.getStatus()
31975                                            };
31976    
31977                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_I_S, args);
31978                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S,
31979                                            args);
31980                            }
31981    
31982                            if ((journalArticleModelImpl.getColumnBitmask() &
31983                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C.getColumnBitmask()) != 0) {
31984                                    Object[] args = new Object[] {
31985                                                    journalArticleModelImpl.getOriginalGroupId(),
31986                                                    journalArticleModelImpl.getOriginalUserId(),
31987                                                    journalArticleModelImpl.getOriginalClassNameId()
31988                                            };
31989    
31990                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_C, args);
31991                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C,
31992                                            args);
31993    
31994                                    args = new Object[] {
31995                                                    journalArticleModelImpl.getGroupId(),
31996                                                    journalArticleModelImpl.getUserId(),
31997                                                    journalArticleModelImpl.getClassNameId()
31998                                            };
31999    
32000                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_C, args);
32001                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C,
32002                                            args);
32003                            }
32004    
32005                            if ((journalArticleModelImpl.getColumnBitmask() &
32006                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST.getColumnBitmask()) != 0) {
32007                                    Object[] args = new Object[] {
32008                                                    journalArticleModelImpl.getOriginalGroupId(),
32009                                                    journalArticleModelImpl.getOriginalFolderId(),
32010                                                    journalArticleModelImpl.getOriginalStatus()
32011                                            };
32012    
32013                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_ST, args);
32014                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST,
32015                                            args);
32016    
32017                                    args = new Object[] {
32018                                                    journalArticleModelImpl.getGroupId(),
32019                                                    journalArticleModelImpl.getFolderId(),
32020                                                    journalArticleModelImpl.getStatus()
32021                                            };
32022    
32023                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_ST, args);
32024                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST,
32025                                            args);
32026                            }
32027    
32028                            if ((journalArticleModelImpl.getColumnBitmask() &
32029                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C.getColumnBitmask()) != 0) {
32030                                    Object[] args = new Object[] {
32031                                                    journalArticleModelImpl.getOriginalGroupId(),
32032                                                    journalArticleModelImpl.getOriginalClassNameId(),
32033                                                    journalArticleModelImpl.getOriginalClassPK()
32034                                            };
32035    
32036                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
32037                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
32038                                            args);
32039    
32040                                    args = new Object[] {
32041                                                    journalArticleModelImpl.getGroupId(),
32042                                                    journalArticleModelImpl.getClassNameId(),
32043                                                    journalArticleModelImpl.getClassPK()
32044                                            };
32045    
32046                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
32047                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
32048                                            args);
32049                            }
32050    
32051                            if ((journalArticleModelImpl.getColumnBitmask() &
32052                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T.getColumnBitmask()) != 0) {
32053                                    Object[] args = new Object[] {
32054                                                    journalArticleModelImpl.getOriginalGroupId(),
32055                                                    journalArticleModelImpl.getOriginalClassNameId(),
32056                                                    journalArticleModelImpl.getOriginalTemplateId()
32057                                            };
32058    
32059                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
32060                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
32061                                            args);
32062    
32063                                    args = new Object[] {
32064                                                    journalArticleModelImpl.getGroupId(),
32065                                                    journalArticleModelImpl.getClassNameId(),
32066                                                    journalArticleModelImpl.getTemplateId()
32067                                            };
32068    
32069                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
32070                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
32071                                            args);
32072                            }
32073    
32074                            if ((journalArticleModelImpl.getColumnBitmask() &
32075                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L.getColumnBitmask()) != 0) {
32076                                    Object[] args = new Object[] {
32077                                                    journalArticleModelImpl.getOriginalGroupId(),
32078                                                    journalArticleModelImpl.getOriginalClassNameId(),
32079                                                    journalArticleModelImpl.getOriginalLayoutUuid()
32080                                            };
32081    
32082                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
32083                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
32084                                            args);
32085    
32086                                    args = new Object[] {
32087                                                    journalArticleModelImpl.getGroupId(),
32088                                                    journalArticleModelImpl.getClassNameId(),
32089                                                    journalArticleModelImpl.getLayoutUuid()
32090                                            };
32091    
32092                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
32093                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
32094                                            args);
32095                            }
32096    
32097                            if ((journalArticleModelImpl.getColumnBitmask() &
32098                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST.getColumnBitmask()) != 0) {
32099                                    Object[] args = new Object[] {
32100                                                    journalArticleModelImpl.getOriginalGroupId(),
32101                                                    journalArticleModelImpl.getOriginalArticleId(),
32102                                                    journalArticleModelImpl.getOriginalStatus()
32103                                            };
32104    
32105                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
32106                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
32107                                            args);
32108    
32109                                    args = new Object[] {
32110                                                    journalArticleModelImpl.getGroupId(),
32111                                                    journalArticleModelImpl.getArticleId(),
32112                                                    journalArticleModelImpl.getStatus()
32113                                            };
32114    
32115                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
32116                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
32117                                            args);
32118                            }
32119    
32120                            if ((journalArticleModelImpl.getColumnBitmask() &
32121                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST.getColumnBitmask()) != 0) {
32122                                    Object[] args = new Object[] {
32123                                                    journalArticleModelImpl.getOriginalGroupId(),
32124                                                    journalArticleModelImpl.getOriginalUrlTitle(),
32125                                                    journalArticleModelImpl.getOriginalStatus()
32126                                            };
32127    
32128                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
32129                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
32130                                            args);
32131    
32132                                    args = new Object[] {
32133                                                    journalArticleModelImpl.getGroupId(),
32134                                                    journalArticleModelImpl.getUrlTitle(),
32135                                                    journalArticleModelImpl.getStatus()
32136                                            };
32137    
32138                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
32139                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
32140                                            args);
32141                            }
32142    
32143                            if ((journalArticleModelImpl.getColumnBitmask() &
32144                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST.getColumnBitmask()) != 0) {
32145                                    Object[] args = new Object[] {
32146                                                    journalArticleModelImpl.getOriginalCompanyId(),
32147                                                    journalArticleModelImpl.getOriginalVersion(),
32148                                                    journalArticleModelImpl.getOriginalStatus()
32149                                            };
32150    
32151                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
32152                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
32153                                            args);
32154    
32155                                    args = new Object[] {
32156                                                    journalArticleModelImpl.getCompanyId(),
32157                                                    journalArticleModelImpl.getVersion(),
32158                                                    journalArticleModelImpl.getStatus()
32159                                            };
32160    
32161                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
32162                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
32163                                            args);
32164                            }
32165                    }
32166    
32167                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
32168                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
32169                            journalArticle);
32170    
32171                    clearUniqueFindersCache(journalArticle);
32172                    cacheUniqueFindersCache(journalArticle);
32173    
32174                    return journalArticle;
32175            }
32176    
32177            protected JournalArticle toUnwrappedModel(JournalArticle journalArticle) {
32178                    if (journalArticle instanceof JournalArticleImpl) {
32179                            return journalArticle;
32180                    }
32181    
32182                    JournalArticleImpl journalArticleImpl = new JournalArticleImpl();
32183    
32184                    journalArticleImpl.setNew(journalArticle.isNew());
32185                    journalArticleImpl.setPrimaryKey(journalArticle.getPrimaryKey());
32186    
32187                    journalArticleImpl.setUuid(journalArticle.getUuid());
32188                    journalArticleImpl.setId(journalArticle.getId());
32189                    journalArticleImpl.setResourcePrimKey(journalArticle.getResourcePrimKey());
32190                    journalArticleImpl.setGroupId(journalArticle.getGroupId());
32191                    journalArticleImpl.setCompanyId(journalArticle.getCompanyId());
32192                    journalArticleImpl.setUserId(journalArticle.getUserId());
32193                    journalArticleImpl.setUserName(journalArticle.getUserName());
32194                    journalArticleImpl.setCreateDate(journalArticle.getCreateDate());
32195                    journalArticleImpl.setModifiedDate(journalArticle.getModifiedDate());
32196                    journalArticleImpl.setFolderId(journalArticle.getFolderId());
32197                    journalArticleImpl.setClassNameId(journalArticle.getClassNameId());
32198                    journalArticleImpl.setClassPK(journalArticle.getClassPK());
32199                    journalArticleImpl.setTreePath(journalArticle.getTreePath());
32200                    journalArticleImpl.setArticleId(journalArticle.getArticleId());
32201                    journalArticleImpl.setVersion(journalArticle.getVersion());
32202                    journalArticleImpl.setTitle(journalArticle.getTitle());
32203                    journalArticleImpl.setUrlTitle(journalArticle.getUrlTitle());
32204                    journalArticleImpl.setDescription(journalArticle.getDescription());
32205                    journalArticleImpl.setContent(journalArticle.getContent());
32206                    journalArticleImpl.setType(journalArticle.getType());
32207                    journalArticleImpl.setStructureId(journalArticle.getStructureId());
32208                    journalArticleImpl.setTemplateId(journalArticle.getTemplateId());
32209                    journalArticleImpl.setLayoutUuid(journalArticle.getLayoutUuid());
32210                    journalArticleImpl.setDisplayDate(journalArticle.getDisplayDate());
32211                    journalArticleImpl.setExpirationDate(journalArticle.getExpirationDate());
32212                    journalArticleImpl.setReviewDate(journalArticle.getReviewDate());
32213                    journalArticleImpl.setIndexable(journalArticle.isIndexable());
32214                    journalArticleImpl.setSmallImage(journalArticle.isSmallImage());
32215                    journalArticleImpl.setSmallImageId(journalArticle.getSmallImageId());
32216                    journalArticleImpl.setSmallImageURL(journalArticle.getSmallImageURL());
32217                    journalArticleImpl.setStatus(journalArticle.getStatus());
32218                    journalArticleImpl.setStatusByUserId(journalArticle.getStatusByUserId());
32219                    journalArticleImpl.setStatusByUserName(journalArticle.getStatusByUserName());
32220                    journalArticleImpl.setStatusDate(journalArticle.getStatusDate());
32221    
32222                    return journalArticleImpl;
32223            }
32224    
32225            /**
32226             * Returns the journal article with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
32227             *
32228             * @param primaryKey the primary key of the journal article
32229             * @return the journal article
32230             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
32231             * @throws SystemException if a system exception occurred
32232             */
32233            @Override
32234            public JournalArticle findByPrimaryKey(Serializable primaryKey)
32235                    throws NoSuchArticleException, SystemException {
32236                    JournalArticle journalArticle = fetchByPrimaryKey(primaryKey);
32237    
32238                    if (journalArticle == null) {
32239                            if (_log.isWarnEnabled()) {
32240                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
32241                            }
32242    
32243                            throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
32244                                    primaryKey);
32245                    }
32246    
32247                    return journalArticle;
32248            }
32249    
32250            /**
32251             * Returns the journal article with the primary key or throws a {@link com.liferay.portlet.journal.NoSuchArticleException} if it could not be found.
32252             *
32253             * @param id the primary key of the journal article
32254             * @return the journal article
32255             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
32256             * @throws SystemException if a system exception occurred
32257             */
32258            @Override
32259            public JournalArticle findByPrimaryKey(long id)
32260                    throws NoSuchArticleException, SystemException {
32261                    return findByPrimaryKey((Serializable)id);
32262            }
32263    
32264            /**
32265             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
32266             *
32267             * @param primaryKey the primary key of the journal article
32268             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
32269             * @throws SystemException if a system exception occurred
32270             */
32271            @Override
32272            public JournalArticle fetchByPrimaryKey(Serializable primaryKey)
32273                    throws SystemException {
32274                    JournalArticle journalArticle = (JournalArticle)EntityCacheUtil.getResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
32275                                    JournalArticleImpl.class, primaryKey);
32276    
32277                    if (journalArticle == _nullJournalArticle) {
32278                            return null;
32279                    }
32280    
32281                    if (journalArticle == null) {
32282                            Session session = null;
32283    
32284                            try {
32285                                    session = openSession();
32286    
32287                                    journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
32288                                                    primaryKey);
32289    
32290                                    if (journalArticle != null) {
32291                                            cacheResult(journalArticle);
32292                                    }
32293                                    else {
32294                                            EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
32295                                                    JournalArticleImpl.class, primaryKey,
32296                                                    _nullJournalArticle);
32297                                    }
32298                            }
32299                            catch (Exception e) {
32300                                    EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
32301                                            JournalArticleImpl.class, primaryKey);
32302    
32303                                    throw processException(e);
32304                            }
32305                            finally {
32306                                    closeSession(session);
32307                            }
32308                    }
32309    
32310                    return journalArticle;
32311            }
32312    
32313            /**
32314             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
32315             *
32316             * @param id the primary key of the journal article
32317             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
32318             * @throws SystemException if a system exception occurred
32319             */
32320            @Override
32321            public JournalArticle fetchByPrimaryKey(long id) throws SystemException {
32322                    return fetchByPrimaryKey((Serializable)id);
32323            }
32324    
32325            /**
32326             * Returns all the journal articles.
32327             *
32328             * @return the journal articles
32329             * @throws SystemException if a system exception occurred
32330             */
32331            @Override
32332            public List<JournalArticle> findAll() throws SystemException {
32333                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
32334            }
32335    
32336            /**
32337             * Returns a range of all the journal articles.
32338             *
32339             * <p>
32340             * 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.
32341             * </p>
32342             *
32343             * @param start the lower bound of the range of journal articles
32344             * @param end the upper bound of the range of journal articles (not inclusive)
32345             * @return the range of journal articles
32346             * @throws SystemException if a system exception occurred
32347             */
32348            @Override
32349            public List<JournalArticle> findAll(int start, int end)
32350                    throws SystemException {
32351                    return findAll(start, end, null);
32352            }
32353    
32354            /**
32355             * Returns an ordered range of all the journal articles.
32356             *
32357             * <p>
32358             * 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.
32359             * </p>
32360             *
32361             * @param start the lower bound of the range of journal articles
32362             * @param end the upper bound of the range of journal articles (not inclusive)
32363             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
32364             * @return the ordered range of journal articles
32365             * @throws SystemException if a system exception occurred
32366             */
32367            @Override
32368            public List<JournalArticle> findAll(int start, int end,
32369                    OrderByComparator orderByComparator) throws SystemException {
32370                    boolean pagination = true;
32371                    FinderPath finderPath = null;
32372                    Object[] finderArgs = null;
32373    
32374                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
32375                                    (orderByComparator == null)) {
32376                            pagination = false;
32377                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
32378                            finderArgs = FINDER_ARGS_EMPTY;
32379                    }
32380                    else {
32381                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
32382                            finderArgs = new Object[] { start, end, orderByComparator };
32383                    }
32384    
32385                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
32386                                    finderArgs, this);
32387    
32388                    if (list == null) {
32389                            StringBundler query = null;
32390                            String sql = null;
32391    
32392                            if (orderByComparator != null) {
32393                                    query = new StringBundler(2 +
32394                                                    (orderByComparator.getOrderByFields().length * 3));
32395    
32396                                    query.append(_SQL_SELECT_JOURNALARTICLE);
32397    
32398                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
32399                                            orderByComparator);
32400    
32401                                    sql = query.toString();
32402                            }
32403                            else {
32404                                    sql = _SQL_SELECT_JOURNALARTICLE;
32405    
32406                                    if (pagination) {
32407                                            sql = sql.concat(JournalArticleModelImpl.ORDER_BY_JPQL);
32408                                    }
32409                            }
32410    
32411                            Session session = null;
32412    
32413                            try {
32414                                    session = openSession();
32415    
32416                                    Query q = session.createQuery(sql);
32417    
32418                                    if (!pagination) {
32419                                            list = (List<JournalArticle>)QueryUtil.list(q,
32420                                                            getDialect(), start, end, false);
32421    
32422                                            Collections.sort(list);
32423    
32424                                            list = new UnmodifiableList<JournalArticle>(list);
32425                                    }
32426                                    else {
32427                                            list = (List<JournalArticle>)QueryUtil.list(q,
32428                                                            getDialect(), start, end);
32429                                    }
32430    
32431                                    cacheResult(list);
32432    
32433                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
32434                            }
32435                            catch (Exception e) {
32436                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
32437    
32438                                    throw processException(e);
32439                            }
32440                            finally {
32441                                    closeSession(session);
32442                            }
32443                    }
32444    
32445                    return list;
32446            }
32447    
32448            /**
32449             * Removes all the journal articles from the database.
32450             *
32451             * @throws SystemException if a system exception occurred
32452             */
32453            @Override
32454            public void removeAll() throws SystemException {
32455                    for (JournalArticle journalArticle : findAll()) {
32456                            remove(journalArticle);
32457                    }
32458            }
32459    
32460            /**
32461             * Returns the number of journal articles.
32462             *
32463             * @return the number of journal articles
32464             * @throws SystemException if a system exception occurred
32465             */
32466            @Override
32467            public int countAll() throws SystemException {
32468                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
32469                                    FINDER_ARGS_EMPTY, this);
32470    
32471                    if (count == null) {
32472                            Session session = null;
32473    
32474                            try {
32475                                    session = openSession();
32476    
32477                                    Query q = session.createQuery(_SQL_COUNT_JOURNALARTICLE);
32478    
32479                                    count = (Long)q.uniqueResult();
32480    
32481                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
32482                                            FINDER_ARGS_EMPTY, count);
32483                            }
32484                            catch (Exception e) {
32485                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
32486                                            FINDER_ARGS_EMPTY);
32487    
32488                                    throw processException(e);
32489                            }
32490                            finally {
32491                                    closeSession(session);
32492                            }
32493                    }
32494    
32495                    return count.intValue();
32496            }
32497    
32498            @Override
32499            protected Set<String> getBadColumnNames() {
32500                    return _badColumnNames;
32501            }
32502    
32503            /**
32504             * Initializes the journal article persistence.
32505             */
32506            public void afterPropertiesSet() {
32507                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
32508                                            com.liferay.portal.util.PropsUtil.get(
32509                                                    "value.object.listener.com.liferay.portlet.journal.model.JournalArticle")));
32510    
32511                    if (listenerClassNames.length > 0) {
32512                            try {
32513                                    List<ModelListener<JournalArticle>> listenersList = new ArrayList<ModelListener<JournalArticle>>();
32514    
32515                                    for (String listenerClassName : listenerClassNames) {
32516                                            listenersList.add((ModelListener<JournalArticle>)InstanceFactory.newInstance(
32517                                                            getClassLoader(), listenerClassName));
32518                                    }
32519    
32520                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
32521                            }
32522                            catch (Exception e) {
32523                                    _log.error(e);
32524                            }
32525                    }
32526            }
32527    
32528            public void destroy() {
32529                    EntityCacheUtil.removeCache(JournalArticleImpl.class.getName());
32530                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
32531                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
32532                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
32533            }
32534    
32535            private static final String _SQL_SELECT_JOURNALARTICLE = "SELECT journalArticle FROM JournalArticle journalArticle";
32536            private static final String _SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT journalArticle FROM JournalArticle journalArticle WHERE ";
32537            private static final String _SQL_COUNT_JOURNALARTICLE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle";
32538            private static final String _SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle WHERE ";
32539            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "journalArticle.resourcePrimKey";
32540            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT DISTINCT {journalArticle.*} FROM JournalArticle journalArticle WHERE ";
32541            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1 =
32542                    "SELECT {JournalArticle.*} FROM (SELECT DISTINCT journalArticle.id_ FROM JournalArticle journalArticle WHERE ";
32543            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2 =
32544                    ") TEMP_TABLE INNER JOIN JournalArticle ON TEMP_TABLE.id_ = JournalArticle.id_";
32545            private static final String _FILTER_SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(DISTINCT journalArticle.id_) AS COUNT_VALUE FROM JournalArticle journalArticle WHERE ";
32546            private static final String _FILTER_ENTITY_ALIAS = "journalArticle";
32547            private static final String _FILTER_ENTITY_TABLE = "JournalArticle";
32548            private static final String _ORDER_BY_ENTITY_ALIAS = "journalArticle.";
32549            private static final String _ORDER_BY_ENTITY_TABLE = "JournalArticle.";
32550            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalArticle exists with the primary key ";
32551            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalArticle exists with the key {";
32552            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
32553            private static Log _log = LogFactoryUtil.getLog(JournalArticlePersistenceImpl.class);
32554            private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
32555                                    "uuid", "id", "type"
32556                            });
32557            private static JournalArticle _nullJournalArticle = new JournalArticleImpl() {
32558                            @Override
32559                            public Object clone() {
32560                                    return this;
32561                            }
32562    
32563                            @Override
32564                            public CacheModel<JournalArticle> toCacheModel() {
32565                                    return _nullJournalArticleCacheModel;
32566                            }
32567                    };
32568    
32569            private static CacheModel<JournalArticle> _nullJournalArticleCacheModel = new CacheModel<JournalArticle>() {
32570                            @Override
32571                            public JournalArticle toEntityModel() {
32572                                    return _nullJournalArticle;
32573                            }
32574                    };
32575    }